summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-01-30 07:14:35 +0100
committerGitHub <noreply@github.com>2017-01-30 07:14:35 +0100
commita925473995af1832f6773faef9ca07a7957692a1 (patch)
treefc06b055c847ad16e4b04829aa7ecd2d9c0e5048 /src/core/hle/service
parentMerge pull request #2495 from Kloen/killing-warnings-chain-of-memories (diff)
parentCFG: override language setting on boot (diff)
downloadyuzu-a925473995af1832f6773faef9ca07a7957692a1.tar
yuzu-a925473995af1832f6773faef9ca07a7957692a1.tar.gz
yuzu-a925473995af1832f6773faef9ca07a7957692a1.tar.bz2
yuzu-a925473995af1832f6773faef9ca07a7957692a1.tar.lz
yuzu-a925473995af1832f6773faef9ca07a7957692a1.tar.xz
yuzu-a925473995af1832f6773faef9ca07a7957692a1.tar.zst
yuzu-a925473995af1832f6773faef9ca07a7957692a1.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/cfg/cfg.cpp74
1 files changed, 38 insertions, 36 deletions
diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp
index 59dd6d1cd..6f13cde27 100644
--- a/src/core/hle/service/cfg/cfg.cpp
+++ b/src/core/hle/service/cfg/cfg.cpp
@@ -322,47 +322,11 @@ static ResultVal<void*> GetConfigInfoBlockPointer(u32 block_id, u32 size, u32 fl
return MakeResult<void*>(pointer);
}
-/// Checks if the language is available in the chosen region, and returns a proper one
-static u8 AdjustLanguageInfoBlock(u32 region, u8 language) {
- static const std::array<std::vector<u8>, 7> region_languages{{
- // JPN
- {LANGUAGE_JP},
- // USA
- {LANGUAGE_EN, LANGUAGE_FR, LANGUAGE_ES, LANGUAGE_PT},
- // EUR
- {LANGUAGE_EN, LANGUAGE_FR, LANGUAGE_DE, LANGUAGE_IT, LANGUAGE_ES, LANGUAGE_NL, LANGUAGE_PT,
- LANGUAGE_RU},
- // AUS
- {LANGUAGE_EN, LANGUAGE_FR, LANGUAGE_DE, LANGUAGE_IT, LANGUAGE_ES, LANGUAGE_NL, LANGUAGE_PT,
- LANGUAGE_RU},
- // CHN
- {LANGUAGE_ZH},
- // KOR
- {LANGUAGE_KO},
- // TWN
- {LANGUAGE_TW},
- }};
- const auto& available = region_languages[region];
- if (std::find(available.begin(), available.end(), language) == available.end()) {
- return available[0];
- }
- return language;
-}
-
ResultCode GetConfigInfoBlock(u32 block_id, u32 size, u32 flag, void* output) {
void* pointer;
CASCADE_RESULT(pointer, GetConfigInfoBlockPointer(block_id, size, flag));
memcpy(output, pointer, size);
- // override the language setting if the region setting is auto
- if (block_id == LanguageBlockID &&
- Settings::values.region_value == Settings::REGION_VALUE_AUTO_SELECT) {
- u8 language;
- memcpy(&language, output, sizeof(u8));
- language = AdjustLanguageInfoBlock(preferred_region_code, language);
- memcpy(output, &language, sizeof(u8));
- }
-
return RESULT_SUCCESS;
}
@@ -586,9 +550,47 @@ void Init() {
void Shutdown() {}
+/// Checks if the language is available in the chosen region, and returns a proper one
+static SystemLanguage AdjustLanguageInfoBlock(u32 region, SystemLanguage language) {
+ static const std::array<std::vector<SystemLanguage>, 7> region_languages{{
+ // JPN
+ {LANGUAGE_JP},
+ // USA
+ {LANGUAGE_EN, LANGUAGE_FR, LANGUAGE_ES, LANGUAGE_PT},
+ // EUR
+ {LANGUAGE_EN, LANGUAGE_FR, LANGUAGE_DE, LANGUAGE_IT, LANGUAGE_ES, LANGUAGE_NL, LANGUAGE_PT,
+ LANGUAGE_RU},
+ // AUS
+ {LANGUAGE_EN, LANGUAGE_FR, LANGUAGE_DE, LANGUAGE_IT, LANGUAGE_ES, LANGUAGE_NL, LANGUAGE_PT,
+ LANGUAGE_RU},
+ // CHN
+ {LANGUAGE_ZH},
+ // KOR
+ {LANGUAGE_KO},
+ // TWN
+ {LANGUAGE_TW},
+ }};
+ const auto& available = region_languages[region];
+ if (std::find(available.begin(), available.end(), language) == available.end()) {
+ return available[0];
+ }
+ return language;
+}
+
void SetPreferredRegionCode(u32 region_code) {
preferred_region_code = region_code;
LOG_INFO(Service_CFG, "Preferred region code set to %u", preferred_region_code);
+
+ if (Settings::values.region_value == Settings::REGION_VALUE_AUTO_SELECT) {
+ const SystemLanguage current_language = GetSystemLanguage();
+ const SystemLanguage adjusted_language =
+ AdjustLanguageInfoBlock(region_code, current_language);
+ if (current_language != adjusted_language) {
+ LOG_WARNING(Service_CFG, "System language %d does not fit the region. Adjusted to %d",
+ static_cast<int>(current_language), static_cast<int>(adjusted_language));
+ SetSystemLanguage(adjusted_language);
+ }
+ }
}
void SetUsername(const std::u16string& name) {