summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorPucklaMotzer09 <jonaas.pucher000000@gmail.com>2022-01-04 18:52:32 +0100
committerPucklaMotzer09 <jonaas.pucher000000@gmail.com>2022-08-03 12:31:29 +0200
commitb32b570d7a64dfdce02605557532754a8629e68a (patch)
tree542859f8b4fe89417c16e635597a2dba187e45df /editor
parent0f9086e131923e09e97a2ef2f0e9f39565be0c27 (diff)
Show dependency warning when removing remaps and fallback if translation
remap does not exist
Diffstat (limited to 'editor')
-rw-r--r--editor/dependency_editor.cpp40
-rw-r--r--editor/dependency_editor.h1
-rw-r--r--editor/editor_node.cpp2
-rw-r--r--editor/localization_editor.cpp6
4 files changed, 48 insertions, 1 deletions
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 5b4da0e32b..43961a7ceb 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -417,6 +417,45 @@ void DependencyRemoveDialog::_find_all_removed_dependencies(EditorFileSystemDire
}
}
+void DependencyRemoveDialog::_find_localization_remaps_of_removed_files(Vector<RemovedDependency> &p_removed) {
+ for (KeyValue<String, String> &files : all_remove_files) {
+ const String &path = files.key;
+
+ // Look for dependencies in the translation remaps.
+ if (ProjectSettings::get_singleton()->has_setting("internationalization/locale/translation_remaps")) {
+ Dictionary remaps = ProjectSettings::get_singleton()->get("internationalization/locale/translation_remaps");
+
+ if (remaps.has(path)) {
+ RemovedDependency dep;
+ dep.file = TTR("Localization remap");
+ dep.file_type = "";
+ dep.dependency = path;
+ dep.dependency_folder = files.value;
+ p_removed.push_back(dep);
+ }
+
+ Array remap_keys = remaps.keys();
+ for (int j = 0; j < remap_keys.size(); j++) {
+ PackedStringArray remapped_files = remaps[remap_keys[j]];
+ for (int k = 0; k < remapped_files.size(); k++) {
+ int splitter_pos = remapped_files[k].rfind(":");
+ String res_path = remapped_files[k].substr(0, splitter_pos);
+ if (res_path == path) {
+ String locale_name = remapped_files[k].substr(splitter_pos + 1);
+
+ RemovedDependency dep;
+ dep.file = vformat(TTR("Localization remap for path '%s' and locale '%s'."), remap_keys[j], locale_name);
+ dep.file_type = "";
+ dep.dependency = path;
+ dep.dependency_folder = files.value;
+ p_removed.push_back(dep);
+ }
+ }
+ }
+ }
+ }
+}
+
void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed) {
owners->clear();
owners->create_item(); // root
@@ -473,6 +512,7 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector<
Vector<RemovedDependency> removed_deps;
_find_all_removed_dependencies(EditorFileSystem::get_singleton()->get_filesystem(), removed_deps);
+ _find_localization_remaps_of_removed_files(removed_deps);
removed_deps.sort();
if (removed_deps.is_empty()) {
owners->hide();
diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h
index 96d82d58eb..6e39015ec3 100644
--- a/editor/dependency_editor.h
+++ b/editor/dependency_editor.h
@@ -119,6 +119,7 @@ class DependencyRemoveDialog : public ConfirmationDialog {
void _find_files_in_removed_folder(EditorFileSystemDirectory *efsd, const String &p_folder);
void _find_all_removed_dependencies(EditorFileSystemDirectory *efsd, Vector<RemovedDependency> &p_removed);
+ void _find_localization_remaps_of_removed_files(Vector<RemovedDependency> &p_removed);
void _build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed);
void ok_pressed() override;
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 532bc3041d..84c567ee31 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -6877,7 +6877,7 @@ EditorNode::EditorNode() {
filesystem_dock->connect("inherit", callable_mp(this, &EditorNode::_inherit_request));
filesystem_dock->connect("instance", callable_mp(this, &EditorNode::_instantiate_request));
filesystem_dock->connect("display_mode_changed", callable_mp(this, &EditorNode::_save_docks));
- project_settings->connect_filesystem_dock_signals(filesystem_dock);
+ get_project_settings()->connect_filesystem_dock_signals(filesystem_dock);
// Scene: Top left.
dock_slot[DOCK_SLOT_LEFT_UR]->add_child(SceneTreeDock::get_singleton());
diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp
index 5d944956f6..e8fb80eb57 100644
--- a/editor/localization_editor.cpp
+++ b/editor/localization_editor.cpp
@@ -551,6 +551,12 @@ void LocalizationEditor::update_translations() {
t2->set_editable(1, true);
t2->set_metadata(1, path);
t2->set_tooltip(1, locale);
+
+ // Display that it has been removed if this is the case.
+ if (!FileAccess::exists(path)) {
+ t2->set_text(0, t2->get_text(0) + vformat(" (%s)", TTR("Removed")));
+ t2->set_tooltip(0, vformat(TTR("%s cannot be found."), t2->get_tooltip(0)));
+ }
}
}
}