mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-23 09:49:15 +01:00
Rework GetDesiredLanguage
+ Remove LanguageCode
alias type
This commit is contained in:
parent
6135f531ae
commit
ca97517d81
@ -7,8 +7,6 @@
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
|
||||||
namespace skyline {
|
namespace skyline {
|
||||||
using LanguageCode = u64;
|
|
||||||
|
|
||||||
namespace constant {
|
namespace constant {
|
||||||
constexpr size_t OldLanguageCodeListSize{15}; //!< The size of the pre 4.0.0 language code list
|
constexpr size_t OldLanguageCodeListSize{15}; //!< The size of the pre 4.0.0 language code list
|
||||||
constexpr size_t NewLanguageCodeListSize{18}; //!< The size of the post 10.1.0 language code list (was 17 between 4.0.0 - 10.1.0)
|
constexpr size_t NewLanguageCodeListSize{18}; //!< The size of the post 10.1.0 language code list (was 17 between 4.0.0 - 10.1.0)
|
||||||
@ -54,28 +52,28 @@ namespace skyline {
|
|||||||
SimplifiedChinese,
|
SimplifiedChinese,
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr std::array<LanguageCode, constant::NewLanguageCodeListSize> LanguageCodeList{
|
constexpr std::array<u64, constant::NewLanguageCodeListSize> LanguageCodeList{
|
||||||
util::MakeMagic<LanguageCode>("ja"),
|
util::MakeMagic<u64>("ja"),
|
||||||
util::MakeMagic<LanguageCode>("en-US"),
|
util::MakeMagic<u64>("en-US"),
|
||||||
util::MakeMagic<LanguageCode>("fr"),
|
util::MakeMagic<u64>("fr"),
|
||||||
util::MakeMagic<LanguageCode>("de"),
|
util::MakeMagic<u64>("de"),
|
||||||
util::MakeMagic<LanguageCode>("it"),
|
util::MakeMagic<u64>("it"),
|
||||||
util::MakeMagic<LanguageCode>("es"),
|
util::MakeMagic<u64>("es"),
|
||||||
util::MakeMagic<LanguageCode>("zh-CN"),
|
util::MakeMagic<u64>("zh-CN"),
|
||||||
util::MakeMagic<LanguageCode>("ko"),
|
util::MakeMagic<u64>("ko"),
|
||||||
util::MakeMagic<LanguageCode>("nl"),
|
util::MakeMagic<u64>("nl"),
|
||||||
util::MakeMagic<LanguageCode>("pt"),
|
util::MakeMagic<u64>("pt"),
|
||||||
util::MakeMagic<LanguageCode>("ru"),
|
util::MakeMagic<u64>("ru"),
|
||||||
util::MakeMagic<LanguageCode>("zh-TW"),
|
util::MakeMagic<u64>("zh-TW"),
|
||||||
util::MakeMagic<LanguageCode>("en-GB"),
|
util::MakeMagic<u64>("en-GB"),
|
||||||
util::MakeMagic<LanguageCode>("fr-CA"),
|
util::MakeMagic<u64>("fr-CA"),
|
||||||
util::MakeMagic<LanguageCode>("es-419"),
|
util::MakeMagic<u64>("es-419"),
|
||||||
util::MakeMagic<LanguageCode>("zh-Hans"),
|
util::MakeMagic<u64>("zh-Hans"),
|
||||||
util::MakeMagic<LanguageCode>("zh-Hant"),
|
util::MakeMagic<u64>("zh-Hant"),
|
||||||
util::MakeMagic<LanguageCode>("pt-BR"),
|
util::MakeMagic<u64>("pt-BR"),
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr LanguageCode GetLanguageCode(SystemLanguage language) {
|
constexpr u64 GetLanguageCode(SystemLanguage language) {
|
||||||
return LanguageCodeList.at(static_cast<size_t>(language));
|
return LanguageCodeList.at(static_cast<size_t>(language));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,12 @@ namespace skyline::service::am {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result IApplicationFunctions::GetDesiredLanguage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
Result IApplicationFunctions::GetDesiredLanguage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
|
||||||
response.Push(languages::GetLanguageCode(state.os->systemLanguage));
|
auto desiredLanguage{languages::GetApplicationLanguage(state.os->systemLanguage)};
|
||||||
|
|
||||||
|
if ((1 << static_cast<u32>(desiredLanguage) & state.loader->nacp->nacpContents.supportedLanguageFlag) == 0)
|
||||||
|
desiredLanguage = state.loader->nacp->GetFirstSupportedLanguage();
|
||||||
|
|
||||||
|
response.Push(languages::GetLanguageCode(languages::GetSystemLanguage(desiredLanguage)));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@ namespace skyline::vfs {
|
|||||||
return static_cast<languages::ApplicationLanguage>(std::countr_zero(supportedTitleLanguages));
|
return static_cast<languages::ApplicationLanguage>(std::countr_zero(supportedTitleLanguages));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
languages::ApplicationLanguage NACP::GetFirstSupportedLanguage() {
|
||||||
|
return static_cast<languages::ApplicationLanguage>(std::countr_zero(nacpContents.supportedLanguageFlag));
|
||||||
|
}
|
||||||
|
|
||||||
std::string NACP::GetApplicationName(languages::ApplicationLanguage language) {
|
std::string NACP::GetApplicationName(languages::ApplicationLanguage language) {
|
||||||
auto applicationName{span(nacpContents.titleEntries.at(static_cast<size_t>(language)).applicationName)};
|
auto applicationName{span(nacpContents.titleEntries.at(static_cast<size_t>(language)).applicationName)};
|
||||||
return std::string(applicationName.as_string(true));
|
return std::string(applicationName.as_string(true));
|
||||||
|
@ -39,6 +39,8 @@ namespace skyline::vfs {
|
|||||||
|
|
||||||
languages::ApplicationLanguage GetFirstSupportedTitleLanguage();
|
languages::ApplicationLanguage GetFirstSupportedTitleLanguage();
|
||||||
|
|
||||||
|
languages::ApplicationLanguage GetFirstSupportedLanguage();
|
||||||
|
|
||||||
std::string GetApplicationName(languages::ApplicationLanguage language);
|
std::string GetApplicationName(languages::ApplicationLanguage language);
|
||||||
|
|
||||||
std::string GetApplicationPublisher(languages::ApplicationLanguage language);
|
std::string GetApplicationPublisher(languages::ApplicationLanguage language);
|
||||||
|
Loading…
Reference in New Issue
Block a user