diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index af85869258..b431fd091f 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -919,7 +919,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) QAction* pad_configure = menu.addAction(gameinfo->hasCustomPadConfig ? tr("&Change Custom Gamepad Configuration") : tr("&Create Custom Gamepad Configuration")); - QAction* configure_patches = menu.addAction(tr("&Configure Game Patches")); + QAction* configure_patches = menu.addAction(tr("&Manage Game Patches")); QAction* create_ppu_cache = menu.addAction(tr("&Create PPU Cache")); menu.addSeparator(); QAction* rename_title = menu.addAction(tr("&Rename In Game List")); @@ -1099,7 +1099,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) } } }); - connect(configure_patches, &QAction::triggered, [this, current_game, gameinfo]() + connect(configure_patches, &QAction::triggered, [this, gameinfo]() { std::unordered_map> games; for (const auto& game : m_game_data) @@ -1109,7 +1109,7 @@ void game_list_frame::ShowContextMenu(const QPoint &pos) games[game->info.serial].insert(game_list_frame::GetGameVersion(game)); } } - patch_manager_dialog patch_manager(m_gui_settings, games, current_game.serial, this); + patch_manager_dialog patch_manager(m_gui_settings, games, gameinfo->info.serial, GetGameVersion(gameinfo), this); patch_manager.exec(); }); connect(open_game_folder, &QAction::triggered, [current_game]() diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 5170d71c0b..16f2fd301f 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -1880,7 +1880,7 @@ void main_window::CreateConnects() } } } - patch_manager_dialog patch_manager(m_gui_settings, games, "", this); + patch_manager_dialog patch_manager(m_gui_settings, games, "", "", this); patch_manager.exec(); }); diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.cpp b/rpcs3/rpcs3qt/patch_manager_dialog.cpp index 2a24d45be8..19ae06e27c 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/patch_manager_dialog.cpp @@ -52,9 +52,11 @@ enum node_level : int patch_level }; -patch_manager_dialog::patch_manager_dialog(std::shared_ptr gui_settings, std::unordered_map> games, const std::string& search_term, QWidget* parent) +patch_manager_dialog::patch_manager_dialog(std::shared_ptr gui_settings, std::unordered_map> games, const std::string& title_id, const std::string& version, QWidget* parent) : QDialog(parent) , m_gui_settings(gui_settings) + , m_expand_current_match(!title_id.empty() && !version.empty()) // Expand first search results + , m_search_version(QString::fromStdString(version)) , m_owned_games(std::move(games)) , ui(new Ui::patch_manager_dialog) { @@ -68,7 +70,7 @@ patch_manager_dialog::patch_manager_dialog(std::shared_ptr gui_set m_show_owned_games_only = m_gui_settings->GetValue(gui::pm_show_owned).toBool(); // Initialize gui controls - ui->patch_filter->setText(QString::fromStdString(search_term)); + ui->patch_filter->setText(QString::fromStdString(title_id)); ui->cb_owned_games_only->setChecked(m_show_owned_games_only); ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Download latest patches")); @@ -416,11 +418,61 @@ void patch_manager_dialog::filter_patches(const QString& term) return visible_items; }; + bool found_version = false; + // Go through each top level item and try to find matches for (auto top_level_item : ui->patch_tree->findItems(".*", Qt::MatchRegularExpression)) { - show_matches(top_level_item, false); + if (!top_level_item) + continue; + + const int matches = show_matches(top_level_item, false); + + if (matches <= 0 || !m_expand_current_match) + continue; + + // Expand only items that match the serial and version + for (int i = 0; i < top_level_item->childCount(); i++) + { + if (const auto item = top_level_item->child(i); + item && !item->isHidden() && item->data(0, app_version_role).toString() == m_search_version) + { + // This should always be a serial level item + ensure(item->data(0, node_level_role) == node_level::serial_level); + top_level_item->setExpanded(true); + item->setExpanded(true); + found_version = true; + break; + } + } } + + if (m_expand_current_match && !found_version) + { + // Expand all matching top_level items if the correct version wasn't found + for (auto top_level_item : ui->patch_tree->findItems(".*", Qt::MatchRegularExpression)) + { + if (!top_level_item || top_level_item->isHidden()) + continue; + + top_level_item->setExpanded(true); + + // Expand the "All Versions" item + for (int i = 0; i < top_level_item->childCount(); i++) + { + if (const auto item = top_level_item->child(i); + item && !item->isHidden() && item->data(0, app_version_role).toString().toStdString() == patch_key::all) + { + // This should always be a serial level item + ensure(item->data(0, node_level_role) == node_level::serial_level); + item->setExpanded(true); + break; + } + } + } + } + + m_expand_current_match = false; } void patch_manager_dialog::update_patch_info(const patch_manager_dialog::gui_patch_info& info) diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.h b/rpcs3/rpcs3qt/patch_manager_dialog.h index 55af11199d..29807bd1b9 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.h +++ b/rpcs3/rpcs3qt/patch_manager_dialog.h @@ -37,7 +37,7 @@ class patch_manager_dialog : public QDialog const QString tr_all_versions = tr("All versions"); public: - explicit patch_manager_dialog(std::shared_ptr gui_settings, std::unordered_map> games, const std::string& search_term, QWidget* parent = nullptr); + explicit patch_manager_dialog(std::shared_ptr gui_settings, std::unordered_map> games, const std::string& title_id, const std::string& version, QWidget* parent = nullptr); ~patch_manager_dialog(); int exec() override; @@ -61,6 +61,9 @@ private: std::shared_ptr m_gui_settings; + bool m_expand_current_match = false; + QString m_search_version; + std::unordered_map> m_owned_games; bool m_show_owned_games_only = false;