You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +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() {
|
||||
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++) {
|
||||
if (!_is_scene_unsaved(i)) {
|
||||
continue;
|
||||
@@ -2064,8 +2064,8 @@ void EditorNode::_save_all_scenes() {
|
||||
ERR_FAIL_NULL(scene);
|
||||
|
||||
const String &scene_path = scene->get_scene_file_path();
|
||||
if (!scene_path.is_empty() && !DirAccess::exists(scene_path.get_base_dir())) {
|
||||
all_saved = false;
|
||||
if (scene_path.is_empty() || !DirAccess::exists(scene_path.get_base_dir())) {
|
||||
scenes_to_save_as.push_back(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2075,11 +2075,11 @@ void EditorNode::_save_all_scenes() {
|
||||
_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();
|
||||
|
||||
if (!scenes_to_save_as.is_empty()) {
|
||||
_proceed_save_asing_scene_tabs();
|
||||
}
|
||||
}
|
||||
|
||||
void EditorNode::_mark_unsaved_scenes() {
|
||||
@@ -2146,8 +2146,9 @@ void EditorNode::_dialog_action(String p_file) {
|
||||
case FILE_CLOSE:
|
||||
case SCENE_TAB_CLOSE:
|
||||
case FILE_SAVE_SCENE:
|
||||
case FILE_MULTI_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) {
|
||||
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;
|
||||
|
||||
case FILE_SAVE_AND_RUN: {
|
||||
@@ -2853,8 +2858,9 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
||||
}
|
||||
[[fallthrough]];
|
||||
}
|
||||
case FILE_MULTI_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);
|
||||
|
||||
@@ -5694,6 +5700,16 @@ void EditorNode::_proceed_closing_scene_tabs() {
|
||||
_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 {
|
||||
return tab_closing_menu_option == FILE_QUIT || tab_closing_menu_option == PROJECT_QUIT_TO_PROJECT_MANAGER || tab_closing_menu_option == PROJECT_RELOAD_CURRENT_PROJECT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user