diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 74 |
1 files changed, 63 insertions, 11 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index a32ade3b71..c2fb604044 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -289,6 +289,7 @@ void EditorNode::_notification(int p_what) { _editor_select(EDITOR_3D); _update_debug_options(); + _load_docks(); } if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { @@ -3110,6 +3111,10 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b push_item(new_scene); + if (!restoring_scenes) { + save_layout(); + } + return OK; } @@ -3630,6 +3635,7 @@ void EditorNode::_save_docks() { config.instance(); _save_docks_to_config(config, "docks"); + _save_open_scenes_to_config(config, "EditorNode"); editor_data.get_plugin_window_layout(config); config->save(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); @@ -3680,6 +3686,18 @@ void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p } } +void EditorNode::_save_open_scenes_to_config(Ref<ConfigFile> p_layout, const String &p_section) { + Array scenes; + for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { + String path = editor_data.get_scene_path(i); + if (path == "") { + continue; + } + scenes.push_back(path); + } + p_layout->set_value(p_section, "open_scenes", scenes); +} + void EditorNode::save_layout() { dock_drag_timer->start(); @@ -3704,6 +3722,7 @@ void EditorNode::_load_docks() { } _load_docks_from_config(config, "docks"); + _load_open_scenes_from_config(config, "EditorNode"); editor_data.set_plugin_window_layout(config); } @@ -3850,6 +3869,25 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String } } +void EditorNode::_load_open_scenes_from_config(Ref<ConfigFile> p_layout, const String &p_section) { + if (!bool(EDITOR_DEF("interface/scene_tabs/restore_scenes_on_load", false))) { + return; + } + + if (!p_layout->has_section(p_section) || !p_layout->has_section_key(p_section, "open_scenes")) { + return; + } + + restoring_scenes = true; + + Array scenes = p_layout->get_value(p_section, "open_scenes"); + for (int i = 0; i < scenes.size(); i++) { + load_scene(scenes[i]); + } + + restoring_scenes = false; +} + void EditorNode::_update_layouts_menu() { editor_layouts->clear(); @@ -3948,6 +3986,8 @@ void EditorNode::_scene_tab_closed(int p_tab) { } else { _discard_changes(); } + + save_layout(); _update_scene_tabs(); } @@ -4645,6 +4685,7 @@ EditorNode::EditorNode() { changing_scene = false; _initializing_addons = false; docks_visible = true; + restoring_scenes = false; scene_distraction = false; script_distraction = false; @@ -5262,13 +5303,14 @@ EditorNode::EditorNode() { } scene_tree_dock = memnew(SceneTreeDock(this, scene_root, editor_selection, editor_data)); - scene_tree_dock->set_name(TTR("Scene")); dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(scene_tree_dock); + dock_slot[DOCK_SLOT_RIGHT_UL]->set_tab_title(scene_tree_dock->get_index(), TTR("Scene")); dock_slot[DOCK_SLOT_LEFT_BR]->hide(); VBoxContainer *prop_editor_base = memnew(VBoxContainer); - prop_editor_base->set_name(TTR("Inspector")); // Properties? + prop_editor_base->set_name("Inspector"); dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(prop_editor_base); + dock_slot[DOCK_SLOT_RIGHT_BL]->set_tab_title(prop_editor_base->get_index(), TTR("Inspector")); HBoxContainer *prop_editor_hb = memnew(HBoxContainer); @@ -5391,28 +5433,31 @@ EditorNode::EditorNode() { import_dock = memnew(ImportDock); dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(import_dock); - import_dock->set_name(TTR("Import")); + dock_slot[DOCK_SLOT_RIGHT_UL]->set_tab_title(import_dock->get_index(), TTR("Import")); bool use_single_dock_column = (OS::get_singleton()->get_screen_size(OS::get_singleton()->get_current_screen()).x < 1200); node_dock = memnew(NodeDock); if (use_single_dock_column) { dock_slot[DOCK_SLOT_RIGHT_UL]->add_child(node_dock); + dock_slot[DOCK_SLOT_RIGHT_UL]->set_tab_title(node_dock->get_index(), TTR("Node")); } else { dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(node_dock); + dock_slot[DOCK_SLOT_RIGHT_BL]->set_tab_title(node_dock->get_index(), TTR("Node")); } filesystem_dock = memnew(FileSystemDock(this)); - filesystem_dock->set_name(TTR("FileSystem")); filesystem_dock->set_display_mode(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode"))); if (use_single_dock_column) { dock_slot[DOCK_SLOT_RIGHT_BL]->add_child(filesystem_dock); + dock_slot[DOCK_SLOT_RIGHT_BL]->set_tab_title(filesystem_dock->get_index(), TTR("FileSystem")); left_r_vsplit->hide(); dock_slot[DOCK_SLOT_LEFT_UR]->hide(); dock_slot[DOCK_SLOT_LEFT_BR]->hide(); } else { dock_slot[DOCK_SLOT_LEFT_UR]->add_child(filesystem_dock); + dock_slot[DOCK_SLOT_LEFT_UR]->set_tab_title(filesystem_dock->get_index(), TTR("FileSystem")); } filesystem_dock->connect("open", this, "open_request"); filesystem_dock->connect("instance", this, "_instance_request"); @@ -5421,9 +5466,9 @@ EditorNode::EditorNode() { overridden_default_layout = -1; default_layout.instance(); - default_layout->set_value(docks_section, "dock_3", TTR("FileSystem")); - default_layout->set_value(docks_section, "dock_5", TTR("Scene") + "," + TTR("Import")); - default_layout->set_value(docks_section, "dock_6", TTR("Inspector") + "," + TTR("Node")); + default_layout->set_value(docks_section, "dock_3", "FileSystem"); + default_layout->set_value(docks_section, "dock_5", "Scene,Import"); + default_layout->set_value(docks_section, "dock_6", "Inspector,Node"); for (int i = 0; i < DOCK_SLOT_MAX / 2; i++) default_layout->set_value(docks_section, "dock_hsplit_" + itos(i + 1), 0); @@ -5624,6 +5669,7 @@ EditorNode::EditorNode() { editor_plugin_screen = NULL; editor_plugins_over = memnew(EditorPluginList); + editor_plugins_force_over = memnew(EditorPluginList); editor_plugins_force_input_forwarding = memnew(EditorPluginList); _edit_current(); @@ -5716,8 +5762,6 @@ EditorNode::EditorNode() { _initializing_addons = false; } - _load_docks(); - FileAccess::set_file_close_fail_notify_callback(_file_access_close_error_notify); waiting_for_first_scan = true; @@ -5748,6 +5792,7 @@ EditorNode::~EditorNode() { memdelete(EditorHelp::get_doc_data()); memdelete(editor_selection); memdelete(editor_plugins_over); + memdelete(editor_plugins_force_over); memdelete(editor_plugins_force_input_forwarding); memdelete(file_server); memdelete(progress_hb); @@ -5801,10 +5846,17 @@ bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<Inp return discard; } -void EditorPluginList::forward_draw_over_canvas(Control *p_canvas) { +void EditorPluginList::forward_draw_over_viewport(Control *p_overlay) { + + for (int i = 0; i < plugins_list.size(); i++) { + plugins_list[i]->forward_draw_over_viewport(p_overlay); + } +} + +void EditorPluginList::forward_force_draw_over_viewport(Control *p_overlay) { for (int i = 0; i < plugins_list.size(); i++) { - plugins_list[i]->forward_draw_over_canvas(p_canvas); + plugins_list[i]->forward_force_draw_over_viewport(p_overlay); } } |