1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Merge pull request #2825 from StraToN/fix-tabclose-confirmation

Ask confirmation on closing a scene tab
This commit is contained in:
Juan Linietsky
2015-11-20 08:17:53 -03:00
2 changed files with 28 additions and 10 deletions

View File

@@ -2011,6 +2011,11 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
} break;
case SCENE_TAB_CLOSE: {
_remove_scene(tab_closing);
_update_scene_tabs();
current_option = -1;
} break; } break;
case FILE_SAVE_SCENE: { case FILE_SAVE_SCENE: {
@@ -2023,7 +2028,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) {
return; return;
}; };
// fallthrough to save_as // fallthrough to save_as
}; } break;
case FILE_SAVE_AS_SCENE: { case FILE_SAVE_AS_SCENE: {
Node *scene = editor_data.get_edited_scene_root(); Node *scene = editor_data.get_edited_scene_root();
@@ -2957,23 +2962,23 @@ void EditorNode::_remove_edited_scene() {
_update_title(); _update_title();
_update_scene_tabs(); _update_scene_tabs();
if (editor_data.get_edited_scene_count()==1) { // if (editor_data.get_edited_scene_count()==1) {
//make new scene appear saved // //make new scene appear saved
set_current_version(editor_data.get_undo_redo().get_version()); // set_current_version(editor_data.get_undo_redo().get_version());
unsaved_cache=false; // unsaved_cache=false;
} // }
} }
void EditorNode::_remove_scene(int index) { void EditorNode::_remove_scene(int index) {
// printf("Attempting to remove scene %d (current is %d)\n", index, editor_data.get_edited_scene()); // printf("Attempting to remove scene %d (current is %d)\n", index, editor_data.get_edited_scene());
if (editor_data.get_edited_scene() == index) { if (editor_data.get_edited_scene() == index) {
//Scene to remove is current scene //Scene to remove is current scene
_remove_edited_scene(); _remove_edited_scene();
} }
else { else {
// Scene to remove is not active scene."); // Scene to remove is not active scene
editor_data.remove_scene(index); editor_data.remove_scene(index);
editor_data.get_undo_redo().clear_history();
} }
} }
@@ -4467,8 +4472,19 @@ void EditorNode::_scene_tab_script_edited(int p_tab) {
} }
void EditorNode::_scene_tab_closed(int p_tab) { void EditorNode::_scene_tab_closed(int p_tab) {
current_option = SCENE_TAB_CLOSE;
tab_closing = p_tab;
if (unsaved_cache) {
confirmation->get_ok()->set_text("Yes");
//confirmation->get_cancel()->show();
confirmation->set_text("Close scene? (Unsaved changes will be lost)");
confirmation->popup_centered_minsize();
}
else {
_remove_scene(p_tab); _remove_scene(p_tab);
_update_scene_tabs(); //_update_scene_tabs();
}
} }

View File

@@ -173,6 +173,7 @@ class EditorNode : public Node {
SOURCES_REIMPORT, SOURCES_REIMPORT,
DEPENDENCY_LOAD_CHANGED_IMAGES, DEPENDENCY_LOAD_CHANGED_IMAGES,
DEPENDENCY_UPDATE_IMPORTED, DEPENDENCY_UPDATE_IMPORTED,
SCENE_TAB_CLOSE,
IMPORT_PLUGIN_BASE=100, IMPORT_PLUGIN_BASE=100,
@@ -217,6 +218,7 @@ class EditorNode : public Node {
//main tabs //main tabs
Tabs *scene_tabs; Tabs *scene_tabs;
int tab_closing;
int old_split_ofs; int old_split_ofs;