Skip to content

Commit 493b11e

Browse files
authored
UI: Refresh debugger when graphic packs are loaded or unloaded (#1653)
1 parent 191357c commit 493b11e

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

src/Cafe/GraphicPack/GraphicPack2.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "util/IniParser/IniParser.h"
1212
#include "util/helpers/StringHelpers.h"
1313
#include "Cafe/CafeSystem.h"
14+
#include "HW/Espresso/Debugger/Debugger.h"
15+
1416
#include <cinttypes>
1517

1618
std::vector<GraphicPackPtr> GraphicPack2::s_graphic_packs;
@@ -130,6 +132,7 @@ bool GraphicPack2::ActivateGraphicPack(const std::shared_ptr<GraphicPack2>& grap
130132
if (graphic_pack->Activate())
131133
{
132134
s_active_graphic_packs.push_back(graphic_pack);
135+
g_debuggerDispatcher.NotifyGraphicPacksModified();
133136
return true;
134137
}
135138

@@ -153,6 +156,7 @@ bool GraphicPack2::DeactivateGraphicPack(const std::shared_ptr<GraphicPack2>& gr
153156

154157
graphic_pack->Deactivate();
155158
s_active_graphic_packs.erase(it);
159+
g_debuggerDispatcher.NotifyGraphicPacksModified();
156160
return true;
157161
}
158162

src/Cafe/HW/Espresso/Debugger/Debugger.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class DebuggerCallbacks
2424
virtual void MoveIP() {}
2525
virtual void NotifyModuleLoaded(void* module) {}
2626
virtual void NotifyModuleUnloaded(void* module) {}
27+
virtual void NotifyGraphicPacksModified() {}
2728
virtual ~DebuggerCallbacks() = default;
2829
};
2930

@@ -77,6 +78,11 @@ class DebuggerDispatcher
7778
{
7879
m_callbacks->NotifyModuleUnloaded(module);
7980
}
81+
82+
void NotifyGraphicPacksModified()
83+
{
84+
m_callbacks->NotifyGraphicPacksModified();
85+
}
8086
} extern g_debuggerDispatcher;
8187

8288
struct DebuggerBreakpoint

src/gui/wxgui/debugger/DebuggerWindow2.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ wxDEFINE_EVENT(wxEVT_MOVE_IP, wxCommandEvent);
5454
wxDEFINE_EVENT(wxEVT_RUN, wxCommandEvent);
5555
wxDEFINE_EVENT(wxEVT_NOTIFY_MODULE_LOADED, wxCommandEvent);
5656
wxDEFINE_EVENT(wxEVT_NOTIFY_MODULE_UNLOADED, wxCommandEvent);
57+
wxDEFINE_EVENT(wxEVT_NOTIFY_GRAPHIC_PACKS_MODIFIED, wxCommandEvent);
5758

5859
wxBEGIN_EVENT_TABLE(DebuggerWindow2, wxFrame)
5960
EVT_SHOW(DebuggerWindow2::OnShow)
@@ -66,6 +67,7 @@ wxBEGIN_EVENT_TABLE(DebuggerWindow2, wxFrame)
6667
EVT_COMMAND(wxID_ANY, wxEVT_RUN, DebuggerWindow2::OnRunProgram)
6768
EVT_COMMAND(wxID_ANY, wxEVT_NOTIFY_MODULE_LOADED, DebuggerWindow2::OnNotifyModuleLoaded)
6869
EVT_COMMAND(wxID_ANY, wxEVT_NOTIFY_MODULE_UNLOADED, DebuggerWindow2::OnNotifyModuleUnloaded)
70+
EVT_COMMAND(wxID_ANY, wxEVT_NOTIFY_GRAPHIC_PACKS_MODIFIED, DebuggerWindow2::OnNotifyGraphicPacksModified)
6971
EVT_COMMAND(wxID_ANY, wxEVT_DISASMCTRL_NOTIFY_GOTO_ADDRESS, DebuggerWindow2::OnDisasmCtrlGotoAddress)
7072
// file menu
7173
EVT_MENU(MENU_ID_FILE_EXIT, DebuggerWindow2::OnExit)
@@ -437,6 +439,13 @@ void DebuggerWindow2::OnNotifyModuleUnloaded(wxCommandEvent& event)
437439
m_disasm_ctrl->Init();
438440
}
439441

442+
void DebuggerWindow2::OnNotifyGraphicPacksModified(wxCommandEvent& event)
443+
{
444+
m_module_window->OnGameLoaded();
445+
m_symbol_window->OnGameLoaded();
446+
m_disasm_ctrl->Init();
447+
}
448+
440449
void DebuggerWindow2::OnGameLoaded()
441450
{
442451
m_disasm_ctrl->Init();
@@ -720,6 +729,12 @@ void DebuggerWindow2::NotifyModuleLoaded(void* module)
720729
wxQueueEvent(this, evt);
721730
}
722731

732+
void DebuggerWindow2::NotifyGraphicPacksModified()
733+
{
734+
auto* evt = new wxCommandEvent(wxEVT_NOTIFY_GRAPHIC_PACKS_MODIFIED);
735+
wxQueueEvent(this, evt);
736+
}
737+
723738
void DebuggerWindow2::NotifyModuleUnloaded(void* module)
724739
{
725740
auto* evt = new wxCommandEvent(wxEVT_NOTIFY_MODULE_UNLOADED);

src/gui/wxgui/debugger/DebuggerWindow2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ wxDECLARE_EVENT(wxEVT_BREAKPOINT_CHANGE, wxCommandEvent);
2424
wxDECLARE_EVENT(wxEVT_MOVE_IP, wxCommandEvent);
2525
wxDECLARE_EVENT(wxEVT_NOTIFY_MODULE_LOADED, wxCommandEvent);
2626
wxDECLARE_EVENT(wxEVT_NOTIFY_MODULE_UNLOADED, wxCommandEvent);
27+
wxDECLARE_EVENT(wxEVT_NOTIFY_GRAPHIC_PACKS_MODIFIED, wxCommandEvent);
2728

2829
struct DebuggerConfig
2930
{
@@ -95,6 +96,7 @@ class DebuggerWindow2 : public wxFrame, public DebuggerCallbacks
9596
void OnMoveIP(wxCommandEvent& event);
9697
void OnNotifyModuleLoaded(wxCommandEvent& event);
9798
void OnNotifyModuleUnloaded(wxCommandEvent& event);
99+
void OnNotifyGraphicPacksModified(wxCommandEvent& event);
98100
// events from DisasmCtrl
99101
void OnDisasmCtrlGotoAddress(wxCommandEvent& event);
100102

@@ -106,6 +108,7 @@ class DebuggerWindow2 : public wxFrame, public DebuggerCallbacks
106108
void NotifyRun() override;
107109
void MoveIP() override;
108110
void NotifyModuleLoaded(void* module) override;
111+
void NotifyGraphicPacksModified() override;
109112
void NotifyModuleUnloaded(void* module) override;
110113

111114
XMLDebuggerConfig m_config;

0 commit comments

Comments
 (0)