mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 14:46:49 +01:00
Merge pull request #9790 from AdmiralCurtiss/cheat-manager-config-change
CheatsManager: Avoid recreating child widgets on every OnStateChanged(), and take running game info directly from SConfig.
This commit is contained in:
commit
a208d529de
@ -191,6 +191,7 @@ struct SConfig
|
|||||||
bool m_disc_booted_from_game_list = false;
|
bool m_disc_booted_from_game_list = false;
|
||||||
|
|
||||||
const std::string& GetGameID() const { return m_game_id; }
|
const std::string& GetGameID() const { return m_game_id; }
|
||||||
|
const std::string& GetGameTDBID() const { return m_gametdb_id; }
|
||||||
const std::string& GetTitleName() const { return m_title_name; }
|
const std::string& GetTitleName() const { return m_title_name; }
|
||||||
const std::string& GetTitleDescription() const { return m_title_description; }
|
const std::string& GetTitleDescription() const { return m_title_description; }
|
||||||
u64 GetTitleID() const { return m_title_id; }
|
u64 GetTitleID() const { return m_title_id; }
|
||||||
|
@ -151,8 +151,7 @@ static bool Compare(T mem_value, T value, CompareType op)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CheatsManager::CheatsManager(const GameListModel& game_list_model, QWidget* parent)
|
CheatsManager::CheatsManager(QWidget* parent) : QDialog(parent)
|
||||||
: QDialog(parent), m_game_list_model(game_list_model)
|
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Cheats Manager"));
|
setWindowTitle(tr("Cheats Manager"));
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
@ -175,29 +174,32 @@ void CheatsManager::OnStateChanged(Core::State state)
|
|||||||
if (state != Core::State::Running && state != Core::State::Paused)
|
if (state != Core::State::Running && state != Core::State::Paused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < m_game_list_model.rowCount(QModelIndex()); i++)
|
const auto& game_id = SConfig::GetInstance().GetGameID();
|
||||||
|
const auto& game_tdb_id = SConfig::GetInstance().GetGameTDBID();
|
||||||
|
u16 revision = SConfig::GetInstance().GetRevision();
|
||||||
|
|
||||||
|
if (m_game_id == game_id && m_game_tdb_id == game_tdb_id && m_revision == revision)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_game_id = game_id;
|
||||||
|
m_game_tdb_id = game_tdb_id;
|
||||||
|
m_revision = revision;
|
||||||
|
|
||||||
|
if (m_tab_widget->count() == 3)
|
||||||
{
|
{
|
||||||
auto file = m_game_list_model.GetGameFile(i);
|
m_tab_widget->removeTab(0);
|
||||||
|
m_tab_widget->removeTab(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (file->GetGameID() == SConfig::GetInstance().GetGameID())
|
if (m_tab_widget->count() == 1)
|
||||||
{
|
{
|
||||||
m_game_file = file;
|
if (m_ar_code)
|
||||||
if (m_tab_widget->count() == 3)
|
m_ar_code->deleteLater();
|
||||||
{
|
|
||||||
m_tab_widget->removeTab(0);
|
|
||||||
m_tab_widget->removeTab(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_tab_widget->count() == 1)
|
m_ar_code = new ARCodeWidget(m_game_id, m_revision, false);
|
||||||
{
|
m_tab_widget->insertTab(0, m_ar_code, tr("AR Code"));
|
||||||
if (m_ar_code)
|
auto* gecko_code = new GeckoCodeWidget(m_game_id, m_game_tdb_id, m_revision, false);
|
||||||
m_ar_code->deleteLater();
|
m_tab_widget->insertTab(1, gecko_code, tr("Gecko Codes"));
|
||||||
|
|
||||||
m_ar_code = new ARCodeWidget(*m_game_file, false);
|
|
||||||
m_tab_widget->insertTab(0, m_ar_code, tr("AR Code"));
|
|
||||||
m_tab_widget->insertTab(1, new GeckoCodeWidget(*m_game_file, false), tr("Gecko Codes"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class CheatsManager : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CheatsManager(const GameListModel& game_list_model, QWidget* parent = nullptr);
|
explicit CheatsManager(QWidget* parent = nullptr);
|
||||||
~CheatsManager();
|
~CheatsManager();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -62,10 +62,12 @@ private:
|
|||||||
void OnMatchContextMenu();
|
void OnMatchContextMenu();
|
||||||
void OnWatchItemChanged(QTableWidgetItem* item);
|
void OnWatchItemChanged(QTableWidgetItem* item);
|
||||||
|
|
||||||
const GameListModel& m_game_list_model;
|
std::string m_game_id;
|
||||||
|
std::string m_game_tdb_id;
|
||||||
|
u16 m_revision = 0;
|
||||||
|
|
||||||
std::vector<Result> m_results;
|
std::vector<Result> m_results;
|
||||||
std::vector<Result> m_watch;
|
std::vector<Result> m_watch;
|
||||||
std::shared_ptr<const UICommon::GameFile> m_game_file;
|
|
||||||
QDialogButtonBox* m_button_box;
|
QDialogButtonBox* m_button_box;
|
||||||
QTabWidget* m_tab_widget = nullptr;
|
QTabWidget* m_tab_widget = nullptr;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "DolphinQt/Config/ARCodeWidget.h"
|
#include "DolphinQt/Config/ARCodeWidget.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
@ -23,8 +25,8 @@
|
|||||||
|
|
||||||
#include "UICommon/GameFile.h"
|
#include "UICommon/GameFile.h"
|
||||||
|
|
||||||
ARCodeWidget::ARCodeWidget(const UICommon::GameFile& game, bool restart_required)
|
ARCodeWidget::ARCodeWidget(std::string game_id, u16 game_revision, bool restart_required)
|
||||||
: m_game(game), m_game_id(game.GetGameID()), m_game_revision(game.GetRevision()),
|
: m_game_id(std::move(game_id)), m_game_revision(game_revision),
|
||||||
m_restart_required(restart_required)
|
m_restart_required(restart_required)
|
||||||
{
|
{
|
||||||
CreateWidgets();
|
CreateWidgets();
|
||||||
|
@ -16,11 +16,6 @@ namespace ActionReplay
|
|||||||
struct ARCode;
|
struct ARCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace UICommon
|
|
||||||
{
|
|
||||||
class GameFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CheatWarningWidget;
|
class CheatWarningWidget;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QListWidget;
|
class QListWidget;
|
||||||
@ -31,7 +26,7 @@ class ARCodeWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ARCodeWidget(const UICommon::GameFile& game, bool restart_required = true);
|
explicit ARCodeWidget(std::string game_id, u16 game_revision, bool restart_required = true);
|
||||||
~ARCodeWidget() override;
|
~ARCodeWidget() override;
|
||||||
|
|
||||||
void AddCode(ActionReplay::ARCode code);
|
void AddCode(ActionReplay::ARCode code);
|
||||||
@ -56,7 +51,6 @@ private:
|
|||||||
|
|
||||||
void OnListReordered();
|
void OnListReordered();
|
||||||
|
|
||||||
const UICommon::GameFile& m_game;
|
|
||||||
std::string m_game_id;
|
std::string m_game_id;
|
||||||
u16 m_game_revision;
|
u16 m_game_revision;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "DolphinQt/Config/GeckoCodeWidget.h"
|
#include "DolphinQt/Config/GeckoCodeWidget.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
@ -28,9 +30,10 @@
|
|||||||
|
|
||||||
#include "UICommon/GameFile.h"
|
#include "UICommon/GameFile.h"
|
||||||
|
|
||||||
GeckoCodeWidget::GeckoCodeWidget(const UICommon::GameFile& game, bool restart_required)
|
GeckoCodeWidget::GeckoCodeWidget(std::string game_id, std::string gametdb_id, u16 game_revision,
|
||||||
: m_game(game), m_game_id(game.GetGameID()), m_gametdb_id(game.GetGameTDBID()),
|
bool restart_required)
|
||||||
m_game_revision(game.GetRevision()), m_restart_required(restart_required)
|
: m_game_id(std::move(game_id)), m_gametdb_id(std::move(gametdb_id)),
|
||||||
|
m_game_revision(game_revision), m_restart_required(restart_required)
|
||||||
{
|
{
|
||||||
CreateWidgets();
|
CreateWidgets();
|
||||||
ConnectWidgets();
|
ConnectWidgets();
|
||||||
|
@ -23,16 +23,12 @@ namespace Gecko
|
|||||||
class GeckoCode;
|
class GeckoCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace UICommon
|
|
||||||
{
|
|
||||||
class GameFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
class GeckoCodeWidget : public QWidget
|
class GeckoCodeWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit GeckoCodeWidget(const UICommon::GameFile& game, bool restart_required = true);
|
explicit GeckoCodeWidget(std::string game_id, std::string gametdb_id, u16 game_revision,
|
||||||
|
bool restart_required = true);
|
||||||
~GeckoCodeWidget() override;
|
~GeckoCodeWidget() override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -54,7 +50,6 @@ private:
|
|||||||
void SaveCodes();
|
void SaveCodes();
|
||||||
void SortAlphabetically();
|
void SortAlphabetically();
|
||||||
|
|
||||||
const UICommon::GameFile& m_game;
|
|
||||||
std::string m_game_id;
|
std::string m_game_id;
|
||||||
std::string m_gametdb_id;
|
std::string m_gametdb_id;
|
||||||
u16 m_game_revision;
|
u16 m_game_revision;
|
||||||
|
@ -38,8 +38,9 @@ PropertiesDialog::PropertiesDialog(QWidget* parent, const UICommon::GameFile& ga
|
|||||||
QTabWidget* tab_widget = new QTabWidget(this);
|
QTabWidget* tab_widget = new QTabWidget(this);
|
||||||
InfoWidget* info = new InfoWidget(game);
|
InfoWidget* info = new InfoWidget(game);
|
||||||
|
|
||||||
ARCodeWidget* ar = new ARCodeWidget(game);
|
ARCodeWidget* ar = new ARCodeWidget(game.GetGameID(), game.GetRevision());
|
||||||
GeckoCodeWidget* gecko = new GeckoCodeWidget(game);
|
GeckoCodeWidget* gecko =
|
||||||
|
new GeckoCodeWidget(game.GetGameID(), game.GetGameTDBID(), game.GetRevision());
|
||||||
PatchesWidget* patches = new PatchesWidget(game);
|
PatchesWidget* patches = new PatchesWidget(game);
|
||||||
GameConfigWidget* game_config = new GameConfigWidget(game);
|
GameConfigWidget* game_config = new GameConfigWidget(game);
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ void MainWindow::CreateComponents()
|
|||||||
m_watch_widget = new WatchWidget(this);
|
m_watch_widget = new WatchWidget(this);
|
||||||
m_breakpoint_widget = new BreakpointWidget(this);
|
m_breakpoint_widget = new BreakpointWidget(this);
|
||||||
m_code_widget = new CodeWidget(this);
|
m_code_widget = new CodeWidget(this);
|
||||||
m_cheats_manager = new CheatsManager(m_game_list->GetGameListModel(), this);
|
m_cheats_manager = new CheatsManager(this);
|
||||||
|
|
||||||
const auto request_watch = [this](QString name, u32 addr) {
|
const auto request_watch = [this](QString name, u32 addr) {
|
||||||
m_watch_widget->AddWatch(name, addr);
|
m_watch_widget->AddWatch(name, addr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user