You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
Prompt to Save As when saving all scenes
This commit is contained in:
@@ -2054,7 +2054,7 @@ void EditorNode::restart_editor(bool p_goto_project_manager) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_save_all_scenes() {
|
void EditorNode::_save_all_scenes() {
|
||||||
bool all_saved = true;
|
scenes_to_save_as.clear(); // In case saving was canceled before.
|
||||||
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
|
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
|
||||||
if (!_is_scene_unsaved(i)) {
|
if (!_is_scene_unsaved(i)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -2064,8 +2064,8 @@ void EditorNode::_save_all_scenes() {
|
|||||||
ERR_FAIL_NULL(scene);
|
ERR_FAIL_NULL(scene);
|
||||||
|
|
||||||
const String &scene_path = scene->get_scene_file_path();
|
const String &scene_path = scene->get_scene_file_path();
|
||||||
if (!scene_path.is_empty() && !DirAccess::exists(scene_path.get_base_dir())) {
|
if (scene_path.is_empty() || !DirAccess::exists(scene_path.get_base_dir())) {
|
||||||
all_saved = false;
|
scenes_to_save_as.push_back(i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2075,11 +2075,11 @@ void EditorNode::_save_all_scenes() {
|
|||||||
_save_scene(scene_path, i);
|
_save_scene(scene_path, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!all_saved) {
|
|
||||||
show_warning(TTR("Could not save one or more scenes!"), TTR("Save All Scenes"));
|
|
||||||
}
|
|
||||||
save_default_environment();
|
save_default_environment();
|
||||||
|
|
||||||
|
if (!scenes_to_save_as.is_empty()) {
|
||||||
|
_proceed_save_asing_scene_tabs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_mark_unsaved_scenes() {
|
void EditorNode::_mark_unsaved_scenes() {
|
||||||
@@ -2146,8 +2146,9 @@ void EditorNode::_dialog_action(String p_file) {
|
|||||||
case FILE_CLOSE:
|
case FILE_CLOSE:
|
||||||
case SCENE_TAB_CLOSE:
|
case SCENE_TAB_CLOSE:
|
||||||
case FILE_SAVE_SCENE:
|
case FILE_SAVE_SCENE:
|
||||||
|
case FILE_MULTI_SAVE_AS_SCENE:
|
||||||
case FILE_SAVE_AS_SCENE: {
|
case FILE_SAVE_AS_SCENE: {
|
||||||
int scene_idx = (current_menu_option == FILE_SAVE_SCENE || current_menu_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing_idx;
|
int scene_idx = (current_menu_option == FILE_SAVE_SCENE || current_menu_option == FILE_SAVE_AS_SCENE || current_menu_option == FILE_MULTI_SAVE_AS_SCENE) ? -1 : tab_closing_idx;
|
||||||
|
|
||||||
if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
|
if (file->get_file_mode() == EditorFileDialog::FILE_MODE_SAVE_FILE) {
|
||||||
bool same_open_scene = false;
|
bool same_open_scene = false;
|
||||||
@@ -2175,6 +2176,10 @@ void EditorNode::_dialog_action(String p_file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (current_menu_option == FILE_MULTI_SAVE_AS_SCENE) {
|
||||||
|
_proceed_save_asing_scene_tabs();
|
||||||
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case FILE_SAVE_AND_RUN: {
|
case FILE_SAVE_AND_RUN: {
|
||||||
@@ -2853,8 +2858,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
}
|
}
|
||||||
|
case FILE_MULTI_SAVE_AS_SCENE:
|
||||||
case FILE_SAVE_AS_SCENE: {
|
case FILE_SAVE_AS_SCENE: {
|
||||||
int scene_idx = (p_option == FILE_SAVE_SCENE || p_option == FILE_SAVE_AS_SCENE) ? -1 : tab_closing_idx;
|
int scene_idx = (p_option == FILE_SAVE_SCENE || p_option == FILE_SAVE_AS_SCENE || p_option == FILE_MULTI_SAVE_AS_SCENE) ? -1 : tab_closing_idx;
|
||||||
|
|
||||||
Node *scene = editor_data.get_edited_scene_root(scene_idx);
|
Node *scene = editor_data.get_edited_scene_root(scene_idx);
|
||||||
|
|
||||||
@@ -5694,6 +5700,16 @@ void EditorNode::_proceed_closing_scene_tabs() {
|
|||||||
_scene_tab_closed(tab_idx);
|
_scene_tab_closed(tab_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorNode::_proceed_save_asing_scene_tabs() {
|
||||||
|
if (scenes_to_save_as.is_empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int scene_idx = scenes_to_save_as.front()->get();
|
||||||
|
scenes_to_save_as.pop_front();
|
||||||
|
_set_current_scene(scene_idx);
|
||||||
|
_menu_option_confirm(FILE_MULTI_SAVE_AS_SCENE, false);
|
||||||
|
}
|
||||||
|
|
||||||
bool EditorNode::_is_closing_editor() const {
|
bool EditorNode::_is_closing_editor() const {
|
||||||
return tab_closing_menu_option == FILE_QUIT || tab_closing_menu_option == PROJECT_QUIT_TO_PROJECT_MANAGER || tab_closing_menu_option == PROJECT_RELOAD_CURRENT_PROJECT;
|
return tab_closing_menu_option == FILE_QUIT || tab_closing_menu_option == PROJECT_QUIT_TO_PROJECT_MANAGER || tab_closing_menu_option == PROJECT_RELOAD_CURRENT_PROJECT;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ public:
|
|||||||
FILE_SAVE_SCENE,
|
FILE_SAVE_SCENE,
|
||||||
FILE_SAVE_AS_SCENE,
|
FILE_SAVE_AS_SCENE,
|
||||||
FILE_SAVE_ALL_SCENES,
|
FILE_SAVE_ALL_SCENES,
|
||||||
|
FILE_MULTI_SAVE_AS_SCENE,
|
||||||
FILE_QUICK_OPEN,
|
FILE_QUICK_OPEN,
|
||||||
FILE_QUICK_OPEN_SCENE,
|
FILE_QUICK_OPEN_SCENE,
|
||||||
FILE_QUICK_OPEN_SCRIPT,
|
FILE_QUICK_OPEN_SCRIPT,
|
||||||
@@ -295,6 +296,7 @@ private:
|
|||||||
|
|
||||||
int tab_closing_idx = 0;
|
int tab_closing_idx = 0;
|
||||||
List<String> tabs_to_close;
|
List<String> tabs_to_close;
|
||||||
|
List<int> scenes_to_save_as;
|
||||||
int tab_closing_menu_option = -1;
|
int tab_closing_menu_option = -1;
|
||||||
|
|
||||||
bool exiting = false;
|
bool exiting = false;
|
||||||
@@ -611,6 +613,7 @@ private:
|
|||||||
bool _find_scene_in_use(Node *p_node, const String &p_path) const;
|
bool _find_scene_in_use(Node *p_node, const String &p_path) const;
|
||||||
|
|
||||||
void _proceed_closing_scene_tabs();
|
void _proceed_closing_scene_tabs();
|
||||||
|
void _proceed_save_asing_scene_tabs();
|
||||||
bool _is_closing_editor() const;
|
bool _is_closing_editor() const;
|
||||||
void _restart_editor(bool p_goto_project_manager = false);
|
void _restart_editor(bool p_goto_project_manager = false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user