mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
Merge pull request #12604 from mitaclaw/qt-cheats-global-system
CheatsManager/CheatSearchWidget: Avoid Global System Accessor
This commit is contained in:
commit
ee4f2be68a
@ -54,8 +54,10 @@ constexpr int ADDRESS_TABLE_COLUMN_INDEX_ADDRESS = 1;
|
|||||||
constexpr int ADDRESS_TABLE_COLUMN_INDEX_LAST_VALUE = 2;
|
constexpr int ADDRESS_TABLE_COLUMN_INDEX_LAST_VALUE = 2;
|
||||||
constexpr int ADDRESS_TABLE_COLUMN_INDEX_CURRENT_VALUE = 3;
|
constexpr int ADDRESS_TABLE_COLUMN_INDEX_CURRENT_VALUE = 3;
|
||||||
|
|
||||||
CheatSearchWidget::CheatSearchWidget(std::unique_ptr<Cheats::CheatSearchSessionBase> session)
|
CheatSearchWidget::CheatSearchWidget(Core::System& system,
|
||||||
: m_session(std::move(session))
|
std::unique_ptr<Cheats::CheatSearchSessionBase> session,
|
||||||
|
QWidget* parent)
|
||||||
|
: QWidget(parent), m_system(system), m_session(std::move(session))
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
CreateWidgets();
|
CreateWidgets();
|
||||||
@ -275,13 +277,10 @@ void CheatSearchWidget::ConnectWidgets()
|
|||||||
|
|
||||||
void CheatSearchWidget::OnNextScanClicked()
|
void CheatSearchWidget::OnNextScanClicked()
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
|
||||||
const bool had_old_results = m_session->WasFirstSearchDone();
|
const bool had_old_results = m_session->WasFirstSearchDone();
|
||||||
const size_t old_count = m_session->GetResultCount();
|
|
||||||
|
|
||||||
const auto filter_type = m_value_source_dropdown->currentData().value<Cheats::FilterType>();
|
const auto filter_type = m_value_source_dropdown->currentData().value<Cheats::FilterType>();
|
||||||
if (filter_type == Cheats::FilterType::CompareAgainstLastValue &&
|
if (filter_type == Cheats::FilterType::CompareAgainstLastValue && !had_old_results)
|
||||||
!m_session->WasFirstSearchDone())
|
|
||||||
{
|
{
|
||||||
m_info_label_1->setText(tr("Cannot compare against last value on first search."));
|
m_info_label_1->setText(tr("Cannot compare against last value on first search."));
|
||||||
return;
|
return;
|
||||||
@ -301,7 +300,8 @@ void CheatSearchWidget::OnNextScanClicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Cheats::SearchErrorCode error_code = m_session->RunSearch(guard);
|
const size_t old_count = m_session->GetResultCount();
|
||||||
|
const Cheats::SearchErrorCode error_code = m_session->RunSearch(Core::CPUThreadGuard{m_system});
|
||||||
|
|
||||||
if (error_code == Cheats::SearchErrorCode::Success)
|
if (error_code == Cheats::SearchErrorCode::Success)
|
||||||
{
|
{
|
||||||
@ -416,11 +416,11 @@ void CheatSearchWidget::UpdateTableVisibleCurrentValues(const UpdateSource sourc
|
|||||||
if (source == UpdateSource::Auto && !m_autoupdate_current_values->isChecked())
|
if (source == UpdateSource::Auto && !m_autoupdate_current_values->isChecked())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
|
||||||
if (m_address_table->rowCount() == 0)
|
if (m_address_table->rowCount() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateTableRows(guard, GetVisibleRowsBeginIndex(), GetVisibleRowsEndIndex(), source);
|
UpdateTableRows(Core::CPUThreadGuard{m_system}, GetVisibleRowsBeginIndex(),
|
||||||
|
GetVisibleRowsEndIndex(), source);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheatSearchWidget::UpdateTableAllCurrentValues(const UpdateSource source)
|
bool CheatSearchWidget::UpdateTableAllCurrentValues(const UpdateSource source)
|
||||||
@ -428,7 +428,6 @@ bool CheatSearchWidget::UpdateTableAllCurrentValues(const UpdateSource source)
|
|||||||
if (source == UpdateSource::Auto && !m_autoupdate_current_values->isChecked())
|
if (source == UpdateSource::Auto && !m_autoupdate_current_values->isChecked())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
|
||||||
const size_t result_count = m_address_table->rowCount();
|
const size_t result_count = m_address_table->rowCount();
|
||||||
if (result_count == 0)
|
if (result_count == 0)
|
||||||
{
|
{
|
||||||
@ -437,7 +436,7 @@ bool CheatSearchWidget::UpdateTableAllCurrentValues(const UpdateSource source)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return UpdateTableRows(guard, 0, result_count, source);
|
return UpdateTableRows(Core::CPUThreadGuard{m_system}, 0, result_count, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatSearchWidget::OnRefreshClicked()
|
void CheatSearchWidget::OnRefreshClicked()
|
||||||
@ -447,7 +446,6 @@ void CheatSearchWidget::OnRefreshClicked()
|
|||||||
|
|
||||||
void CheatSearchWidget::OnResetClicked()
|
void CheatSearchWidget::OnResetClicked()
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
|
||||||
m_session->ResetResults();
|
m_session->ResetResults();
|
||||||
m_address_table_current_values.clear();
|
m_address_table_current_values.clear();
|
||||||
|
|
||||||
@ -525,7 +523,6 @@ void CheatSearchWidget::OnDisplayHexCheckboxStateChanged()
|
|||||||
|
|
||||||
void CheatSearchWidget::GenerateARCode()
|
void CheatSearchWidget::GenerateARCode()
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
|
||||||
if (m_address_table->selectedItems().isEmpty())
|
if (m_address_table->selectedItems().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ namespace ActionReplay
|
|||||||
{
|
{
|
||||||
struct ARCode;
|
struct ARCode;
|
||||||
}
|
}
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
@ -36,7 +40,9 @@ class CheatSearchWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CheatSearchWidget(std::unique_ptr<Cheats::CheatSearchSessionBase> session);
|
explicit CheatSearchWidget(Core::System& system,
|
||||||
|
std::unique_ptr<Cheats::CheatSearchSessionBase> session,
|
||||||
|
QWidget* parent = nullptr);
|
||||||
~CheatSearchWidget() override;
|
~CheatSearchWidget() override;
|
||||||
|
|
||||||
enum class UpdateSource
|
enum class UpdateSource
|
||||||
@ -74,6 +80,8 @@ private:
|
|||||||
int GetVisibleRowsBeginIndex() const;
|
int GetVisibleRowsBeginIndex() const;
|
||||||
int GetVisibleRowsEndIndex() const;
|
int GetVisibleRowsEndIndex() const;
|
||||||
|
|
||||||
|
Core::System& m_system;
|
||||||
|
|
||||||
std::unique_ptr<Cheats::CheatSearchSessionBase> m_session;
|
std::unique_ptr<Cheats::CheatSearchSessionBase> m_session;
|
||||||
|
|
||||||
// storage for the 'Current Value' column's data
|
// storage for the 'Current Value' column's data
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
#include "VideoCommon/VideoEvents.h"
|
#include "VideoCommon/VideoEvents.h"
|
||||||
|
|
||||||
CheatsManager::CheatsManager(QWidget* parent) : QDialog(parent)
|
CheatsManager::CheatsManager(Core::System& system, QWidget* parent)
|
||||||
|
: QDialog(parent), m_system(system)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Cheats Manager"));
|
setWindowTitle(tr("Cheats Manager"));
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
@ -169,7 +170,7 @@ void CheatsManager::CreateWidgets()
|
|||||||
|
|
||||||
void CheatsManager::OnNewSessionCreated(const Cheats::CheatSearchSessionBase& session)
|
void CheatsManager::OnNewSessionCreated(const Cheats::CheatSearchSessionBase& session)
|
||||||
{
|
{
|
||||||
auto* w = new CheatSearchWidget(session.Clone());
|
auto* w = new CheatSearchWidget(m_system, session.Clone());
|
||||||
const int tab_index = m_tab_widget->addTab(w, tr("Cheat Search"));
|
const int tab_index = m_tab_widget->addTab(w, tr("Cheat Search"));
|
||||||
w->connect(w, &CheatSearchWidget::ActionReplayCodeGenerated, this,
|
w->connect(w, &CheatSearchWidget::ActionReplayCodeGenerated, this,
|
||||||
[this](const ActionReplay::ARCode& ar_code) {
|
[this](const ActionReplay::ARCode& ar_code) {
|
||||||
|
@ -26,13 +26,14 @@ class PartiallyClosableTabWidget;
|
|||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
enum class State;
|
enum class State;
|
||||||
}
|
class System;
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
class CheatsManager : public QDialog
|
class CheatsManager : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CheatsManager(QWidget* parent = nullptr);
|
explicit CheatsManager(Core::System& system, QWidget* parent = nullptr);
|
||||||
~CheatsManager();
|
~CheatsManager();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -64,6 +65,8 @@ private:
|
|||||||
std::string m_game_tdb_id;
|
std::string m_game_tdb_id;
|
||||||
u16 m_revision = 0;
|
u16 m_revision = 0;
|
||||||
|
|
||||||
|
Core::System& m_system;
|
||||||
|
|
||||||
QDialogButtonBox* m_button_box;
|
QDialogButtonBox* m_button_box;
|
||||||
PartiallyClosableTabWidget* m_tab_widget = nullptr;
|
PartiallyClosableTabWidget* m_tab_widget = nullptr;
|
||||||
|
|
||||||
|
@ -456,7 +456,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(this);
|
m_cheats_manager = new CheatsManager(Core::System::GetInstance(), this);
|
||||||
m_assembler_widget = new AssemblerWidget(this);
|
m_assembler_widget = new AssemblerWidget(this);
|
||||||
|
|
||||||
const auto request_watch = [this](QString name, u32 addr) {
|
const auto request_watch = [this](QString name, u32 addr) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user