diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/debugger/editor_debugger_node.cpp | 2 | ||||
-rw-r--r-- | editor/editor_autoload_settings.cpp | 16 | ||||
-rw-r--r-- | editor/editor_help_search.cpp | 5 | ||||
-rw-r--r-- | editor/editor_inspector.cpp | 2 | ||||
-rw-r--r-- | editor/editor_node.cpp | 14 | ||||
-rw-r--r-- | editor/editor_resource_picker.cpp | 16 | ||||
-rw-r--r-- | editor/filesystem_dock.cpp | 61 | ||||
-rw-r--r-- | editor/plugins/animation_blend_tree_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 41 | ||||
-rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/node_3d_editor_plugin.cpp | 18 | ||||
-rw-r--r-- | editor/plugins/packed_scene_translation_parser_plugin.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/packed_scene_translation_parser_plugin.h | 4 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 4 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/project_export.cpp | 2 | ||||
-rw-r--r-- | editor/project_export.h | 2 |
18 files changed, 93 insertions, 115 deletions
diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 6d9ad9398c..55add92533 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -683,7 +683,7 @@ EditorDebuggerNode::CameraOverride EditorDebuggerNode::get_camera_override() { void EditorDebuggerNode::add_debugger_plugin(const Ref<Script> &p_script) { ERR_FAIL_COND_MSG(debugger_plugins.has(p_script), "Debugger plugin already exists."); ERR_FAIL_COND_MSG(p_script.is_null(), "Debugger plugin script is null"); - ERR_FAIL_COND_MSG(String(p_script->get_instance_base_type()) == "", "Debugger plugin script has error."); + ERR_FAIL_COND_MSG(p_script->get_instance_base_type() == StringName(), "Debugger plugin script has error."); ERR_FAIL_COND_MSG(String(p_script->get_instance_base_type()) != "EditorDebuggerPlugin", "Base type of debugger plugin is not 'EditorDebuggerPlugin'."); ERR_FAIL_COND_MSG(!p_script->is_tool(), "Debugger plugin script is not in tool mode."); debugger_plugins.insert(p_script); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index d27d0c8b53..70836fa377 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -362,21 +362,21 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { RES res = ResourceLoader::load(p_path); ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, "Can't autoload: " + p_path + "."); Node *n = nullptr; - if (res->is_class("PackedScene")) { - Ref<PackedScene> ps = res; - n = ps->instantiate(); - } else if (res->is_class("Script")) { - Ref<Script> s = res; - StringName ibt = s->get_instance_base_type(); + Ref<PackedScene> scn = res; + Ref<Script> script = res; + if (scn.is_valid()) { + n = scn->instantiate(); + } else if (script.is_valid()) { + StringName ibt = script->get_instance_base_type(); bool valid_type = ClassDB::is_parent_class(ibt, "Node"); ERR_FAIL_COND_V_MSG(!valid_type, nullptr, "Script does not inherit a Node: " + p_path + "."); Object *obj = ClassDB::instantiate(ibt); - ERR_FAIL_COND_V_MSG(obj == nullptr, nullptr, "Cannot instance script for AutoLoad, expected 'Node' inheritance, got: " + String(ibt) + "."); + ERR_FAIL_COND_V_MSG(!obj, nullptr, "Cannot instance script for AutoLoad, expected 'Node' inheritance, got: " + String(ibt) + "."); n = Object::cast_to<Node>(obj); - n->set_script(s); + n->set_script(script); } ERR_FAIL_COND_V_MSG(!n, nullptr, "Path in AutoLoad not a node or script: " + p_path + "."); diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index 550e6ee72b..260e794545 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -610,11 +610,6 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons text = p_text; } else { icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons")); - /*// In flat mode, show the class icon. -if (ui_service->has_icon(p_class_name, "EditorIcons")) -icon = ui_service->get_icon(p_class_name, "EditorIcons"); -else if (ClassDB::is_parent_class(p_class_name, "Object")) -icon = ui_service->get_icon("Object", "EditorIcons");*/ text = p_class_name + "." + p_text; } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index d898c84a02..8e813838c4 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2425,7 +2425,7 @@ void EditorInspector::update_tree() { if (!ClassDB::class_exists(type) && !ScriptServer::is_global_class(type) && p.hint_string.length() && FileAccess::exists(p.hint_string)) { // If we have a category inside a script, search for the first script with a valid icon. Ref<Script> script = ResourceLoader::load(p.hint_string, "Script"); - String base_type; + StringName base_type; if (script.is_valid()) { base_type = script->get_instance_base_type(); } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index a4b6790d1c..ad2a5b0ed8 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -745,7 +745,6 @@ void EditorNode::_notification(int p_what) { bottom_panel_raise->set_icon(gui_base->get_theme_icon(SNAME("ExpandBottomDock"), SNAME("EditorIcons"))); - // clear_button->set_icon(gui_base->get_icon("Close", "EditorIcons")); don't have access to that node. needs to become a class property if (gui_base->is_layout_rtl()) { dock_tab_move_left->set_icon(theme->get_icon(SNAME("Forward"), SNAME("EditorIcons"))); dock_tab_move_right->set_icon(theme->get_icon(SNAME("Back"), SNAME("EditorIcons"))); @@ -2280,7 +2279,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) { if (main_plugin) { // special case if use of external editor is true Resource *current_res = Object::cast_to<Resource>(current_obj); - if (main_plugin->get_name() == "Script" && current_obj->get_class_name() != StringName("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { + if (main_plugin->get_name() == "Script" && current_obj->is_class("VisualScript") && current_res && !current_res->is_built_in() && (bool(EditorSettings::get_singleton()->get("text_editor/external/use_external_editor")) || overrides_external_editor(current_obj))) { if (!changing_scene) { main_plugin->edit(current_obj); } @@ -3293,8 +3292,8 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled, return; } - // Errors in the script cause the base_type to be an empty string. - if (String(script->get_instance_base_type()) == "") { + // Errors in the script cause the base_type to be an empty StringName. + if (script->get_instance_base_type() == StringName()) { show_warning(vformat(TTR("Unable to load addon script from path: '%s'. This might be due to a code error in that script.\nDisabling the addon at '%s' to prevent further errors."), script_path, p_addon)); _remove_plugin_from_enabled(p_addon); return; @@ -3937,7 +3936,7 @@ StringName EditorNode::get_object_custom_type_name(const Object *p_object) const ERR_FAIL_COND_V(!p_object, StringName()); Ref<Script> script = p_object->get_script(); - if (script.is_null() && p_object->is_class("Script")) { + if (script.is_null() && Object::cast_to<Script>(p_object)) { script = p_object; } @@ -4148,13 +4147,12 @@ Ref<Texture2D> EditorNode::_file_dialog_get_icon(const String &p_path) { void EditorNode::_build_icon_type_cache() { List<StringName> tl; - StringName ei = "EditorIcons"; - theme_base->get_theme()->get_icon_list(ei, &tl); + theme_base->get_theme()->get_icon_list(SNAME("EditorIcons"), &tl); for (const StringName &E : tl) { if (!ClassDB::class_exists(E)) { continue; } - icon_type_cache[E] = theme_base->get_theme()->get_icon(E, ei); + icon_type_cache[E] = theme_base->get_theme()->get_icon(E, SNAME("EditorIcons")); } } diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp index 734cfa39cb..398a096550 100644 --- a/editor/editor_resource_picker.cpp +++ b/editor/editor_resource_picker.cpp @@ -77,16 +77,16 @@ void EditorResourcePicker::_update_resource_preview(const String &p_path, const return; } - String type = edited_resource->get_class_name(); - if (ClassDB::is_parent_class(type, "Script")) { - assign_button->set_text(edited_resource->get_path().get_file()); + Ref<Script> script = edited_resource; + if (script.is_valid()) { + assign_button->set_text(script->get_path().get_file()); return; } if (p_preview.is_valid()) { preview_rect->set_offset(SIDE_LEFT, assign_button->get_icon()->get_width() + assign_button->get_theme_stylebox(SNAME("normal"))->get_default_margin(SIDE_LEFT) + get_theme_constant(SNAME("hseparation"), SNAME("Button"))); - if (type == "GradientTexture1D") { + if (Ref<GradientTexture1D>(edited_resource).is_valid()) { preview_rect->set_stretch_mode(TextureRect::STRETCH_SCALE); assign_button->set_custom_minimum_size(Size2(1, 1)); } else { @@ -642,7 +642,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ for (Set<String>::Element *E = allowed_types.front(); E; E = E->next()) { String at = E->get().strip_edges(); - if (at == "BaseMaterial3D" && ClassDB::is_parent_class(dropped_resource->get_class(), "Texture2D")) { + if (at == "BaseMaterial3D" && Ref<Texture2D>(dropped_resource).is_valid()) { // Use existing resource if possible and only replace its data. Ref<StandardMaterial3D> mat = edited_resource; if (!mat.is_valid()) { @@ -653,7 +653,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ break; } - if (at == "ShaderMaterial" && ClassDB::is_parent_class(dropped_resource->get_class(), "Shader")) { + if (at == "ShaderMaterial" && Ref<Shader>(dropped_resource).is_valid()) { Ref<ShaderMaterial> mat = edited_resource; if (!mat.is_valid()) { mat.instantiate(); @@ -663,7 +663,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ break; } - if (at == "Font" && ClassDB::is_parent_class(dropped_resource->get_class(), "FontData")) { + if (at == "Font" && Ref<FontData>(dropped_resource).is_valid()) { Ref<Font> font = edited_resource; if (!font.is_valid()) { font.instantiate(); @@ -673,7 +673,7 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_ break; } - if (at == "Texture2D" && ClassDB::is_parent_class(dropped_resource->get_class(), "Image")) { + if (at == "Texture2D" && Ref<Image>(dropped_resource).is_valid()) { Ref<ImageTexture> texture = edited_resource; if (!texture.is_valid()) { texture.instantiate(); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 324aed5d02..5adf6406cb 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -338,30 +338,28 @@ void FileSystemDock::_notification(int p_what) { EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &FileSystemDock::_fs_changed)); EditorResourcePreview::get_singleton()->connect("preview_invalidated", callable_mp(this, &FileSystemDock::_preview_invalidated)); - String ei = "EditorIcons"; - - button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei)); - button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei)); + button_reload->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); button_file_list_display_mode->connect("pressed", callable_mp(this, &FileSystemDock::_toggle_file_display)); files->connect("item_activated", callable_mp(this, &FileSystemDock::_file_list_activate_file)); button_hist_next->connect("pressed", callable_mp(this, &FileSystemDock::_fw_history)); button_hist_prev->connect("pressed", callable_mp(this, &FileSystemDock::_bw_history)); - tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); + tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); tree_search_box->set_clear_button_enabled(true); - tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); + tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); - file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); + file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); file_list_search_box->set_clear_button_enabled(true); - file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); + file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei)); - button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } else { - button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei)); - button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } file_list_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_file_list_rmb_option)); tree_popup->connect("id_pressed", callable_mp(this, &FileSystemDock::_tree_rmb_option)); @@ -412,15 +410,14 @@ void FileSystemDock::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { // Update icons. - String ei = "EditorIcons"; - button_reload->set_icon(get_theme_icon(SNAME("Reload"), ei)); - button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), ei)); + button_reload->set_icon(get_theme_icon(SNAME("Reload"), SNAME("EditorIcons"))); + button_toggle_display_mode->set_icon(get_theme_icon(SNAME("Panels2"), SNAME("EditorIcons"))); if (is_layout_rtl()) { - button_hist_next->set_icon(get_theme_icon(SNAME("Back"), ei)); - button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); + button_hist_prev->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); } else { - button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), ei)); - button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), ei)); + button_hist_next->set_icon(get_theme_icon(SNAME("Forward"), SNAME("EditorIcons"))); + button_hist_prev->set_icon(get_theme_icon(SNAME("Back"), SNAME("EditorIcons"))); } if (file_list_display_mode == FILE_LIST_DISPLAY_LIST) { button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileThumbnail"), SNAME("EditorIcons"))); @@ -428,13 +425,13 @@ void FileSystemDock::_notification(int p_what) { button_file_list_display_mode->set_icon(get_theme_icon(SNAME("FileList"), SNAME("EditorIcons"))); } - tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); + tree_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); tree_search_box->set_clear_button_enabled(true); - tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); + tree_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); - file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), ei)); + file_list_search_box->set_right_icon(get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); file_list_search_box->set_clear_button_enabled(true); - file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), ei)); + file_list_button_sort->set_icon(get_theme_icon(SNAME("Sort"), SNAME("EditorIcons"))); // Update always show folders. bool new_always_show_folders = bool(EditorSettings::get_singleton()->get("docks/filesystem/always_show_folders")); @@ -718,7 +715,6 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { String directory = path; String file = ""; - String ei = "EditorIcons"; int thumbnail_size = EditorSettings::get_singleton()->get("docks/filesystem/thumbnail_size"); thumbnail_size *= EDSCALE; Ref<Texture2D> folder_thumbnail; @@ -736,13 +732,13 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { files->set_fixed_icon_size(Size2(thumbnail_size, thumbnail_size)); if (thumbnail_size < 64) { - folder_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), ei); - file_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), ei); - file_thumbnail_broken = get_theme_icon(SNAME("FileDeadMediumThumb"), ei); + folder_thumbnail = get_theme_icon(SNAME("FolderMediumThumb"), SNAME("EditorIcons")); + file_thumbnail = get_theme_icon(SNAME("FileMediumThumb"), SNAME("EditorIcons")); + file_thumbnail_broken = get_theme_icon(SNAME("FileDeadMediumThumb"), SNAME("EditorIcons")); } else { - folder_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), ei); - file_thumbnail = get_theme_icon(SNAME("FileBigThumb"), ei); - file_thumbnail_broken = get_theme_icon(SNAME("FileDeadBigThumb"), ei); + folder_thumbnail = get_theme_icon(SNAME("FolderBigThumb"), SNAME("EditorIcons")); + file_thumbnail = get_theme_icon(SNAME("FileBigThumb"), SNAME("EditorIcons")); + file_thumbnail_broken = get_theme_icon(SNAME("FileDeadBigThumb"), SNAME("EditorIcons")); } } else { // No thumbnails. @@ -871,7 +867,6 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { // Fills the ItemList control node from the FileInfos. String main_scene = ProjectSettings::get_singleton()->get("application/run/main_scene"); - String oi = "Object"; for (FileInfo &E : file_list) { FileInfo *finfo = &(E); String fname = finfo->name; @@ -885,10 +880,10 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) { // Select the icons. if (!finfo->import_broken) { - type_icon = (has_theme_icon(ftype, ei)) ? get_theme_icon(ftype, ei) : get_theme_icon(oi, ei); + type_icon = (has_theme_icon(ftype, SNAME("EditorIcons"))) ? get_theme_icon(ftype, SNAME("EditorIcons")) : get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); big_icon = file_thumbnail; } else { - type_icon = get_theme_icon(SNAME("ImportFail"), ei); + type_icon = get_theme_icon(SNAME("ImportFail"), SNAME("EditorIcons")); big_icon = file_thumbnail_broken; tooltip += "\n" + TTR("Status: Import of file failed. Please fix file and reimport manually."); } diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index 216405110b..68f86001d3 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -300,7 +300,7 @@ void AnimationNodeBlendTreeEditor::_add_node(int p_idx) { base_name = add_options[p_idx].name; } else { ERR_FAIL_COND(add_options[p_idx].script.is_null()); - String base_type = add_options[p_idx].script->get_instance_base_type(); + StringName base_type = add_options[p_idx].script->get_instance_base_type(); AnimationNode *an = Object::cast_to<AnimationNode>(ClassDB::instantiate(base_type)); ERR_FAIL_COND(!an); anode = Ref<AnimationNode>(an); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 4a7c8d7d01..73b34dcf95 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5804,7 +5804,7 @@ void CanvasItemEditorViewport::_create_nodes(Node *parent, Node *child, String & } // make visible for certain node type - if (ClassDB::is_parent_class(child->get_class(), "Control")) { + if (Object::cast_to<Control>(child)) { Size2 texture_size = texture->get_size(); editor_data->get_undo_redo().add_do_property(child, "rect_size", texture_size); } else if (Object::cast_to<Polygon2D>(child)) { @@ -5935,29 +5935,32 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian if (String(d["type"]) == "files") { Vector<String> files = d["files"]; bool can_instantiate = false; - for (int i = 0; i < files.size(); i++) { // check if dragged files contain resource or scene can be created at least once - RES res = ResourceLoader::load(files[i]); - if (res.is_null()) { - continue; - } - String type = res->get_class(); - if (type == "PackedScene") { - Ref<PackedScene> sdata = Ref<PackedScene>(Object::cast_to<PackedScene>(*res)); - Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE); - if (!instantiated_scene) { + + List<String> scene_extensions; + ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions); + List<String> texture_extensions; + ResourceLoader::get_recognized_extensions_for_type("Texture2D", &texture_extensions); + + for (int i = 0; i < files.size(); i++) { + // Check if dragged files with texture or scene extension can be created at least once. + if (texture_extensions.find(files[i].get_extension()) || scene_extensions.find(files[i].get_extension())) { + RES res = ResourceLoader::load(files[i]); + if (res.is_null()) { continue; } - memdelete(instantiated_scene); - } else if (ClassDB::is_parent_class(type, "Texture2D")) { - Ref<Texture2D> texture = Ref<Texture2D>(Object::cast_to<Texture2D>(*res)); - if (!texture.is_valid()) { + Ref<PackedScene> scn = res; + if (scn.is_valid()) { + Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE); + if (!instantiated_scene) { + continue; + } + memdelete(instantiated_scene); + } else { continue; } - } else { - continue; + can_instantiate = true; + break; } - can_instantiate = true; - break; } if (can_instantiate) { if (!preview_node->get_parent()) { // create preview only once diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 7e0019faac..d23b52014e 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -188,7 +188,7 @@ bool EditorImagePreviewPlugin::generate_small_preview_automatically() const { } //////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////// + bool EditorBitmapPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "BitMap"); } @@ -308,7 +308,7 @@ void EditorMaterialPreviewPlugin::_preview_done() { } bool EditorMaterialPreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Material"); //any material + return ClassDB::is_parent_class(p_type, "Material"); // Any material. } bool EditorMaterialPreviewPlugin::generate_small_preview_automatically() const { @@ -699,7 +699,7 @@ void EditorMeshPreviewPlugin::_preview_done() { } bool EditorMeshPreviewPlugin::handles(const String &p_type) const { - return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh + return ClassDB::is_parent_class(p_type, "Mesh"); // Any mesh. } Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 &p_size) const { diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index b069cbc0bf..1624529161 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -3978,7 +3978,7 @@ AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, boo if (child) { AABB child_bounds = _calculate_spatial_bounds(child, false); - if (bounds.size == Vector3() && p_parent->get_class_name() == StringName("Node3D")) { + if (bounds.size == Vector3() && Object::cast_to<Node3D>(p_parent)) { bounds = child_bounds; } else { bounds.merge_with(child_bounds); @@ -3986,7 +3986,7 @@ AABB Node3DEditorViewport::_calculate_spatial_bounds(const Node3D *p_parent, boo } } - if (bounds.size == Vector3() && p_parent->get_class_name() != StringName("Node3D")) { + if (bounds.size == Vector3() && !Object::cast_to<Node3D>(p_parent)) { bounds = AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); } @@ -4213,25 +4213,19 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant ResourceLoader::get_recognized_extensions_for_type("Mesh", &mesh_extensions); for (int i = 0; i < files.size(); i++) { + // Check if dragged files with mesh or scene extension can be created at least once. if (mesh_extensions.find(files[i].get_extension()) || scene_extensions.find(files[i].get_extension())) { RES res = ResourceLoader::load(files[i]); if (res.is_null()) { continue; } - - String type = res->get_class(); - if (type == "PackedScene") { - Ref<PackedScene> sdata = ResourceLoader::load(files[i]); - Node *instantiated_scene = sdata->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE); + Ref<PackedScene> scn = res; + if (scn.is_valid()) { + Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE); if (!instantiated_scene) { continue; } memdelete(instantiated_scene); - } else if (ClassDB::is_parent_class(type, "Mesh")) { - Ref<Mesh> mesh = ResourceLoader::load(files[i]); - if (!mesh.is_valid()) { - continue; - } } else { continue; } diff --git a/editor/plugins/packed_scene_translation_parser_plugin.cpp b/editor/plugins/packed_scene_translation_parser_plugin.cpp index b492c27f41..9a8584f4a2 100644 --- a/editor/plugins/packed_scene_translation_parser_plugin.cpp +++ b/editor/plugins/packed_scene_translation_parser_plugin.cpp @@ -132,10 +132,7 @@ PackedSceneEditorTranslationParserPlugin::PackedSceneEditorTranslationParserPlug lookup_properties.insert("script"); // Exception list (to prevent false positives). - exception_list.insert("LineEdit", Vector<StringName>()); - exception_list["LineEdit"].append("text"); - exception_list.insert("TextEdit", Vector<StringName>()); - exception_list["TextEdit"].append("text"); - exception_list.insert("CodeEdit", Vector<StringName>()); - exception_list["CodeEdit"].append("text"); + exception_list.insert("LineEdit", { "text" }); + exception_list.insert("TextEdit", { "text" }); + exception_list.insert("CodeEdit", { "text" }); } diff --git a/editor/plugins/packed_scene_translation_parser_plugin.h b/editor/plugins/packed_scene_translation_parser_plugin.h index fc19496eb6..ecd090b31b 100644 --- a/editor/plugins/packed_scene_translation_parser_plugin.h +++ b/editor/plugins/packed_scene_translation_parser_plugin.h @@ -37,9 +37,9 @@ class PackedSceneEditorTranslationParserPlugin : public EditorTranslationParserP GDCLASS(PackedSceneEditorTranslationParserPlugin, EditorTranslationParserPlugin); // Scene Node's properties that contain translation strings. - Set<StringName> lookup_properties; + Set<String> lookup_properties; // Properties from specific Nodes that should be ignored. - Map<StringName, Vector<StringName>> exception_list; + Map<String, Vector<String>> exception_list; public: virtual Error parse_file(const String &p_path, Vector<String> *r_ids, Vector<Vector<String>> *r_ids_ctx_plural) override; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index b20f9650ac..fdda1556ff 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -2265,7 +2265,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra if (use_external_editor && (EditorDebuggerNode::get_singleton()->get_dump_stack_script() != p_resource || EditorDebuggerNode::get_singleton()->get_debug_with_external_editor()) && p_resource->get_path().is_resource_file() && - p_resource->get_class_name() != StringName("VisualScript")) { + !Ref<VisualScript>(p_resource).is_valid()) { String path = EditorSettings::get_singleton()->get("text_editor/external/exec_path"); String flags = EditorSettings::get_singleton()->get("text_editor/external/exec_flags"); @@ -2364,7 +2364,7 @@ bool ScriptEditor::edit(const RES &p_resource, int p_line, int p_col, bool p_gra se->set_edited_resource(p_resource); - if (p_resource->get_class_name() != StringName("VisualScript")) { + if (!Ref<VisualScript>(p_resource).is_valid()) { bool highlighter_set = false; for (int i = 0; i < syntax_highlighters.size(); i++) { Ref<EditorSyntaxHighlighter> highlighter = syntax_highlighters[i]->_create(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index a818caabbe..b18a7fef5d 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1373,7 +1373,7 @@ void ScriptTextEditor::reload(bool p_soft) { return; } scr->set_source_code(te->get_text()); - bool soft = p_soft || scr->get_instance_base_type() == "EditorPlugin"; //always soft-reload editor plugins + bool soft = p_soft || scr->get_instance_base_type() == "EditorPlugin"; // Always soft-reload editor plugins. scr->get_language()->reload_tool_script(scr, soft); } diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index ac316427da..72b2ad0292 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -2584,7 +2584,7 @@ void VisualShaderEditor::_add_node(int p_idx, const Vector<Variant> &p_ops, Stri vsnode = Ref<VisualShaderNode>(vsn); } else { ERR_FAIL_COND(add_options[p_idx].script.is_null()); - String base_type = add_options[p_idx].script->get_instance_base_type(); + StringName base_type = add_options[p_idx].script->get_instance_base_type(); VisualShaderNode *vsn = Object::cast_to<VisualShaderNode>(ClassDB::instantiate(base_type)); ERR_FAIL_COND(!vsn); vsnode = Ref<VisualShaderNode>(vsn); diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 5e2334f5e3..55dd20eb86 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -1275,8 +1275,6 @@ ProjectExportDialog::ProjectExportDialog() { set_hide_on_ok(false); - editor_icons = "EditorIcons"; - default_filename = EditorSettings::get_singleton()->get_project_metadata("export_options", "default_filename", ""); // If no default set, use project name if (default_filename.is_empty()) { diff --git a/editor/project_export.h b/editor/project_export.h index 3d90a0d3ff..09e402c67f 100644 --- a/editor/project_export.h +++ b/editor/project_export.h @@ -85,8 +85,6 @@ private: Label *include_label; MarginContainer *include_margin; - StringName editor_icons; - Button *export_button; Button *export_all_button; AcceptDialog *export_all_dialog; |