diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 75 |
1 files changed, 71 insertions, 4 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 8c9974404e..67fba4f278 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -291,6 +291,8 @@ void EditorNode::_notification(int p_what) { get_tree()->get_root()->set_as_audio_listener_2d(false); get_tree()->set_auto_accept_quit(false); get_tree()->connect("files_dropped", this, "_dropped_files"); + + /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ } if (p_what == NOTIFICATION_EXIT_TREE) { @@ -305,7 +307,8 @@ void EditorNode::_notification(int p_what) { _editor_select(EDITOR_3D); _update_debug_options(); - _load_docks(); + + /* DO NOT LOAD SCENES HERE, WAIT FOR FILE SCANNING AND REIMPORT TO COMPLETE */ } if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { @@ -528,6 +531,10 @@ void EditorNode::_sources_changed(bool p_exist) { if (waiting_for_first_scan) { + EditorResourcePreview::get_singleton()->start(); //start previes now that it's safe + + _load_docks(); + if (defer_load_scene != "") { load_scene(defer_load_scene); @@ -1017,6 +1024,35 @@ bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_nod return false; } +static bool _find_edited_resources(const Ref<Resource> &p_resource, Set<Ref<Resource> > &edited_resources) { + + if (p_resource->is_edited()) { + edited_resources.insert(p_resource); + return true; + } + + List<PropertyInfo> plist; + + p_resource->get_property_list(&plist); + + for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { + if (E->get().type == Variant::OBJECT && E->get().usage & PROPERTY_USAGE_STORAGE && !(E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT)) { + RES res = p_resource->get(E->get().name); + if (res.is_null()) { + continue; + } + if (res->get_path().is_resource_file()) { //not a subresource, continue + continue; + } + if (_find_edited_resources(res, edited_resources)) { + return true; + } + } + } + + return false; +} + void EditorNode::_save_scene(String p_file, int idx) { Node *scene = editor_data.get_edited_scene_root(idx); @@ -1080,16 +1116,28 @@ void EditorNode::_save_scene(String p_file, int idx) { //_save_edited_subresources(scene, processed, flg); { //instead, just find globally unsaved subresources and save them + Set<Ref<Resource> > edited_subresources; + List<Ref<Resource> > cached; ResourceCache::get_cached_resources(&cached); for (List<Ref<Resource> >::Element *E = cached.front(); E; E = E->next()) { Ref<Resource> res = E->get(); - if (res->is_edited() && res->get_path().is_resource_file()) { + if (!res->get_path().is_resource_file()) + continue; + //not only check if this resourec is edited, check contained subresources too + if (_find_edited_resources(res, edited_subresources)) { ResourceSaver::save(res->get_path(), res, flg); - res->set_edited(false); } } + + // clear later, because user may have put the same subresource in two different resources, + // which will be shared until the next reload + + for (Set<Ref<Resource> >::Element *E = edited_subresources.front(); E; E = E->next()) { + Ref<Resource> res = E->get(); + res->set_edited(false); + } } editor_data.save_editor_external_data(); @@ -2542,6 +2590,7 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan singleton->editor_plugins_over->get_plugins_list().erase(p_editor); singleton->remove_child(p_editor); singleton->editor_data.remove_editor_plugin(p_editor); + singleton->get_editor_plugins_force_input_forwarding()->remove_plugin(p_editor); } void EditorNode::_update_addon_config() { @@ -3631,6 +3680,8 @@ void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p } p_layout->set_value(p_section, "dock_filesystem_split", filesystem_dock->get_split_offset()); + p_layout->set_value(p_section, "dock_filesystem_display_mode", filesystem_dock->get_display_mode()); + p_layout->set_value(p_section, "dock_filesystem_file_list_display_mode", filesystem_dock->get_file_list_display_mode()); for (int i = 0; i < vsplits.size(); i++) { @@ -3818,6 +3869,17 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String int fs_split_ofs = 0; if (p_layout->has_section_key(p_section, "dock_filesystem_split")) { fs_split_ofs = p_layout->get_value(p_section, "dock_filesystem_split"); + filesystem_dock->set_split_offset(fs_split_ofs); + } + + if (p_layout->has_section_key(p_section, "dock_filesystem_display_mode")) { + FileSystemDock::DisplayMode dock_filesystem_display_mode = FileSystemDock::DisplayMode(int(p_layout->get_value(p_section, "dock_filesystem_display_mode"))); + filesystem_dock->set_display_mode(dock_filesystem_display_mode); + } + + if (p_layout->has_section_key(p_section, "dock_filesystem_file_list_display_mode")) { + FileSystemDock::FileListDisplayMode dock_filesystem_file_list_display_mode = FileSystemDock::FileListDisplayMode(int(p_layout->get_value(p_section, "dock_filesystem_file_list_display_mode"))); + filesystem_dock->set_file_list_display_mode(dock_filesystem_file_list_display_mode); } filesystem_dock->set_split_offset(fs_split_ofs); @@ -5579,9 +5641,10 @@ EditorNode::EditorNode() { node_dock = memnew(NodeDock); filesystem_dock = memnew(FileSystemDock(this)); - filesystem_dock->set_file_list_display_mode(int(EditorSettings::get_singleton()->get("docks/filesystem/files_display_mode"))); filesystem_dock->connect("open", this, "open_request"); + filesystem_dock->set_file_list_display_mode(FileSystemDock::FILE_LIST_DISPLAY_LIST); filesystem_dock->connect("instance", this, "_instance_request"); + filesystem_dock->connect("display_mode_changed", this, "_save_docks"); // Scene: Top left dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scene_tree_dock); @@ -6059,6 +6122,10 @@ void EditorPluginList::add_plugin(EditorPlugin *p_plugin) { plugins_list.push_back(p_plugin); } +void EditorPluginList::remove_plugin(EditorPlugin *p_plugin) { + plugins_list.erase(p_plugin); +} + bool EditorPluginList::empty() { return plugins_list.empty(); } |