From c63f23bcaac69f7d55d8317b966d3e7885ab1f24 Mon Sep 17 00:00:00 2001 From: SaracenOne Date: Wed, 1 Dec 2021 09:50:42 +0000 Subject: [PATCH] Properly handle named class types inheriting from scripts without names. --- editor/create_dialog.cpp | 77 +++++++++++++++++++++++++++++++++------- editor/create_dialog.h | 10 ++++-- 2 files changed, 72 insertions(+), 15 deletions(-) diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index dec4f50f037..fd44355436e 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -170,7 +170,7 @@ void CreateDialog::_update_search() { root->set_text(0, base_type); root->set_icon(0, search_options->get_theme_icon(icon_fallback, SNAME("EditorIcons"))); search_options_types[base_type] = root; - _configure_search_option_item(root, base_type, ClassDB::class_exists(base_type)); + _configure_search_option_item(root, base_type, ClassDB::class_exists(base_type) ? TypeCategory::CPP_TYPE : TypeCategory::OTHER_TYPE); const String search_text = search_box->get_text(); bool empty_search = search_text == ""; @@ -185,7 +185,7 @@ void CreateDialog::_update_search() { // Build the type tree. for (int i = 0; i < candidates.size(); i++) { - _add_type(candidates[i], ClassDB::class_exists(candidates[i])); + _add_type(candidates[i], ClassDB::class_exists(candidates[i]) ? TypeCategory::CPP_TYPE : TypeCategory::OTHER_TYPE); } // Select the best result. @@ -202,31 +202,80 @@ void CreateDialog::_update_search() { } } -void CreateDialog::_add_type(const String &p_type, bool p_cpp_type) { +void CreateDialog::_add_type(const String &p_type, const TypeCategory p_type_category) { if (search_options_types.has(p_type)) { return; } String inherits; - if (p_cpp_type) { + + TypeCategory inherited_type = TypeCategory::OTHER_TYPE; + + if (p_type_category == TypeCategory::CPP_TYPE) { inherits = ClassDB::get_parent_class(p_type); - } else if (ScriptServer::is_global_class(p_type)) { - inherits = EditorNode::get_editor_data().script_class_get_base(p_type); + inherited_type = TypeCategory::CPP_TYPE; + } else if (p_type_category == TypeCategory::PATH_TYPE) { + ERR_FAIL_COND(!ResourceLoader::exists(p_type, "Script")); + Ref