From 8e150c46b9abb29337633df90b115637deaf80a8 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Sat, 25 Aug 2018 19:06:16 -0400 Subject: [PATCH] game_list: Display patch names and versions on list --- src/yuzu/game_list.cpp | 26 ++++++++++++++++++++++++++ src/yuzu/game_list.h | 1 + 2 files changed, 27 insertions(+) diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index baf78af09..1aec08cdb 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -21,6 +21,7 @@ #include "core/file_sys/content_archive.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/nca_metadata.h" +#include "core/file_sys/patch_manager.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/romfs.h" #include "core/file_sys/vfs_real.h" @@ -232,6 +233,7 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, GMainWindow* parent) item_model->insertColumns(0, COLUMN_COUNT); item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, "Name"); item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, "Compatibility"); + item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, "Add-ons"); item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, "File type"); item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, "Size"); @@ -454,6 +456,26 @@ static QString FormatGameName(const std::string& physical_name) { return physical_name_as_qstring; } +static QString FormatPatchNameVersions(u64 title_id, bool updatable = true) { + const FileSys::PatchManager patch_manager(title_id); + QString out; + for (const auto& kv : patch_manager.GetPatchVersionNames()) { + if (!updatable && kv.first == FileSys::PatchType::Update) + continue; + + if (kv.second == 0) { + out.append(fmt::format("{}\n", FileSys::FormatPatchTypeName(kv.first)).c_str()); + } else { + out.append(fmt::format("{} ({})\n", FileSys::FormatPatchTypeName(kv.first), + FileSys::FormatTitleVersion(kv.second)) + .c_str()); + } + } + + out.chop(1); + return out; +} + void GameList::RefreshGameDirectory() { if (!UISettings::values.gamedir.isEmpty() && current_worker != nullptr) { LOG_INFO(Frontend, "Change detected in the games directory. Reloading game list."); @@ -515,6 +537,7 @@ void GameListWorker::AddInstalledTitlesToGameList(std::shared_ptrGetFullPath()), icon, QString::fromStdString(name), QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), program_id), + new GameListItem(FormatPatchNameVersions(program_id)), new GameListItem( QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), new GameListItemSize(file->GetSize()), @@ -596,12 +619,15 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign if (it != compatibility_list.end()) compatibility = it->second.first; + FileSys::PatchManager patch{program_id}; + emit EntryReady({ new GameListItemPath( FormatGameName(physical_name), icon, QString::fromStdString(name), QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), program_id), new GameListItemCompat(compatibility), + new GameListItem(FormatPatchNameVersions(program_id, loader->IsRomFSUpdatable())), new GameListItem( QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), new GameListItemSize(FileUtil::GetSize(physical_name)), diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index 84731464a..3fcb298ed 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h @@ -38,6 +38,7 @@ public: enum { COLUMN_NAME, COLUMN_COMPATIBILITY, + COLUMN_ADD_ONS, COLUMN_FILE_TYPE, COLUMN_SIZE, COLUMN_COUNT, // Number of columns