Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Optimize selecting files in the FileSystem dock

NoNormalDev607c4a3eda52
diff --git a/editor/docks/filesystem_dock.cpp b/editor/docks/filesystem_dock.cpp
index e067e602a2a..0aad4126592 100644
--- a/editor/docks/filesystem_dock.cpp
+++ b/editor/docks/filesystem_dock.cpp
@@ -4141,39 +4141,12 @@ void FileSystemDock::_update_import_dock() {
_get_imported_files(fpath, extension, efiles);
}
- // Check import.
- Vector<String> imports;
- String import_type;
- for (int i = 0; i < efiles.size(); i++) {
- const String &fpath = efiles[i];
- Ref<ConfigFile> cf;
- cf.instantiate();
- Error err = cf->load(fpath + ".import");
- if (err != OK) {
- imports.clear();
- break;
- }
-
- String type;
- if (cf->has_section_key("remap", "type")) {
- type = cf->get_value("remap", "type");
- }
- if (import_type.is_empty()) {
- import_type = type;
- } else if (import_type != type) {
- // All should be the same type.
- imports.clear();
- break;
- }
- imports.push_back(fpath);
- }
-
- if (imports.is_empty()) {
+ if (efiles.is_empty()) {
ImportDock::get_singleton()->clear();
- } else if (imports.size() == 1) {
- ImportDock::get_singleton()->set_edit_path(imports[0]);
+ } else if (efiles.size() == 1) {
+ ImportDock::get_singleton()->set_edit_path(efiles[0]);
} else {
- ImportDock::get_singleton()->set_edit_multiple_paths(imports);
+ ImportDock::get_singleton()->set_edit_multiple_paths(efiles);
}
import_dock_needs_update = false;
diff --git a/editor/docks/import_dock.cpp b/editor/docks/import_dock.cpp
index 477ed42da16..e5f58868361 100644
--- a/editor/docks/import_dock.cpp
+++ b/editor/docks/import_dock.cpp
@@ -234,6 +234,8 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
HashMap<String, Dictionary> value_frequency;
HashSet<String> extensions;
+ String import_type;
+
for (int i = 0; i < p_paths.size(); i++) {
Ref<ConfigFile> config;
config.instantiate();
@@ -241,6 +243,15 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) {
Error err = config->load(p_paths[i] + ".import");
ERR_CONTINUE(err != OK);
+ const String type = config->get_value("remap", "type", String());
+ if (import_type.is_empty()) {
+ import_type = type;
+ } else if (import_type != type) {
+ // All should be the same type.
+ clear();
+ return;
+ }
+
if (i == 0) {
String importer_name = config->get_value("remap", "importer");
if (importer_name == "keep") {