1
0
Fork 0

CreateDialog: return type name instead of script path for custom types

This commit is contained in:
Saulo-de-Souza 2026-01-28 16:05:31 -03:00
parent 0cd4a62f3b
commit 35a9ec140f
2 changed files with 12 additions and 7 deletions

View File

@ -499,7 +499,7 @@ void CreateDialog::_cleanup() {
}
void CreateDialog::_confirmed() {
String selected_item = get_selected_type();
String selected_item = get_selected_type_name();
if (selected_item.is_empty()) {
return;
}
@ -632,6 +632,14 @@ String CreateDialog::get_selected_type() {
return String(selected->get_meta("_script_path", "")); // Script types
}
String CreateDialog::get_selected_type_name() {
TreeItem *selected = search_options->get_selected();
if (!selected) {
return String();
}
return selected->get_text(0).get_slicec(' ', 0);
}
void CreateDialog::set_base_type(const String &p_base) {
base_type = p_base;
is_base_type_node = ClassDB::is_parent_class(p_base, "Node");
@ -669,11 +677,7 @@ Variant CreateDialog::instantiate_selected() {
}
void CreateDialog::_item_selected() {
String name = get_selected_type();
if (name.is_resource_file()) {
name = search_options->get_selected()->get_text(0).get_slicec(' ', 0);
}
select_type(name, false);
select_type(get_selected_type_name(), false);
}
void CreateDialog::_hide_requested() {
@ -690,7 +694,7 @@ void CreateDialog::_favorite_toggled() {
return;
}
String name = item->get_text(0).get_slicec(' ', 0);
String name = get_selected_type_name();
if (favorite_list.has(name)) {
favorite_list.erase(name);

View File

@ -117,6 +117,7 @@ protected:
public:
Variant instantiate_selected();
String get_selected_type();
String get_selected_type_name();
void set_base_type(const String &p_base);
String get_base_type() const { return base_type; }