You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Show dependency warning when removing remaps and fallback if translation
remap does not exist
This commit is contained in:
@@ -819,6 +819,12 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
|
|||||||
if (r_translation_remapped) {
|
if (r_translation_remapped) {
|
||||||
*r_translation_remapped = true;
|
*r_translation_remapped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fallback to p_path if new_path does not exist.
|
||||||
|
if (!FileAccess::exists(new_path)) {
|
||||||
|
WARN_PRINT(vformat("Translation remap '%s' does not exist. Falling back to '%s'.", new_path, p_path));
|
||||||
|
new_path = p_path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path_remaps.has(new_path)) {
|
if (path_remaps.has(new_path)) {
|
||||||
|
|||||||
@@ -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) {
|
void DependencyRemoveDialog::_build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed) {
|
||||||
owners->clear();
|
owners->clear();
|
||||||
owners->create_item(); // root
|
owners->create_item(); // root
|
||||||
@@ -473,6 +512,7 @@ void DependencyRemoveDialog::show(const Vector<String> &p_folders, const Vector<
|
|||||||
|
|
||||||
Vector<RemovedDependency> removed_deps;
|
Vector<RemovedDependency> removed_deps;
|
||||||
_find_all_removed_dependencies(EditorFileSystem::get_singleton()->get_filesystem(), removed_deps);
|
_find_all_removed_dependencies(EditorFileSystem::get_singleton()->get_filesystem(), removed_deps);
|
||||||
|
_find_localization_remaps_of_removed_files(removed_deps);
|
||||||
removed_deps.sort();
|
removed_deps.sort();
|
||||||
if (removed_deps.is_empty()) {
|
if (removed_deps.is_empty()) {
|
||||||
owners->hide();
|
owners->hide();
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ class DependencyRemoveDialog : public ConfirmationDialog {
|
|||||||
|
|
||||||
void _find_files_in_removed_folder(EditorFileSystemDirectory *efsd, const String &p_folder);
|
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_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 _build_removed_dependency_tree(const Vector<RemovedDependency> &p_removed);
|
||||||
|
|
||||||
void ok_pressed() override;
|
void ok_pressed() override;
|
||||||
|
|||||||
@@ -6877,7 +6877,7 @@ EditorNode::EditorNode() {
|
|||||||
filesystem_dock->connect("inherit", callable_mp(this, &EditorNode::_inherit_request));
|
filesystem_dock->connect("inherit", callable_mp(this, &EditorNode::_inherit_request));
|
||||||
filesystem_dock->connect("instance", callable_mp(this, &EditorNode::_instantiate_request));
|
filesystem_dock->connect("instance", callable_mp(this, &EditorNode::_instantiate_request));
|
||||||
filesystem_dock->connect("display_mode_changed", callable_mp(this, &EditorNode::_save_docks));
|
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.
|
// Scene: Top left.
|
||||||
dock_slot[DOCK_SLOT_LEFT_UR]->add_child(SceneTreeDock::get_singleton());
|
dock_slot[DOCK_SLOT_LEFT_UR]->add_child(SceneTreeDock::get_singleton());
|
||||||
|
|||||||
@@ -551,6 +551,12 @@ void LocalizationEditor::update_translations() {
|
|||||||
t2->set_editable(1, true);
|
t2->set_editable(1, true);
|
||||||
t2->set_metadata(1, path);
|
t2->set_metadata(1, path);
|
||||||
t2->set_tooltip(1, locale);
|
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)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user