summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Keve12272023-06-03 17:13:24 +0200
committerGravatar Keve12272023-06-03 17:13:24 +0200
commitd0aa63069f6a9ec0b062b086a93dbcd2f880ac84 (patch)
tree20ed1ca1a56047bb92924f889aeb0bca942d5632 /src
parentUpdate README.md (Add Android at builds description) (#10586) (diff)
downloadyuzu-d0aa63069f6a9ec0b062b086a93dbcd2f880ac84.tar.gz
yuzu-d0aa63069f6a9ec0b062b086a93dbcd2f880ac84.tar.xz
yuzu-d0aa63069f6a9ec0b062b086a93dbcd2f880ac84.zip
Pick game icon based on the configured system language
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/patch_manager.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index 4c80e13a9..fa282615b 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -24,6 +24,8 @@
24#include "core/file_sys/vfs_layered.h" 24#include "core/file_sys/vfs_layered.h"
25#include "core/file_sys/vfs_vector.h" 25#include "core/file_sys/vfs_vector.h"
26#include "core/hle/service/filesystem/filesystem.h" 26#include "core/hle/service/filesystem/filesystem.h"
27#include "core/hle/service/ns/language.h"
28#include "core/hle/service/set/set.h"
27#include "core/loader/loader.h" 29#include "core/loader/loader.h"
28#include "core/loader/nso.h" 30#include "core/loader/nso.h"
29#include "core/memory/cheat_engine.h" 31#include "core/memory/cheat_engine.h"
@@ -623,8 +625,37 @@ PatchManager::Metadata PatchManager::ParseControlNCA(const NCA& nca) const {
623 625
624 auto nacp = nacp_file == nullptr ? nullptr : std::make_unique<NACP>(nacp_file); 626 auto nacp = nacp_file == nullptr ? nullptr : std::make_unique<NACP>(nacp_file);
625 627
628 // Get language code from settings
629 const auto language_code =
630 Service::Set::GetLanguageCodeFromIndex(Settings::values.language_index.GetValue());
631
632 // Convert to application language and get priority list
633 const auto application_language =
634 Service::NS::ConvertToApplicationLanguage(language_code)
635 .value_or(Service::NS::ApplicationLanguage::AmericanEnglish);
636 const auto language_priority_list =
637 Service::NS::GetApplicationLanguagePriorityList(application_language);
638
639 // Convert to language names
640 auto priority_language_names = FileSys::LANGUAGE_NAMES; // Copy
641 if (language_priority_list) {
642 for (size_t i = 0; i < priority_language_names.size(); ++i) {
643 // Relies on FileSys::LANGUAGE_NAMES being in the same order as
644 // Service::NS::ApplicationLanguage
645 const auto language_index = static_cast<u8>(language_priority_list->at(i));
646
647 if (language_index < FileSys::LANGUAGE_NAMES.size()) {
648 priority_language_names[i] = FileSys::LANGUAGE_NAMES[language_index];
649 } else {
650 // Not a catastrophy, unlikely to happen
651 LOG_WARNING(Loader, "Invalid language index {}", language_index);
652 }
653 }
654 }
655
656 // Get first matching icon
626 VirtualFile icon_file; 657 VirtualFile icon_file;
627 for (const auto& language : FileSys::LANGUAGE_NAMES) { 658 for (const auto& language : priority_language_names) {
628 icon_file = extracted->GetFile(std::string("icon_").append(language).append(".dat")); 659 icon_file = extracted->GetFile(std::string("icon_").append(language).append(".dat"));
629 if (icon_file != nullptr) { 660 if (icon_file != nullptr) {
630 break; 661 break;