diff options
Diffstat (limited to 'editor/editor_node.cpp')
-rw-r--r-- | editor/editor_node.cpp | 131 |
1 files changed, 63 insertions, 68 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 73bb1f3856..b962ea6e3e 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -32,6 +32,7 @@ #include "core/config/project_settings.h" #include "core/core_bind.h" +#include "core/extension/native_extension_manager.h" #include "core/input/input.h" #include "core/io/config_file.h" #include "core/io/file_access.h" @@ -1243,7 +1244,7 @@ void EditorNode::_get_scene_metadata(const String &p_file) { String path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); Ref<ConfigFile> cf; - cf.instance(); + cf.instantiate(); Error err = cf->load(path); if (err != OK || !cf->has_section("editor_states")) { @@ -1277,7 +1278,7 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { String path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); Ref<ConfigFile> cf; - cf.instance(); + cf.instantiate(); Dictionary md; @@ -1422,7 +1423,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { // We cannot fallback on the 2D editor, because it may not have been used yet, // which would result in an invalid texture. if (c3d == 0 && c2d == 0) { - img.instance(); + img.instantiate(); img->create(1, 1, false, Image::FORMAT_RGB8); } else if (c3d < c2d) { Ref<ViewportTexture> viewport_texture = scene_root->get_texture(); @@ -1607,16 +1608,16 @@ void EditorNode::_save_scene(String p_file, int idx) { if (ResourceCache::has(p_file)) { // something may be referencing this resource and we are good with that. // we must update it, but also let the previous scene state go, as - // old version still work for referencing changes in instanced or inherited scenes + // old version still work for referencing changes in instantiated or inherited scenes sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(ResourceCache::get(p_file))); if (sdata.is_valid()) { sdata->recreate_state(); } else { - sdata.instance(); + sdata.instantiate(); } } else { - sdata.instance(); + sdata.instantiate(); } Error err = sdata->pack(scene); @@ -1625,15 +1626,6 @@ void EditorNode::_save_scene(String p_file, int idx) { return; } - // force creation of node path cache - // (hacky but needed for the tree to update properly) - Node *dummy_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); - if (!dummy_scene) { - show_accept(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."), TTR("OK")); - return; - } - memdelete(dummy_scene); - int flg = 0; if (EditorSettings::get_singleton()->get("filesystem/on_save/compress_binary_resources")) { flg |= ResourceSaver::FLAG_COMPRESS; @@ -1849,11 +1841,11 @@ void EditorNode::_dialog_action(String p_file) { } Ref<ConfigFile> config; - config.instance(); + config.instantiate(); Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err == ERR_FILE_CANT_OPEN || err == ERR_FILE_NOT_FOUND) { - config.instance(); // new config + config.instantiate(); // new config } else if (err != OK) { show_warning(TTR("An error occurred while trying to save the editor layout.\nMake sure the editor's user data path is writable.")); return; @@ -1877,7 +1869,7 @@ void EditorNode::_dialog_action(String p_file) { } Ref<ConfigFile> config; - config.instance(); + config.instantiate(); Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err != OK || !config->has_section(p_file)) { @@ -2082,7 +2074,7 @@ void EditorNode::_edit_current() { editable_warning = TTR("This resource belongs to a scene that was imported, so it's not editable.\nPlease read the documentation relevant to importing scenes to better understand this workflow."); } else { if ((!get_edited_scene() || get_edited_scene()->get_filename() != base_path) && ResourceLoader::get_resource_type(base_path) == "PackedScene") { - editable_warning = TTR("This resource belongs to a scene that was instanced or inherited.\nChanges to it won't be kept when saving the current scene."); + editable_warning = TTR("This resource belongs to a scene that was instantiated or inherited.\nChanges to it won't be kept when saving the current scene."); } } } else if (current_res->get_path().is_resource_file()) { @@ -2408,11 +2400,13 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } } break; - case FILE_CLOSE_ALL_AND_QUIT: - case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: case FILE_CLOSE: { + _scene_tab_closed(editor_data.get_edited_scene()); + } break; + case FILE_CLOSE_ALL_AND_QUIT: + case FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER: { if (!p_confirmed) { - tab_closing = p_option == FILE_CLOSE ? editor_data.get_edited_scene() : _next_unsaved_scene(false); + tab_closing = _next_unsaved_scene(false); _scene_tab_changed(tab_closing); if (unsaved_cache || p_option == FILE_CLOSE_ALL_AND_QUIT || p_option == FILE_CLOSE_ALL_AND_RUN_PROJECT_MANAGER) { @@ -2425,8 +2419,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { break; } } - } else if (p_option == FILE_CLOSE) { - tab_closing = editor_data.get_edited_scene(); } if (!editor_data.get_edited_scene_root(tab_closing)) { // empty tab @@ -3144,7 +3136,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, } Ref<ConfigFile> cf; - cf.instance(); + cf.instantiate(); if (!DirAccess::exists(p_addon.get_base_dir())) { _remove_plugin_from_enabled(p_addon); WARN_PRINT("Addon '" + p_addon + "' failed to load. No directory found. Removing from enabled plugins."); @@ -3525,7 +3517,7 @@ Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, b sdata->set_path(lpath, true); //take over path } - Node *new_scene = sdata->instance(PackedScene::GEN_EDIT_STATE_MAIN); + Node *new_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_MAIN); if (!new_scene) { sdata.unref(); @@ -3589,11 +3581,11 @@ void EditorNode::open_request(const String &p_path) { } void EditorNode::request_instance_scene(const String &p_path) { - scene_tree_dock->instance(p_path); + scene_tree_dock->instantiate(p_path); } -void EditorNode::request_instance_scenes(const Vector<String> &p_files) { - scene_tree_dock->instance_scenes(p_files); +void EditorNode::request_instantiate_scenes(const Vector<String> &p_files) { + scene_tree_dock->instantiate_scenes(p_files); } ImportDock *EditorNode::get_import_dock() { @@ -3617,8 +3609,8 @@ void EditorNode::_inherit_request(String p_file) { _dialog_action(p_file); } -void EditorNode::_instance_request(const Vector<String> &p_files) { - request_instance_scenes(p_files); +void EditorNode::_instantiate_request(const Vector<String> &p_files) { + request_instantiate_scenes(p_files); } void EditorNode::_close_messages() { @@ -3780,9 +3772,12 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorScenePostImport>(); //ClassDB::register_type<EditorImportExport>(); ClassDB::register_class<EditorDebuggerPlugin>(); + + NativeExtensionManager::get_singleton()->initialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR); } void EditorNode::unregister_editor_types() { + NativeExtensionManager::get_singleton()->deinitialize_extensions(NativeExtension::INITIALIZATION_LEVEL_EDITOR); _init_callbacks.clear(); if (EditorPaths::get_singleton()) { EditorPaths::free(); @@ -4352,7 +4347,7 @@ void EditorNode::_save_docks() { return; //scanning, do not touch docks } Ref<ConfigFile> config; - config.instance(); + config.instantiate(); // Load and amend existing config if it exists. config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); @@ -4417,7 +4412,7 @@ void EditorNode::_dock_split_dragged(int ofs) { void EditorNode::_load_docks() { Ref<ConfigFile> config; - config.instance(); + config.instantiate(); Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); if (err != OK) { //no config @@ -4650,7 +4645,7 @@ bool EditorNode::has_scenes_in_session() { return false; } Ref<ConfigFile> config; - config.instance(); + config.instantiate(); Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); if (err != OK) { return false; @@ -4743,7 +4738,7 @@ void EditorNode::_update_layouts_menu() { editor_layouts->add_shortcut(ED_SHORTCUT("layout/default", TTR("Default")), SETTINGS_LAYOUT_DEFAULT); Ref<ConfigFile> config; - config.instance(); + config.instantiate(); Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err != OK) { return; //no config @@ -4786,7 +4781,7 @@ void EditorNode::_layout_menu_option(int p_id) { } break; default: { Ref<ConfigFile> config; - config.instance(); + config.instantiate(); Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err != OK) { return; //no config @@ -5337,7 +5332,7 @@ void EditorNode::reload_scene(const String &p_path) { if (scene_idx == -1) { if (get_edited_scene()) { - //scene is not open, so at it might be instanced. We'll refresh the whole scene later. + //scene is not open, so at it might be instantiated. We'll refresh the whole scene later. editor_data.get_undo_redo().clear_history(); } return; @@ -5734,87 +5729,87 @@ EditorNode::EditorNode() { { //register importers at the beginning, so dialogs are created with the right extensions Ref<ResourceImporterTexture> import_texture; - import_texture.instance(); + import_texture.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_texture); Ref<ResourceImporterLayeredTexture> import_cubemap; - import_cubemap.instance(); + import_cubemap.instantiate(); import_cubemap->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP); ResourceFormatImporter::get_singleton()->add_importer(import_cubemap); Ref<ResourceImporterLayeredTexture> import_array; - import_array.instance(); + import_array.instantiate(); import_array->set_mode(ResourceImporterLayeredTexture::MODE_2D_ARRAY); ResourceFormatImporter::get_singleton()->add_importer(import_array); Ref<ResourceImporterLayeredTexture> import_cubemap_array; - import_cubemap_array.instance(); + import_cubemap_array.instantiate(); import_cubemap_array->set_mode(ResourceImporterLayeredTexture::MODE_CUBEMAP_ARRAY); ResourceFormatImporter::get_singleton()->add_importer(import_cubemap_array); Ref<ResourceImporterLayeredTexture> import_3d; - import_3d.instance(); + import_3d.instantiate(); import_3d->set_mode(ResourceImporterLayeredTexture::MODE_3D); ResourceFormatImporter::get_singleton()->add_importer(import_3d); Ref<ResourceImporterImage> import_image; - import_image.instance(); + import_image.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_image); Ref<ResourceImporterTextureAtlas> import_texture_atlas; - import_texture_atlas.instance(); + import_texture_atlas.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_texture_atlas); Ref<ResourceImporterCSVTranslation> import_csv_translation; - import_csv_translation.instance(); + import_csv_translation.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_csv_translation); Ref<ResourceImporterWAV> import_wav; - import_wav.instance(); + import_wav.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_wav); Ref<ResourceImporterOBJ> import_obj; - import_obj.instance(); + import_obj.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_obj); Ref<ResourceImporterShaderFile> import_shader_file; - import_shader_file.instance(); + import_shader_file.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_shader_file); Ref<ResourceImporterScene> import_scene; - import_scene.instance(); + import_scene.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_scene); { Ref<EditorSceneImporterCollada> import_collada; - import_collada.instance(); + import_collada.instantiate(); import_scene->add_importer(import_collada); Ref<EditorOBJImporter> import_obj2; - import_obj2.instance(); + import_obj2.instantiate(); import_scene->add_importer(import_obj2); Ref<EditorSceneImporterESCN> import_escn; - import_escn.instance(); + import_escn.instantiate(); import_scene->add_importer(import_escn); } Ref<ResourceImporterBitMap> import_bitmap; - import_bitmap.instance(); + import_bitmap.instantiate(); ResourceFormatImporter::get_singleton()->add_importer(import_bitmap); } { Ref<EditorInspectorDefaultPlugin> eidp; - eidp.instance(); + eidp.instantiate(); EditorInspector::add_inspector_plugin(eidp); Ref<EditorInspectorRootMotionPlugin> rmp; - rmp.instance(); + rmp.instantiate(); EditorInspector::add_inspector_plugin(rmp); Ref<EditorInspectorShaderModePlugin> smp; - smp.instance(); + smp.instantiate(); EditorInspector::add_inspector_plugin(smp); } @@ -6517,7 +6512,7 @@ EditorNode::EditorNode() { filesystem_dock = memnew(FileSystemDock(this)); filesystem_dock->connect("inherit", callable_mp(this, &EditorNode::_inherit_request)); - filesystem_dock->connect("instance", callable_mp(this, &EditorNode::_instance_request)); + filesystem_dock->connect("instance", callable_mp(this, &EditorNode::_instantiate_request)); filesystem_dock->connect("display_mode_changed", callable_mp(this, &EditorNode::_save_docks)); // Scene: Top left @@ -6557,7 +6552,7 @@ EditorNode::EditorNode() { const String docks_section = "docks"; overridden_default_layout = -1; - default_layout.instance(); + default_layout.instantiate(); // Dock numbers are based on DockSlot enum value + 1 default_layout->set_value(docks_section, "dock_3", "Scene,Import"); default_layout->set_value(docks_section, "dock_4", "FileSystem"); @@ -6838,31 +6833,31 @@ EditorNode::EditorNode() { { Ref<StandardMaterial3DConversionPlugin> spatial_mat_convert; - spatial_mat_convert.instance(); + spatial_mat_convert.instantiate(); resource_conversion_plugins.push_back(spatial_mat_convert); Ref<CanvasItemMaterialConversionPlugin> canvas_item_mat_convert; - canvas_item_mat_convert.instance(); + canvas_item_mat_convert.instantiate(); resource_conversion_plugins.push_back(canvas_item_mat_convert); Ref<ParticlesMaterialConversionPlugin> particles_mat_convert; - particles_mat_convert.instance(); + particles_mat_convert.instantiate(); resource_conversion_plugins.push_back(particles_mat_convert); Ref<ProceduralSkyMaterialConversionPlugin> procedural_sky_mat_convert; - procedural_sky_mat_convert.instance(); + procedural_sky_mat_convert.instantiate(); resource_conversion_plugins.push_back(procedural_sky_mat_convert); Ref<PanoramaSkyMaterialConversionPlugin> panorama_sky_mat_convert; - panorama_sky_mat_convert.instance(); + panorama_sky_mat_convert.instantiate(); resource_conversion_plugins.push_back(panorama_sky_mat_convert); Ref<PhysicalSkyMaterialConversionPlugin> physical_sky_mat_convert; - physical_sky_mat_convert.instance(); + physical_sky_mat_convert.instantiate(); resource_conversion_plugins.push_back(physical_sky_mat_convert); Ref<VisualShaderConversionPlugin> vshader_convert; - vshader_convert.instance(); + vshader_convert.instantiate(); resource_conversion_plugins.push_back(vshader_convert); } update_spinner_step_msec = OS::get_singleton()->get_ticks_msec(); @@ -6875,12 +6870,12 @@ EditorNode::EditorNode() { editor_plugins_force_input_forwarding = memnew(EditorPluginList); Ref<EditorExportTextSceneToBinaryPlugin> export_text_to_binary_plugin; - export_text_to_binary_plugin.instance(); + export_text_to_binary_plugin.instantiate(); EditorExport::get_singleton()->add_export_plugin(export_text_to_binary_plugin); Ref<PackedSceneEditorTranslationParserPlugin> packed_scene_translation_parser_plugin; - packed_scene_translation_parser_plugin.instance(); + packed_scene_translation_parser_plugin.instantiate(); EditorTranslationParser::get_singleton()->add_parser(packed_scene_translation_parser_plugin, EditorTranslationParser::STANDARD); _edit_current(); @@ -6901,7 +6896,7 @@ EditorNode::EditorNode() { saved_version = 1; unsaved_cache = true; - _last_instanced_scene = nullptr; + _last_instantiated_scene = nullptr; quick_open = memnew(EditorQuickOpen); gui_base->add_child(quick_open); |