diff options
| author | 2023-06-07 14:03:28 -0400 | |
|---|---|---|
| committer | 2023-06-07 14:03:28 -0400 | |
| commit | 219bd901525c2d6d2b3c9e8296f91afd8f9aeaa0 (patch) | |
| tree | d8eca785c52d8a2afb2a55b8339ccc1ce35c091c /src/core | |
| parent | Merge pull request #10651 from Morph1984/a (diff) | |
| parent | Fix typo (diff) | |
| download | yuzu-219bd901525c2d6d2b3c9e8296f91afd8f9aeaa0.tar.gz yuzu-219bd901525c2d6d2b3c9e8296f91afd8f9aeaa0.tar.xz yuzu-219bd901525c2d6d2b3c9e8296f91afd8f9aeaa0.zip | |
Merge pull request #10591 from keve1227/localized-game-icons
Localize game icons
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/file_sys/control_metadata.cpp | 12 | ||||
| -rw-r--r-- | src/core/file_sys/control_metadata.h | 4 | ||||
| -rw-r--r-- | src/core/file_sys/patch_manager.cpp | 33 |
3 files changed, 40 insertions, 9 deletions
diff --git a/src/core/file_sys/control_metadata.cpp b/src/core/file_sys/control_metadata.cpp index 50f44f598..cd9ac2e75 100644 --- a/src/core/file_sys/control_metadata.cpp +++ b/src/core/file_sys/control_metadata.cpp | |||
| @@ -23,8 +23,8 @@ const std::array<const char*, 16> LANGUAGE_NAMES{{ | |||
| 23 | "Portuguese", | 23 | "Portuguese", |
| 24 | "Russian", | 24 | "Russian", |
| 25 | "Korean", | 25 | "Korean", |
| 26 | "Taiwanese", | 26 | "TraditionalChinese", |
| 27 | "Chinese", | 27 | "SimplifiedChinese", |
| 28 | "BrazilianPortuguese", | 28 | "BrazilianPortuguese", |
| 29 | }}; | 29 | }}; |
| 30 | 30 | ||
| @@ -45,17 +45,17 @@ constexpr std::array<Language, 18> language_to_codes = {{ | |||
| 45 | Language::German, | 45 | Language::German, |
| 46 | Language::Italian, | 46 | Language::Italian, |
| 47 | Language::Spanish, | 47 | Language::Spanish, |
| 48 | Language::Chinese, | 48 | Language::SimplifiedChinese, |
| 49 | Language::Korean, | 49 | Language::Korean, |
| 50 | Language::Dutch, | 50 | Language::Dutch, |
| 51 | Language::Portuguese, | 51 | Language::Portuguese, |
| 52 | Language::Russian, | 52 | Language::Russian, |
| 53 | Language::Taiwanese, | 53 | Language::TraditionalChinese, |
| 54 | Language::BritishEnglish, | 54 | Language::BritishEnglish, |
| 55 | Language::CanadianFrench, | 55 | Language::CanadianFrench, |
| 56 | Language::LatinAmericanSpanish, | 56 | Language::LatinAmericanSpanish, |
| 57 | Language::Chinese, | 57 | Language::SimplifiedChinese, |
| 58 | Language::Taiwanese, | 58 | Language::TraditionalChinese, |
| 59 | Language::BrazilianPortuguese, | 59 | Language::BrazilianPortuguese, |
| 60 | }}; | 60 | }}; |
| 61 | 61 | ||
diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index 6a81873b1..c98efb00d 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 { | |||
| 84 | Portuguese = 10, | 84 | Portuguese = 10, |
| 85 | Russian = 11, | 85 | Russian = 11, |
| 86 | Korean = 12, | 86 | Korean = 12, |
| 87 | Taiwanese = 13, | 87 | TraditionalChinese = 13, |
| 88 | Chinese = 14, | 88 | SimplifiedChinese = 14, |
| 89 | BrazilianPortuguese = 15, | 89 | BrazilianPortuguese = 15, |
| 90 | 90 | ||
| 91 | Default = 255, | 91 | Default = 255, |
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index f786f2add..4e61d4335 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -25,6 +25,8 @@ | |||
| 25 | #include "core/file_sys/vfs_layered.h" | 25 | #include "core/file_sys/vfs_layered.h" |
| 26 | #include "core/file_sys/vfs_vector.h" | 26 | #include "core/file_sys/vfs_vector.h" |
| 27 | #include "core/hle/service/filesystem/filesystem.h" | 27 | #include "core/hle/service/filesystem/filesystem.h" |
| 28 | #include "core/hle/service/ns/language.h" | ||
| 29 | #include "core/hle/service/set/set.h" | ||
| 28 | #include "core/loader/loader.h" | 30 | #include "core/loader/loader.h" |
| 29 | #include "core/loader/nso.h" | 31 | #include "core/loader/nso.h" |
| 30 | #include "core/memory/cheat_engine.h" | 32 | #include "core/memory/cheat_engine.h" |
| @@ -624,8 +626,37 @@ PatchManager::Metadata PatchManager::ParseControlNCA(const NCA& nca) const { | |||
| 624 | 626 | ||
| 625 | auto nacp = nacp_file == nullptr ? nullptr : std::make_unique<NACP>(nacp_file); | 627 | auto nacp = nacp_file == nullptr ? nullptr : std::make_unique<NACP>(nacp_file); |
| 626 | 628 | ||
| 629 | // Get language code from settings | ||
| 630 | const auto language_code = | ||
| 631 | Service::Set::GetLanguageCodeFromIndex(Settings::values.language_index.GetValue()); | ||
| 632 | |||
| 633 | // Convert to application language and get priority list | ||
| 634 | const auto application_language = | ||
| 635 | Service::NS::ConvertToApplicationLanguage(language_code) | ||
| 636 | .value_or(Service::NS::ApplicationLanguage::AmericanEnglish); | ||
| 637 | const auto language_priority_list = | ||
| 638 | Service::NS::GetApplicationLanguagePriorityList(application_language); | ||
| 639 | |||
| 640 | // Convert to language names | ||
| 641 | auto priority_language_names = FileSys::LANGUAGE_NAMES; // Copy | ||
| 642 | if (language_priority_list) { | ||
| 643 | for (size_t i = 0; i < priority_language_names.size(); ++i) { | ||
| 644 | // Relies on FileSys::LANGUAGE_NAMES being in the same order as | ||
| 645 | // Service::NS::ApplicationLanguage | ||
| 646 | const auto language_index = static_cast<u8>(language_priority_list->at(i)); | ||
| 647 | |||
| 648 | if (language_index < FileSys::LANGUAGE_NAMES.size()) { | ||
| 649 | priority_language_names[i] = FileSys::LANGUAGE_NAMES[language_index]; | ||
| 650 | } else { | ||
| 651 | // Not a catastrophe, unlikely to happen | ||
| 652 | LOG_WARNING(Loader, "Invalid language index {}", language_index); | ||
| 653 | } | ||
| 654 | } | ||
| 655 | } | ||
| 656 | |||
| 657 | // Get first matching icon | ||
| 627 | VirtualFile icon_file; | 658 | VirtualFile icon_file; |
| 628 | for (const auto& language : FileSys::LANGUAGE_NAMES) { | 659 | for (const auto& language : priority_language_names) { |
| 629 | icon_file = extracted->GetFile(std::string("icon_").append(language).append(".dat")); | 660 | icon_file = extracted->GetFile(std::string("icon_").append(language).append(".dat")); |
| 630 | if (icon_file != nullptr) { | 661 | if (icon_file != nullptr) { |
| 631 | break; | 662 | break; |