summaryrefslogtreecommitdiffstats
path: root/editor/gui
diff options
context:
space:
mode:
authorSpartan322 <Megacake1234@gmail.com>2024-11-15 14:24:07 -0500
committerSpartan322 <Megacake1234@gmail.com>2024-11-15 14:24:07 -0500
commit4a5836e5462554a738b502aa8bbde5e4a051eb56 (patch)
treed58eaa8daad3e30c8b84a50e70a21f93b05525c5 /editor/gui
parentac1a49725fc038ae11ef9060fecb2b0f9c6333b2 (diff)
parent6c05ec3d6732cac44cf85c91db7d3fd1075bcb23 (diff)
downloadredot-engine-4a5836e5462554a738b502aa8bbde5e4a051eb56.tar.gz
Merge commit godotengine/godot@6c05ec3d6732cac44cf85c91db7d3fd1075bcb23
Diffstat (limited to 'editor/gui')
-rw-r--r--editor/gui/editor_file_dialog.cpp31
-rw-r--r--editor/gui/editor_file_dialog.h1
-rw-r--r--editor/gui/scene_tree_editor.cpp13
3 files changed, 37 insertions, 8 deletions
diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp
index b1e837ffae..6d0390ab99 100644
--- a/editor/gui/editor_file_dialog.cpp
+++ b/editor/gui/editor_file_dialog.cpp
@@ -67,7 +67,7 @@ void EditorFileDialog::_native_popup() {
} else if (access == ACCESS_USERDATA) {
root = OS::get_singleton()->get_user_data_dir();
}
- DisplayServer::get_singleton()->file_dialog_with_options_show(get_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), filters, _get_options(), callable_mp(this, &EditorFileDialog::_native_dialog_cb));
+ DisplayServer::get_singleton()->file_dialog_with_options_show(get_translated_title(), ProjectSettings::get_singleton()->globalize_path(dir->get_text()), root, file->get_text().get_file(), show_hidden_files, DisplayServer::FileDialogMode(mode), processed_filters, _get_options(), callable_mp(this, &EditorFileDialog::_native_dialog_cb));
}
void EditorFileDialog::popup(const Rect2i &p_rect) {
@@ -1150,37 +1150,54 @@ void EditorFileDialog::_filter_selected(int) {
void EditorFileDialog::update_filters() {
filter->clear();
+ processed_filters.clear();
if (filters.size() > 1) {
String all_filters;
+ String all_filters_full;
const int max_filters = 5;
for (int i = 0; i < MIN(max_filters, filters.size()); i++) {
- String flt = filters[i].get_slice(";", 0).strip_edges();
+ String flt = filters[i].get_slicec(';', 0).strip_edges();
if (i > 0) {
all_filters += ", ";
}
all_filters += flt;
}
+ for (int i = 0; i < filters.size(); i++) {
+ String flt = filters[i].get_slicec(';', 0).strip_edges();
+ if (i > 0) {
+ all_filters_full += ",";
+ }
+ all_filters_full += flt;
+ }
if (max_filters < filters.size()) {
all_filters += ", ...";
}
- filter->add_item(TTR("All Recognized") + " (" + all_filters + ")");
+ String f = TTR("All Recognized") + " (" + all_filters + ")";
+ filter->add_item(f);
+ processed_filters.push_back(all_filters_full + ";" + f);
}
for (int i = 0; i < filters.size(); i++) {
- String flt = filters[i].get_slice(";", 0).strip_edges();
+ String flt = filters[i].get_slicec(';', 0).strip_edges();
String desc = filters[i].get_slice(";", 1).strip_edges();
if (desc.length()) {
- filter->add_item(desc + " (" + flt + ")");
+ String f = desc + " (" + flt + ")";
+ filter->add_item(f);
+ processed_filters.push_back(flt + ";" + f);
} else {
- filter->add_item("(" + flt + ")");
+ String f = "(" + flt + ")";
+ filter->add_item(f);
+ processed_filters.push_back(flt + ";" + f);
}
}
- filter->add_item(TTR("All Files (*)"));
+ String f = TTR("All Files (*)");
+ filter->add_item(f);
+ processed_filters.push_back("*.*;" + f);
}
void EditorFileDialog::clear_filters() {
diff --git a/editor/gui/editor_file_dialog.h b/editor/gui/editor_file_dialog.h
index c74e3aae5b..52b5686cc0 100644
--- a/editor/gui/editor_file_dialog.h
+++ b/editor/gui/editor_file_dialog.h
@@ -147,6 +147,7 @@ private:
void _push_history();
Vector<String> filters;
+ Vector<String> processed_filters;
bool previews_enabled = true;
bool preview_waiting = false;
diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp
index 36ddfa757d..70ff927bd3 100644
--- a/editor/gui/scene_tree_editor.cpp
+++ b/editor/gui/scene_tree_editor.cpp
@@ -1100,8 +1100,19 @@ void SceneTreeEditor::rename_node(Node *p_node, const String &p_name, TreeItem *
// Trim leading/trailing whitespace to prevent node names from containing accidental whitespace, which would make it more difficult to get the node via `get_node()`.
new_name = new_name.strip_edges();
+ if (new_name.is_empty() && p_node->get_owner() != nullptr && !p_node->get_scene_file_path().is_empty()) {
+ // If name is empty and node is root of an instance, revert to the original name.
+ const Ref<PackedScene> node_scene = ResourceLoader::load(p_node->get_scene_file_path());
+ if (node_scene.is_valid()) {
+ const Ref<SceneState> &state = node_scene->get_state();
+ if (state->get_node_count() > 0) {
+ new_name = state->get_node_name(0); // Root's name.
+ }
+ }
+ }
+
if (new_name.is_empty()) {
- // If name is empty, fallback to class name.
+ // If name is still empty, fallback to class name.
if (GLOBAL_GET("editor/naming/node_name_casing").operator int() != NAME_CASING_PASCAL_CASE) {
new_name = Node::adjust_name_casing(p_node->get_class());
} else {