2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-07-23 18:33:24 +02:00
|
|
|
|
2022-10-22 15:27:34 +02:00
|
|
|
#include "common/settings.h"
|
2018-07-23 18:33:24 +02:00
|
|
|
#include "common/string_util.h"
|
|
|
|
#include "common/swap.h"
|
|
|
|
#include "core/file_sys/control_metadata.h"
|
2020-08-23 20:20:37 +02:00
|
|
|
#include "core/file_sys/vfs.h"
|
2018-07-23 18:33:24 +02:00
|
|
|
|
|
|
|
namespace FileSys {
|
|
|
|
|
2021-10-29 02:04:33 +02:00
|
|
|
const std::array<const char*, 16> LANGUAGE_NAMES{{
|
2018-11-27 19:18:12 +01:00
|
|
|
"AmericanEnglish",
|
|
|
|
"BritishEnglish",
|
|
|
|
"Japanese",
|
|
|
|
"French",
|
|
|
|
"German",
|
|
|
|
"LatinAmericanSpanish",
|
|
|
|
"Spanish",
|
|
|
|
"Italian",
|
|
|
|
"Dutch",
|
|
|
|
"CanadianFrench",
|
|
|
|
"Portuguese",
|
|
|
|
"Russian",
|
|
|
|
"Korean",
|
2023-06-03 17:23:14 +02:00
|
|
|
"TraditionalChinese",
|
|
|
|
"SimplifiedChinese",
|
2021-10-29 02:04:33 +02:00
|
|
|
"BrazilianPortuguese",
|
2018-11-27 19:18:12 +01:00
|
|
|
}};
|
2018-09-20 00:55:33 +02:00
|
|
|
|
2018-07-23 18:33:24 +02:00
|
|
|
std::string LanguageEntry::GetApplicationName() const {
|
2018-10-16 02:11:42 +02:00
|
|
|
return Common::StringFromFixedZeroTerminatedBuffer(application_name.data(),
|
|
|
|
application_name.size());
|
2018-07-23 18:33:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string LanguageEntry::GetDeveloperName() const {
|
2018-10-16 02:11:42 +02:00
|
|
|
return Common::StringFromFixedZeroTerminatedBuffer(developer_name.data(),
|
|
|
|
developer_name.size());
|
2018-07-23 18:33:24 +02:00
|
|
|
}
|
|
|
|
|
2022-10-22 15:27:34 +02:00
|
|
|
constexpr std::array<Language, 18> language_to_codes = {{
|
|
|
|
Language::Japanese,
|
|
|
|
Language::AmericanEnglish,
|
|
|
|
Language::French,
|
|
|
|
Language::German,
|
|
|
|
Language::Italian,
|
|
|
|
Language::Spanish,
|
2023-06-03 17:23:14 +02:00
|
|
|
Language::SimplifiedChinese,
|
2022-10-22 15:27:34 +02:00
|
|
|
Language::Korean,
|
|
|
|
Language::Dutch,
|
|
|
|
Language::Portuguese,
|
|
|
|
Language::Russian,
|
2023-06-03 17:23:14 +02:00
|
|
|
Language::TraditionalChinese,
|
2022-10-22 15:27:34 +02:00
|
|
|
Language::BritishEnglish,
|
|
|
|
Language::CanadianFrench,
|
|
|
|
Language::LatinAmericanSpanish,
|
2023-06-03 17:23:14 +02:00
|
|
|
Language::SimplifiedChinese,
|
|
|
|
Language::TraditionalChinese,
|
2022-10-22 15:27:34 +02:00
|
|
|
Language::BrazilianPortuguese,
|
|
|
|
}};
|
|
|
|
|
2018-12-11 04:17:45 +01:00
|
|
|
NACP::NACP() = default;
|
2018-12-07 02:25:32 +01:00
|
|
|
|
|
|
|
NACP::NACP(VirtualFile file) {
|
|
|
|
file->ReadObject(&raw);
|
2018-07-23 18:33:24 +02:00
|
|
|
}
|
|
|
|
|
2018-09-20 01:19:05 +02:00
|
|
|
NACP::~NACP() = default;
|
|
|
|
|
2022-10-22 15:27:34 +02:00
|
|
|
const LanguageEntry& NACP::GetLanguageEntry() const {
|
2023-05-10 23:57:25 +02:00
|
|
|
Language language =
|
|
|
|
language_to_codes[static_cast<s32>(Settings::values.language_index.GetValue())];
|
2022-10-22 15:27:34 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
const auto& language_entry = raw.language_entries.at(static_cast<u8>(language));
|
|
|
|
if (!language_entry.GetApplicationName().empty())
|
|
|
|
return language_entry;
|
2018-09-04 01:00:14 +02:00
|
|
|
}
|
2018-09-20 01:02:04 +02:00
|
|
|
|
2018-12-07 02:25:32 +01:00
|
|
|
for (const auto& language_entry : raw.language_entries) {
|
2018-09-20 01:02:04 +02:00
|
|
|
if (!language_entry.GetApplicationName().empty())
|
|
|
|
return language_entry;
|
|
|
|
}
|
|
|
|
|
2022-10-22 15:27:34 +02:00
|
|
|
return raw.language_entries.at(static_cast<u8>(Language::AmericanEnglish));
|
2018-07-23 18:33:24 +02:00
|
|
|
}
|
|
|
|
|
2022-10-22 15:27:34 +02:00
|
|
|
std::string NACP::GetApplicationName() const {
|
|
|
|
return GetLanguageEntry().GetApplicationName();
|
2018-07-23 18:33:24 +02:00
|
|
|
}
|
|
|
|
|
2022-10-22 15:27:34 +02:00
|
|
|
std::string NACP::GetDeveloperName() const {
|
|
|
|
return GetLanguageEntry().GetDeveloperName();
|
2018-07-23 18:33:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u64 NACP::GetTitleId() const {
|
2019-03-26 04:30:56 +01:00
|
|
|
return raw.save_data_owner_id;
|
2018-07-23 18:33:24 +02:00
|
|
|
}
|
|
|
|
|
2018-10-15 00:58:07 +02:00
|
|
|
u64 NACP::GetDLCBaseTitleId() const {
|
2018-12-07 02:25:32 +01:00
|
|
|
return raw.dlc_base_title_id;
|
2018-10-15 00:58:07 +02:00
|
|
|
}
|
|
|
|
|
2018-07-23 18:33:24 +02:00
|
|
|
std::string NACP::GetVersionString() const {
|
2018-12-07 02:25:32 +01:00
|
|
|
return Common::StringFromFixedZeroTerminatedBuffer(raw.version_string.data(),
|
|
|
|
raw.version_string.size());
|
2018-07-23 18:33:24 +02:00
|
|
|
}
|
2018-10-28 19:55:32 +01:00
|
|
|
|
2018-12-07 02:25:55 +01:00
|
|
|
u64 NACP::GetDefaultNormalSaveSize() const {
|
2019-03-26 04:30:56 +01:00
|
|
|
return raw.user_account_save_data_size;
|
2018-12-07 02:25:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
u64 NACP::GetDefaultJournalSaveSize() const {
|
2019-03-26 04:30:56 +01:00
|
|
|
return raw.user_account_save_data_journal_size;
|
2018-12-07 02:25:55 +01:00
|
|
|
}
|
|
|
|
|
2019-06-16 11:06:33 +02:00
|
|
|
bool NACP::GetUserAccountSwitchLock() const {
|
2019-06-17 00:17:26 +02:00
|
|
|
return raw.user_account_switch_lock != 0;
|
2019-06-16 11:06:33 +02:00
|
|
|
}
|
|
|
|
|
2019-05-23 09:55:56 +02:00
|
|
|
u32 NACP::GetSupportedLanguages() const {
|
|
|
|
return raw.supported_languages;
|
|
|
|
}
|
|
|
|
|
2020-04-14 19:53:45 +02:00
|
|
|
u64 NACP::GetDeviceSaveDataSize() const {
|
|
|
|
return raw.device_save_data_size;
|
|
|
|
}
|
|
|
|
|
2021-03-26 16:03:18 +01:00
|
|
|
u32 NACP::GetParentalControlFlag() const {
|
|
|
|
return raw.parental_control;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::array<u8, 0x20>& NACP::GetRatingAge() const {
|
|
|
|
return raw.rating_age;
|
|
|
|
}
|
|
|
|
|
2018-10-28 19:55:32 +01:00
|
|
|
std::vector<u8> NACP::GetRawBytes() const {
|
|
|
|
std::vector<u8> out(sizeof(RawNACP));
|
2018-12-07 02:25:32 +01:00
|
|
|
std::memcpy(out.data(), &raw, sizeof(RawNACP));
|
2018-10-28 19:55:32 +01:00
|
|
|
return out;
|
|
|
|
}
|
2018-07-23 18:33:24 +02:00
|
|
|
} // namespace FileSys
|