summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_bezier_editor.cpp3
-rw-r--r--editor/editor_file_system.cpp6
-rw-r--r--editor/editor_node.cpp125
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/editor_properties.cpp10
-rw-r--r--editor/editor_resource_preview.cpp6
-rw-r--r--editor/filesystem_dock.cpp10
-rw-r--r--editor/plugins/animation_tree_editor_plugin.cpp2
-rw-r--r--editor/plugins/animation_tree_editor_plugin.h2
-rw-r--r--editor/plugins/script_editor_plugin.cpp15
-rw-r--r--editor/property_editor.cpp8
-rw-r--r--editor/quick_open.cpp65
-rw-r--r--editor/quick_open.h3
-rw-r--r--editor/scene_tree_dock.cpp29
-rw-r--r--editor/scene_tree_editor.cpp2
15 files changed, 217 insertions, 71 deletions
diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp
index f880ece88b..e52f234218 100644
--- a/editor/animation_bezier_editor.cpp
+++ b/editor/animation_bezier_editor.cpp
@@ -31,6 +31,7 @@
#include "animation_bezier_editor.h"
#include "editor/editor_node.h"
+#include "editor_scale.h"
float AnimationBezierTrackEdit::_bezier_h_to_pixel(float p_h) {
float h = p_h;
@@ -539,7 +540,7 @@ void AnimationBezierTrackEdit::_play_position_draw() {
if (px >= timeline->get_name_limit() && px < (get_size().width - timeline->get_buttons_width())) {
Color color = get_theme_color("accent_color", "Editor");
- play_position->draw_line(Point2(px, 0), Point2(px, h), color);
+ play_position->draw_line(Point2(px, 0), Point2(px, h), color, Math::round(2 * EDSCALE));
}
}
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index d88c61d7b2..9ca3d387d9 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -233,9 +233,9 @@ void EditorFileSystem::_scan_filesystem() {
FileCache fc;
fc.type = split[1];
- fc.modification_time = split[2].to_int64();
- fc.import_modification_time = split[3].to_int64();
- fc.import_valid = split[4].to_int64() != 0;
+ fc.modification_time = split[2].to_int();
+ fc.import_modification_time = split[3].to_int();
+ fc.import_valid = split[4].to_int() != 0;
fc.import_group_file = split[5].strip_edges();
fc.script_class_name = split[6].get_slice("<>", 0);
fc.script_class_extends = split[6].get_slice("<>", 1);
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 8909fb2cfe..b30d280023 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -178,6 +178,111 @@
EditorNode *EditorNode::singleton = nullptr;
+void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames) {
+ // Keep track of a list of "index sets," i.e. sets of indices
+ // within disambiguated_scene_names which contain the same name.
+ Vector<Set<int>> index_sets;
+ Map<String, int> scene_name_to_set_index;
+ for (int i = 0; i < r_filenames.size(); i++) {
+ String scene_name = r_filenames[i];
+ if (!scene_name_to_set_index.has(scene_name)) {
+ index_sets.append(Set<int>());
+ scene_name_to_set_index.insert(r_filenames[i], index_sets.size() - 1);
+ }
+ index_sets.write[scene_name_to_set_index[scene_name]].insert(i);
+ }
+
+ // For each index set with a size > 1, we need to disambiguate
+ for (int i = 0; i < index_sets.size(); i++) {
+ Set<int> iset = index_sets[i];
+ while (iset.size() > 1) {
+ // Append the parent folder to each scene name
+ for (Set<int>::Element *E = iset.front(); E; E = E->next()) {
+ int set_idx = E->get();
+ String scene_name = r_filenames[set_idx];
+ String full_path = p_full_paths[set_idx];
+
+ // Get rid of file extensions and res:// prefixes
+ if (scene_name.rfind(".") >= 0) {
+ scene_name = scene_name.substr(0, scene_name.rfind("."));
+ }
+ if (full_path.begins_with("res://")) {
+ full_path = full_path.substr(6);
+ }
+ if (full_path.rfind(".") >= 0) {
+ full_path = full_path.substr(0, full_path.rfind("."));
+ }
+
+ int scene_name_size = scene_name.size();
+ int full_path_size = full_path.size();
+ int difference = full_path_size - scene_name_size;
+
+ // Find just the parent folder of the current path and append it.
+ // If the current name is foo.tscn, and the full path is /some/folder/foo.tscn
+ // then slash_idx is the second '/', so that we select just "folder", and
+ // append that to yield "folder/foo.tscn".
+ if (difference > 0) {
+ String parent = full_path.substr(0, difference);
+ int slash_idx = parent.rfind("/");
+ slash_idx = parent.rfind("/", slash_idx - 1);
+ parent = slash_idx >= 0 ? parent.substr(slash_idx + 1) : parent;
+ r_filenames.write[set_idx] = parent + r_filenames[set_idx];
+ }
+ }
+
+ // Loop back through scene names and remove non-ambiguous names
+ bool can_proceed = false;
+ Set<int>::Element *E = iset.front();
+ while (E) {
+ String scene_name = r_filenames[E->get()];
+ bool duplicate_found = false;
+ for (Set<int>::Element *F = iset.front(); F; F = F->next()) {
+ if (E->get() == F->get()) {
+ continue;
+ }
+ String other_scene_name = r_filenames[F->get()];
+ if (other_scene_name == scene_name) {
+ duplicate_found = true;
+ break;
+ }
+ }
+
+ Set<int>::Element *to_erase = duplicate_found ? nullptr : E;
+
+ // We need to check that we could actually append anymore names
+ // if we wanted to for disambiguation. If we can't, then we have
+ // to abort even with ambiguous names. We clean the full path
+ // and the scene name first to remove extensions so that this
+ // comparison actually works.
+ String path = p_full_paths[E->get()];
+ if (path.begins_with("res://")) {
+ path = path.substr(6);
+ }
+ if (path.rfind(".") >= 0) {
+ path = path.substr(0, path.rfind("."));
+ }
+ if (scene_name.rfind(".") >= 0) {
+ scene_name = scene_name.substr(0, scene_name.rfind("."));
+ }
+
+ // We can proceed iff the full path is longer than the scene name,
+ // meaning that there is at least one more parent folder we can
+ // tack onto the name.
+ can_proceed = can_proceed || (path.size() - scene_name.size()) >= 1;
+
+ E = E->next();
+ if (to_erase) {
+ iset.erase(to_erase);
+ }
+ }
+
+ if (!can_proceed) {
+ break;
+ }
+ }
+ }
+}
+
void EditorNode::_update_scene_tabs() {
bool show_rb = EditorSettings::get_singleton()->get("interface/scene_tabs/show_script_button");
@@ -185,6 +290,16 @@ void EditorNode::_update_scene_tabs() {
DisplayServer::get_singleton()->global_menu_clear("_dock");
}
+ // Get all scene names, which may be ambiguous
+ Vector<String> disambiguated_scene_names;
+ Vector<String> full_path_names;
+ for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
+ disambiguated_scene_names.append(editor_data.get_scene_title(i));
+ full_path_names.append(editor_data.get_scene_path(i));
+ }
+
+ disambiguate_filenames(full_path_names, disambiguated_scene_names);
+
scene_tabs->clear_tabs();
Ref<Texture2D> script_icon = gui_base->get_theme_icon("Script", "EditorIcons");
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
@@ -196,7 +311,7 @@ void EditorNode::_update_scene_tabs() {
int current = editor_data.get_edited_scene();
bool unsaved = (i == current) ? saved_version != editor_data.get_undo_redo().get_version() : editor_data.get_scene_version(i) != 0;
- scene_tabs->add_tab(editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), icon);
+ scene_tabs->add_tab(disambiguated_scene_names[i] + (unsaved ? "(*)" : ""), icon);
if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_GLOBAL_MENU)) {
DisplayServer::get_singleton()->global_menu_add_item("_dock", editor_data.get_scene_title(i) + (unsaved ? "(*)" : ""), callable_mp(this, &EditorNode::_global_menu_scene), i);
@@ -360,7 +475,7 @@ void EditorNode::_notification(int p_what) {
bool dof_jitter = GLOBAL_GET("rendering/quality/depth_of_field/depth_of_field_use_jitter");
RS::get_singleton()->camera_effects_set_dof_blur_quality(dof_quality, dof_jitter);
RS::get_singleton()->environment_set_ssao_quality(RS::EnvironmentSSAOQuality(int(GLOBAL_GET("rendering/quality/ssao/quality"))), GLOBAL_GET("rendering/quality/ssao/half_size"));
- RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_enable"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_amount"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_limit"));
+ RS::get_singleton()->screen_space_roughness_limiter_set_active(GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_enabled"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_amount"), GLOBAL_GET("rendering/quality/screen_filters/screen_space_roughness_limiter_limit"));
bool glow_bicubic = int(GLOBAL_GET("rendering/quality/glow/upscale_mode")) > 0;
RS::get_singleton()->environment_glow_set_use_bicubic_upscale(glow_bicubic);
RS::EnvironmentSSRRoughnessQuality ssr_roughness_quality = RS::EnvironmentSSRRoughnessQuality(int(GLOBAL_GET("rendering/quality/screen_space_reflection/roughness_quality")));
@@ -3411,10 +3526,14 @@ void EditorNode::_update_recent_scenes() {
void EditorNode::_quick_opened() {
Vector<String> files = quick_open->get_selected_files();
+ bool open_scene_dialog = quick_open->get_base_type() == "PackedScene";
for (int i = 0; i < files.size(); i++) {
String res_path = files[i];
- if (quick_open->get_base_type() == "PackedScene") {
+ List<String> scene_extensions;
+ ResourceLoader::get_recognized_extensions_for_type("PackedScene", &scene_extensions);
+
+ if (open_scene_dialog || scene_extensions.find(files[i].get_extension())) {
open_request(res_path);
} else {
load_resource(res_path);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index b0e0c5614c..413e228e2a 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -687,6 +687,8 @@ public:
static void add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);
static void remove_editor_plugin(EditorPlugin *p_editor, bool p_config_changed = false);
+ static void disambiguate_filenames(const Vector<String> p_full_paths, Vector<String> &r_filenames);
+
void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE, false); }
void set_docks_visible(bool p_show);
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index eee610e9a8..23db6ebb4e 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -377,13 +377,13 @@ void EditorPropertyMember::_property_select() {
selector->select_method_from_base_type(hint_text, current);
} else if (hint == MEMBER_METHOD_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
selector->select_method_from_instance(instance, current);
}
} else if (hint == MEMBER_METHOD_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
selector->select_method_from_script(Object::cast_to<Script>(obj), current);
}
@@ -408,13 +408,13 @@ void EditorPropertyMember::_property_select() {
selector->select_property_from_base_type(hint_text, current);
} else if (hint == MEMBER_PROPERTY_OF_INSTANCE) {
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
selector->select_property_from_instance(instance, current);
}
} else if (hint == MEMBER_PROPERTY_OF_SCRIPT) {
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
selector->select_property_from_script(Object::cast_to<Script>(obj), current);
}
@@ -488,7 +488,7 @@ void EditorPropertyEnum::setup(const Vector<String> &p_options) {
for (int i = 0; i < p_options.size(); i++) {
Vector<String> text_split = p_options[i].split(":");
if (text_split.size() != 1) {
- current_val = text_split[1].to_int64();
+ current_val = text_split[1].to_int();
}
options->add_item(text_split[0]);
options->set_item_metadata(i, current_val);
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp
index 7ac8fae156..d2250fed7a 100644
--- a/editor/editor_resource_preview.cpp
+++ b/editor/editor_resource_preview.cpp
@@ -110,7 +110,7 @@ void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Textur
uint64_t modified_time = 0;
if (p_str.begins_with("ID:")) {
- hash = uint32_t(p_str.get_slicec(':', 2).to_int64());
+ hash = uint32_t(p_str.get_slicec(':', 2).to_int());
path = "ID:" + p_str.get_slicec(':', 1);
} else {
modified_time = FileAccess::get_modified_time(path);
@@ -257,9 +257,9 @@ void EditorResourcePreview::_thread() {
_generate_preview(texture, small_texture, item, cache_base);
} else {
uint64_t modtime = FileAccess::get_modified_time(item.path);
- int tsize = f->get_line().to_int64();
+ int tsize = f->get_line().to_int();
bool has_small_texture = f->get_line().to_int();
- uint64_t last_modtime = f->get_line().to_int64();
+ uint64_t last_modtime = f->get_line().to_int();
bool cache_valid = true;
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index c700fdccad..133aa39cd3 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2313,7 +2313,7 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) {
tree_popup->clear();
tree_popup->set_size(Size2(1, 1));
_file_and_folders_fill_popup(tree_popup, paths);
- tree_popup->set_position(tree->get_global_position() + p_pos);
+ tree_popup->set_position(tree->get_screen_position() + p_pos);
tree_popup->popup();
}
}
@@ -2508,10 +2508,10 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_tree_thumbnail_done"), &FileSystemDock::_tree_thumbnail_done);
ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file);
- ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &FileSystemDock::get_drag_data_fw);
- ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &FileSystemDock::can_drop_data_fw);
- ClassDB::bind_method(D_METHOD("drop_data_fw"), &FileSystemDock::drop_data_fw);
- ClassDB::bind_method(D_METHOD("navigate_to_path"), &FileSystemDock::navigate_to_path);
+ ClassDB::bind_method(D_METHOD("get_drag_data_fw", "position", "from"), &FileSystemDock::get_drag_data_fw);
+ ClassDB::bind_method(D_METHOD("can_drop_data_fw", "position", "data", "from"), &FileSystemDock::can_drop_data_fw);
+ ClassDB::bind_method(D_METHOD("drop_data_fw", "position", "data", "from"), &FileSystemDock::drop_data_fw);
+ ClassDB::bind_method(D_METHOD("navigate_to_path", "path"), &FileSystemDock::navigate_to_path);
ClassDB::bind_method(D_METHOD("_update_import_dock"), &FileSystemDock::_update_import_dock);
diff --git a/editor/plugins/animation_tree_editor_plugin.cpp b/editor/plugins/animation_tree_editor_plugin.cpp
index ec3e25f999..dc813896ff 100644
--- a/editor/plugins/animation_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_tree_editor_plugin.cpp
@@ -238,7 +238,7 @@ AnimationTreeEditor::AnimationTreeEditor() {
add_child(memnew(HSeparator));
singleton = this;
- editor_base = memnew(PanelContainer);
+ editor_base = memnew(MarginContainer);
editor_base->set_v_size_flags(SIZE_EXPAND_FILL);
add_child(editor_base);
diff --git a/editor/plugins/animation_tree_editor_plugin.h b/editor/plugins/animation_tree_editor_plugin.h
index 25af81ea9b..79a010b0c0 100644
--- a/editor/plugins/animation_tree_editor_plugin.h
+++ b/editor/plugins/animation_tree_editor_plugin.h
@@ -55,7 +55,7 @@ class AnimationTreeEditor : public VBoxContainer {
HBoxContainer *path_hb;
AnimationTree *tree;
- PanelContainer *editor_base;
+ MarginContainer *editor_base;
Vector<String> button_path;
Vector<String> edited_path;
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index fd415d40da..66f0155c6a 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -538,7 +538,7 @@ void ScriptEditor::_close_tab(int p_idx, bool p_save, bool p_history_back) {
ScriptEditorBase *current = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected));
if (current) {
if (p_save) {
- apply_scripts();
+ _menu_option(FILE_SAVE);
}
Ref<Script> script = current->get_edited_resource();
@@ -1731,6 +1731,19 @@ void ScriptEditor::_update_script_names() {
sedata.push_back(sd);
}
+ Vector<String> disambiguated_script_names;
+ Vector<String> full_script_paths;
+ for (int j = 0; j < sedata.size(); j++) {
+ disambiguated_script_names.append(sedata[j].name);
+ full_script_paths.append(sedata[j].tooltip);
+ }
+
+ EditorNode::disambiguate_filenames(full_script_paths, disambiguated_script_names);
+
+ for (int j = 0; j < sedata.size(); j++) {
+ sedata.write[j].name = disambiguated_script_names[j];
+ }
+
EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(i));
if (eh) {
String name = eh->get_class();
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 49b9ca167b..f4838d336f 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -597,7 +597,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_METHOD_OF_INSTANCE) {
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
property_select->select_method_from_instance(instance, v);
}
@@ -607,7 +607,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_METHOD_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
property_select->select_method_from_script(Object::cast_to<Script>(obj), v);
}
@@ -646,7 +646,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_PROPERTY_OF_INSTANCE) {
MAKE_PROPSELECT
- Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *instance = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (instance) {
property_select->select_property_from_instance(instance, v);
}
@@ -657,7 +657,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
} else if (hint == PROPERTY_HINT_PROPERTY_OF_SCRIPT) {
MAKE_PROPSELECT
- Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int64()));
+ Object *obj = ObjectDB::get_instance(ObjectID(hint_text.to_int()));
if (Object::cast_to<Script>(obj)) {
property_select->select_property_from_script(Object::cast_to<Script>(obj), v);
}
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index 4719fcaae4..4af6fb2053 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -62,7 +62,6 @@ Vector<String> EditorQuickOpen::get_selected_files() const {
TreeItem *item = search_options->get_next_selected(search_options->get_root());
while (item) {
files.push_back("res://" + item->get_text(0));
-
item = search_options->get_next_selected(item);
}
@@ -90,7 +89,6 @@ void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) {
}
TreeItem *current = search_options->get_selected();
-
TreeItem *item = search_options->get_next_selected(root);
while (item) {
item->deselect(0);
@@ -98,25 +96,29 @@ void EditorQuickOpen::_sbox_input(const Ref<InputEvent> &p_ie) {
}
current->select(0);
+ current->set_as_cursor(0);
} break;
}
}
}
-float EditorQuickOpen::_path_cmp(String search, String path) const {
- // Exact match.
- if (search == path) {
- return 1.2f;
+float EditorQuickOpen::_score_path(String search, String path) const {
+ // Positive bias for matches close to the _beginning of the file name_.
+ String file = path.get_file();
+ int pos = file.findn(search);
+ if (pos != -1) {
+ return 1.0f - 0.1f * (float(pos) / file.length());
}
- // Substring match, with positive bias for matches close to the end of the path.
- int pos = path.rfindn(search);
+ // Positive bias for matches close to the _end of the path_.
+ String base = path.get_base_dir();
+ pos = base.rfindn(search);
if (pos != -1) {
- return 1.1f + 0.09 / (path.length() - pos + 1);
+ return 0.9f - 0.1f * (float(base.length() - pos) / base.length());
}
- // Similarity.
- return path.to_lower().similarity(search.to_lower());
+ // Results that contain all characters but not the string.
+ return path.similarity(search) * 0.8f;
}
void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D>>> &list) {
@@ -124,25 +126,25 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<Str
_parse_fs(efsd->get_subdir(i), list);
}
- String search_text = search_box->get_text();
-
for (int i = 0; i < efsd->get_file_count(); i++) {
- String file = efsd->get_file_path(i);
- file = file.substr(6, file.length());
-
StringName file_type = efsd->get_file_type(i);
- if (ClassDB::is_parent_class(file_type, base_type) && search_text.is_subsequence_ofi(file)) {
- Pair<String, Ref<Texture2D>> pair;
- pair.first = file;
- StringName icon_name = search_options->has_theme_icon(file_type, ei) ? file_type : ot;
- pair.second = search_options->get_theme_icon(icon_name, ei);
- list.push_back(pair);
+
+ if (ClassDB::is_parent_class(file_type, base_type)) {
+ String file = efsd->get_file_path(i);
+ file = file.substr(6, file.length());
+
+ if (search_box->get_text().is_subsequence_ofi(file)) {
+ Pair<String, Ref<Texture2D>> pair;
+ pair.first = file;
+ pair.second = search_options->get_theme_icon(search_options->has_theme_icon(file_type, ei) ? file_type : ot, ei);
+ list.push_back(pair);
+ }
}
}
}
Vector<Pair<String, Ref<Texture2D>>> EditorQuickOpen::_sort_fs(Vector<Pair<String, Ref<Texture2D>>> &list) {
- String search_text = search_box->get_text();
+ String search_text = search_box->get_text().to_lower();
Vector<Pair<String, Ref<Texture2D>>> sorted_list;
if (search_text == String() || list.size() == 0) {
@@ -152,7 +154,7 @@ Vector<Pair<String, Ref<Texture2D>>> EditorQuickOpen::_sort_fs(Vector<Pair<Strin
Vector<float> scores;
scores.resize(list.size());
for (int i = 0; i < list.size(); i++) {
- scores.write[i] = _path_cmp(search_text, list[i].first);
+ scores.write[i] = _score_path(search_text, list[i].first.to_lower());
}
while (list.size() > 0) {
@@ -190,19 +192,17 @@ void EditorQuickOpen::_update_search() {
ti->set_icon(0, list[i].second);
}
- if (root->get_children()) {
- TreeItem *ti = root->get_children();
-
- ti->select(0);
- ti->set_as_cursor(0);
+ TreeItem *result = root->get_children();
+ if (result) {
+ result->select(0);
+ result->set_as_cursor(0);
}
- get_ok()->set_disabled(root->get_children() == nullptr);
+ get_ok()->set_disabled(!result);
}
void EditorQuickOpen::_confirmed() {
- TreeItem *ti = search_options->get_selected();
- if (!ti) {
+ if (!search_options->get_selected()) {
return;
}
emit_signal("quick_open");
@@ -252,7 +252,6 @@ EditorQuickOpen::EditorQuickOpen() {
vbc->add_margin_child(TTR("Matches:"), search_options, true);
get_ok()->set_text(TTR("Open"));
- get_ok()->set_disabled(true);
register_text_enter(search_box);
set_hide_on_ok(false);
diff --git a/editor/quick_open.h b/editor/quick_open.h
index 8670bb1ade..5bcdfc7bf2 100644
--- a/editor/quick_open.h
+++ b/editor/quick_open.h
@@ -41,6 +41,7 @@ class EditorQuickOpen : public ConfirmationDialog {
LineEdit *search_box;
Tree *search_options;
+
StringName base_type;
StringName ei;
StringName ot;
@@ -50,7 +51,7 @@ class EditorQuickOpen : public ConfirmationDialog {
void _sbox_input(const Ref<InputEvent> &p_ie);
void _parse_fs(EditorFileSystemDirectory *efsd, Vector<Pair<String, Ref<Texture2D>>> &list);
Vector<Pair<String, Ref<Texture2D>>> _sort_fs(Vector<Pair<String, Ref<Texture2D>>> &list);
- float _path_cmp(String search, String path) const;
+ float _score_path(String search, String path) const;
void _confirmed();
void _text_changed(const String &p_newtext);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 04ac809d03..b8ac405f53 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -741,17 +741,28 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
_delete_confirm();
} else {
- if (remove_list.size() >= 2) {
- delete_dialog->set_text(vformat(TTR("Delete %d nodes?"), remove_list.size()));
- } else if (remove_list.size() == 1 && remove_list[0] == editor_data->get_edited_scene_root()) {
- delete_dialog->set_text(vformat(TTR("Delete the root node \"%s\"?"), remove_list[0]->get_name()));
- } else if (remove_list.size() == 1 && remove_list[0]->get_filename() == "" && remove_list[0]->get_child_count() >= 1) {
- // Display this message only for non-instanced scenes
- delete_dialog->set_text(vformat(TTR("Delete node \"%s\" and its children?"), remove_list[0]->get_name()));
+ String msg;
+ if (remove_list.size() > 1) {
+ bool any_children = false;
+ for (int i = 0; !any_children && i < remove_list.size(); i++) {
+ any_children = remove_list[i]->get_child_count() > 0;
+ }
+
+ msg = vformat(any_children ? TTR("Delete %d nodes and any children?") : TTR("Delete %d nodes?"), remove_list.size());
} else {
- delete_dialog->set_text(vformat(TTR("Delete node \"%s\"?"), remove_list[0]->get_name()));
+ Node *node = remove_list[0];
+ if (node == editor_data->get_edited_scene_root()) {
+ msg = vformat(TTR("Delete the root node \"%s\"?"), node->get_name());
+ } else if (node->get_filename() == "" && node->get_child_count() > 0) {
+ // Display this message only for non-instanced scenes
+ msg = vformat(TTR("Delete node \"%s\" and its children?"), node->get_name());
+ } else {
+ msg = vformat(TTR("Delete node \"%s\"?"), node->get_name());
+ }
}
+ delete_dialog->set_text(msg);
+
// Resize the dialog to its minimum size.
// This prevents the dialog from being too wide after displaying
// a deletion confirmation for a node with a long name.
@@ -2388,7 +2399,7 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) {
}
menu->set_size(Size2(1, 1));
- menu->set_position(p_menu_pos);
+ menu->set_position(get_screen_position() + p_menu_pos);
menu->popup();
return;
}
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index 1b818036e1..6f29633188 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -1072,7 +1072,7 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) {
- emit_signal("rmb_pressed", tree->get_global_transform().xform(p_pos));
+ emit_signal("rmb_pressed", tree->get_screen_transform().xform(p_pos));
}
void SceneTreeEditor::_warning_changed(Node *p_for_node) {