summaryrefslogtreecommitdiff
path: root/tools/editor/create_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/create_dialog.cpp')
-rw-r--r--tools/editor/create_dialog.cpp42
1 files changed, 34 insertions, 8 deletions
diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp
index c156b1b2de..5275e1beeb 100644
--- a/tools/editor/create_dialog.cpp
+++ b/tools/editor/create_dialog.cpp
@@ -36,6 +36,8 @@
#if 1
#include "os/keyboard.h"
+#include "editor_settings.h"
+#include "editor_help.h"
void CreateDialog::popup(bool p_dontclear) {
@@ -101,12 +103,27 @@ void CreateDialog::add_type(const String& p_type,HashMap<String,TreeItem*>& p_ty
item->set_selectable(0,false);
} else {
- if (!*to_select && (search_box->get_text()=="" || p_type.findn(search_box->get_text())!=-1)) {
+ if (!*to_select && (search_box->get_text().is_subsequence_ofi(p_type))) {
*to_select=item;
}
}
+ if (bool(EditorSettings::get_singleton()->get("scenetree_editor/start_create_dialog_fully_expanded"))) {
+ item->set_collapsed(false);
+ } else {
+ // don't collapse search results
+ bool collapse = (search_box->get_text() == "");
+ // don't collapse the root node
+ collapse &= (item != p_root);
+ // don't collapse abstract nodes on the first tree level
+ collapse &= ((parent != p_root) || (ObjectTypeDB::can_instance(p_type)));
+ item->set_collapsed(collapse);
+ }
+
+ const String& description = EditorHelp::get_doc_data()->class_list[p_type].brief_description;
+ item->set_tooltip(0,description);
+
if (has_icon(p_type,"EditorIcons")) {
@@ -155,7 +172,7 @@ void CreateDialog::_update_search() {
bool found=false;
String type=I->get();
while(type!="" && ObjectTypeDB::is_type(type,base_type) && type!=base_type) {
- if (type.findn(search_box->get_text())!=-1) {
+ if (search_box->get_text().is_subsequence_ofi(type)) {
found=true;
break;
@@ -177,7 +194,7 @@ void CreateDialog::_update_search() {
const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type];
for(int i=0;i<ct.size();i++) {
- bool show = search_box->get_text()=="" || ct[i].name.findn(search_box->get_text())!=-1;
+ bool show = search_box->get_text().is_subsequence_ofi(ct[i].name);
if (!show)
continue;
@@ -251,10 +268,19 @@ void CreateDialog::_notification(int p_what) {
void CreateDialog::set_base_type(const String& p_base) {
base_type=p_base;
- set_title(TTR("Create New ")+p_base);
+ set_title(TTR("Create New")+" "+p_base);
_update_search();
}
+String CreateDialog::get_selected_type() {
+
+ TreeItem *selected = search_options->get_selected();
+ if (selected)
+ return selected->get_text(0);
+ else
+ return String();
+}
+
Object *CreateDialog::instance_selected() {
TreeItem *selected = search_options->get_selected();
@@ -541,7 +567,7 @@ void CreateDialog::_bind_methods() {
void CreateDialog::set_base_type(const String& p_base) {
- set_title(TTR("Create ")+p_base+" Type");
+ set_title(vformat("Create %s Type",p_base));
if (base==p_base)
return;
@@ -562,14 +588,14 @@ CreateDialog::CreateDialog() {
add_child(vbc);
set_child_rect(vbc);
- get_ok()->set_text(TTR("Create"));
+ get_ok()->set_text("Create");
tree = memnew( Tree );
- vbc->add_margin_child(TTR("Type:"),tree,true);
+ vbc->add_margin_child("Type:",tree,true);
//tree->set_hide_root(true);
filter = memnew( LineEdit );
- vbc->add_margin_child(TTR("Filter:"),filter);
+ vbc->add_margin_child("Filter:",filter);
base="Node";
set_as_toplevel(true);