From 980923d3511e549699ec0bdc9022107f0b3a0f78 Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Sat, 20 Jan 2018 11:33:14 -0600 Subject: [PATCH 1/8] allow installed apps to display in the game list --- src/citra_qt/game_list.cpp | 37 ++++++++++++++++++++++++++++++++++++- src/citra_qt/game_list_p.h | 16 +++++++++------- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 133f7cfe2..12dc8d0b2 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -24,6 +24,7 @@ #include "common/common_paths.h" #include "common/logging/log.h" #include "common/string_util.h" +#include "core/hle/service/fs/archive.h" #include "core/loader/loader.h" GameList::SearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist) { @@ -401,8 +402,27 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign u64 program_id = 0; loader->ReadProgramId(program_id); + std::vector update_smdh; + std::string update_path; + u64 update_id = 0; + std::unique_ptr update_loader = nullptr; + + if (0x4000000000000 <= program_id && program_id <= 0x40000FFFFFFFF) { + update_id = program_id + 0xe00000000; + update_path = + Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, update_id); + if (FileUtil::Exists(update_path)) { + update_loader = Loader::GetLoader(update_path); + if (update_loader) { + update_loader->ReadIcon(update_smdh); + update_loader->ReadProgramId(update_id); + } + } + } + emit EntryReady({ - new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id), + new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id, + update_smdh), new GameListItem( QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), new GameListItemSize(FileUtil::GetSize(physical_name)), @@ -421,7 +441,22 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign void GameListWorker::run() { stop_processing = false; watch_list.append(dir_path); + watch_list.append(QString::fromStdString( + std::string(FileUtil::GetUserPath(D_SDMC_IDX).c_str()) + + "Nintendo " + "3DS/00000000000000000000000000000000/00000000000000000000000000000000/title/00040000")); + watch_list.append( + QString::fromStdString(std::string(FileUtil::GetUserPath(D_NAND_IDX).c_str()) + + "00000000000000000000000000000000/title/00040010")); AddFstEntriesToGameList(dir_path.toStdString(), deep_scan ? 256 : 0); + AddFstEntriesToGameList( + std::string(FileUtil::GetUserPath(D_SDMC_IDX).c_str()) + + "Nintendo " + "3DS/00000000000000000000000000000000/00000000000000000000000000000000/title/00040000", + true ? 256 : 0); + AddFstEntriesToGameList(std::string(FileUtil::GetUserPath(D_NAND_IDX).c_str()) + + "00000000000000000000000000000000/title/00040010", + true ? 256 : 0); emit Finished(watch_list); } diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 12212a3a4..7294831ff 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -72,24 +72,26 @@ public: static const int ProgramIdRole = Qt::UserRole + 3; GameListItemPath() : GameListItem() {} - GameListItemPath(const QString& game_path, const std::vector& smdh_data, u64 program_id) + GameListItemPath(const QString& game_path, const std::vector& smdh_data, u64 program_id, + const std::vector& update_smdh) : GameListItem() { setData(game_path, FullPathRole); setData(qulonglong(program_id), ProgramIdRole); - if (!Loader::IsValidSMDH(smdh_data)) { + Loader::SMDH smdh; + if (Loader::IsValidSMDH(update_smdh)) { + 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 setData(GetDefaultIcon(true), Qt::DecorationRole); return; } - - Loader::SMDH smdh; - memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); - // Get icon from SMDH setData(GetQPixmapFromSMDH(smdh, true), Qt::DecorationRole); - // Get title form SMDH + // Get title from SMDH setData(GetQStringShortTitleFromSMDH(smdh, Loader::SMDH::TitleLanguage::English), TitleRole); } From 38c5ca68b244de84ba3ad258e726ab74b0c1f9cb Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Mon, 22 Jan 2018 07:56:24 -0600 Subject: [PATCH 2/8] reduce the scope of the variables --- src/citra_qt/game_list.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 12dc8d0b2..65cba7006 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -402,23 +402,27 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign u64 program_id = 0; loader->ReadProgramId(program_id); - std::vector update_smdh; - std::string update_path; - u64 update_id = 0; - std::unique_ptr update_loader = nullptr; + std::vector update_smdh = [program_id]() -> std::vector { + if (0x4000000000000 > program_id && program_id > 0x40000FFFFFFFF) + return {}; - if (0x4000000000000 <= program_id && program_id <= 0x40000FFFFFFFF) { - update_id = program_id + 0xe00000000; - update_path = + u64 update_id = program_id + 0xe00000000; + std::string update_path = Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, update_id); - if (FileUtil::Exists(update_path)) { - update_loader = Loader::GetLoader(update_path); - if (update_loader) { - update_loader->ReadIcon(update_smdh); - update_loader->ReadProgramId(update_id); - } - } - } + + if (!FileUtil::Exists(update_path)) + return {}; + + std::unique_ptr update_loader = Loader::GetLoader(update_path); + + if (!update_loader) + return {}; + + std::vector update_smdh; + update_loader->ReadIcon(update_smdh); + update_loader->ReadProgramId(update_id); + return update_smdh; + }(); emit EntryReady({ new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id, From 4da837c929dab4735f55695dc69a482b9e9121bb Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Tue, 23 Jan 2018 14:13:54 -0600 Subject: [PATCH 3/8] only search to two recursions, add update dir to watch list --- src/citra_qt/game_list.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 65cba7006..8c8def73f 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -449,6 +449,10 @@ void GameListWorker::run() { std::string(FileUtil::GetUserPath(D_SDMC_IDX).c_str()) + "Nintendo " "3DS/00000000000000000000000000000000/00000000000000000000000000000000/title/00040000")); + watch_list.append(QString::fromStdString( + std::string(FileUtil::GetUserPath(D_SDMC_IDX).c_str()) + + "Nintendo " + "3DS/00000000000000000000000000000000/00000000000000000000000000000000/title/0004000e")); watch_list.append( QString::fromStdString(std::string(FileUtil::GetUserPath(D_NAND_IDX).c_str()) + "00000000000000000000000000000000/title/00040010")); @@ -457,10 +461,10 @@ void GameListWorker::run() { std::string(FileUtil::GetUserPath(D_SDMC_IDX).c_str()) + "Nintendo " "3DS/00000000000000000000000000000000/00000000000000000000000000000000/title/00040000", - true ? 256 : 0); + 2); AddFstEntriesToGameList(std::string(FileUtil::GetUserPath(D_NAND_IDX).c_str()) + "00000000000000000000000000000000/title/00040010", - true ? 256 : 0); + 2); emit Finished(watch_list); } From eb1b5f588a079573b7ae9d285672bbf96c8b5fda Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Tue, 23 Jan 2018 21:32:27 -0600 Subject: [PATCH 4/8] only pass one smdh --- src/citra_qt/game_list.cpp | 25 +++++++++++-------------- src/citra_qt/game_list_p.h | 12 +++++------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 8c8def73f..481fea616 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -396,37 +396,34 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign if (!loader) return true; - std::vector smdh; - loader->ReadIcon(smdh); - u64 program_id = 0; loader->ReadProgramId(program_id); - std::vector update_smdh = [program_id]() -> std::vector { - if (0x4000000000000 > program_id && program_id > 0x40000FFFFFFFF) - return {}; + std::vector smdh = [program_id, &loader]() -> std::vector { + std::vector original_smdh; + loader->ReadIcon(original_smdh); - u64 update_id = program_id + 0xe00000000; - std::string update_path = - Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC, update_id); + if (0x4000000000000 > program_id && program_id > 0x40000FFFFFFFF) + return original_smdh; + + std::string update_path = Service::AM::GetTitleContentPath( + Service::FS::MediaType::SDMC, program_id + 0xe00000000); if (!FileUtil::Exists(update_path)) - return {}; + return original_smdh; std::unique_ptr update_loader = Loader::GetLoader(update_path); if (!update_loader) - return {}; + return original_smdh; std::vector update_smdh; update_loader->ReadIcon(update_smdh); - update_loader->ReadProgramId(update_id); return update_smdh; }(); emit EntryReady({ - new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id, - update_smdh), + new GameListItemPath(QString::fromStdString(physical_name), smdh, program_id), new GameListItem( QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), new GameListItemSize(FileUtil::GetSize(physical_name)), diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 7294831ff..6b68c65b2 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -72,22 +72,20 @@ public: static const int ProgramIdRole = Qt::UserRole + 3; GameListItemPath() : GameListItem() {} - GameListItemPath(const QString& game_path, const std::vector& smdh_data, u64 program_id, - const std::vector& update_smdh) + GameListItemPath(const QString& game_path, const std::vector& smdh_data, u64 program_id) : GameListItem() { setData(game_path, FullPathRole); setData(qulonglong(program_id), ProgramIdRole); Loader::SMDH smdh; - if (Loader::IsValidSMDH(update_smdh)) { - memcpy(&smdh, update_smdh.data(), sizeof(Loader::SMDH)); - } else if (Loader::IsValidSMDH(smdh_data)) { - memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); - } else { + if (!Loader::IsValidSMDH(smdh_data)) { // SMDH is not valid, set a default icon setData(GetDefaultIcon(true), Qt::DecorationRole); return; } + + memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); + // Get icon from SMDH setData(GetQPixmapFromSMDH(smdh, true), Qt::DecorationRole); From 1e54b52edf53cadfe80c8d9e3a5c74a1167adb29 Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Wed, 24 Jan 2018 10:16:40 -0600 Subject: [PATCH 5/8] revert move --- src/citra_qt/game_list_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 6b68c65b2..7b56287ee 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -77,13 +77,13 @@ public: setData(game_path, FullPathRole); setData(qulonglong(program_id), ProgramIdRole); - Loader::SMDH smdh; if (!Loader::IsValidSMDH(smdh_data)) { // SMDH is not valid, set a default icon setData(GetDefaultIcon(true), Qt::DecorationRole); return; } - + + Loader::SMDH smdh; memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); // Get icon from SMDH From db3c83fedcd1234b455c8c8ddb5ec42178a74847 Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Wed, 24 Jan 2018 10:17:04 -0600 Subject: [PATCH 6/8] remove spaces --- src/citra_qt/game_list_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/citra_qt/game_list_p.h b/src/citra_qt/game_list_p.h index 7b56287ee..6cf29be9e 100644 --- a/src/citra_qt/game_list_p.h +++ b/src/citra_qt/game_list_p.h @@ -82,7 +82,7 @@ public: setData(GetDefaultIcon(true), Qt::DecorationRole); return; } - + Loader::SMDH smdh; memcpy(&smdh, smdh_data.data(), sizeof(Loader::SMDH)); From 4f5892d86d58286d2037bef2484aecf100a62fee Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Thu, 25 Jan 2018 20:50:22 -0600 Subject: [PATCH 7/8] Fix comparison operators --- src/citra_qt/game_list.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 481fea616..8c1941154 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -403,7 +403,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign std::vector original_smdh; loader->ReadIcon(original_smdh); - if (0x4000000000000 > program_id && program_id > 0x40000FFFFFFFF) + if (program_id >= 0x4000000000000 && program_id <= 0x40000FFFFFFFF) return original_smdh; std::string update_path = Service::AM::GetTitleContentPath( From 79e4fe58dc65d83cdb00c02b8f7c52d41b0154ff Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Fri, 26 Jan 2018 17:12:50 -0600 Subject: [PATCH 8/8] fix comparison operator --- src/citra_qt/game_list.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 8c1941154..1cb5ec207 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -403,11 +403,11 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign std::vector original_smdh; loader->ReadIcon(original_smdh); - if (program_id >= 0x4000000000000 && program_id <= 0x40000FFFFFFFF) + if (program_id < 0x00040000'00000000 || program_id > 0x00040000'FFFFFFFF) return original_smdh; std::string update_path = Service::AM::GetTitleContentPath( - Service::FS::MediaType::SDMC, program_id + 0xe00000000); + Service::FS::MediaType::SDMC, program_id + 0x0000000E'00000000); if (!FileUtil::Exists(update_path)) return original_smdh;