only pass one smdh
This commit is contained in:
parent
4da837c929
commit
eb1b5f588a
|
@ -396,37 +396,34 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
|
||||||
if (!loader)
|
if (!loader)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
std::vector<u8> smdh;
|
|
||||||
loader->ReadIcon(smdh);
|
|
||||||
|
|
||||||
u64 program_id = 0;
|
u64 program_id = 0;
|
||||||
loader->ReadProgramId(program_id);
|
loader->ReadProgramId(program_id);
|
||||||
|
|
||||||
std::vector<u8> update_smdh = [program_id]() -> std::vector<u8> {
|
std::vector<u8> smdh = [program_id, &loader]() -> std::vector<u8> {
|
||||||
if (0x4000000000000 > program_id && program_id > 0x40000FFFFFFFF)
|
std::vector<u8> original_smdh;
|
||||||
return {};
|
loader->ReadIcon(original_smdh);
|
||||||
|
|
||||||
u64 update_id = program_id + 0xe00000000;
|
if (0x4000000000000 > program_id && program_id > 0x40000FFFFFFFF)
|
||||||
std::string update_path =
|
return original_smdh;
|
||||||
Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, update_id);
|
|
||||||
|
std::string update_path = Service::AM::GetTitleContentPath(
|
||||||
|
Service::FS::MediaType::SDMC, program_id + 0xe00000000);
|
||||||
|
|
||||||
if (!FileUtil::Exists(update_path))
|
if (!FileUtil::Exists(update_path))
|
||||||
return {};
|
return original_smdh;
|
||||||
|
|
||||||
std::unique_ptr<Loader::AppLoader> update_loader = Loader::GetLoader(update_path);
|
std::unique_ptr<Loader::AppLoader> update_loader = Loader::GetLoader(update_path);
|
||||||
|
|
||||||
if (!update_loader)
|
if (!update_loader)
|
||||||
return {};
|
return original_smdh;
|
||||||
|
|
||||||
std::vector<u8> update_smdh;
|
std::vector<u8> update_smdh;
|
||||||
update_loader->ReadIcon(update_smdh);
|
update_loader->ReadIcon(update_smdh);
|
||||||
update_loader->ReadProgramId(update_id);
|
|
||||||
return update_smdh;
|
return update_smdh;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
emit EntryReady({
|
emit EntryReady({
|
||||||
new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id,
|
new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id),
|
||||||
update_smdh),
|
|
||||||
new GameListItem(
|
new GameListItem(
|
||||||
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))),
|
QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))),
|
||||||
new GameListItemSize(FileUtil::GetSize(physical_name)),
|
new GameListItemSize(FileUtil::GetSize(physical_name)),
|
||||||
|
|
|
@ -72,22 +72,20 @@ public:
|
||||||
static const int ProgramIdRole = Qt::UserRole + 3;
|
static const int ProgramIdRole = Qt::UserRole + 3;
|
||||||
|
|
||||||
GameListItemPath() : GameListItem() {}
|
GameListItemPath() : GameListItem() {}
|
||||||
GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id,
|
GameListItemPath(const QString& game_path, const std::vector<u8>& smdh_data, u64 program_id)
|
||||||
const std::vector<u8>& update_smdh)
|
|
||||||
: GameListItem() {
|
: GameListItem() {
|
||||||
setData(game_path, FullPathRole);
|
setData(game_path, FullPathRole);
|
||||||
setData(qulonglong(program_id), ProgramIdRole);
|
setData(qulonglong(program_id), ProgramIdRole);
|
||||||
|
|
||||||
Loader::SMDH smdh;
|
Loader::SMDH smdh;
|
||||||
if (Loader::IsValidSMDH(update_smdh)) {
|
if (!Loader::IsValidSMDH(smdh_data)) {
|
||||||
memcpy(&smdh, update_smdh.data(), sizeof(Loader::SMDH));
|
|
||||||
} else if (Loader::IsValidSMDH(smdh_data)) {
|
|
||||||
memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH));
|
|
||||||
} else {
|
|
||||||
// SMDH is not valid, set a default icon
|
// SMDH is not valid, set a default icon
|
||||||
setData(GetDefaultIcon(true), Qt::DecorationRole);
|
setData(GetDefaultIcon(true), Qt::DecorationRole);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH));
|
||||||
|
|
||||||
// Get icon from SMDH
|
// Get icon from SMDH
|
||||||
setData(GetQPixmapFromSMDH(smdh, true), Qt::DecorationRole);
|
setData(GetQPixmapFromSMDH(smdh, true), Qt::DecorationRole);
|
||||||
|
|
||||||
|
|
Reference in New Issue