Skip to content

Commit 9318466

Browse files
committed
Open translation CSV in the text editor instead of printing errors.
1 parent 9283328 commit 9318466

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

editor/editor_node.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,12 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
15281528
Error err;
15291529

15301530
Ref<Resource> res;
1531-
if (ResourceLoader::exists(p_resource, "")) {
1531+
if (force_textfile_extensions.has(p_resource.get_extension())) {
1532+
res = ResourceCache::get_ref(p_resource);
1533+
if (res.is_null() || !res->is_class("TextFile")) {
1534+
res = ScriptEditor::get_singleton()->open_file(p_resource);
1535+
}
1536+
} else if (ResourceLoader::exists(p_resource, "")) {
15321537
res = ResourceLoader::load(p_resource, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
15331538
} else if (textfile_extensions.has(p_resource.get_extension())) {
15341539
res = ScriptEditor::get_singleton()->open_file(p_resource);
@@ -7825,6 +7830,8 @@ EditorNode::EditorNode() {
78257830
other_file_extensions.insert(E);
78267831
}
78277832

7833+
force_textfile_extensions.insert("csv"); // CSV translation source, has `Translation` resource type, but not loadable as resource.
7834+
78287835
resource_preview = memnew(EditorResourcePreview);
78297836
add_child(resource_preview);
78307837
progress_dialog = memnew(ProgressDialog);

editor/editor_node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ class EditorNode : public Node {
475475
SceneImportSettingsDialog *scene_import_settings = nullptr;
476476
AudioStreamImportSettingsDialog *audio_stream_import_settings = nullptr;
477477

478+
HashSet<String> force_textfile_extensions;
478479
HashSet<String> textfile_extensions;
479480
HashSet<String> other_file_extensions;
480481
HashSet<FileDialog *> file_dialogs;

0 commit comments

Comments
 (0)