summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/filesystem_dock.cpp47
-rw-r--r--editor/filesystem_dock.h1
2 files changed, 32 insertions, 16 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 4f37fcf39c..31903c89be 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2430,11 +2430,31 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
}
}
-void FileSystemDock::_update_import_dock() {
- if (!import_dock_needs_update) {
+void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &files) const {
+ if (!p_path.ends_with("/")) {
+ if (FileAccess::exists(p_path + ".import")) {
+ files.push_back(p_path);
+ }
return;
}
+ DirAccess *da = DirAccess::open(p_path);
+ da->list_dir_begin();
+ String n = da->get_next();
+ while (n != String()) {
+ if (n != "." && n != ".." && !n.ends_with(".import")) {
+ String npath = p_path + n + (da->current_is_dir() ? "/" : "");
+ _get_imported_files(npath, files);
+ }
+ n = da->get_next();
+ }
+ da->list_dir_end();
+}
+
+void FileSystemDock::_update_import_dock() {
+ if (!import_dock_needs_update)
+ return;
+
// List selected.
Vector<String> selected;
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
@@ -2444,29 +2464,24 @@ void FileSystemDock::_update_import_dock() {
} else {
// Use the file list.
for (int i = 0; i < files->get_item_count(); i++) {
- if (!files->is_selected(i)) {
+ if (!files->is_selected(i))
continue;
- }
selected.push_back(files->get_item_metadata(i));
}
}
+ // Expand directory selection
+ Vector<String> efiles;
+ for (int i = 0; i < selected.size(); i++) {
+ _get_imported_files(selected[i], efiles);
+ }
+
// Check import.
Vector<String> imports;
String import_type;
- for (int i = 0; i < selected.size(); i++) {
- String fpath = selected[i];
-
- if (fpath.ends_with("/")) {
- imports.clear();
- break;
- }
-
- if (!FileAccess::exists(fpath + ".import")) {
- imports.clear();
- break;
- }
+ for (int i = 0; i < efiles.size(); i++) {
+ String fpath = efiles[i];
Ref<ConfigFile> cf;
cf.instance();
Error err = cf->load(fpath + ".import");
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index b0118f11aa..ec2a075834 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -195,6 +195,7 @@ private:
void _file_multi_selected(int p_index, bool p_selected);
void _tree_multi_selected(Object *p_item, int p_column, bool p_selected);
+ void _get_imported_files(const String &p_path, Vector<String> &files) const;
void _update_import_dock();
void _get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const;