You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
Modified FileSystemDock so folders can be selected for reimport.
This commit is contained in:
@@ -2430,11 +2430,31 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSystemDock::_update_import_dock() {
|
void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &files) const {
|
||||||
if (!import_dock_needs_update) {
|
if (!p_path.ends_with("/")) {
|
||||||
|
if (FileAccess::exists(p_path + ".import")) {
|
||||||
|
files.push_back(p_path);
|
||||||
|
}
|
||||||
return;
|
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.
|
// List selected.
|
||||||
Vector<String> selected;
|
Vector<String> selected;
|
||||||
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
|
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
|
||||||
@@ -2444,29 +2464,24 @@ void FileSystemDock::_update_import_dock() {
|
|||||||
} else {
|
} else {
|
||||||
// Use the file list.
|
// Use the file list.
|
||||||
for (int i = 0; i < files->get_item_count(); i++) {
|
for (int i = 0; i < files->get_item_count(); i++) {
|
||||||
if (!files->is_selected(i)) {
|
if (!files->is_selected(i))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
selected.push_back(files->get_item_metadata(i));
|
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.
|
// Check import.
|
||||||
Vector<String> imports;
|
Vector<String> imports;
|
||||||
String import_type;
|
String import_type;
|
||||||
for (int i = 0; i < selected.size(); i++) {
|
for (int i = 0; i < efiles.size(); i++) {
|
||||||
String fpath = selected[i];
|
String fpath = efiles[i];
|
||||||
|
|
||||||
if (fpath.ends_with("/")) {
|
|
||||||
imports.clear();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!FileAccess::exists(fpath + ".import")) {
|
|
||||||
imports.clear();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Ref<ConfigFile> cf;
|
Ref<ConfigFile> cf;
|
||||||
cf.instance();
|
cf.instance();
|
||||||
Error err = cf->load(fpath + ".import");
|
Error err = cf->load(fpath + ".import");
|
||||||
|
|||||||
@@ -195,6 +195,7 @@ private:
|
|||||||
void _file_multi_selected(int p_index, bool p_selected);
|
void _file_multi_selected(int p_index, bool p_selected);
|
||||||
void _tree_multi_selected(Object *p_item, int p_column, 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 _update_import_dock();
|
||||||
|
|
||||||
void _get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const;
|
void _get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vector<String> &files, Vector<String> &folders) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user