From d0aa63069f6a9ec0b062b086a93dbcd2f880ac84 Mon Sep 17 00:00:00 2001 From: Keve1227 Date: Sat, 3 Jun 2023 17:13:24 +0200 Subject: [PATCH 1/4] Pick game icon based on the configured system language --- src/core/file_sys/patch_manager.cpp | 33 ++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 4c80e13a92..fa282615b6 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -24,6 +24,8 @@ #include "core/file_sys/vfs_layered.h" #include "core/file_sys/vfs_vector.h" #include "core/hle/service/filesystem/filesystem.h" +#include "core/hle/service/ns/language.h" +#include "core/hle/service/set/set.h" #include "core/loader/loader.h" #include "core/loader/nso.h" #include "core/memory/cheat_engine.h" @@ -623,8 +625,37 @@ PatchManager::Metadata PatchManager::ParseControlNCA(const NCA& nca) const { auto nacp = nacp_file == nullptr ? nullptr : std::make_unique(nacp_file); + // Get language code from settings + const auto language_code = + Service::Set::GetLanguageCodeFromIndex(Settings::values.language_index.GetValue()); + + // Convert to application language and get priority list + const auto application_language = + Service::NS::ConvertToApplicationLanguage(language_code) + .value_or(Service::NS::ApplicationLanguage::AmericanEnglish); + const auto language_priority_list = + Service::NS::GetApplicationLanguagePriorityList(application_language); + + // Convert to language names + auto priority_language_names = FileSys::LANGUAGE_NAMES; // Copy + if (language_priority_list) { + for (size_t i = 0; i < priority_language_names.size(); ++i) { + // Relies on FileSys::LANGUAGE_NAMES being in the same order as + // Service::NS::ApplicationLanguage + const auto language_index = static_cast(language_priority_list->at(i)); + + if (language_index < FileSys::LANGUAGE_NAMES.size()) { + priority_language_names[i] = FileSys::LANGUAGE_NAMES[language_index]; + } else { + // Not a catastrophy, unlikely to happen + LOG_WARNING(Loader, "Invalid language index {}", language_index); + } + } + } + + // Get first matching icon VirtualFile icon_file; - for (const auto& language : FileSys::LANGUAGE_NAMES) { + for (const auto& language : priority_language_names) { icon_file = extracted->GetFile(std::string("icon_").append(language).append(".dat")); if (icon_file != nullptr) { break; From 27313fe576fdab68009b4e051a95df4e4e912e5a Mon Sep 17 00:00:00 2001 From: Keve1227 Date: Sat, 3 Jun 2023 17:17:03 +0200 Subject: [PATCH 2/4] Issue a reload if the system language changed --- src/yuzu/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 82bce9a3ae..145fea5f12 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -3491,6 +3491,7 @@ void GMainWindow::ResetWindowSize1080() { void GMainWindow::OnConfigure() { const auto old_theme = UISettings::values.theme; const bool old_discord_presence = UISettings::values.enable_discord_presence.GetValue(); + const auto old_language_index = Settings::values.language_index.GetValue(); Settings::SetConfiguringGlobal(true); ConfigureDialog configure_dialog(this, hotkey_registry, input_subsystem.get(), *system, @@ -3559,7 +3560,7 @@ void GMainWindow::OnConfigure() { emit UpdateThemedIcons(); const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false); - if (reload) { + if (reload || Settings::values.language_index.GetValue() != old_language_index) { game_list->PopulateAsync(UISettings::values.game_dirs); } From a0f235f4fd6b04589a4cd17bb01ec64fb2f51e54 Mon Sep 17 00:00:00 2001 From: Keve1227 Date: Sat, 3 Jun 2023 17:23:14 +0200 Subject: [PATCH 3/4] Update Chinese NX language names ... as per the TLoZ: TotK icon files. Would this conflict with older games? --- src/core/file_sys/control_metadata.cpp | 12 ++++++------ src/core/file_sys/control_metadata.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/file_sys/control_metadata.cpp b/src/core/file_sys/control_metadata.cpp index 50f44f598f..cd9ac2e751 100644 --- a/src/core/file_sys/control_metadata.cpp +++ b/src/core/file_sys/control_metadata.cpp @@ -23,8 +23,8 @@ const std::array LANGUAGE_NAMES{{ "Portuguese", "Russian", "Korean", - "Taiwanese", - "Chinese", + "TraditionalChinese", + "SimplifiedChinese", "BrazilianPortuguese", }}; @@ -45,17 +45,17 @@ constexpr std::array language_to_codes = {{ Language::German, Language::Italian, Language::Spanish, - Language::Chinese, + Language::SimplifiedChinese, Language::Korean, Language::Dutch, Language::Portuguese, Language::Russian, - Language::Taiwanese, + Language::TraditionalChinese, Language::BritishEnglish, Language::CanadianFrench, Language::LatinAmericanSpanish, - Language::Chinese, - Language::Taiwanese, + Language::SimplifiedChinese, + Language::TraditionalChinese, Language::BrazilianPortuguese, }}; diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index 6a81873b15..c98efb00db 100644 --- a/src/core/file_sys/control_metadata.h +++ b/src/core/file_sys/control_metadata.h @@ -84,8 +84,8 @@ enum class Language : u8 { Portuguese = 10, Russian = 11, Korean = 12, - Taiwanese = 13, - Chinese = 14, + TraditionalChinese = 13, + SimplifiedChinese = 14, BrazilianPortuguese = 15, Default = 255, From a2cfe3749af8c39272b90cf0cca24c300aefa57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Sundqvist=20Norl=C3=A9n?= Date: Sat, 3 Jun 2023 21:31:44 +0200 Subject: [PATCH 4/4] Fix typo Co-authored-by: liamwhite --- src/core/file_sys/patch_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index fa282615b6..27bfce641f 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -647,7 +647,7 @@ PatchManager::Metadata PatchManager::ParseControlNCA(const NCA& nca) const { if (language_index < FileSys::LANGUAGE_NAMES.size()) { priority_language_names[i] = FileSys::LANGUAGE_NAMES[language_index]; } else { - // Not a catastrophy, unlikely to happen + // Not a catastrophe, unlikely to happen LOG_WARNING(Loader, "Invalid language index {}", language_index); } }