diff options
author | wwylele <wwylele@gmail.com> | 2017-01-18 23:06:52 +0100 |
---|---|---|
committer | wwylele <wwylele@gmail.com> | 2017-01-19 09:28:35 +0100 |
commit | 0045ea662fc6a58601b90118632ddb8cbb18b9d4 (patch) | |
tree | 5fa088fbe5b1b37f52e29e6e808ac0de87798359 /src | |
parent | Merge pull request #2424 from Kloen/qt-ui-warnings-really (diff) | |
download | yuzu-0045ea662fc6a58601b90118632ddb8cbb18b9d4.tar yuzu-0045ea662fc6a58601b90118632ddb8cbb18b9d4.tar.gz yuzu-0045ea662fc6a58601b90118632ddb8cbb18b9d4.tar.bz2 yuzu-0045ea662fc6a58601b90118632ddb8cbb18b9d4.tar.lz yuzu-0045ea662fc6a58601b90118632ddb8cbb18b9d4.tar.xz yuzu-0045ea662fc6a58601b90118632ddb8cbb18b9d4.tar.zst yuzu-0045ea662fc6a58601b90118632ddb8cbb18b9d4.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/service/cfg/cfg.cpp | 74 |
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) { |