diff options
Diffstat (limited to 'editor/filesystem_dock.cpp')
-rw-r--r-- | editor/filesystem_dock.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 54d5ddacab..378e06b4c9 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1531,6 +1531,10 @@ void FileSystemDock::_make_scene_confirm() { EditorNode::get_singleton()->save_scene_list({ scene_path }); } +void FileSystemDock::_resource_removed(const Ref<Resource> &p_resource) { + emit_signal(SNAME("resource_removed"), p_resource); +} + void FileSystemDock::_file_removed(String p_file) { emit_signal(SNAME("file_removed"), p_file); @@ -2941,12 +2945,19 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) { } } -void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &r_files) const { +bool FileSystemDock::_get_imported_files(const String &p_path, String &r_extension, Vector<String> &r_files) const { if (!p_path.ends_with("/")) { if (FileAccess::exists(p_path + ".import")) { + if (r_extension.is_empty()) { + r_extension = p_path.get_extension(); + } else if (r_extension != p_path.get_extension()) { + r_files.clear(); + return false; // File type mismatch, stop search. + } + r_files.push_back(p_path); } - return; + return true; } Ref<DirAccess> da = DirAccess::open(p_path); @@ -2955,11 +2966,14 @@ void FileSystemDock::_get_imported_files(const String &p_path, Vector<String> &r while (!n.is_empty()) { if (n != "." && n != ".." && !n.ends_with(".import")) { String npath = p_path + n + (da->current_is_dir() ? "/" : ""); - _get_imported_files(npath, r_files); + if (!_get_imported_files(npath, r_extension, r_files)) { + return false; + } } n = da->get_next(); } da->list_dir_end(); + return true; } void FileSystemDock::_update_import_dock() { @@ -2984,10 +2998,16 @@ void FileSystemDock::_update_import_dock() { } } - // Expand directory selection + if (!selected.is_empty() && selected[0] == "res://") { + // Scanning res:// is costly and unlikely to yield any useful results. + return; + } + + // Expand directory selection. Vector<String> efiles; - for (int i = 0; i < selected.size(); i++) { - _get_imported_files(selected[i], efiles); + String extension; + for (const String &fpath : selected) { + _get_imported_files(fpath, extension, efiles); } // Check import. @@ -3079,6 +3099,7 @@ void FileSystemDock::_bind_methods() { ADD_SIGNAL(MethodInfo("inherit", PropertyInfo(Variant::STRING, "file"))); ADD_SIGNAL(MethodInfo("instantiate", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files"))); + ADD_SIGNAL(MethodInfo("resource_removed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); ADD_SIGNAL(MethodInfo("file_removed", PropertyInfo(Variant::STRING, "file"))); ADD_SIGNAL(MethodInfo("folder_removed", PropertyInfo(Variant::STRING, "folder"))); ADD_SIGNAL(MethodInfo("files_moved", PropertyInfo(Variant::STRING, "old_file"), PropertyInfo(Variant::STRING, "new_file"))); @@ -3238,6 +3259,7 @@ FileSystemDock::FileSystemDock() { add_child(owners_editor); remove_dialog = memnew(DependencyRemoveDialog); + remove_dialog->connect("resource_removed", callable_mp(this, &FileSystemDock::_resource_removed)); remove_dialog->connect("file_removed", callable_mp(this, &FileSystemDock::_file_removed)); remove_dialog->connect("folder_removed", callable_mp(this, &FileSystemDock::_folder_removed)); add_child(remove_dialog); |