[FileSystem Dock] Add option to show some unsupported files in the dock.

This commit is contained in:
bruvzg 2024-09-05 12:12:59 +03:00
parent b6223c0df0
commit 22b19c433f
No known key found for this signature in database
GPG key ID: 7960FCF39844EC38
8 changed files with 51 additions and 8 deletions

View file

@ -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);