diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-11-20 08:17:53 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-11-20 08:17:53 -0300 |
commit | cf3ae61a7feaf352e9535e14c1f11e3ae0634eb6 (patch) | |
tree | 7553185748d65b148f70d00fd644acf698d5773d /tools | |
parent | 85eedffbc77d9bdd92c8851aea09146feaf2d843 (diff) | |
parent | 6d20ded6d7d776a0397ba8bd3f9e8250d2c4d9ff (diff) |
Merge pull request #2825 from StraToN/fix-tabclose-confirmation
Ask confirmation on closing a scene tab
Diffstat (limited to 'tools')
-rw-r--r-- | tools/editor/editor_node.cpp | 36 | ||||
-rw-r--r-- | tools/editor/editor_node.h | 2 |
2 files changed, 28 insertions, 10 deletions
diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 22acfd4d07..7d837f3211 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -2012,6 +2012,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; case FILE_SAVE_SCENE: { @@ -2023,7 +2028,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { return; }; // fallthrough to save_as - }; + } break; case FILE_SAVE_AS_SCENE: { Node *scene = editor_data.get_edited_scene_root(); @@ -2957,23 +2962,23 @@ void EditorNode::_remove_edited_scene() { _update_title(); _update_scene_tabs(); - if (editor_data.get_edited_scene_count()==1) { - //make new scene appear saved - set_current_version(editor_data.get_undo_redo().get_version()); - unsaved_cache=false; - } +// if (editor_data.get_edited_scene_count()==1) { +// //make new scene appear saved +// set_current_version(editor_data.get_undo_redo().get_version()); +// unsaved_cache=false; +// } } void EditorNode::_remove_scene(int index) { // printf("Attempting to remove scene %d (current is %d)\n", index, editor_data.get_edited_scene()); + if (editor_data.get_edited_scene() == index) { //Scene to remove is current scene _remove_edited_scene(); } else { - // Scene to remove is not active scene."); + // Scene to remove is not active scene 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) { - _remove_scene(p_tab); - _update_scene_tabs(); + 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); + //_update_scene_tabs(); + } + } diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index bd88e1a4b9..002df0f3ea 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -173,6 +173,7 @@ class EditorNode : public Node { SOURCES_REIMPORT, DEPENDENCY_LOAD_CHANGED_IMAGES, DEPENDENCY_UPDATE_IMPORTED, + SCENE_TAB_CLOSE, IMPORT_PLUGIN_BASE=100, @@ -217,6 +218,7 @@ class EditorNode : public Node { //main tabs Tabs *scene_tabs; + int tab_closing; int old_split_ofs; |