2018-07-23 12:33:24 -04:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "common/string_util.h"
|
|
|
|
#include "common/swap.h"
|
|
|
|
#include "core/file_sys/control_metadata.h"
|
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
2018-09-19 18:55:33 -04:00
|
|
|
const std::array<const char*, 15> LANGUAGE_NAMES = {
|
|
|
|
"AmericanEnglish", "BritishEnglish", "Japanese",
|
|
|
|
"French", "German", "LatinAmericanSpanish",
|
|
|
|
"Spanish", "Italian", "Dutch",
|
|
|
|
"CanadianFrench", "Portugese", "Russian",
|
|
|
|
"Korean", "Taiwanese", "Chinese",
|
|
|
|
};
|
|
|
|
|
2018-07-23 12:33:24 -04:00
|
|
|
std::string LanguageEntry::GetApplicationName() const {
|
|
|
|
return Common::StringFromFixedZeroTerminatedBuffer(application_name.data(), 0x200);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string LanguageEntry::GetDeveloperName() const {
|
|
|
|
return Common::StringFromFixedZeroTerminatedBuffer(developer_name.data(), 0x100);
|
|
|
|
}
|
|
|
|
|
2018-08-11 22:45:30 -04:00
|
|
|
NACP::NACP(VirtualFile file) : raw(std::make_unique<RawNACP>()) {
|
2018-07-23 12:33:24 -04:00
|
|
|
file->ReadObject(raw.get());
|
|
|
|
}
|
|
|
|
|
2018-09-19 19:19:05 -04:00
|
|
|
NACP::~NACP() = default;
|
|
|
|
|
2018-07-23 12:33:24 -04:00
|
|
|
const LanguageEntry& NACP::GetLanguageEntry(Language language) const {
|
2018-09-03 19:00:14 -04:00
|
|
|
if (language != Language::Default) {
|
|
|
|
return raw->language_entries.at(static_cast<u8>(language));
|
|
|
|
}
|
2018-09-19 19:02:04 -04:00
|
|
|
|
|
|
|
for (const auto& language_entry : raw->language_entries) {
|
|
|
|
if (!language_entry.GetApplicationName().empty())
|
|
|
|
return language_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fallback to English
|
|
|
|
return GetLanguageEntry(Language::AmericanEnglish);
|
2018-07-23 12:33:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string NACP::GetApplicationName(Language language) const {
|
|
|
|
return GetLanguageEntry(language).GetApplicationName();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string NACP::GetDeveloperName(Language language) const {
|
|
|
|
return GetLanguageEntry(language).GetDeveloperName();
|
|
|
|
}
|
|
|
|
|
|
|
|
u64 NACP::GetTitleId() const {
|
|
|
|
return raw->title_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string NACP::GetVersionString() const {
|
|
|
|
return Common::StringFromFixedZeroTerminatedBuffer(raw->version_string.data(), 0x10);
|
|
|
|
}
|
|
|
|
} // namespace FileSys
|