1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-04 17:04:49 +00:00

Optimize the callback argument of popup_create_dialog()

This commit is contained in:
Lazy-Rabbit-2001
2025-06-22 17:47:53 +08:00
committed by YuuKaana
parent 2d113cc224
commit 251d037c18
2 changed files with 7 additions and 3 deletions

View File

@@ -370,7 +370,9 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const StringN
if (is_tool) {
tooltip = TTR("The script will run in the editor.") + "\n" + tooltip;
}
r_item->add_button(0, get_editor_theme_icon(SNAME("Script")), 1, false, vformat(tooltip, ScriptServer::get_global_class_path(p_type)));
const String script_path = ScriptServer::get_global_class_path(p_type);
r_item->add_button(0, get_editor_theme_icon(SNAME("Script")), 1, false, vformat(tooltip, script_path));
r_item->set_meta(SNAME("_script_path"), script_path);
if (is_tool) {
int button_index = r_item->get_button_count(0) - 1;
r_item->set_button_color(0, button_index, get_theme_color(SNAME("accent_color"), EditorStringName(Editor)));
@@ -608,11 +610,13 @@ void CreateDialog::select_base() {
String CreateDialog::get_selected_type() {
TreeItem *selected = search_options->get_selected();
if (!selected) {
return String();
}
return selected->get_text(0);
String type = selected->get_text(0);
return ClassDB::class_exists(type) ? type : String(selected->get_meta("_script_path", ""));
}
void CreateDialog::set_base_type(const String &p_base) {