summaryrefslogtreecommitdiff
path: root/editor/create_dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/create_dialog.cpp')
-rw-r--r--editor/create_dialog.cpp63
1 files changed, 38 insertions, 25 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 926fa37040..26bd651c2b 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -89,8 +89,9 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) {
_save_and_update_favorite_list();
// Restore valid window bounds or pop up at default size.
- if (EditorSettings::get_singleton()->has_setting("interface/dialogs/create_new_node_bounds")) {
- popup(EditorSettings::get_singleton()->get("interface/dialogs/create_new_node_bounds"));
+ Rect2 saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", Rect2());
+ if (saved_size != Rect2()) {
+ popup(saved_size);
} else {
Size2 popup_size = Size2(900, 700) * editor_get_scale();
@@ -112,18 +113,6 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode) {
_update_search();
- bool enable_rl = EditorSettings::get_singleton()->get("docks/scene_tree/draw_relationship_lines");
- Color rl_color = EditorSettings::get_singleton()->get("docks/scene_tree/relationship_line_color");
-
- if (enable_rl) {
- search_options->add_constant_override("draw_relationship_lines", 1);
- search_options->add_color_override("relationship_line_color", rl_color);
- search_options->add_constant_override("draw_guides", 0);
- } else {
- search_options->add_constant_override("draw_relationship_lines", 0);
- search_options->add_constant_override("draw_guides", 1);
- }
-
is_replace_mode = p_replace_mode;
if (p_replace_mode) {
@@ -207,7 +196,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
if (!can_instance) {
item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
item->set_selectable(0, false);
- } else {
+ } else if (!(*to_select && (*to_select)->get_text(0) == search_box->get_text())) {
bool is_search_subsequence = search_box->get_text().is_subsequence_ofi(p_type);
String to_select_type = *to_select ? (*to_select)->get_text(0) : "";
to_select_type = to_select_type.split(" ")[0];
@@ -215,16 +204,16 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
if (cpp_type) {
String cpp_to_select_type = to_select_type;
if (ScriptServer::is_global_class(to_select_type))
- cpp_to_select_type = ScriptServer::get_global_class_base(to_select_type);
+ cpp_to_select_type = ScriptServer::get_global_class_native_base(to_select_type);
current_item_is_preferred = ClassDB::is_parent_class(p_type, preferred_search_result_type) && !ClassDB::is_parent_class(cpp_to_select_type, preferred_search_result_type);
} else {
current_item_is_preferred = ed.script_class_is_parent(p_type, preferred_search_result_type) && !ed.script_class_is_parent(to_select_type, preferred_search_result_type) && search_box->get_text() != to_select_type;
}
- if (*to_select && p_type.length() < (*to_select)->get_text(0).length()) {
+ if (search_box->get_text() == p_type || (*to_select && p_type.length() < (*to_select)->get_text(0).length())) {
current_item_is_preferred = true;
}
- if (((!*to_select || current_item_is_preferred) && is_search_subsequence) || search_box->get_text() == p_type) {
+ if (((!*to_select || current_item_is_preferred) && is_search_subsequence)) {
*to_select = item;
}
}
@@ -249,6 +238,26 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
p_types[p_type] = item;
}
+bool CreateDialog::_is_class_disabled_by_feature_profile(const StringName &p_class) {
+
+ Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile();
+ if (profile.is_null()) {
+ return false;
+ }
+
+ StringName class_name = p_class;
+
+ while (class_name != StringName()) {
+
+ if (profile->is_class_disabled(class_name)) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class(class_name);
+ }
+
+ return false;
+}
+
void CreateDialog::_update_search() {
search_options->clear();
@@ -275,6 +284,10 @@ void CreateDialog::_update_search() {
for (List<StringName>::Element *I = type_list.front(); I; I = I->next()) {
String type = I->get();
+
+ if (_is_class_disabled_by_feature_profile(type)) {
+ continue;
+ }
bool cpp_type = ClassDB::class_exists(type);
if (base_type == "Node" && type.begins_with("Editor"))
@@ -298,15 +311,15 @@ void CreateDialog::_update_search() {
} else {
bool found = false;
- String type = I->get();
- while (type != "" && (cpp_type ? ClassDB::is_parent_class(type, base_type) : ed.script_class_is_parent(type, base_type)) && type != base_type) {
- if (search_box->get_text().is_subsequence_ofi(type)) {
+ String type2 = I->get();
+ while (type2 != "" && (cpp_type ? ClassDB::is_parent_class(type2, base_type) : ed.script_class_is_parent(type2, base_type)) && type2 != base_type) {
+ if (search_box->get_text().is_subsequence_ofi(type2)) {
found = true;
break;
}
- type = cpp_type ? ClassDB::get_parent_class(type) : ed.script_class_get_base(type);
+ type2 = cpp_type ? ClassDB::get_parent_class(type2) : ed.script_class_get_base(type2);
}
if (found)
@@ -415,7 +428,7 @@ void CreateDialog::_notification(int p_what) {
}
} break;
case NOTIFICATION_POPUP_HIDE: {
- EditorSettings::get_singleton()->set("interface/dialogs/create_new_node_bounds", get_rect());
+ EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "create_new_node", get_rect());
} break;
}
}