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-11-27 13:18:12 -05:00
|
|
|
const std::array<const char*, 15> LANGUAGE_NAMES{{
|
|
|
|
"AmericanEnglish",
|
|
|
|
"BritishEnglish",
|
|
|
|
"Japanese",
|
|
|
|
"French",
|
|
|
|
"German",
|
|
|
|
"LatinAmericanSpanish",
|
|
|
|
"Spanish",
|
|
|
|
"Italian",
|
|
|
|
"Dutch",
|
|
|
|
"CanadianFrench",
|
|
|
|
"Portuguese",
|
|
|
|
"Russian",
|
|
|
|
"Korean",
|
|
|
|
"Taiwanese",
|
|
|
|
"Chinese",
|
|
|
|
}};
|
2018-09-19 18:55:33 -04:00
|
|
|
|
2018-07-23 12:33:24 -04:00
|
|
|
std::string LanguageEntry::GetApplicationName() const {
|
2018-10-15 20:11:42 -04:00
|
|
|
return Common::StringFromFixedZeroTerminatedBuffer(application_name.data(),
|
|
|
|
application_name.size());
|
2018-07-23 12:33:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string LanguageEntry::GetDeveloperName() const {
|
2018-10-15 20:11:42 -04:00
|
|
|
return Common::StringFromFixedZeroTerminatedBuffer(developer_name.data(),
|
|
|
|
developer_name.size());
|
2018-07-23 12:33:24 -04:00
|
|
|
}
|
|
|
|
|
2018-12-10 22:17:45 -05:00
|
|
|
NACP::NACP() = default;
|
2018-12-06 20:25:32 -05:00
|
|
|
|
|
|
|
NACP::NACP(VirtualFile file) {
|
|
|
|
file->ReadObject(&raw);
|
2018-07-23 12:33:24 -04:00
|
|
|
}
|
|
|
|
|
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) {
|
2018-12-06 20:25:32 -05:00
|
|
|
return raw.language_entries.at(static_cast<u8>(language));
|
2018-09-03 19:00:14 -04:00
|
|
|
}
|
2018-09-19 19:02:04 -04:00
|
|
|
|
2018-12-06 20:25:32 -05:00
|
|
|
for (const auto& language_entry : raw.language_entries) {
|
2018-09-19 19:02:04 -04:00
|
|
|
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 {
|
2019-03-25 23:30:56 -04:00
|
|
|
return raw.save_data_owner_id;
|
2018-07-23 12:33:24 -04:00
|
|
|
}
|
|
|
|
|
2018-10-14 18:58:07 -04:00
|
|
|
u64 NACP::GetDLCBaseTitleId() const {
|
2018-12-06 20:25:32 -05:00
|
|
|
return raw.dlc_base_title_id;
|
2018-10-14 18:58:07 -04:00
|
|
|
}
|
|
|
|
|
2018-07-23 12:33:24 -04:00
|
|
|
std::string NACP::GetVersionString() const {
|
2018-12-06 20:25:32 -05:00
|
|
|
return Common::StringFromFixedZeroTerminatedBuffer(raw.version_string.data(),
|
|
|
|
raw.version_string.size());
|
2018-07-23 12:33:24 -04:00
|
|
|
}
|
2018-10-28 14:55:32 -04:00
|
|
|
|
2018-12-06 20:25:55 -05:00
|
|
|
u64 NACP::GetDefaultNormalSaveSize() const {
|
2019-03-25 23:30:56 -04:00
|
|
|
return raw.user_account_save_data_size;
|
2018-12-06 20:25:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
u64 NACP::GetDefaultJournalSaveSize() const {
|
2019-03-25 23:30:56 -04:00
|
|
|
return raw.user_account_save_data_journal_size;
|
2018-12-06 20:25:55 -05:00
|
|
|
}
|
|
|
|
|
2019-05-23 03:55:56 -04:00
|
|
|
u32 NACP::GetSupportedLanguages() const {
|
|
|
|
return raw.supported_languages;
|
|
|
|
}
|
|
|
|
|
2018-10-28 14:55:32 -04:00
|
|
|
std::vector<u8> NACP::GetRawBytes() const {
|
|
|
|
std::vector<u8> out(sizeof(RawNACP));
|
2018-12-06 20:25:32 -05:00
|
|
|
std::memcpy(out.data(), &raw, sizeof(RawNACP));
|
2018-10-28 14:55:32 -04:00
|
|
|
return out;
|
|
|
|
}
|
2018-07-23 12:33:24 -04:00
|
|
|
} // namespace FileSys
|