diff options
| author | 2018-09-03 19:00:14 -0400 | |
|---|---|---|
| committer | 2018-09-04 14:30:03 -0400 | |
| commit | e973cceaddf060b3738417504856db1baa4a04fa (patch) | |
| tree | d9f4661fbc6dad9cce078fa7a049b3dd614ac664 /src/core | |
| parent | card_image: Add program title ID getter (diff) | |
| download | yuzu-e973cceaddf060b3738417504856db1baa4a04fa.tar.gz yuzu-e973cceaddf060b3738417504856db1baa4a04fa.tar.xz yuzu-e973cceaddf060b3738417504856db1baa4a04fa.zip | |
control_metadata: Use alternate language names if AmericanEnglish isn't available
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/file_sys/control_metadata.cpp | 12 | ||||
| -rw-r--r-- | src/core/file_sys/control_metadata.h | 9 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/core/file_sys/control_metadata.cpp b/src/core/file_sys/control_metadata.cpp index ae21ad5b9..e76bf77bf 100644 --- a/src/core/file_sys/control_metadata.cpp +++ b/src/core/file_sys/control_metadata.cpp | |||
| @@ -21,7 +21,17 @@ NACP::NACP(VirtualFile file) : raw(std::make_unique<RawNACP>()) { | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | const LanguageEntry& NACP::GetLanguageEntry(Language language) const { | 23 | const LanguageEntry& NACP::GetLanguageEntry(Language language) const { |
| 24 | return raw->language_entries.at(static_cast<u8>(language)); | 24 | if (language != Language::Default) { |
| 25 | return raw->language_entries.at(static_cast<u8>(language)); | ||
| 26 | } else { | ||
| 27 | for (const auto& language_entry : raw->language_entries) { | ||
| 28 | if (!language_entry.GetApplicationName().empty()) | ||
| 29 | return language_entry; | ||
| 30 | } | ||
| 31 | |||
| 32 | // Fallback to English | ||
| 33 | return GetLanguageEntry(Language::AmericanEnglish); | ||
| 34 | } | ||
| 25 | } | 35 | } |
| 26 | 36 | ||
| 27 | std::string NACP::GetApplicationName(Language language) const { | 37 | std::string NACP::GetApplicationName(Language language) const { |
diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index 1568046f1..8a510bf46 100644 --- a/src/core/file_sys/control_metadata.h +++ b/src/core/file_sys/control_metadata.h | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <string> | 9 | #include <string> |
| 10 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/swap.h" | ||
| 12 | #include "core/file_sys/vfs.h" | 13 | #include "core/file_sys/vfs.h" |
| 13 | 14 | ||
| 14 | namespace FileSys { | 15 | namespace FileSys { |
| @@ -61,6 +62,8 @@ enum class Language : u8 { | |||
| 61 | Korean = 12, | 62 | Korean = 12, |
| 62 | Taiwanese = 13, | 63 | Taiwanese = 13, |
| 63 | Chinese = 14, | 64 | Chinese = 14, |
| 65 | |||
| 66 | Default = 255, | ||
| 64 | }; | 67 | }; |
| 65 | 68 | ||
| 66 | static constexpr std::array<const char*, 15> LANGUAGE_NAMES = { | 69 | static constexpr std::array<const char*, 15> LANGUAGE_NAMES = { |
| @@ -75,9 +78,9 @@ static constexpr std::array<const char*, 15> LANGUAGE_NAMES = { | |||
| 75 | class NACP { | 78 | class NACP { |
| 76 | public: | 79 | public: |
| 77 | explicit NACP(VirtualFile file); | 80 | explicit NACP(VirtualFile file); |
| 78 | const LanguageEntry& GetLanguageEntry(Language language = Language::AmericanEnglish) const; | 81 | const LanguageEntry& GetLanguageEntry(Language language = Language::Default) const; |
| 79 | std::string GetApplicationName(Language language = Language::AmericanEnglish) const; | 82 | std::string GetApplicationName(Language language = Language::Default) const; |
| 80 | std::string GetDeveloperName(Language language = Language::AmericanEnglish) const; | 83 | std::string GetDeveloperName(Language language = Language::Default) const; |
| 81 | u64 GetTitleId() const; | 84 | u64 GetTitleId() const; |
| 82 | std::string GetVersionString() const; | 85 | std::string GetVersionString() const; |
| 83 | 86 | ||