Address CR

This commit is contained in:
lynxnb 2021-09-27 18:24:07 +02:00 committed by ◱ Mark
parent 0077833667
commit c6d91c552b
16 changed files with 38 additions and 38 deletions

View File

@ -8,7 +8,7 @@
#include <android/asset_manager_jni.h>
#include <sys/system_properties.h>
#include "skyline/common.h"
#include "skyline/common/languages.h"
#include "skyline/common/language.h"
#include "skyline/common/signal.h"
#include "skyline/common/settings.h"
#include "skyline/common/trace.h"
@ -91,7 +91,7 @@ extern "C" JNIEXPORT void Java_emu_skyline_EmulationActivity_executeApplication(
settings,
std::string(appFilesPath),
GetTimeZoneName(),
static_cast<skyline::languages::SystemLanguage>(systemLanguage),
static_cast<skyline::language::SystemLanguage>(systemLanguage),
std::make_shared<skyline::vfs::AndroidAssetFileSystem>(AAssetManager_fromJava(env, assetManager))
)};
OsWeak = os;

View File

@ -53,7 +53,7 @@ extern "C" JNIEXPORT jint JNICALL Java_emu_skyline_loader_RomFile_populate(JNIEn
jfieldID rawIconField{env->GetFieldID(clazz, "rawIcon", "[B")};
if (loader->nacp) {
auto language{skyline::languages::GetApplicationLanguage(static_cast<skyline::languages::SystemLanguage>(systemLanguage))};
auto language{skyline::language::GetApplicationLanguage(static_cast<skyline::language::SystemLanguage>(systemLanguage))};
if (((1 << static_cast<skyline::u32>(language)) & loader->nacp->supportedTitleLanguages) == 0)
language = loader->nacp->GetFirstSupportedTitleLanguage();

View File

@ -13,7 +13,7 @@ namespace skyline {
constexpr size_t NewLanguageCodeListSize{18}; //!< The size of the post 10.1.0 language code list (was 17 between 4.0.0 - 10.1.0)
}
namespace languages {
namespace language {
/**
* @brief The list of all languages. Entries parameters are language, language code, system language index, application language index and map which holds a macro used for filtering some application languages that don't have a direct corresponding system language
* @example #define LANG_ENTRY(lang, code, sysIndex, appIndex, map) func(lang, code, sysIndex, appIndex, map) <br> LANGUAGES <br> #undef LANG_ENTRY

View File

@ -87,7 +87,7 @@ namespace skyline::loader {
virtual ~Loader() = default;
virtual std::vector<u8> GetIcon(languages::ApplicationLanguage language) {
virtual std::vector<u8> GetIcon(language::ApplicationLanguage language) {
return std::vector<u8>();
}

View File

@ -29,7 +29,7 @@ namespace skyline::loader {
}
}
std::vector<u8> NroLoader::GetIcon(languages::ApplicationLanguage language) {
std::vector<u8> NroLoader::GetIcon(language::ApplicationLanguage language) {
NroAssetSection &segmentHeader{assetHeader.icon};
std::vector<u8> buffer(segmentHeader.size);

View File

@ -70,7 +70,7 @@ namespace skyline::loader {
public:
NroLoader(std::shared_ptr<vfs::Backing> backing);
std::vector<u8> GetIcon(languages::ApplicationLanguage language) override;
std::vector<u8> GetIcon(language::ApplicationLanguage language) override;
void *LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) override;
};

View File

@ -57,15 +57,15 @@ namespace skyline::loader {
return NcaLoader::LoadExeFs(this, programNca->exeFs, process, state);
}
std::vector<u8> NspLoader::GetIcon(languages::ApplicationLanguage language) {
std::vector<u8> NspLoader::GetIcon(language::ApplicationLanguage language) {
if (controlRomFs == nullptr)
return std::vector<u8>();
std::shared_ptr<vfs::Backing> icon{};
auto iconName{fmt::format("icon_{}.dat", languages::ToString(language))};
auto iconName{fmt::format("icon_{}.dat", language::ToString(language))};
if (!(icon = controlRomFs->OpenFileUnchecked(iconName, {true, false, false}))) {
iconName = fmt::format("icon_{}.dat", languages::ToString(nacp->GetFirstSupportedTitleLanguage()));
iconName = fmt::format("icon_{}.dat", language::ToString(nacp->GetFirstSupportedTitleLanguage()));
icon = controlRomFs->OpenFileUnchecked(iconName, {true, false, false});
}

View File

@ -24,7 +24,7 @@ namespace skyline::loader {
public:
NspLoader(const std::shared_ptr<vfs::Backing> &backing, const std::shared_ptr<crypto::KeyStore> &keyStore);
std::vector<u8> GetIcon(languages::ApplicationLanguage language) override;
std::vector<u8> GetIcon(language::ApplicationLanguage language) override;
void *LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) override;
};

View File

@ -65,15 +65,15 @@ namespace skyline::loader {
return NcaLoader::LoadExeFs(this, programNca->exeFs, process, state);
}
std::vector<u8> XciLoader::GetIcon(languages::ApplicationLanguage language) {
std::vector<u8> XciLoader::GetIcon(language::ApplicationLanguage language) {
if (controlRomFs == nullptr)
return std::vector<u8>();
std::shared_ptr<vfs::Backing> icon{};
auto iconName{fmt::format("icon_{}.dat", languages::ToString(language))};
auto iconName{fmt::format("icon_{}.dat", language::ToString(language))};
if (!(icon = controlRomFs->OpenFileUnchecked(iconName, {true, false, false}))) {
iconName = fmt::format("icon_{}.dat", languages::ToString(nacp->GetFirstSupportedTitleLanguage()));
iconName = fmt::format("icon_{}.dat", language::ToString(nacp->GetFirstSupportedTitleLanguage()));
icon = controlRomFs->OpenFileUnchecked(iconName, {true, false, false});
}

View File

@ -117,7 +117,7 @@ namespace skyline::loader {
public:
XciLoader(const std::shared_ptr<vfs::Backing> &backing, const std::shared_ptr<crypto::KeyStore> &keyStore);
std::vector<u8> GetIcon(languages::ApplicationLanguage language) override;
std::vector<u8> GetIcon(language::ApplicationLanguage language) override;
void *LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) override;
};

View File

@ -19,7 +19,7 @@ namespace skyline::kernel {
std::shared_ptr<Settings> &settings,
std::string appFilesPath,
std::string deviceTimeZone,
languages::SystemLanguage systemLanguage,
language::SystemLanguage systemLanguage,
std::shared_ptr<vfs::FileSystem> assetFileSystem
) : state(this, jvmManager, settings, logger),
appFilesPath(std::move(appFilesPath)),

View File

@ -3,7 +3,7 @@
#pragma once
#include <common/languages.h>
#include <common/language.h>
#include "vfs/filesystem.h"
#include "loader/loader.h"
#include "services/serviceman.h"
@ -19,7 +19,7 @@ namespace skyline::kernel {
std::string deviceTimeZone; //!< The timezone name (e.g. Europe/London)
std::shared_ptr<vfs::FileSystem> assetFileSystem; //!< A filesystem to be used for accessing emulator assets (like tzdata)
service::ServiceManager serviceManager;
languages::SystemLanguage systemLanguage;
language::SystemLanguage systemLanguage;
/**
* @param logger An instance of the Logger class
@ -32,7 +32,7 @@ namespace skyline::kernel {
std::shared_ptr<Settings> &settings,
std::string appFilesPath,
std::string deviceTimeZone,
languages::SystemLanguage systemLanguage,
language::SystemLanguage systemLanguage,
std::shared_ptr<vfs::FileSystem> assetFileSystem
);

View File

@ -33,13 +33,13 @@ namespace skyline::service::am {
}
Result IApplicationFunctions::GetDesiredLanguage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto desiredLanguage{languages::GetApplicationLanguage(state.os->systemLanguage)};
auto desiredLanguage{language::GetApplicationLanguage(state.os->systemLanguage)};
// In the future we might want to trigger an UI dialog if the user selected languages is not available, for now it will use the first available
if (((1 << static_cast<u32>(desiredLanguage)) & state.loader->nacp->nacpContents.supportedLanguageFlag) == 0)
desiredLanguage = state.loader->nacp->GetFirstSupportedLanguage();
response.Push(languages::GetLanguageCode(languages::GetSystemLanguage(desiredLanguage)));
response.Push(language::GetLanguageCode(language::GetSystemLanguage(desiredLanguage)));
return {};
}

View File

@ -1,25 +1,25 @@
// SPDX-License-Identifier: MPL-2.0
// Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/)
#include <common/languages.h>
#include <common/language.h>
#include "ISettingsServer.h"
namespace skyline::service::settings {
ISettingsServer::ISettingsServer(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {}
Result ISettingsServer::GetAvailableLanguageCodes(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
request.outputBuf.at(0).copy_from(span(languages::LanguageCodeList).first(constant::OldLanguageCodeListSize));
request.outputBuf.at(0).copy_from(span(language::LanguageCodeList).first(constant::OldLanguageCodeListSize));
response.Push<i32>(constant::OldLanguageCodeListSize);
return {};
}
Result ISettingsServer::MakeLanguageCode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
response.Push<u64>(languages::LanguageCodeList.at(request.Pop<i32>()));
response.Push<u64>(language::LanguageCodeList.at(request.Pop<i32>()));
return {};
}
Result ISettingsServer::GetAvailableLanguageCodes2(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
request.outputBuf.at(0).copy_from(languages::LanguageCodeList);
request.outputBuf.at(0).copy_from(language::LanguageCodeList);
response.Push<i32>(constant::NewLanguageCodeListSize);
return {};
}

View File

@ -8,7 +8,7 @@ namespace skyline::vfs {
NACP::NACP(const std::shared_ptr<vfs::Backing> &backing) {
nacpContents = backing->Read<NacpData>();
u32 counter{0};
u32 counter{};
for (auto &entry : nacpContents.titleEntries) {
if (entry.applicationName.front() != '\0') {
supportedTitleLanguages |= (1 << counter);
@ -17,20 +17,20 @@ namespace skyline::vfs {
}
}
languages::ApplicationLanguage NACP::GetFirstSupportedTitleLanguage() {
return static_cast<languages::ApplicationLanguage>(std::countr_zero(supportedTitleLanguages));
language::ApplicationLanguage NACP::GetFirstSupportedTitleLanguage() {
return static_cast<language::ApplicationLanguage>(std::countr_zero(supportedTitleLanguages));
}
languages::ApplicationLanguage NACP::GetFirstSupportedLanguage() {
return static_cast<languages::ApplicationLanguage>(std::countr_zero(nacpContents.supportedLanguageFlag));
language::ApplicationLanguage NACP::GetFirstSupportedLanguage() {
return static_cast<language::ApplicationLanguage>(std::countr_zero(nacpContents.supportedLanguageFlag));
}
std::string NACP::GetApplicationName(languages::ApplicationLanguage language) {
std::string NACP::GetApplicationName(language::ApplicationLanguage language) {
auto applicationName{span(nacpContents.titleEntries.at(static_cast<size_t>(language)).applicationName)};
return std::string(applicationName.as_string(true));
}
std::string NACP::GetApplicationPublisher(languages::ApplicationLanguage language) {
std::string NACP::GetApplicationPublisher(language::ApplicationLanguage language) {
auto applicationPublisher{span(nacpContents.titleEntries.at(static_cast<size_t>(language)).applicationPublisher)};
return std::string(applicationPublisher.as_string(true));
}

View File

@ -3,7 +3,7 @@
#pragma once
#include <common/languages.h>
#include <common/language.h>
#include "backing.h"
namespace skyline::vfs {
@ -35,16 +35,16 @@ namespace skyline::vfs {
} nacpContents{};
static_assert(sizeof(NacpData) == 0x4000);
u32 supportedTitleLanguages{0}; //<! A bitmask containing the available title entry languages and game icons
u32 supportedTitleLanguages{}; //<! A bitmask containing the available title entry languages and game icons
NACP(const std::shared_ptr<vfs::Backing> &backing);
languages::ApplicationLanguage GetFirstSupportedTitleLanguage();
language::ApplicationLanguage GetFirstSupportedTitleLanguage();
languages::ApplicationLanguage GetFirstSupportedLanguage();
language::ApplicationLanguage GetFirstSupportedLanguage();
std::string GetApplicationName(languages::ApplicationLanguage language);
std::string GetApplicationName(language::ApplicationLanguage language);
std::string GetApplicationPublisher(languages::ApplicationLanguage language);
std::string GetApplicationPublisher(language::ApplicationLanguage language);
};
}