summaryrefslogtreecommitdiff
path: root/editor/create_dialog.cpp
diff options
context:
space:
mode:
authortoger5 <toger5@hotmail.de>2017-09-29 20:57:31 +0200
committertoger5 <toger5@hotmail.de>2017-09-29 21:00:10 +0200
commit3f423342f4d28b8cd4a8ef1b783ffc76425ce1e0 (patch)
tree616f507b0d65ced6fedd50f494d28022641a4506 /editor/create_dialog.cpp
parentdee100139008bd4dd8c270da6a7f5aa326a32c25 (diff)
create dialog search preferrence fixes: #11697
Diffstat (limited to 'editor/create_dialog.cpp')
-rw-r--r--editor/create_dialog.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 0305013776..ca68d84abd 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -168,8 +168,11 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
item->set_selectable(0, false);
} else {
+ bool is_search_subsequence = search_box->get_text().is_subsequence_ofi(p_type);
+ String to_select_type = *to_select ? (*to_select)->get_text(0) : "";
+ bool current_item_is_preffered = ClassDB::is_parent_class(p_type, preferred_search_result_type) && !ClassDB::is_parent_class(to_select_type, preferred_search_result_type);
- if ((!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) || search_box->get_text() == p_type) {
+ if (((!*to_select || current_item_is_preffered) && is_search_subsequence) || search_box->get_text() == p_type) {
*to_select = item;
}
}
@@ -361,6 +364,19 @@ void CreateDialog::set_base_type(const String &p_base) {
_update_search();
}
+String CreateDialog::get_base_type() const {
+
+ return base_type;
+}
+
+void CreateDialog::set_preferred_search_result_type(const String &p_preferred_type) {
+ preferred_search_result_type = p_preferred_type;
+}
+
+String CreateDialog::get_preferred_search_result_type() {
+
+ return preferred_search_result_type;
+}
String CreateDialog::get_selected_type() {
TreeItem *selected = search_options->get_selected();
@@ -411,11 +427,6 @@ Object *CreateDialog::instance_selected() {
return NULL;
}
-String CreateDialog::get_base_type() const {
-
- return base_type;
-}
-
void CreateDialog::_item_selected() {
TreeItem *item = search_options->get_selected();
@@ -654,6 +665,7 @@ CreateDialog::CreateDialog() {
search_options->connect("cell_selected", this, "_item_selected");
//search_options->set_hide_root(true);
base_type = "Object";
+ preferred_search_result_type = "";
help_bit = memnew(EditorHelpBit);
vbc->add_margin_child(TTR("Description:"), help_bit);