From d81b58f320f9ace1d80cfca6889cbee98813cd83 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 23 May 2019 01:28:27 -0700 Subject: Address review comments --- src/core/hle/service/ns/language.cpp | 392 ++++++++++++++++++++++++++++++++ src/core/hle/service/ns/language.h | 45 ++++ src/core/hle/service/ns/ns.cpp | 29 ++- src/core/hle/service/ns/ns.h | 14 +- src/core/hle/service/ns/ns_language.cpp | 391 ------------------------------- src/core/hle/service/ns/ns_language.h | 4 +- 6 files changed, 474 insertions(+), 401 deletions(-) create mode 100644 src/core/hle/service/ns/language.cpp create mode 100644 src/core/hle/service/ns/language.h delete mode 100644 src/core/hle/service/ns/ns_language.cpp (limited to 'src/core/hle/service') diff --git a/src/core/hle/service/ns/language.cpp b/src/core/hle/service/ns/language.cpp new file mode 100644 index 000000000..29c4a820c --- /dev/null +++ b/src/core/hle/service/ns/language.cpp @@ -0,0 +1,392 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/service/ns/language.h" +#include "core/hle/service/set/set.h" + +namespace Service::NS { + +constexpr ApplicationLanguagePriorityList priority_list_american_english = {{ + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_british_english = {{ + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_japanese = {{ + ApplicationLanguage::Japanese, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_french = {{ + ApplicationLanguage::French, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_german = {{ + ApplicationLanguage::German, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::French, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_latin_american_spanish = {{ + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::Spanish, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::Portuguese, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::French, + ApplicationLanguage::Italian, + ApplicationLanguage::German, + ApplicationLanguage::Dutch, + ApplicationLanguage::Russian, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_spanish = {{ + ApplicationLanguage::Spanish, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_italian = {{ + ApplicationLanguage::Italian, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_dutch = {{ + ApplicationLanguage::Dutch, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_canadian_french = {{ + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::French, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::Spanish, + ApplicationLanguage::German, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_portuguese = {{ + ApplicationLanguage::Portuguese, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Russian, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_russian = {{ + ApplicationLanguage::Russian, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_korean = {{ + ApplicationLanguage::Korean, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::Japanese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_traditional_chinese = {{ + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::Japanese, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::Korean, +}}; + +constexpr ApplicationLanguagePriorityList priority_list_simplified_chinese = {{ + ApplicationLanguage::SimplifiedChinese, + ApplicationLanguage::TraditionalChinese, + ApplicationLanguage::AmericanEnglish, + ApplicationLanguage::BritishEnglish, + ApplicationLanguage::Japanese, + ApplicationLanguage::LatinAmericanSpanish, + ApplicationLanguage::CanadianFrench, + ApplicationLanguage::French, + ApplicationLanguage::German, + ApplicationLanguage::Spanish, + ApplicationLanguage::Italian, + ApplicationLanguage::Dutch, + ApplicationLanguage::Portuguese, + ApplicationLanguage::Russian, + ApplicationLanguage::Korean, +}}; + +const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList( + const ApplicationLanguage lang) { + switch (lang) { + case ApplicationLanguage::AmericanEnglish: + return &priority_list_american_english; + case ApplicationLanguage::BritishEnglish: + return &priority_list_british_english; + case ApplicationLanguage::Japanese: + return &priority_list_japanese; + case ApplicationLanguage::French: + return &priority_list_french; + case ApplicationLanguage::German: + return &priority_list_german; + case ApplicationLanguage::LatinAmericanSpanish: + return &priority_list_latin_american_spanish; + case ApplicationLanguage::Spanish: + return &priority_list_spanish; + case ApplicationLanguage::Italian: + return &priority_list_italian; + case ApplicationLanguage::Dutch: + return &priority_list_dutch; + case ApplicationLanguage::CanadianFrench: + return &priority_list_canadian_french; + case ApplicationLanguage::Portuguese: + return &priority_list_portuguese; + case ApplicationLanguage::Russian: + return &priority_list_russian; + case ApplicationLanguage::Korean: + return &priority_list_korean; + case ApplicationLanguage::TraditionalChinese: + return &priority_list_traditional_chinese; + case ApplicationLanguage::SimplifiedChinese: + return &priority_list_simplified_chinese; + default: + return nullptr; + } +} + +std::optional ConvertToApplicationLanguage( + const Set::LanguageCode language_code) { + switch (language_code) { + case Set::LanguageCode::EN_US: + return ApplicationLanguage::AmericanEnglish; + case Set::LanguageCode::EN_GB: + return ApplicationLanguage::BritishEnglish; + case Set::LanguageCode::JA: + return ApplicationLanguage::Japanese; + case Set::LanguageCode::FR: + return ApplicationLanguage::French; + case Set::LanguageCode::DE: + return ApplicationLanguage::German; + case Set::LanguageCode::ES_419: + return ApplicationLanguage::LatinAmericanSpanish; + case Set::LanguageCode::ES: + return ApplicationLanguage::Spanish; + case Set::LanguageCode::IT: + return ApplicationLanguage::Italian; + case Set::LanguageCode::NL: + return ApplicationLanguage::Dutch; + case Set::LanguageCode::FR_CA: + return ApplicationLanguage::CanadianFrench; + case Set::LanguageCode::PT: + return ApplicationLanguage::Portuguese; + case Set::LanguageCode::RU: + return ApplicationLanguage::Russian; + case Set::LanguageCode::KO: + return ApplicationLanguage::Korean; + case Set::LanguageCode::ZH_HANT: + return ApplicationLanguage::TraditionalChinese; + case Set::LanguageCode::ZH_HANS: + return ApplicationLanguage::SimplifiedChinese; + default: + return std::nullopt; + } +} + +std::optional ConvertToLanguageCode(const ApplicationLanguage lang) { + switch (lang) { + case ApplicationLanguage::AmericanEnglish: + return Set::LanguageCode::EN_US; + case ApplicationLanguage::BritishEnglish: + return Set::LanguageCode::EN_GB; + case ApplicationLanguage::Japanese: + return Set::LanguageCode::JA; + case ApplicationLanguage::French: + return Set::LanguageCode::FR; + case ApplicationLanguage::German: + return Set::LanguageCode::DE; + case ApplicationLanguage::LatinAmericanSpanish: + return Set::LanguageCode::ES_419; + case ApplicationLanguage::Spanish: + return Set::LanguageCode::ES; + case ApplicationLanguage::Italian: + return Set::LanguageCode::IT; + case ApplicationLanguage::Dutch: + return Set::LanguageCode::NL; + case ApplicationLanguage::CanadianFrench: + return Set::LanguageCode::FR_CA; + case ApplicationLanguage::Portuguese: + return Set::LanguageCode::PT; + case ApplicationLanguage::Russian: + return Set::LanguageCode::RU; + case ApplicationLanguage::Korean: + return Set::LanguageCode::KO; + case ApplicationLanguage::TraditionalChinese: + return Set::LanguageCode::ZH_HANT; + case ApplicationLanguage::SimplifiedChinese: + return Set::LanguageCode::ZH_HANS; + default: + return std::nullopt; + } +} +} // namespace Service::NS \ No newline at end of file diff --git a/src/core/hle/service/ns/language.h b/src/core/hle/service/ns/language.h new file mode 100644 index 000000000..e9829f9d2 --- /dev/null +++ b/src/core/hle/service/ns/language.h @@ -0,0 +1,45 @@ +// Copyright 2019 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include +#include "common/common_types.h" + +namespace Service::Set { +enum class LanguageCode : u64; +} + +namespace Service::NS { +/// This is nn::ns::detail::ApplicationLanguage +enum class ApplicationLanguage : u8 { + AmericanEnglish = 0, + BritishEnglish, + Japanese, + French, + German, + LatinAmericanSpanish, + Spanish, + Italian, + Dutch, + CanadianFrench, + Portuguese, + Russian, + Korean, + TraditionalChinese, + SimplifiedChinese, + Count +}; +using ApplicationLanguagePriorityList = + const std::array(ApplicationLanguage::Count)>; + +constexpr u32 GetSupportedLanguageFlag(const ApplicationLanguage lang) { + return 1U << static_cast(lang); +} + +const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList(ApplicationLanguage lang); +std::optional ConvertToApplicationLanguage(Set::LanguageCode language_code); +std::optional ConvertToLanguageCode(ApplicationLanguage lang); +} // namespace Service::NS \ No newline at end of file diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index fa49b4293..e892b50f3 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp @@ -9,8 +9,9 @@ #include "core/hle/kernel/hle_ipc.h" #include "core/hle/service/ns/errors.h" #include "core/hle/service/ns/ns.h" -#include "core/hle/service/ns/ns_language.h" +#include "core/hle/service/ns/language.h" #include "core/hle/service/ns/pl_u.h" +#include "core/hle/service/set/set.h" #include "core/settings.h" namespace Service::NS { @@ -25,6 +26,8 @@ IAccountProxyInterface::IAccountProxyInterface() : ServiceFramework{"IAccountPro RegisterHandlers(functions); } +IAccountProxyInterface::~IAccountProxyInterface() = default; + IApplicationManagerInterface::IApplicationManagerInterface() : ServiceFramework{"IApplicationManagerInterface"} { // clang-format off @@ -246,6 +249,8 @@ IApplicationManagerInterface::IApplicationManagerInterface() RegisterHandlers(functions); } +IApplicationManagerInterface::~IApplicationManagerInterface() = default; + void IApplicationManagerInterface::GetApplicationControlData(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto flag = rp.PopRaw(); @@ -325,7 +330,7 @@ ResultVal IApplicationManagerInterface::GetApplicationDesiredLanguage( // Get language code from settings const auto language_code = - Service::Set::GetLanguageCodeFromIndex(Settings::values.language_index); + Set::GetLanguageCodeFromIndex(Settings::values.language_index); // Convert to application language, get priority list const auto application_language = ConvertToApplicationLanguage(language_code); @@ -342,7 +347,7 @@ ResultVal IApplicationManagerInterface::GetApplicationDesiredLanguage( const auto supported_flag = GetSupportedLanguageFlag(lang); if (supported_languages == 0 || (supported_languages & supported_flag) == supported_languages) { - return ResultVal::WithCode(RESULT_SUCCESS, static_cast(lang)); + return MakeResult(static_cast(lang)); } } @@ -373,7 +378,7 @@ ResultVal IApplicationManagerInterface::ConvertApplicationLanguageToLanguag return ERR_APPLICATION_LANGUAGE_NOT_FOUND; } - return ResultVal::WithCode(RESULT_SUCCESS, static_cast(*language_code)); + return MakeResult(static_cast(*language_code)); } IApplicationVersionInterface::IApplicationVersionInterface() @@ -395,6 +400,8 @@ IApplicationVersionInterface::IApplicationVersionInterface() RegisterHandlers(functions); } +IApplicationVersionInterface::~IApplicationVersionInterface() = default; + IContentManagerInterface::IContentManagerInterface() : ServiceFramework{"IContentManagerInterface"} { // clang-format off @@ -413,6 +420,8 @@ IContentManagerInterface::IContentManagerInterface() RegisterHandlers(functions); } +IContentManagerInterface::~IContentManagerInterface() = default; + IDocumentInterface::IDocumentInterface() : ServiceFramework{"IDocumentInterface"} { // clang-format off static const FunctionInfo functions[] = { @@ -425,6 +434,8 @@ IDocumentInterface::IDocumentInterface() : ServiceFramework{"IDocumentInterface" RegisterHandlers(functions); } +IDocumentInterface::~IDocumentInterface() = default; + IDownloadTaskInterface::IDownloadTaskInterface() : ServiceFramework{"IDownloadTaskInterface"} { // clang-format off static const FunctionInfo functions[] = { @@ -443,6 +454,8 @@ IDownloadTaskInterface::IDownloadTaskInterface() : ServiceFramework{"IDownloadTa RegisterHandlers(functions); } +IDownloadTaskInterface::~IDownloadTaskInterface() = default; + IECommerceInterface::IECommerceInterface() : ServiceFramework{"IECommerceInterface"} { // clang-format off static const FunctionInfo functions[] = { @@ -458,6 +471,8 @@ IECommerceInterface::IECommerceInterface() : ServiceFramework{"IECommerceInterfa RegisterHandlers(functions); } +IECommerceInterface::~IECommerceInterface() = default; + IFactoryResetInterface::IFactoryResetInterface::IFactoryResetInterface() : ServiceFramework{"IFactoryResetInterface"} { // clang-format off @@ -471,6 +486,8 @@ IFactoryResetInterface::IFactoryResetInterface::IFactoryResetInterface() RegisterHandlers(functions); } +IFactoryResetInterface::~IFactoryResetInterface() = default; + NS::NS(const char* name) : ServiceFramework{name} { // clang-format off static const FunctionInfo functions[] = { @@ -488,7 +505,9 @@ NS::NS(const char* name) : ServiceFramework{name} { RegisterHandlers(functions); } -std::shared_ptr NS::GetApplicationManagerInterface() { +NS::~NS() = default; + +std::shared_ptr NS::GetApplicationManagerInterface() const { return GetInterface(); } diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h index 155dd6831..0f4bab4cb 100644 --- a/src/core/hle/service/ns/ns.h +++ b/src/core/hle/service/ns/ns.h @@ -5,18 +5,19 @@ #pragma once #include "core/hle/service/service.h" -#include "core/hle/service/set/set.h" namespace Service::NS { class IAccountProxyInterface final : public ServiceFramework { public: explicit IAccountProxyInterface(); + ~IAccountProxyInterface(); }; class IApplicationManagerInterface final : public ServiceFramework { public: explicit IApplicationManagerInterface(); + ~IApplicationManagerInterface(); ResultVal GetApplicationDesiredLanguage(u32 supported_languages); ResultVal ConvertApplicationLanguageToLanguageCode(u8 application_language); @@ -30,38 +31,45 @@ private: class IApplicationVersionInterface final : public ServiceFramework { public: explicit IApplicationVersionInterface(); + ~IApplicationVersionInterface(); }; class IContentManagerInterface final : public ServiceFramework { public: explicit IContentManagerInterface(); + ~IContentManagerInterface(); }; class IDocumentInterface final : public ServiceFramework { public: explicit IDocumentInterface(); + ~IDocumentInterface(); }; class IDownloadTaskInterface final : public ServiceFramework { public: explicit IDownloadTaskInterface(); + ~IDownloadTaskInterface(); }; class IECommerceInterface final : public ServiceFramework { public: explicit IECommerceInterface(); + ~IECommerceInterface(); }; class IFactoryResetInterface final : public ServiceFramework { public: explicit IFactoryResetInterface(); + ~IFactoryResetInterface(); }; class NS final : public ServiceFramework { public: explicit NS(const char* name); + ~NS(); - std::shared_ptr GetApplicationManagerInterface(); + std::shared_ptr GetApplicationManagerInterface() const; private: template @@ -74,7 +82,7 @@ private: } template - std::shared_ptr GetInterface() { + std::shared_ptr GetInterface() const { static_assert(std::is_base_of_v, "Not a base of ServiceFrameworkBase"); diff --git a/src/core/hle/service/ns/ns_language.cpp b/src/core/hle/service/ns/ns_language.cpp deleted file mode 100644 index fa95e75da..000000000 --- a/src/core/hle/service/ns/ns_language.cpp +++ /dev/null @@ -1,391 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "core/hle/service/ns/ns_language.h" - -namespace Service::NS { - -constexpr ApplicationLanguagePriorityList priority_list_american_english = {{ - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_british_english = {{ - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_japanese = {{ - ApplicationLanguage::Japanese, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_french = {{ - ApplicationLanguage::French, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_german = {{ - ApplicationLanguage::German, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::French, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_latin_american_spanish = {{ - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::Spanish, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::Portuguese, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::French, - ApplicationLanguage::Italian, - ApplicationLanguage::German, - ApplicationLanguage::Dutch, - ApplicationLanguage::Russian, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_spanish = {{ - ApplicationLanguage::Spanish, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_italian = {{ - ApplicationLanguage::Italian, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_dutch = {{ - ApplicationLanguage::Dutch, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_canadian_french = {{ - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::French, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::Spanish, - ApplicationLanguage::German, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_portuguese = {{ - ApplicationLanguage::Portuguese, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Russian, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_russian = {{ - ApplicationLanguage::Russian, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_korean = {{ - ApplicationLanguage::Korean, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::Japanese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_traditional_chinese = {{ - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::Japanese, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::Korean, -}}; - -constexpr ApplicationLanguagePriorityList priority_list_simplified_chinese = {{ - ApplicationLanguage::SimplifiedChinese, - ApplicationLanguage::TraditionalChinese, - ApplicationLanguage::AmericanEnglish, - ApplicationLanguage::BritishEnglish, - ApplicationLanguage::Japanese, - ApplicationLanguage::LatinAmericanSpanish, - ApplicationLanguage::CanadianFrench, - ApplicationLanguage::French, - ApplicationLanguage::German, - ApplicationLanguage::Spanish, - ApplicationLanguage::Italian, - ApplicationLanguage::Dutch, - ApplicationLanguage::Portuguese, - ApplicationLanguage::Russian, - ApplicationLanguage::Korean, -}}; - -const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList( - ApplicationLanguage lang) { - switch (lang) { - case ApplicationLanguage::AmericanEnglish: - return &priority_list_american_english; - case ApplicationLanguage::BritishEnglish: - return &priority_list_british_english; - case ApplicationLanguage::Japanese: - return &priority_list_japanese; - case ApplicationLanguage::French: - return &priority_list_french; - case ApplicationLanguage::German: - return &priority_list_german; - case ApplicationLanguage::LatinAmericanSpanish: - return &priority_list_latin_american_spanish; - case ApplicationLanguage::Spanish: - return &priority_list_spanish; - case ApplicationLanguage::Italian: - return &priority_list_italian; - case ApplicationLanguage::Dutch: - return &priority_list_dutch; - case ApplicationLanguage::CanadianFrench: - return &priority_list_canadian_french; - case ApplicationLanguage::Portuguese: - return &priority_list_portuguese; - case ApplicationLanguage::Russian: - return &priority_list_russian; - case ApplicationLanguage::Korean: - return &priority_list_korean; - case ApplicationLanguage::TraditionalChinese: - return &priority_list_traditional_chinese; - case ApplicationLanguage::SimplifiedChinese: - return &priority_list_simplified_chinese; - default: - return nullptr; - } -} - -std::optional ConvertToApplicationLanguage( - const Service::Set::LanguageCode language_code) { - switch (language_code) { - case Service::Set::LanguageCode::EN_US: - return ApplicationLanguage::AmericanEnglish; - case Service::Set::LanguageCode::EN_GB: - return ApplicationLanguage::BritishEnglish; - case Service::Set::LanguageCode::JA: - return ApplicationLanguage::Japanese; - case Service::Set::LanguageCode::FR: - return ApplicationLanguage::French; - case Service::Set::LanguageCode::DE: - return ApplicationLanguage::German; - case Service::Set::LanguageCode::ES_419: - return ApplicationLanguage::LatinAmericanSpanish; - case Service::Set::LanguageCode::ES: - return ApplicationLanguage::Spanish; - case Service::Set::LanguageCode::IT: - return ApplicationLanguage::Italian; - case Service::Set::LanguageCode::NL: - return ApplicationLanguage::Dutch; - case Service::Set::LanguageCode::FR_CA: - return ApplicationLanguage::CanadianFrench; - case Service::Set::LanguageCode::PT: - return ApplicationLanguage::Portuguese; - case Service::Set::LanguageCode::RU: - return ApplicationLanguage::Russian; - case Service::Set::LanguageCode::KO: - return ApplicationLanguage::Korean; - case Service::Set::LanguageCode::ZH_HANT: - return ApplicationLanguage::TraditionalChinese; - case Service::Set::LanguageCode::ZH_HANS: - return ApplicationLanguage::SimplifiedChinese; - default: - return std::nullopt; - } -} - -std::optional ConvertToLanguageCode(const ApplicationLanguage lang) { - switch (lang) { - case ApplicationLanguage::AmericanEnglish: - return Service::Set::LanguageCode::EN_US; - case ApplicationLanguage::BritishEnglish: - return Service::Set::LanguageCode::EN_GB; - case ApplicationLanguage::Japanese: - return Service::Set::LanguageCode::JA; - case ApplicationLanguage::French: - return Service::Set::LanguageCode::FR; - case ApplicationLanguage::German: - return Service::Set::LanguageCode::DE; - case ApplicationLanguage::LatinAmericanSpanish: - return Service::Set::LanguageCode::ES_419; - case ApplicationLanguage::Spanish: - return Service::Set::LanguageCode::ES; - case ApplicationLanguage::Italian: - return Service::Set::LanguageCode::IT; - case ApplicationLanguage::Dutch: - return Service::Set::LanguageCode::NL; - case ApplicationLanguage::CanadianFrench: - return Service::Set::LanguageCode::FR_CA; - case ApplicationLanguage::Portuguese: - return Service::Set::LanguageCode::PT; - case ApplicationLanguage::Russian: - return Service::Set::LanguageCode::RU; - case ApplicationLanguage::Korean: - return Service::Set::LanguageCode::KO; - case ApplicationLanguage::TraditionalChinese: - return Service::Set::LanguageCode::ZH_HANT; - case ApplicationLanguage::SimplifiedChinese: - return Service::Set::LanguageCode::ZH_HANS; - default: - return std::nullopt; - } -} -} // namespace Service::NS \ No newline at end of file diff --git a/src/core/hle/service/ns/ns_language.h b/src/core/hle/service/ns/ns_language.h index 55d7b0bd2..59ac85a19 100644 --- a/src/core/hle/service/ns/ns_language.h +++ b/src/core/hle/service/ns/ns_language.h @@ -1,4 +1,4 @@ -// Copyright 2018 yuzu emulator team +// Copyright 2019 yuzu emulator team // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -32,7 +32,7 @@ using ApplicationLanguagePriorityList = const std::array(ApplicationLanguage::Count)>; constexpr u32 GetSupportedLanguageFlag(const ApplicationLanguage lang) { - return 1u << static_cast(lang); + return 1U << static_cast(lang); } const ApplicationLanguagePriorityList* GetApplicationLanguagePriorityList(ApplicationLanguage lang); -- cgit v1.2.3