From e20db909eeb7dc6670924032e7cbb4add4652908 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 1 Nov 2018 20:22:29 -0400 Subject: content_archive: Add optional KeyManager parameter to constructor Allows resuing a common KeyManager when a large amount of NCAs are handled by the same class. Should the parameter not be provided, a new KeyManager will be constructed, as was the default behavior prior to this. --- src/core/file_sys/content_archive.cpp | 5 +++-- src/core/file_sys/content_archive.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index b46fe893c..19b6f8600 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp @@ -101,8 +101,9 @@ static bool IsValidNCA(const NCAHeader& header) { return header.magic == Common::MakeMagic('N', 'C', 'A', '3'); } -NCA::NCA(VirtualFile file_, VirtualFile bktr_base_romfs_, u64 bktr_base_ivfc_offset) - : file(std::move(file_)), bktr_base_romfs(std::move(bktr_base_romfs_)) { +NCA::NCA(VirtualFile file_, VirtualFile bktr_base_romfs_, u64 bktr_base_ivfc_offset, + Core::Crypto::KeyManager keys_) + : file(std::move(file_)), bktr_base_romfs(std::move(bktr_base_romfs_)), keys(std::move(keys_)) { if (file == nullptr) { status = Loader::ResultStatus::ErrorNullFile; return; diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index 4bba55607..99294cbb4 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h @@ -79,7 +79,8 @@ inline bool IsDirectoryExeFS(const std::shared_ptr& pfs) { class NCA : public ReadOnlyVfsDirectory { public: explicit NCA(VirtualFile file, VirtualFile bktr_base_romfs = nullptr, - u64 bktr_base_ivfc_offset = 0); + u64 bktr_base_ivfc_offset = 0, + Core::Crypto::KeyManager keys = Core::Crypto::KeyManager()); ~NCA() override; Loader::ResultStatus GetStatus() const; -- cgit v1.2.3 From 97d425c3047e67cc36e7dec95cbcbc9236c6573f Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 1 Nov 2018 20:23:38 -0400 Subject: file_sys: Use common KeyManager in NCA container types Creates a single KeyManager for the entire container and then passes it into the NCA constructor, eliminating several unnecessary KeyManager reads. --- src/core/file_sys/card_image.cpp | 2 +- src/core/file_sys/card_image.h | 3 +++ src/core/file_sys/registered_cache.cpp | 13 ++++++++----- src/core/file_sys/registered_cache.h | 3 +++ src/core/file_sys/submission_package.cpp | 2 +- src/core/file_sys/submission_package.h | 2 ++ 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp index 1ece55731..2c145bd09 100644 --- a/src/core/file_sys/card_image.cpp +++ b/src/core/file_sys/card_image.cpp @@ -176,7 +176,7 @@ Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) { for (const VirtualFile& file : partitions[static_cast(part)]->GetFiles()) { if (file->GetExtension() != "nca") continue; - auto nca = std::make_shared(file); + auto nca = std::make_shared(file, nullptr, 0, keys); // TODO(DarkLordZach): Add proper Rev1+ Support if (nca->IsUpdate()) continue; diff --git a/src/core/file_sys/card_image.h b/src/core/file_sys/card_image.h index 8f62571cf..25f5914b6 100644 --- a/src/core/file_sys/card_image.h +++ b/src/core/file_sys/card_image.h @@ -9,6 +9,7 @@ #include #include "common/common_types.h" #include "common/swap.h" +#include "core/crypto/key_manager.h" #include "core/file_sys/vfs.h" namespace Loader { @@ -107,5 +108,7 @@ private: std::shared_ptr secure_partition; std::shared_ptr program; std::vector> ncas; + + Core::Crypto::KeyManager keys; }; } // namespace FileSys diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 96302a241..a3f8f2f73 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -106,9 +106,12 @@ static ContentRecordType GetCRTypeFromNCAType(NCAContentType type) { VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir, std::string_view path) const { - if (dir->GetFileRelative(path) != nullptr) - return dir->GetFileRelative(path); - if (dir->GetDirectoryRelative(path) != nullptr) { + const auto file = dir->GetFileRelative(path); + if (file != nullptr) + return file; + + const auto nca_dir = dir->GetDirectoryRelative(path); + if (nca_dir != nullptr) { const auto nca_dir = dir->GetDirectoryRelative(path); VirtualFile file = nullptr; @@ -225,7 +228,7 @@ void RegisteredCache::ProcessFiles(const std::vector& ids) { if (file == nullptr) continue; - const auto nca = std::make_shared(parser(file, id)); + const auto nca = std::make_shared(parser(file, id), nullptr, 0, keys); if (nca->GetStatus() != Loader::ResultStatus::Success || nca->GetType() != NCAContentType::Meta) { continue; @@ -315,7 +318,7 @@ std::unique_ptr RegisteredCache::GetEntry(u64 title_id, ContentRecordType t const auto raw = GetEntryRaw(title_id, type); if (raw == nullptr) return nullptr; - return std::make_unique(raw); + return std::make_unique(raw, nullptr, 0, keys); } std::unique_ptr RegisteredCache::GetEntry(RegisteredCacheEntry entry) const { diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 6cfb16017..6b89db8de 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h @@ -12,6 +12,7 @@ #include #include #include "common/common_types.h" +#include "core/crypto/key_manager.h" #include "core/file_sys/vfs.h" namespace FileSys { @@ -133,6 +134,8 @@ private: VirtualDir dir; RegisteredCacheParsingFunction parser; + Core::Crypto::KeyManager keys; + // maps tid -> NcaID of meta boost::container::flat_map meta_id; // maps tid -> meta diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 2aaba4179..e1a4210db 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp @@ -252,7 +252,7 @@ void NSP::ReadNCAs(const std::vector& files) { continue; } - auto next_nca = std::make_shared(next_file); + auto next_nca = std::make_shared(next_file, nullptr, 0, keys); if (next_nca->GetType() == NCAContentType::Program) program_status[cnmt.GetTitleID()] = next_nca->GetStatus(); if (next_nca->GetStatus() == Loader::ResultStatus::Success || diff --git a/src/core/file_sys/submission_package.h b/src/core/file_sys/submission_package.h index 338080b7e..9a28ed5bb 100644 --- a/src/core/file_sys/submission_package.h +++ b/src/core/file_sys/submission_package.h @@ -70,6 +70,8 @@ private: std::map>> ncas; std::vector ticket_files; + Core::Crypto::KeyManager keys; + VirtualFile romfs; VirtualDir exefs; }; -- cgit v1.2.3 From 8f183a47dd3dca5247b893960afd09b6f603ae87 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 1 Nov 2018 20:24:32 -0400 Subject: filesystem: Cache RegisteredCacheUnion instead of constructing on demand Prevents unnecessary re-reads of the metadata and unnecessary temporary objects. --- src/core/hle/service/filesystem/filesystem.cpp | 13 ++++++++++--- src/core/hle/service/filesystem/filesystem.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index e32a7c48e..ad865751f 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -319,9 +319,16 @@ ResultVal OpenSDMC() { return sdmc_factory->Open(); } -std::unique_ptr GetUnionContents() { - return std::make_unique(std::vector{ - GetSystemNANDContents(), GetUserNANDContents(), GetSDMCContents()}); +std::shared_ptr registered_cache_union; + +std::shared_ptr GetUnionContents() { + if (registered_cache_union == nullptr) { + registered_cache_union = + std::make_shared(std::vector{ + GetSystemNANDContents(), GetUserNANDContents(), GetSDMCContents()}); + } + + return registered_cache_union; } FileSys::RegisteredCache* GetSystemNANDContents() { diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index 6ca5c5636..6f3e0cd03 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h @@ -47,7 +47,7 @@ ResultVal OpenSaveData(FileSys::SaveDataSpaceId space, FileSys::SaveDataDescriptor save_struct); ResultVal OpenSDMC(); -std::unique_ptr GetUnionContents(); +std::shared_ptr GetUnionContents(); FileSys::RegisteredCache* GetSystemNANDContents(); FileSys::RegisteredCache* GetUserNANDContents(); -- cgit v1.2.3 From 2d2ef05d8c5d476a17ef30609ed055ec0aa75609 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Thu, 1 Nov 2018 20:27:12 -0400 Subject: game_list: Make add-ons column optional As the add-ons column takes the most processing time out of any (as it needs to search registration for updates/dlc, patch control NCAs, search for mods, etc.), an option was added to disable it. This does not affect the application of add-ons. In large game collections, this decreases game list refresh time by as much as 70%. --- src/yuzu/configuration/config.cpp | 2 + src/yuzu/configuration/configure_gamelist.cpp | 2 + src/yuzu/configuration/configure_gamelist.ui | 223 +++++++++++++------------- src/yuzu/game_list.cpp | 33 +++- src/yuzu/game_list_worker.cpp | 24 ++- src/yuzu/ui_settings.h | 1 + 6 files changed, 166 insertions(+), 119 deletions(-) diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index d4fd60a73..526cf6c10 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -162,6 +162,7 @@ void Config::ReadValues() { qt_config->beginGroup("UIGameList"); UISettings::values.show_unknown = qt_config->value("show_unknown", true).toBool(); + UISettings::values.show_add_ons = qt_config->value("show_add_ons", true).toBool(); UISettings::values.icon_size = qt_config->value("icon_size", 64).toUInt(); UISettings::values.row_1_text_id = qt_config->value("row_1_text_id", 3).toUInt(); UISettings::values.row_2_text_id = qt_config->value("row_2_text_id", 2).toUInt(); @@ -298,6 +299,7 @@ void Config::SaveValues() { qt_config->beginGroup("UIGameList"); qt_config->setValue("show_unknown", UISettings::values.show_unknown); + qt_config->setValue("show_add_ons", UISettings::values.show_add_ons); qt_config->setValue("icon_size", UISettings::values.icon_size); qt_config->setValue("row_1_text_id", UISettings::values.row_1_text_id); qt_config->setValue("row_2_text_id", UISettings::values.row_2_text_id); diff --git a/src/yuzu/configuration/configure_gamelist.cpp b/src/yuzu/configuration/configure_gamelist.cpp index 8743ce982..639d5df0f 100644 --- a/src/yuzu/configuration/configure_gamelist.cpp +++ b/src/yuzu/configuration/configure_gamelist.cpp @@ -42,6 +42,7 @@ ConfigureGameList::~ConfigureGameList() = default; void ConfigureGameList::applyConfiguration() { UISettings::values.show_unknown = ui->show_unknown->isChecked(); + UISettings::values.show_add_ons = ui->show_add_ons->isChecked(); UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt(); UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt(); UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt(); @@ -50,6 +51,7 @@ void ConfigureGameList::applyConfiguration() { void ConfigureGameList::setConfiguration() { ui->show_unknown->setChecked(UISettings::values.show_unknown); + ui->show_add_ons->setChecked(UISettings::values.show_add_ons); ui->icon_size_combobox->setCurrentIndex( ui->icon_size_combobox->findData(UISettings::values.icon_size)); ui->row_1_text_combobox->setCurrentIndex( diff --git a/src/yuzu/configuration/configure_gamelist.ui b/src/yuzu/configuration/configure_gamelist.ui index 7471fdb60..7a69377e7 100644 --- a/src/yuzu/configuration/configure_gamelist.ui +++ b/src/yuzu/configuration/configure_gamelist.ui @@ -1,126 +1,133 @@ ConfigureGameList - - - - 0 - 0 - 300 - 377 - - - - Form - - - - + + + + 0 + 0 + 300 + 377 + + + + Form + + + + + + + + General + + + + - - - General - - - - - - - - Show files with type 'Unknown' - - - - - - - + + + Show files with type 'Unknown' + + - - - Icon Size - - - - - - - - - - Icon Size: - - - - - - - - - - - - + + + Show Add-Ons Column + + + + + + + + + + + Icon Size + + + + - - - Row Text + + + + + Icon Size: - - - - - - - - - Row 1 Text: - - - - - - - - - - - - - - Row 2 Text: - - - - - - - - - - - - + + + + + + + + + + + + + + + Row Text + + + + - - - Qt::Vertical + + + + + Row 1 Text: - - - 20 - 40 - + + + + + + + + + + + + + Row 2 Text: - + + + + + + - - + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + - + + + diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index a5a4aa432..11a8c390b 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -215,12 +215,18 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, GMainWindow* parent) tree_view->setUniformRowHeights(true); tree_view->setContextMenuPolicy(Qt::CustomContextMenu); - item_model->insertColumns(0, COLUMN_COUNT); + item_model->insertColumns(0, UISettings::values.show_add_ons ? COLUMN_COUNT : COLUMN_COUNT - 1); item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name")); item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility")); - item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons")); - item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type")); - item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size")); + + if (UISettings::values.show_add_ons) { + item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons")); + item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type")); + item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size")); + } else { + item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type")); + item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size")); + } connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry); connect(tree_view, &QTreeView::customContextMenuRequested, this, &GameList::PopupContextMenu); @@ -394,6 +400,25 @@ void GameList::PopulateAsync(const QString& dir_path, bool deep_scan) { } tree_view->setEnabled(false); + + // Update the columns in case UISettings has changed + item_model->removeColumns(0, item_model->columnCount()); + item_model->insertColumns(0, UISettings::values.show_add_ons ? COLUMN_COUNT : COLUMN_COUNT - 1); + item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name")); + item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility")); + + if (UISettings::values.show_add_ons) { + item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons")); + item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type")); + item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size")); + } else { + item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type")); + item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size")); + item_model->removeColumns(COLUMN_COUNT - 1, 1); + } + + LoadInterfaceLayout(); + // Delete any rows that might already exist if we're repopulating item_model->removeRows(0, item_model->rowCount()); diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 3d865a12d..362902e46 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -123,17 +123,22 @@ void GameListWorker::AddInstalledTitlesToGameList() { if (it != compatibility_list.end()) compatibility = it->second.first; - emit EntryReady({ + QList list{ new GameListItemPath( FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name), QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), program_id), new GameListItemCompat(compatibility), - new GameListItem(FormatPatchNameVersions(patch, *loader)), new GameListItem( QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), new GameListItemSize(file->GetSize()), - }); + }; + + if (UISettings::values.show_add_ons) { + list.insert(2, new GameListItem(FormatPatchNameVersions(patch, *loader))); + } + + emit EntryReady(list); } const auto control_data = cache->ListEntriesFilter(FileSys::TitleType::Application, @@ -216,18 +221,23 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign if (it != compatibility_list.end()) compatibility = it->second.first; - emit EntryReady({ + QList list{ new GameListItemPath( FormatGameName(physical_name), icon, QString::fromStdString(name), QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), program_id), new GameListItemCompat(compatibility), - new GameListItem( - FormatPatchNameVersions(patch, *loader, loader->IsRomFSUpdatable())), new GameListItem( QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), new GameListItemSize(FileUtil::GetSize(physical_name)), - }); + }; + + if (UISettings::values.show_add_ons) { + list.insert(2, new GameListItem(FormatPatchNameVersions( + patch, *loader, loader->IsRomFSUpdatable()))); + } + + emit EntryReady(std::move(list)); } else if (is_dir && recursion > 0) { watch_list.append(QString::fromStdString(physical_name)); AddFstEntriesToGameList(physical_name, recursion - 1); diff --git a/src/yuzu/ui_settings.h b/src/yuzu/ui_settings.h index 2e617d52a..32a0d813c 100644 --- a/src/yuzu/ui_settings.h +++ b/src/yuzu/ui_settings.h @@ -59,6 +59,7 @@ struct Values { // Game List bool show_unknown; + bool show_add_ons; uint32_t icon_size; uint8_t row_1_text_id; uint8_t row_2_text_id; -- cgit v1.2.3