summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/doc_tools.cpp97
-rw-r--r--editor/editor_help.cpp8
-rw-r--r--editor/editor_help_search.cpp4
-rw-r--r--editor/editor_help_search.h4
-rw-r--r--editor/inspector_dock.cpp28
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp6
-rw-r--r--editor/plugins/theme_editor_plugin.cpp57
-rw-r--r--editor/plugins/theme_editor_plugin.h2
-rw-r--r--editor/quick_open.cpp11
9 files changed, 141 insertions, 76 deletions
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp
index c752d0d4fd..56a9d2c258 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -145,15 +145,15 @@ void DocTools::merge_from(const DocTools &p_data) {
}
for (int i = 0; i < c.theme_properties.size(); i++) {
- DocData::PropertyDoc &p = c.theme_properties.write[i];
+ DocData::ThemeItemDoc &ti = c.theme_properties.write[i];
for (int j = 0; j < cf.theme_properties.size(); j++) {
- if (cf.theme_properties[j].name != p.name) {
+ if (cf.theme_properties[j].name != ti.name || cf.theme_properties[j].data_type != ti.data_type) {
continue;
}
- const DocData::PropertyDoc &pf = cf.theme_properties[j];
+ const DocData::ThemeItemDoc &pf = cf.theme_properties[j];
- p.description = pf.description;
+ ti.description = pf.description;
break;
}
}
@@ -464,60 +464,69 @@ void DocTools::generate(bool p_basic_types) {
c.constants.push_back(constant);
}
- //theme stuff
-
+ // Theme items.
{
List<StringName> l;
- Theme::get_default()->get_constant_list(cname, &l);
- for (const StringName &E : l) {
- DocData::PropertyDoc pd;
- pd.name = E;
- pd.type = "int";
- pd.default_value = itos(Theme::get_default()->get_constant(E, cname));
- c.theme_properties.push_back(pd);
- }
- l.clear();
Theme::get_default()->get_color_list(cname, &l);
for (const StringName &E : l) {
- DocData::PropertyDoc pd;
- pd.name = E;
- pd.type = "Color";
- pd.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string();
- c.theme_properties.push_back(pd);
+ DocData::ThemeItemDoc tid;
+ tid.name = E;
+ tid.type = "Color";
+ tid.data_type = "color";
+ tid.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string();
+ c.theme_properties.push_back(tid);
}
l.clear();
- Theme::get_default()->get_icon_list(cname, &l);
+ Theme::get_default()->get_constant_list(cname, &l);
for (const StringName &E : l) {
- DocData::PropertyDoc pd;
- pd.name = E;
- pd.type = "Texture2D";
- c.theme_properties.push_back(pd);
+ DocData::ThemeItemDoc tid;
+ tid.name = E;
+ tid.type = "int";
+ tid.data_type = "constant";
+ tid.default_value = itos(Theme::get_default()->get_constant(E, cname));
+ c.theme_properties.push_back(tid);
}
+
l.clear();
Theme::get_default()->get_font_list(cname, &l);
for (const StringName &E : l) {
- DocData::PropertyDoc pd;
- pd.name = E;
- pd.type = "Font";
- c.theme_properties.push_back(pd);
+ DocData::ThemeItemDoc tid;
+ tid.name = E;
+ tid.type = "Font";
+ tid.data_type = "font";
+ c.theme_properties.push_back(tid);
}
+
l.clear();
Theme::get_default()->get_font_size_list(cname, &l);
for (const StringName &E : l) {
- DocData::PropertyDoc pd;
- pd.name = E;
- pd.type = "int";
- c.theme_properties.push_back(pd);
+ DocData::ThemeItemDoc tid;
+ tid.name = E;
+ tid.type = "int";
+ tid.data_type = "font_size";
+ c.theme_properties.push_back(tid);
+ }
+
+ l.clear();
+ Theme::get_default()->get_icon_list(cname, &l);
+ for (const StringName &E : l) {
+ DocData::ThemeItemDoc tid;
+ tid.name = E;
+ tid.type = "Texture2D";
+ tid.data_type = "icon";
+ c.theme_properties.push_back(tid);
}
+
l.clear();
Theme::get_default()->get_stylebox_list(cname, &l);
for (const StringName &E : l) {
- DocData::PropertyDoc pd;
- pd.name = E;
- pd.type = "StyleBox";
- c.theme_properties.push_back(pd);
+ DocData::ThemeItemDoc tid;
+ tid.name = E;
+ tid.type = "StyleBox";
+ tid.data_type = "style";
+ c.theme_properties.push_back(tid);
}
}
@@ -1069,12 +1078,14 @@ Error DocTools::_load(Ref<XMLParser> parser) {
String name3 = parser->get_node_name();
if (name3 == "theme_item") {
- DocData::PropertyDoc prop2;
+ DocData::ThemeItemDoc prop2;
ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT);
prop2.name = parser->get_attribute_value("name");
ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT);
prop2.type = parser->get_attribute_value("type");
+ ERR_FAIL_COND_V(!parser->has_attribute("data_type"), ERR_FILE_CORRUPT);
+ prop2.data_type = parser->get_attribute_value("data_type");
if (!parser->is_empty()) {
parser->read();
if (parser->get_node_type() == XMLParser::NODE_TEXT) {
@@ -1312,15 +1323,15 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str
_write_string(f, 1, "<theme_items>");
for (int i = 0; i < c.theme_properties.size(); i++) {
- const DocData::PropertyDoc &p = c.theme_properties[i];
+ const DocData::ThemeItemDoc &ti = c.theme_properties[i];
- if (p.default_value != "") {
- _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\" default=\"" + p.default_value.xml_escape(true) + "\">");
+ if (ti.default_value != "") {
+ _write_string(f, 2, "<theme_item name=\"" + ti.name + "\" data_type=\"" + ti.data_type + "\" type=\"" + ti.type + "\" default=\"" + ti.default_value.xml_escape(true) + "\">");
} else {
- _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">");
+ _write_string(f, 2, "<theme_item name=\"" + ti.name + "\" data_type=\"" + ti.data_type + "\" type=\"" + ti.type + "\">");
}
- _write_string(f, 3, p.description.strip_edges().xml_escape());
+ _write_string(f, 3, ti.description.strip_edges().xml_escape());
_write_string(f, 2, "</theme_item>");
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 569a28215c..f92b9ac8ba 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -758,8 +758,8 @@ void EditorHelp::_update_doc() {
if (cd.theme_properties[i].description != "") {
class_desc->push_font(doc_font);
- class_desc->add_text(" ");
class_desc->push_color(comment_color);
+ class_desc->add_text(U" – ");
_add_text(DTR(cd.theme_properties[i].description));
class_desc->pop();
class_desc->pop();
@@ -941,8 +941,7 @@ void EditorHelp::_update_doc() {
if (enum_list[i].description != "") {
class_desc->push_font(doc_font);
class_desc->push_color(comment_color);
- static const char32_t dash[6] = { ' ', ' ', 0x2013 /* en dash */, ' ', ' ', 0 };
- class_desc->add_text(String(dash));
+ class_desc->add_text(U" – ");
_add_text(DTR(enum_list[i].description));
class_desc->pop();
class_desc->pop();
@@ -1011,8 +1010,7 @@ void EditorHelp::_update_doc() {
if (constants[i].description != "") {
class_desc->push_font(doc_font);
class_desc->push_color(comment_color);
- static const char32_t dash[6] = { ' ', ' ', 0x2013 /* en dash */, ' ', ' ', 0 };
- class_desc->add_text(String(dash));
+ class_desc->add_text(U" – ");
_add_text(DTR(constants[i].description));
class_desc->pop();
class_desc->pop();
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index fabbf97f49..57f0345dad 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -367,7 +367,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes() {
if (search_flags & SEARCH_THEME_ITEMS) {
for (int i = 0; i < class_doc.theme_properties.size(); i++) {
if (_match_string(term, class_doc.theme_properties[i].name)) {
- match.theme_properties.push_back(const_cast<DocData::PropertyDoc *>(&class_doc.theme_properties[i]));
+ match.theme_properties.push_back(const_cast<DocData::ThemeItemDoc *>(&class_doc.theme_properties[i]));
}
}
}
@@ -571,7 +571,7 @@ TreeItem *EditorHelpSearch::Runner::_create_property_item(TreeItem *p_parent, co
return _create_member_item(p_parent, p_class_doc->name, "MemberProperty", p_doc->name, p_doc->name, TTRC("Property"), "property", tooltip);
}
-TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) {
+TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ThemeItemDoc *p_doc) {
String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name;
return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, p_doc->name, TTRC("Theme Property"), "theme_item", tooltip);
}
diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h
index 75da2d5aba..bc57c0e3c6 100644
--- a/editor/editor_help_search.h
+++ b/editor/editor_help_search.h
@@ -103,7 +103,7 @@ class EditorHelpSearch::Runner : public RefCounted {
Vector<DocData::MethodDoc *> signals;
Vector<DocData::ConstantDoc *> constants;
Vector<DocData::PropertyDoc *> properties;
- Vector<DocData::PropertyDoc *> theme_properties;
+ Vector<DocData::ThemeItemDoc *> theme_properties;
bool required() {
return name || methods.size() || signals.size() || constants.size() || properties.size() || theme_properties.size();
@@ -145,7 +145,7 @@ class EditorHelpSearch::Runner : public RefCounted {
TreeItem *_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc);
TreeItem *_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc);
TreeItem *_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc);
- TreeItem *_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc);
+ TreeItem *_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ThemeItemDoc *p_doc);
TreeItem *_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip);
public:
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index a566afb597..952bec4d87 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -408,22 +408,12 @@ void InspectorDock::update(Object *p_object) {
current = p_object;
- if (!p_object) {
- open_docs_button->set_disabled(true);
- object_menu->set_disabled(true);
- warning->hide();
- search->set_editable(false);
- editor_path->clear_path();
- return;
- }
-
- bool is_resource = p_object->is_class("Resource");
- bool is_node = p_object->is_class("Node");
-
- object_menu->set_disabled(false);
- search->set_editable(true);
- editor_path->enable_path();
+ const bool is_object = p_object != nullptr;
+ const bool is_resource = is_object && p_object->is_class("Resource");
+ const bool is_node = is_object && p_object->is_class("Node");
+ object_menu->set_disabled(!is_object);
+ search->set_editable(is_object);
resource_save_button->set_disabled(!is_resource);
open_docs_button->set_disabled(!is_resource && !is_node);
@@ -431,6 +421,14 @@ void InspectorDock::update(Object *p_object) {
resource_extra_popup->set_item_disabled(resource_extra_popup->get_item_index(RESOURCE_COPY), !is_resource);
resource_extra_popup->set_item_disabled(resource_extra_popup->get_item_index(RESOURCE_MAKE_BUILT_IN), !is_resource);
+ if (!is_object) {
+ warning->hide();
+ editor_path->clear_path();
+ return;
+ }
+
+ editor_path->enable_path();
+
PopupMenu *p = object_menu->get_popup();
p->clear();
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index e982625e2b..e3d68cf1ea 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -140,9 +140,11 @@ void ViewportRotationControl::_draw_axis(const Axis2D &p_axis) {
}
if (front) {
- String axis_name = direction == 0 ? "X" : (direction == 1 ? "Y" : "Z");
draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS, c);
- draw_char(get_theme_font(SNAME("rotation_control"), SNAME("EditorFonts")), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", get_theme_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts")), Color(0.3, 0.3, 0.3));
+ if (positive) {
+ String axis_name = direction == 0 ? "X" : (direction == 1 ? "Y" : "Z");
+ draw_char(get_theme_font(SNAME("rotation_control"), SNAME("EditorFonts")), p_axis.screen_point + Vector2i(-4, 5) * EDSCALE, axis_name, "", get_theme_font_size(SNAME("rotation_control_size"), SNAME("EditorFonts")), Color(0.0, 0.0, 0.0));
+ }
} else {
draw_circle(p_axis.screen_point, AXIS_CIRCLE_RADIUS * (0.55 + (0.2 * (1.0 + p_axis.z_axis))), c);
}
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 0929a629f8..7ea3deedb9 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -1278,6 +1278,9 @@ void ThemeItemEditorDialog::_update_edit_types() {
edit_items_remove_class->set_disabled(false);
edit_items_remove_custom->set_disabled(false);
edit_items_remove_all->set_disabled(false);
+
+ edit_items_message->set_text("");
+ edit_items_message->hide();
} else {
edit_items_add_color->set_disabled(true);
edit_items_add_constant->set_disabled(true);
@@ -1289,6 +1292,9 @@ void ThemeItemEditorDialog::_update_edit_types() {
edit_items_remove_class->set_disabled(true);
edit_items_remove_custom->set_disabled(true);
edit_items_remove_all->set_disabled(true);
+
+ edit_items_message->set_text(TTR("Select a theme type from the list to edit its items.\nYou can add a custom type or import a type with its items from another theme."));
+ edit_items_message->show();
}
_update_edit_item_tree(selected_type);
}
@@ -1305,6 +1311,7 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) {
TreeItem *root = edit_items_tree->create_item();
List<StringName> names;
+ bool has_any_items = false;
{ // Colors.
names.clear();
@@ -1324,6 +1331,8 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) {
item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
}
+
+ has_any_items = true;
}
}
@@ -1345,6 +1354,8 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) {
item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
}
+
+ has_any_items = true;
}
}
@@ -1366,6 +1377,8 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) {
item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
}
+
+ has_any_items = true;
}
}
@@ -1387,6 +1400,8 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) {
item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
}
+
+ has_any_items = true;
}
}
@@ -1408,6 +1423,8 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) {
item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
}
+
+ has_any_items = true;
}
}
@@ -1429,6 +1446,20 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) {
item->add_button(0, get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), ITEMS_TREE_RENAME_ITEM, false, TTR("Rename Item"));
item->add_button(0, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), ITEMS_TREE_REMOVE_ITEM, false, TTR("Remove Item"));
}
+
+ has_any_items = true;
+ }
+ }
+
+ // If some type is selected, but it doesn't seem to have any items, show a guiding message.
+ Vector<int> selected_ids = edit_type_list->get_selected_items();
+ if (selected_ids.size() > 0) {
+ if (!has_any_items) {
+ edit_items_message->set_text(TTR("This theme type is empty.\nAdd more items to it manually or by importing from another theme."));
+ edit_items_message->show();
+ } else {
+ edit_items_message->set_text("");
+ edit_items_message->hide();
}
}
}
@@ -1873,6 +1904,14 @@ ThemeItemEditorDialog::ThemeItemEditorDialog() {
edit_items_vb->add_child(edit_items_tree);
edit_items_tree->connect("button_pressed", callable_mp(this, &ThemeItemEditorDialog::_item_tree_button_pressed));
+ edit_items_message = memnew(Label);
+ edit_items_message->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
+ edit_items_message->set_mouse_filter(Control::MOUSE_FILTER_STOP);
+ edit_items_message->set_align(Label::ALIGN_CENTER);
+ edit_items_message->set_valign(Label::VALIGN_CENTER);
+ edit_items_message->set_autowrap_mode(Label::AUTOWRAP_WORD);
+ edit_items_tree->add_child(edit_items_message);
+
edit_theme_item_dialog = memnew(ConfirmationDialog);
edit_theme_item_dialog->set_title(TTR("Add Theme Item"));
add_child(edit_theme_item_dialog);
@@ -2542,15 +2581,15 @@ void ThemeTypeEditor::_update_type_items() {
// Various type settings.
if (ClassDB::class_exists(edited_type)) {
type_variation_edit->set_editable(false);
- type_variation_edit->set_tooltip(TTR("A type associated with a built-in class cannot be marked as a variation of another type."));
type_variation_edit->set_text("");
type_variation_button->hide();
+ type_variation_locked->show();
} else {
type_variation_edit->set_editable(true);
- type_variation_edit->set_tooltip("");
type_variation_edit->set_text(edited_theme->get_type_variation_base(edited_type));
_add_focusable(type_variation_edit);
type_variation_button->show();
+ type_variation_locked->hide();
}
}
@@ -3067,8 +3106,11 @@ ThemeTypeEditor::ThemeTypeEditor() {
type_settings_list->set_h_size_flags(SIZE_EXPAND_FILL);
type_settings_sc->add_child(type_settings_list);
+ VBoxContainer *type_variation_vb = memnew(VBoxContainer);
+ type_settings_list->add_child(type_variation_vb);
+
HBoxContainer *type_variation_hb = memnew(HBoxContainer);
- type_settings_list->add_child(type_variation_hb);
+ type_variation_vb->add_child(type_variation_hb);
Label *type_variation_label = memnew(Label);
type_variation_hb->add_child(type_variation_label);
type_variation_label->set_text(TTR("Base Type"));
@@ -3083,6 +3125,13 @@ ThemeTypeEditor::ThemeTypeEditor() {
type_variation_button->set_tooltip(TTR("Select the variation base type from a list of available types."));
type_variation_button->connect("pressed", callable_mp(this, &ThemeTypeEditor::_add_type_variation_cbk));
+ type_variation_locked = memnew(Label);
+ type_variation_vb->add_child(type_variation_locked);
+ type_variation_locked->set_align(Label::ALIGN_CENTER);
+ type_variation_locked->set_autowrap_mode(Label::AUTOWRAP_WORD);
+ type_variation_locked->set_text(TTR("A type associated with a built-in class cannot be marked as a variation of another type."));
+ type_variation_locked->hide();
+
add_type_dialog = memnew(ThemeTypeDialog);
add_child(add_type_dialog);
add_type_dialog->connect("type_selected", callable_mp(this, &ThemeTypeEditor::_add_type_dialog_selected));
@@ -3130,7 +3179,7 @@ void ThemeEditor::_theme_save_button_cbk(bool p_save_as) {
}
void ThemeEditor::_theme_edit_button_cbk() {
- theme_edit_dialog->popup_centered(Size2(850, 760) * EDSCALE);
+ theme_edit_dialog->popup_centered(Size2(850, 700) * EDSCALE);
}
void ThemeEditor::_add_preview_button_cbk() {
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index e78b244a42..5b0357e3f8 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -197,6 +197,7 @@ class ThemeItemEditorDialog : public AcceptDialog {
Button *edit_items_remove_custom;
Button *edit_items_remove_all;
Tree *edit_items_tree;
+ Label *edit_items_message;
enum ItemsTreeAction {
ITEMS_TREE_RENAME_ITEM,
@@ -324,6 +325,7 @@ class ThemeTypeEditor : public MarginContainer {
LineEdit *type_variation_edit;
Button *type_variation_button;
+ Label *type_variation_locked;
enum TypeDialogMode {
ADD_THEME_TYPE,
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index bda7540a23..ed94f859e2 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -118,6 +118,11 @@ void EditorQuickOpen::_update_search() {
float EditorQuickOpen::_score_path(const String &p_search, const String &p_path) {
float score = 0.9f + .1f * (p_search.length() / (float)p_path.length());
+ // Exact match.
+ if (p_search == p_path) {
+ return 1.2f;
+ }
+
// Positive bias for matches close to the beginning of the file name.
String file = p_path.get_file();
int pos = file.findn(p_search);
@@ -128,11 +133,11 @@ float EditorQuickOpen::_score_path(const String &p_search, const String &p_path)
// Positive bias for matches close to the end of the path.
pos = p_path.rfindn(p_search);
if (pos != -1) {
- return score * (0.8f - 0.1f * (float(p_path.length() - pos) / p_path.length()));
+ return 1.1f + 0.09 / (p_path.length() - pos + 1);
}
- // Remaining results belong to the same class of results.
- return score * 0.69f;
+ // Similarity
+ return p_path.to_lower().similarity(p_search.to_lower());
}
void EditorQuickOpen::_confirmed() {