From 980923d3511e549699ec0bdc9022107f0b3a0f78 Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Sat, 20 Jan 2018 11:33:14 -0600 Subject: [PATCH] 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); }