summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-09-06 10:09:36 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-09-06 10:09:36 +0200
commit05709b35faa98e7cd4939ec450df4b50cfdd2dac (patch)
tree255f4cf76d02a5c1671c3e06735a82159962b9d3
parentd06a10c252b5a8440d47e8524fe7dff355591d3e (diff)
parent22b19c433fded045536af6a71dfa8fd823a0de45 (diff)
downloadredot-engine-05709b35faa98e7cd4939ec450df4b50cfdd2dac.tar.gz
Merge pull request #96603 from bruvzg/fs_ext_list
[FileSystem Dock] Add option to show some unsupported files in the dock.
-rw-r--r--doc/classes/EditorSettings.xml5
-rw-r--r--editor/editor_file_system.cpp29
-rw-r--r--editor/editor_file_system.h1
-rw-r--r--editor/editor_node.cpp18
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/editor_settings.cpp1
-rw-r--r--editor/export/project_export.cpp2
-rw-r--r--editor/filesystem_dock.cpp2
8 files changed, 51 insertions, 8 deletions
diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml
index 7f017f39de..1de63b4a39 100644
--- a/doc/classes/EditorSettings.xml
+++ b/doc/classes/EditorSettings.xml
@@ -207,8 +207,11 @@
If [code]true[/code], displays folders in the FileSystem dock's bottom pane when split mode is enabled. If [code]false[/code], only files will be displayed in the bottom pane. Split mode can be toggled by pressing the icon next to the [code]res://[/code] folder path.
[b]Note:[/b] This setting has no effect when split mode is disabled (which is the default).
</member>
+ <member name="docks/filesystem/other_file_extensions" type="String" setter="" getter="">
+ A comma separated list of unsupported file extensions to show in the FileSystem dock, e.g. [code]"ico,icns"[/code].
+ </member>
<member name="docks/filesystem/textfile_extensions" type="String" setter="" getter="">
- List of file extensions to consider as editable text files in the FileSystem dock (by double-clicking on the files).
+ A comma separated list of file extensions to consider as editable text files in the FileSystem dock (by double-clicking on the files), e.g. [code]"txt,md,cfg,ini,log,json,yml,yaml,toml,xml"[/code].
</member>
<member name="docks/filesystem/thumbnail_size" type="int" setter="" getter="">
The thumbnail size to use in the FileSystem dock (in pixels). See also [member filesystem/file_dialog/thumbnail_size].
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index e13a984213..b1b64b5d60 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -1075,7 +1075,7 @@ void EditorFileSystem::_process_file_system(const ScannedDirectory *p_scan_dir,
fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path);
fi->modified_time = 0;
fi->import_modified_time = 0;
- fi->import_valid = fi->type == "TextFile" ? true : ResourceLoader::is_import_valid(path);
+ fi->import_valid = (fi->type == "TextFile" || fi->type == "OtherFile") ? true : ResourceLoader::is_import_valid(path);
ItemAction ia;
ia.action = ItemAction::ACTION_FILE_TEST_REIMPORT;
@@ -1118,6 +1118,9 @@ void EditorFileSystem::_process_file_system(const ScannedDirectory *p_scan_dir,
if (fi->type == "" && textfile_extensions.has(ext)) {
fi->type = "TextFile";
}
+ if (fi->type == "" && other_file_extensions.has(ext)) {
+ fi->type = "OtherFile";
+ }
fi->uid = ResourceLoader::get_resource_uid(path);
fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path);
fi->deps = _get_dependencies(path);
@@ -1263,8 +1266,11 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, ScanPr
if (fi->type == "" && textfile_extensions.has(ext)) {
fi->type = "TextFile";
}
+ if (fi->type == "" && other_file_extensions.has(ext)) {
+ fi->type = "OtherFile";
+ }
fi->script_class_name = _get_global_script_class(fi->type, path, &fi->script_class_extends, &fi->script_class_icon_path);
- fi->import_valid = fi->type == "TextFile" ? true : ResourceLoader::is_import_valid(path);
+ fi->import_valid = (fi->type == "TextFile" || fi->type == "OtherFile") ? true : ResourceLoader::is_import_valid(path);
fi->import_group_file = ResourceLoader::get_import_group_file(path);
{
@@ -2118,6 +2124,9 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {
if (type.is_empty() && textfile_extensions.has(file.get_extension())) {
type = "TextFile";
}
+ if (type.is_empty() && other_file_extensions.has(file.get_extension())) {
+ type = "OtherFile";
+ }
String script_class = ResourceLoader::get_resource_script_class(file);
ResourceUID::ID uid = ResourceLoader::get_resource_uid(file);
@@ -2137,7 +2146,7 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {
EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo);
fi->file = file_name;
fi->import_modified_time = 0;
- fi->import_valid = type == "TextFile" ? true : ResourceLoader::is_import_valid(file);
+ fi->import_valid = (type == "TextFile" || type == "OtherFile") ? true : ResourceLoader::is_import_valid(file);
if (idx == fs->files.size()) {
fs->files.push_back(fi);
@@ -2161,7 +2170,7 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {
fs->files[cpos]->import_group_file = ResourceLoader::get_import_group_file(file);
fs->files[cpos]->modified_time = FileAccess::get_modified_time(file);
fs->files[cpos]->deps = _get_dependencies(file);
- fs->files[cpos]->import_valid = type == "TextFile" ? true : ResourceLoader::is_import_valid(file);
+ fs->files[cpos]->import_valid = (type == "TextFile" || type == "OtherFile") ? true : ResourceLoader::is_import_valid(file);
if (uid != ResourceUID::INVALID_ID) {
if (ResourceUID::get_singleton()->has_id(uid)) {
@@ -2419,6 +2428,9 @@ Error EditorFileSystem::_reimport_group(const String &p_group_file, const Vector
if (fs->files[cpos]->type == "" && textfile_extensions.has(file.get_extension())) {
fs->files[cpos]->type = "TextFile";
}
+ if (fs->files[cpos]->type == "" && other_file_extensions.has(file.get_extension())) {
+ fs->files[cpos]->type = "OtherFile";
+ }
fs->files[cpos]->import_valid = err == OK;
if (ResourceUID::get_singleton()->has_id(uid)) {
@@ -3119,6 +3131,7 @@ void EditorFileSystem::_update_extensions() {
valid_extensions.clear();
import_extensions.clear();
textfile_extensions.clear();
+ other_file_extensions.clear();
List<String> extensionsl;
ResourceLoader::get_recognized_extensions_for_type("", &extensionsl);
@@ -3134,6 +3147,14 @@ void EditorFileSystem::_update_extensions() {
valid_extensions.insert(E);
textfile_extensions.insert(E);
}
+ const Vector<String> other_file_ext = ((String)(EDITOR_GET("docks/filesystem/other_file_extensions"))).split(",", false);
+ for (const String &E : other_file_ext) {
+ if (valid_extensions.has(E)) {
+ continue;
+ }
+ valid_extensions.insert(E);
+ other_file_extensions.insert(E);
+ }
extensionsl.clear();
ResourceFormatImporter::get_singleton()->get_recognized_extensions(&extensionsl);
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index 7848ede8a7..9adab1ed24 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -235,6 +235,7 @@ class EditorFileSystem : public Node {
int _insert_actions_delete_files_directory(EditorFileSystemDirectory *p_dir);
HashSet<String> textfile_extensions;
+ HashSet<String> other_file_extensions;
HashSet<String> valid_extensions;
HashSet<String> import_extensions;
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6de9bfc4aa..6899a35ded 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -825,6 +825,7 @@ void EditorNode::_notification(int p_what) {
if (EditorSettings::get_singleton()->check_changed_settings_in_group("docks/filesystem")) {
HashSet<String> updated_textfile_extensions;
+ HashSet<String> updated_other_file_extensions;
bool extensions_match = true;
const Vector<String> textfile_ext = ((String)(EDITOR_GET("docks/filesystem/textfile_extensions"))).split(",", false);
for (const String &E : textfile_ext) {
@@ -833,9 +834,17 @@ void EditorNode::_notification(int p_what) {
extensions_match = false;
}
}
+ const Vector<String> other_file_ext = ((String)(EDITOR_GET("docks/filesystem/other_file_extensions"))).split(",", false);
+ for (const String &E : other_file_ext) {
+ updated_other_file_extensions.insert(E);
+ if (extensions_match && !other_file_extensions.has(E)) {
+ extensions_match = false;
+ }
+ }
- if (!extensions_match || updated_textfile_extensions.size() < textfile_extensions.size()) {
+ if (!extensions_match || updated_textfile_extensions.size() < textfile_extensions.size() || updated_other_file_extensions.size() < other_file_extensions.size()) {
textfile_extensions = updated_textfile_extensions;
+ other_file_extensions = updated_other_file_extensions;
EditorFileSystem::get_singleton()->scan();
}
}
@@ -1326,6 +1335,9 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
res = ResourceLoader::load(p_resource, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
} else if (textfile_extensions.has(p_resource.get_extension())) {
res = ScriptEditor::get_singleton()->open_file(p_resource);
+ } else if (other_file_extensions.has(p_resource.get_extension())) {
+ OS::get_singleton()->shell_open(ProjectSettings::get_singleton()->globalize_path(p_resource));
+ return OK;
}
ERR_FAIL_COND_V(!res.is_valid(), ERR_CANT_OPEN);
@@ -6980,6 +6992,10 @@ EditorNode::EditorNode() {
for (const String &E : textfile_ext) {
textfile_extensions.insert(E);
}
+ const Vector<String> other_file_ext = ((String)(EDITOR_GET("docks/filesystem/other_file_extensions"))).split(",", false);
+ for (const String &E : other_file_ext) {
+ other_file_extensions.insert(E);
+ }
resource_preview = memnew(EditorResourcePreview);
add_child(resource_preview);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index ffffe87d51..e9d2c28528 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -489,6 +489,7 @@ private:
String import_reload_fn;
HashSet<String> textfile_extensions;
+ HashSet<String> other_file_extensions;
HashSet<FileDialog *> file_dialogs;
HashSet<EditorFileDialog *> editor_file_dialogs;
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 36fbd91313..b1a91fa3dd 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -593,6 +593,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "docks/filesystem/thumbnail_size", 64, "32,128,16")
_initial_set("docks/filesystem/always_show_folders", true);
_initial_set("docks/filesystem/textfile_extensions", "txt,md,cfg,ini,log,json,yml,yaml,toml,xml");
+ _initial_set("docks/filesystem/other_file_extensions", "ico,icns");
// Property editor
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "docks/property_editor/auto_refresh_interval", 0.2, "0.01,1,0.001"); // Update 5 times per second by default.
diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp
index 03e9fba12d..3ad8ab0b19 100644
--- a/editor/export/project_export.cpp
+++ b/editor/export/project_export.cpp
@@ -903,7 +903,7 @@ bool ProjectExportDialog::_fill_tree(EditorFileSystemDirectory *p_dir, TreeItem
if (p_export_filter == EditorExportPreset::EXPORT_SELECTED_SCENES && type != "PackedScene") {
continue;
}
- if (type == "TextFile") {
+ if (type == "TextFile" || type == "OtherFile") {
continue;
}
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index c58b24e078..f7e81b329c 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -271,7 +271,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
List<FileInfo> file_list;
for (int i = 0; i < p_dir->get_file_count(); i++) {
String file_type = p_dir->get_file_type(i);
- if (file_type != "TextFile" && _is_file_type_disabled_by_feature_profile(file_type)) {
+ if (file_type != "TextFile" && file_type != "OtherFile" && _is_file_type_disabled_by_feature_profile(file_type)) {
// If type is disabled, file won't be displayed.
continue;
}