You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Ask before closing with unsaved resources
This commit is contained in:
@@ -2657,9 +2657,22 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
case FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT: {
|
case FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT: {
|
||||||
if (!p_confirmed) {
|
if (!p_confirmed) {
|
||||||
tab_closing_idx = _next_unsaved_scene(false);
|
tab_closing_idx = _next_unsaved_scene(false);
|
||||||
|
if (tab_closing_idx == -1) {
|
||||||
|
tab_closing_idx = -2; // Only external resources are unsaved.
|
||||||
|
} else {
|
||||||
_scene_tab_changed(tab_closing_idx);
|
_scene_tab_changed(tab_closing_idx);
|
||||||
|
}
|
||||||
|
|
||||||
if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER || p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) {
|
if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER || p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) {
|
||||||
|
if (tab_closing_idx == -2) {
|
||||||
|
if (p_option == FILE_CLOSE_ALL_AND_RELOAD_CURRENT_PROJECT) {
|
||||||
|
save_confirmation->set_ok_button_text(TTR("Save & Reload"));
|
||||||
|
save_confirmation->set_text(TTR("Save modified resources before reloading?"));
|
||||||
|
} else {
|
||||||
|
save_confirmation->set_ok_button_text(TTR("Save & Quit"));
|
||||||
|
save_confirmation->set_text(TTR("Save modified resources before closing?"));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Node *scene_root = editor_data.get_edited_scene_root(tab_closing_idx);
|
Node *scene_root = editor_data.get_edited_scene_root(tab_closing_idx);
|
||||||
if (scene_root) {
|
if (scene_root) {
|
||||||
String scene_filename = scene_root->get_scene_file_path();
|
String scene_filename = scene_root->get_scene_file_path();
|
||||||
@@ -2670,11 +2683,12 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
save_confirmation->set_ok_button_text(TTR("Save & Quit"));
|
save_confirmation->set_ok_button_text(TTR("Save & Quit"));
|
||||||
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene"));
|
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), !scene_filename.is_empty() ? scene_filename : "unsaved scene"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
save_confirmation->popup_centered();
|
save_confirmation->popup_centered();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!editor_data.get_edited_scene_root(tab_closing_idx)) {
|
if (!editor_data.get_edited_scene_root(tab_closing_idx)) {
|
||||||
// Empty tab.
|
// Empty tab.
|
||||||
_scene_tab_closed(tab_closing_idx);
|
_scene_tab_closed(tab_closing_idx);
|
||||||
@@ -2945,7 +2959,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
case RELOAD_CURRENT_PROJECT: {
|
case RELOAD_CURRENT_PROJECT: {
|
||||||
if (!p_confirmed) {
|
if (!p_confirmed) {
|
||||||
bool save_each = EDITOR_GET("interface/editor/save_each_scene_on_quit");
|
bool save_each = EDITOR_GET("interface/editor/save_each_scene_on_quit");
|
||||||
if (_next_unsaved_scene(!save_each) == -1) {
|
if (_next_unsaved_scene(!save_each) == -1 && !get_undo_redo()->is_history_unsaved(EditorUndoRedoManager::GLOBAL_HISTORY)) {
|
||||||
_discard_changes();
|
_discard_changes();
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user