mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-30 03:04:17 +01:00
Support game icon selection based on language
This commit is contained in:
parent
01ce09183b
commit
0077833667
@ -60,7 +60,7 @@ extern "C" JNIEXPORT jint JNICALL Java_emu_skyline_loader_RomFile_populate(JNIEn
|
||||
env->SetObjectField(thiz, applicationNameField, env->NewStringUTF(loader->nacp->GetApplicationName(language).c_str()));
|
||||
env->SetObjectField(thiz, applicationAuthorField, env->NewStringUTF(loader->nacp->GetApplicationPublisher(language).c_str()));
|
||||
|
||||
auto icon{loader->GetIcon()};
|
||||
auto icon{loader->GetIcon(language)};
|
||||
jbyteArray iconByteArray{env->NewByteArray(icon.size())};
|
||||
env->SetByteArrayRegion(iconByteArray, 0, icon.size(), reinterpret_cast<const jbyte *>(icon.data()));
|
||||
env->SetObjectField(thiz, rawIconField, iconByteArray);
|
||||
|
@ -87,7 +87,7 @@ namespace skyline::loader {
|
||||
|
||||
virtual ~Loader() = default;
|
||||
|
||||
virtual std::vector<u8> GetIcon() {
|
||||
virtual std::vector<u8> GetIcon(languages::ApplicationLanguage language) {
|
||||
return std::vector<u8>();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace skyline::loader {
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<u8> NroLoader::GetIcon() {
|
||||
std::vector<u8> NroLoader::GetIcon(languages::ApplicationLanguage language) {
|
||||
NroAssetSection &segmentHeader{assetHeader.icon};
|
||||
std::vector<u8> buffer(segmentHeader.size);
|
||||
|
||||
|
@ -70,7 +70,7 @@ namespace skyline::loader {
|
||||
public:
|
||||
NroLoader(std::shared_ptr<vfs::Backing> backing);
|
||||
|
||||
std::vector<u8> GetIcon() override;
|
||||
std::vector<u8> GetIcon(languages::ApplicationLanguage language) override;
|
||||
|
||||
void *LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) override;
|
||||
};
|
||||
|
@ -57,19 +57,16 @@ namespace skyline::loader {
|
||||
return NcaLoader::LoadExeFs(this, programNca->exeFs, process, state);
|
||||
}
|
||||
|
||||
std::vector<u8> NspLoader::GetIcon() {
|
||||
if (romFs == nullptr)
|
||||
std::vector<u8> NspLoader::GetIcon(languages::ApplicationLanguage language) {
|
||||
if (controlRomFs == nullptr)
|
||||
return std::vector<u8>();
|
||||
|
||||
auto root{controlRomFs->OpenDirectory("", {false, true})};
|
||||
std::shared_ptr<vfs::Backing> icon{};
|
||||
|
||||
// Use the first icon file available
|
||||
for (const auto &entry : root->Read()) {
|
||||
if (entry.name.rfind("icon") == 0) {
|
||||
icon = controlRomFs->OpenFileUnchecked(entry.name);
|
||||
break;
|
||||
}
|
||||
auto iconName{fmt::format("icon_{}.dat", languages::ToString(language))};
|
||||
if (!(icon = controlRomFs->OpenFileUnchecked(iconName, {true, false, false}))) {
|
||||
iconName = fmt::format("icon_{}.dat", languages::ToString(nacp->GetFirstSupportedTitleLanguage()));
|
||||
icon = controlRomFs->OpenFileUnchecked(iconName, {true, false, false});
|
||||
}
|
||||
|
||||
if (icon == nullptr)
|
||||
|
@ -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() override;
|
||||
std::vector<u8> GetIcon(languages::ApplicationLanguage language) override;
|
||||
|
||||
void *LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) override;
|
||||
};
|
||||
|
@ -65,19 +65,16 @@ namespace skyline::loader {
|
||||
return NcaLoader::LoadExeFs(this, programNca->exeFs, process, state);
|
||||
}
|
||||
|
||||
std::vector<u8> XciLoader::GetIcon() {
|
||||
if (romFs == nullptr)
|
||||
std::vector<u8> XciLoader::GetIcon(languages::ApplicationLanguage language) {
|
||||
if (controlRomFs == nullptr)
|
||||
return std::vector<u8>();
|
||||
|
||||
auto root{controlRomFs->OpenDirectory("", {false, true})};
|
||||
std::shared_ptr<vfs::Backing> icon{};
|
||||
|
||||
// Use the first icon file available
|
||||
for (const auto &entry : root->Read()) {
|
||||
if (entry.name.rfind("icon") == 0) {
|
||||
icon = controlRomFs->OpenFile(entry.name);
|
||||
break;
|
||||
}
|
||||
auto iconName{fmt::format("icon_{}.dat", languages::ToString(language))};
|
||||
if (!(icon = controlRomFs->OpenFileUnchecked(iconName, {true, false, false}))) {
|
||||
iconName = fmt::format("icon_{}.dat", languages::ToString(nacp->GetFirstSupportedTitleLanguage()));
|
||||
icon = controlRomFs->OpenFileUnchecked(iconName, {true, false, false});
|
||||
}
|
||||
|
||||
if (icon == nullptr)
|
||||
|
@ -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() override;
|
||||
std::vector<u8> GetIcon(languages::ApplicationLanguage language) override;
|
||||
|
||||
void *LoadProcessData(const std::shared_ptr<kernel::type::KProcess> &process, const DeviceState &state) override;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user