2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #9115 from vonchenplus/game_name_by_language

file_sys: Priority display of game titles in the current language
This commit is contained in:
bunnei 2022-10-27 11:33:02 -07:00 committed by GitHub
commit 25d53e66d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 12 deletions

View file

@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "common/settings.h"
#include "common/string_util.h" #include "common/string_util.h"
#include "common/swap.h" #include "common/swap.h"
#include "core/file_sys/control_metadata.h" #include "core/file_sys/control_metadata.h"
@ -37,6 +38,27 @@ std::string LanguageEntry::GetDeveloperName() const {
developer_name.size()); developer_name.size());
} }
constexpr std::array<Language, 18> language_to_codes = {{
Language::Japanese,
Language::AmericanEnglish,
Language::French,
Language::German,
Language::Italian,
Language::Spanish,
Language::Chinese,
Language::Korean,
Language::Dutch,
Language::Portuguese,
Language::Russian,
Language::Taiwanese,
Language::BritishEnglish,
Language::CanadianFrench,
Language::LatinAmericanSpanish,
Language::Chinese,
Language::Taiwanese,
Language::BrazilianPortuguese,
}};
NACP::NACP() = default; NACP::NACP() = default;
NACP::NACP(VirtualFile file) { NACP::NACP(VirtualFile file) {
@ -45,9 +67,13 @@ NACP::NACP(VirtualFile file) {
NACP::~NACP() = default; NACP::~NACP() = default;
const LanguageEntry& NACP::GetLanguageEntry(Language language) const { const LanguageEntry& NACP::GetLanguageEntry() const {
if (language != Language::Default) { Language language = language_to_codes[Settings::values.language_index.GetValue()];
return raw.language_entries.at(static_cast<u8>(language));
{
const auto& language_entry = raw.language_entries.at(static_cast<u8>(language));
if (!language_entry.GetApplicationName().empty())
return language_entry;
} }
for (const auto& language_entry : raw.language_entries) { for (const auto& language_entry : raw.language_entries) {
@ -55,16 +81,15 @@ const LanguageEntry& NACP::GetLanguageEntry(Language language) const {
return language_entry; return language_entry;
} }
// Fallback to English return raw.language_entries.at(static_cast<u8>(Language::AmericanEnglish));
return GetLanguageEntry(Language::AmericanEnglish);
} }
std::string NACP::GetApplicationName(Language language) const { std::string NACP::GetApplicationName() const {
return GetLanguageEntry(language).GetApplicationName(); return GetLanguageEntry().GetApplicationName();
} }
std::string NACP::GetDeveloperName(Language language) const { std::string NACP::GetDeveloperName() const {
return GetLanguageEntry(language).GetDeveloperName(); return GetLanguageEntry().GetDeveloperName();
} }
u64 NACP::GetTitleId() const { u64 NACP::GetTitleId() const {

View file

@ -101,9 +101,9 @@ public:
explicit NACP(VirtualFile file); explicit NACP(VirtualFile file);
~NACP(); ~NACP();
const LanguageEntry& GetLanguageEntry(Language language = Language::Default) const; const LanguageEntry& GetLanguageEntry() const;
std::string GetApplicationName(Language language = Language::Default) const; std::string GetApplicationName() const;
std::string GetDeveloperName(Language language = Language::Default) const; std::string GetDeveloperName() const;
u64 GetTitleId() const; u64 GetTitleId() const;
u64 GetDLCBaseTitleId() const; u64 GetDLCBaseTitleId() const;
std::string GetVersionString() const; std::string GetVersionString() const;