Add options for BreakpointWidget, WatchWidget, and CheatSearches to send address to Memory Widget

This commit is contained in:
TryTwo 2022-05-27 17:34:47 -07:00
parent 70bf89fa59
commit 177dae6a1a
9 changed files with 25 additions and 4 deletions

View File

@ -448,8 +448,12 @@ void CheatSearchWidget::OnAddressTableContextMenu()
if (m_address_table->selectedItems().isEmpty()) if (m_address_table->selectedItems().isEmpty())
return; return;
auto* item = m_address_table->selectedItems()[0];
const u32 address = item->data(ADDRESS_TABLE_ADDRESS_ROLE).toUInt();
QMenu* menu = new QMenu(this); QMenu* menu = new QMenu(this);
menu->addAction(tr("Show in memory"), [this, address] { emit ShowMemory(address); });
menu->addAction(tr("Generate Action Replay Code"), this, &CheatSearchWidget::GenerateARCode); menu->addAction(tr("Generate Action Replay Code"), this, &CheatSearchWidget::GenerateARCode);
menu->exec(QCursor::pos()); menu->exec(QCursor::pos());

View File

@ -41,6 +41,7 @@ public:
signals: signals:
void ActionReplayCodeGenerated(const ActionReplay::ARCode& ar_code); void ActionReplayCodeGenerated(const ActionReplay::ARCode& ar_code);
void ShowMemory(const u32 address);
private: private:
void CreateWidgets(); void CreateWidgets();

View File

@ -122,6 +122,7 @@ void CheatsManager::OnNewSessionCreated(const Cheats::CheatSearchSessionBase& se
if (m_ar_code) if (m_ar_code)
m_ar_code->AddCode(ar_code); m_ar_code->AddCode(ar_code);
}); });
w->connect(w, &CheatSearchWidget::ShowMemory, [this](u32 address) { emit ShowMemory(address); });
m_tab_widget->setCurrentIndex(tab_index); m_tab_widget->setCurrentIndex(tab_index);
} }

View File

@ -35,6 +35,7 @@ public:
signals: signals:
void OpenGeneralSettings(); void OpenGeneralSettings();
void ShowMemory(u32 address);
private: private:
void CreateWidgets(); void CreateWidgets();

View File

@ -18,6 +18,7 @@
#include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PPCSymbolDB.h"
#include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/PowerPC.h"
#include "DolphinQt/Debugger/MemoryWidget.h"
#include "DolphinQt/Debugger/NewBreakpointDialog.h" #include "DolphinQt/Debugger/NewBreakpointDialog.h"
#include "DolphinQt/Resources.h" #include "DolphinQt/Resources.h"
#include "DolphinQt/Settings.h" #include "DolphinQt/Settings.h"
@ -355,13 +356,13 @@ void BreakpointWidget::OnContextMenu()
if (bp_iter == inst_breakpoints.end()) if (bp_iter == inst_breakpoints.end())
return; return;
menu->addAction(tr("Show in Code"), [this, bp_address] { emit ShowCode(bp_address); });
menu->addAction(bp_iter->is_enabled ? tr("Disable") : tr("Enable"), [this, &bp_address]() { menu->addAction(bp_iter->is_enabled ? tr("Disable") : tr("Enable"), [this, &bp_address]() {
PowerPC::breakpoints.ToggleBreakPoint(bp_address); PowerPC::breakpoints.ToggleBreakPoint(bp_address);
emit BreakpointsChanged(); emit BreakpointsChanged();
Update(); Update();
}); });
menu->addAction(tr("Go to"), [this, bp_address] { emit SelectedBreakpoint(bp_address); });
} }
else else
{ {
@ -372,6 +373,7 @@ void BreakpointWidget::OnContextMenu()
if (mb_iter == memory_breakpoints.end()) if (mb_iter == memory_breakpoints.end())
return; return;
menu->addAction(tr("Show in Memory"), [this, bp_address] { emit ShowMemory(bp_address); });
menu->addAction(mb_iter->is_enabled ? tr("Disable") : tr("Enable"), [this, &bp_address]() { menu->addAction(mb_iter->is_enabled ? tr("Disable") : tr("Enable"), [this, &bp_address]() {
PowerPC::memchecks.ToggleBreakPoint(bp_address); PowerPC::memchecks.ToggleBreakPoint(bp_address);

View File

@ -31,7 +31,8 @@ public:
signals: signals:
void BreakpointsChanged(); void BreakpointsChanged();
void SelectedBreakpoint(u32 address); void ShowCode(u32 address);
void ShowMemory(u32 address);
protected: protected:
void closeEvent(QCloseEvent*) override; void closeEvent(QCloseEvent*) override;

View File

@ -310,6 +310,7 @@ void WatchWidget::ShowContextMenu()
if (row >= 0) if (row >= 0)
{ {
menu->addAction(tr("Show in Memory"), this, [this, row] { ShowInMemory(row); });
// i18n: This kind of "watch" is used for watching emulated memory. // i18n: This kind of "watch" is used for watching emulated memory.
// It's not related to timekeeping devices. // It's not related to timekeeping devices.
menu->addAction(tr("&Delete Watch"), this, [this, row] { DeleteWatch(row); }); menu->addAction(tr("&Delete Watch"), this, [this, row] { DeleteWatch(row); });
@ -395,6 +396,11 @@ void WatchWidget::AddWatchBreakpoint(int row)
emit RequestMemoryBreakpoint(PowerPC::debug_interface.GetWatch(row).address); emit RequestMemoryBreakpoint(PowerPC::debug_interface.GetWatch(row).address);
} }
void WatchWidget::ShowInMemory(int row)
{
emit ShowMemory(PowerPC::debug_interface.GetWatch(row).address);
}
void WatchWidget::AddWatch(QString name, u32 addr) void WatchWidget::AddWatch(QString name, u32 addr)
{ {
PowerPC::debug_interface.SetWatch(addr, name.toStdString()); PowerPC::debug_interface.SetWatch(addr, name.toStdString());

View File

@ -24,6 +24,7 @@ public:
void AddWatch(QString name, u32 addr); void AddWatch(QString name, u32 addr);
signals: signals:
void RequestMemoryBreakpoint(u32 addr); void RequestMemoryBreakpoint(u32 addr);
void ShowMemory(u32 addr);
protected: protected:
void closeEvent(QCloseEvent*) override; void closeEvent(QCloseEvent*) override;
@ -47,7 +48,7 @@ private:
void OnItemChanged(QTableWidgetItem* item); void OnItemChanged(QTableWidgetItem* item);
void DeleteWatch(int row); void DeleteWatch(int row);
void AddWatchBreakpoint(int row); void AddWatchBreakpoint(int row);
void ShowInMemory(int row);
void UpdateIcons(); void UpdateIcons();
QAction* m_new; QAction* m_new;

View File

@ -455,6 +455,7 @@ void MainWindow::CreateComponents()
}; };
connect(m_watch_widget, &WatchWidget::RequestMemoryBreakpoint, request_memory_breakpoint); connect(m_watch_widget, &WatchWidget::RequestMemoryBreakpoint, request_memory_breakpoint);
connect(m_watch_widget, &WatchWidget::ShowMemory, m_memory_widget, &MemoryWidget::SetAddress);
connect(m_register_widget, &RegisterWidget::RequestMemoryBreakpoint, request_memory_breakpoint); connect(m_register_widget, &RegisterWidget::RequestMemoryBreakpoint, request_memory_breakpoint);
connect(m_register_widget, &RegisterWidget::RequestWatch, request_watch); connect(m_register_widget, &RegisterWidget::RequestWatch, request_watch);
connect(m_register_widget, &RegisterWidget::RequestViewInMemory, request_view_in_memory); connect(m_register_widget, &RegisterWidget::RequestViewInMemory, request_view_in_memory);
@ -480,10 +481,13 @@ void MainWindow::CreateComponents()
&CodeWidget::Update); &CodeWidget::Update);
connect(m_breakpoint_widget, &BreakpointWidget::BreakpointsChanged, m_memory_widget, connect(m_breakpoint_widget, &BreakpointWidget::BreakpointsChanged, m_memory_widget,
&MemoryWidget::Update); &MemoryWidget::Update);
connect(m_breakpoint_widget, &BreakpointWidget::SelectedBreakpoint, [this](u32 address) { connect(m_breakpoint_widget, &BreakpointWidget::ShowCode, [this](u32 address) {
if (Core::GetState() == Core::State::Paused) if (Core::GetState() == Core::State::Paused)
m_code_widget->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithDetailedUpdate); m_code_widget->SetAddress(address, CodeViewWidget::SetAddressUpdate::WithDetailedUpdate);
}); });
connect(m_breakpoint_widget, &BreakpointWidget::ShowMemory, m_memory_widget,
&MemoryWidget::SetAddress);
connect(m_cheats_manager, &CheatsManager::ShowMemory, m_memory_widget, &MemoryWidget::SetAddress);
} }
void MainWindow::ConnectMenuBar() void MainWindow::ConnectMenuBar()