From f6f65035785479934ddd443a9236ec142b7a0ed6 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Tue, 4 Dec 2018 13:34:46 -0500 Subject: [PATCH] qt: Add Properties menu to game list right-click --- src/yuzu/configuration/config.cpp | 2 +- .../configuration/configure_per_general.cpp | 18 +++++++----- .../configuration/configure_per_general.h | 18 ++++-------- src/yuzu/game_list.cpp | 3 ++ src/yuzu/game_list.h | 1 + src/yuzu/game_list_worker.cpp | 2 +- src/yuzu/main.cpp | 29 +++++++++++++++++++ src/yuzu/main.h | 1 + src/yuzu_cmd/default_ini.h | 2 +- 9 files changed, 54 insertions(+), 22 deletions(-) diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 4d4bd2a467..97a1633b0c 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -669,7 +669,7 @@ void Config::SaveValues() { int i = 0; for (const auto& elem : Settings::values.disabled_addons) { qt_config->setArrayIndex(i); - qt_config->setValue("title_id", elem.first); + qt_config->setValue("title_id", QVariant::fromValue(elem.first)); qt_config->beginWriteArray("disabled"); for (std::size_t j = 0; j < elem.second.size(); ++j) { qt_config->setArrayIndex(j); diff --git a/src/yuzu/configuration/configure_per_general.cpp b/src/yuzu/configuration/configure_per_general.cpp index ed85f84a92..80109b434d 100644 --- a/src/yuzu/configuration/configure_per_general.cpp +++ b/src/yuzu/configuration/configure_per_general.cpp @@ -5,24 +5,27 @@ #include #include #include + +#include #include #include #include #include #include #include -#include "common/param_package.h" + #include "core/file_sys/control_metadata.h" #include "core/file_sys/patch_manager.h" #include "core/file_sys/xts_archive.h" #include "core/loader/loader.h" -#include "input_common/main.h" +#include "ui_configure_per_general.h" #include "yuzu/configuration/config.h" #include "yuzu/configuration/configure_input.h" #include "yuzu/configuration/configure_per_general.h" #include "yuzu/ui_settings.h" +#include "yuzu/util/util.h" -ConfigurePerGameGeneral::ConfigurePerGameGeneral(u64 title_id, QWidget* parent) +ConfigurePerGameGeneral::ConfigurePerGameGeneral(QWidget* parent, u64 title_id) : QDialog(parent), ui(std::make_unique()), title_id(title_id) { ui->setupUi(this); @@ -61,11 +64,13 @@ ConfigurePerGameGeneral::ConfigurePerGameGeneral(u64 title_id, QWidget* parent) ui->icon_view->setScene(scene); connect(item_model, &QStandardItemModel::itemChanged, - [&]() { UISettings::values.is_game_list_reload_pending.exchange(true); }); + [] { UISettings::values.is_game_list_reload_pending.exchange(true); }); this->loadConfiguration(); } +ConfigurePerGameGeneral::~ConfigurePerGameGeneral() = default; + void ConfigurePerGameGeneral::applyConfiguration() { std::vector disabled_addons; @@ -107,7 +112,7 @@ void ConfigurePerGameGeneral::loadConfiguration() { if (loader->ReadDeveloper(developer) == Loader::ResultStatus::Success) ui->display_developer->setText(QString::fromStdString(developer)); - ui->display_version->setText("1.0.0"); + ui->display_version->setText(QStringLiteral("1.0.0")); } if (control.second != nullptr) { @@ -160,7 +165,6 @@ void ConfigurePerGameGeneral::loadConfiguration() { ui->display_format->setText( QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))); - QLocale locale = this->locale(); - QString valueText = locale.formattedDataSize(file->GetSize()); + const auto valueText = ReadableByteSize(file->GetSize()); ui->display_size->setText(valueText); } diff --git a/src/yuzu/configuration/configure_per_general.h b/src/yuzu/configuration/configure_per_general.h index 5f958bbbab..a4494446c1 100644 --- a/src/yuzu/configuration/configure_per_general.h +++ b/src/yuzu/configuration/configure_per_general.h @@ -4,21 +4,14 @@ #pragma once -#include -#include #include -#include -#include +#include + #include #include #include -#include -#include "common/param_package.h" -#include "core/file_sys/vfs.h" -#include "core/settings.h" -#include "input_common/main.h" -#include "ui_configure_per_general.h" -#include "yuzu/configuration/config.h" + +#include "core/file_sys/vfs_types.h" class QTreeView; class QGraphicsScene; @@ -33,7 +26,8 @@ class ConfigurePerGameGeneral : public QDialog { Q_OBJECT public: - explicit ConfigurePerGameGeneral(u64 title_id, QWidget* parent = nullptr); + explicit ConfigurePerGameGeneral(QWidget* parent, u64 title_id); + ~ConfigurePerGameGeneral() override; /// Save all button configurations to settings file void applyConfiguration(); diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index b52a509157..8e9524fd65 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp @@ -333,6 +333,8 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { QAction* dump_romfs = context_menu.addAction(tr("Dump RomFS")); QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard")); QAction* navigate_to_gamedb_entry = context_menu.addAction(tr("Navigate to GameDB entry")); + context_menu.addSeparator(); + QAction* properties = context_menu.addAction(tr("Properties")); open_save_location->setEnabled(program_id != 0); auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); @@ -346,6 +348,7 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { connect(copy_tid, &QAction::triggered, [&]() { emit CopyTIDRequested(program_id); }); connect(navigate_to_gamedb_entry, &QAction::triggered, [&]() { emit NavigateToGamedbEntryRequested(program_id, compatibility_list); }); + connect(properties, &QAction::triggered, [&]() { emit OpenPerGameGeneralRequested(path); }); context_menu.exec(tree_view->viewport()->mapToGlobal(menu_location)); } diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index 05e115e19f..b317eb2fc8 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h @@ -70,6 +70,7 @@ signals: void CopyTIDRequested(u64 program_id); void NavigateToGamedbEntryRequested(u64 program_id, const CompatibilityList& compatibility_list); + void OpenPerGameGeneralRequested(const std::string& file); private slots: void onTextChanged(const QString& newText); diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 1edc60df75..5532692695 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp @@ -62,7 +62,7 @@ QString FormatPatchNameVersions(const FileSys::PatchManager& patch_manager, FileSys::VirtualFile update_raw; loader.ReadUpdateRaw(update_raw); for (const auto& kv : patch_manager.GetPatchVersionNames(update_raw)) { - const bool is_update = kv.first == "Update"; + const bool is_update = kv.first == "Update" || kv.first == "[D] Update"; if (!updatable && is_update) { continue; } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 22c207a3af..90b212ba5b 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -9,6 +9,7 @@ // VFS includes must be before glad as they will conflict with Windows file api, which uses defines. #include "applets/software_keyboard.h" +#include "configuration/configure_per_general.h" #include "core/file_sys/vfs.h" #include "core/file_sys/vfs_real.h" #include "core/hle/service/acc/profile_manager.h" @@ -441,6 +442,8 @@ void GMainWindow::ConnectWidgetEvents() { connect(game_list, &GameList::CopyTIDRequested, this, &GMainWindow::OnGameListCopyTID); connect(game_list, &GameList::NavigateToGamedbEntryRequested, this, &GMainWindow::OnGameListNavigateToGamedbEntry); + connect(game_list, &GameList::OpenPerGameGeneralRequested, this, + &GMainWindow::OnGameListOpenPerGameProperties); connect(this, &GMainWindow::EmulationStarting, render_window, &GRenderWindow::OnEmulationStarting); @@ -988,6 +991,32 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id, QDesktopServices::openUrl(QUrl("https://yuzu-emu.org/game/" + directory)); } +void GMainWindow::OnGameListOpenPerGameProperties(const std::string& file) { + u64 title_id{}; + const auto v_file = Core::GetGameFileFromPath(vfs, file); + const auto loader = Loader::GetLoader(v_file); + if (loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) { + QMessageBox::information(this, tr("Properties"), + tr("The game properties could not be loaded.")); + return; + } + + ConfigurePerGameGeneral dialog(this, title_id); + dialog.loadFromFile(v_file); + auto result = dialog.exec(); + if (result == QDialog::Accepted) { + dialog.applyConfiguration(); + + const auto reload = UISettings::values.is_game_list_reload_pending.exchange(false); + if (reload) { + game_list->PopulateAsync(UISettings::values.gamedir, + UISettings::values.gamedir_deepscan); + } + + config->Save(); + } +} + void GMainWindow::OnMenuLoadFile() { const QString extensions = QString("*.").append(GameList::supported_file_extensions.join(" *.")).append(" main"); diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 674e734125..ca9c503672 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h @@ -168,6 +168,7 @@ private slots: void OnGameListCopyTID(u64 program_id); void OnGameListNavigateToGamedbEntry(u64 program_id, const CompatibilityList& compatibility_list); + void OnGameListOpenPerGameProperties(const std::string& file); void OnMenuLoadFile(); void OnMenuLoadFolder(); void OnMenuInstallToNAND(); diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 25236d05de..0f3f8da502 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -225,7 +225,7 @@ yuzu_token = [AddOns] # Used to disable add-ons # List of title IDs of games that will have add-ons disabled (separated by '|'): -title_ids = +title_ids = # For each title ID, have a key/value pair called `disabled_` equal to the names of the add-ons to disable (sep. by '|') # e.x. disabled_0100000000010000 = Update|DLC <- disables Updates and DLC on Super Mario Odyssey )";