UI: Refresh debugger when graphic packs are loaded or unloaded (#1653)

This commit is contained in:
Crementif 2025-07-26 22:45:44 +02:00 committed by GitHub
parent 191357c518
commit 493b11e23a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 0 deletions

View file

@ -11,6 +11,8 @@
#include "util/IniParser/IniParser.h"
#include "util/helpers/StringHelpers.h"
#include "Cafe/CafeSystem.h"
#include "HW/Espresso/Debugger/Debugger.h"
#include <cinttypes>
std::vector<GraphicPackPtr> GraphicPack2::s_graphic_packs;
@ -130,6 +132,7 @@ bool GraphicPack2::ActivateGraphicPack(const std::shared_ptr<GraphicPack2>& grap
if (graphic_pack->Activate())
{
s_active_graphic_packs.push_back(graphic_pack);
g_debuggerDispatcher.NotifyGraphicPacksModified();
return true;
}
@ -153,6 +156,7 @@ bool GraphicPack2::DeactivateGraphicPack(const std::shared_ptr<GraphicPack2>& gr
graphic_pack->Deactivate();
s_active_graphic_packs.erase(it);
g_debuggerDispatcher.NotifyGraphicPacksModified();
return true;
}

View file

@ -24,6 +24,7 @@ class DebuggerCallbacks
virtual void MoveIP() {}
virtual void NotifyModuleLoaded(void* module) {}
virtual void NotifyModuleUnloaded(void* module) {}
virtual void NotifyGraphicPacksModified() {}
virtual ~DebuggerCallbacks() = default;
};
@ -77,6 +78,11 @@ class DebuggerDispatcher
{
m_callbacks->NotifyModuleUnloaded(module);
}
void NotifyGraphicPacksModified()
{
m_callbacks->NotifyGraphicPacksModified();
}
} extern g_debuggerDispatcher;
struct DebuggerBreakpoint

View file

@ -54,6 +54,7 @@ wxDEFINE_EVENT(wxEVT_MOVE_IP, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_RUN, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_NOTIFY_MODULE_LOADED, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_NOTIFY_MODULE_UNLOADED, wxCommandEvent);
wxDEFINE_EVENT(wxEVT_NOTIFY_GRAPHIC_PACKS_MODIFIED, wxCommandEvent);
wxBEGIN_EVENT_TABLE(DebuggerWindow2, wxFrame)
EVT_SHOW(DebuggerWindow2::OnShow)
@ -66,6 +67,7 @@ wxBEGIN_EVENT_TABLE(DebuggerWindow2, wxFrame)
EVT_COMMAND(wxID_ANY, wxEVT_RUN, DebuggerWindow2::OnRunProgram)
EVT_COMMAND(wxID_ANY, wxEVT_NOTIFY_MODULE_LOADED, DebuggerWindow2::OnNotifyModuleLoaded)
EVT_COMMAND(wxID_ANY, wxEVT_NOTIFY_MODULE_UNLOADED, DebuggerWindow2::OnNotifyModuleUnloaded)
EVT_COMMAND(wxID_ANY, wxEVT_NOTIFY_GRAPHIC_PACKS_MODIFIED, DebuggerWindow2::OnNotifyGraphicPacksModified)
EVT_COMMAND(wxID_ANY, wxEVT_DISASMCTRL_NOTIFY_GOTO_ADDRESS, DebuggerWindow2::OnDisasmCtrlGotoAddress)
// file menu
EVT_MENU(MENU_ID_FILE_EXIT, DebuggerWindow2::OnExit)
@ -437,6 +439,13 @@ void DebuggerWindow2::OnNotifyModuleUnloaded(wxCommandEvent& event)
m_disasm_ctrl->Init();
}
void DebuggerWindow2::OnNotifyGraphicPacksModified(wxCommandEvent& event)
{
m_module_window->OnGameLoaded();
m_symbol_window->OnGameLoaded();
m_disasm_ctrl->Init();
}
void DebuggerWindow2::OnGameLoaded()
{
m_disasm_ctrl->Init();
@ -720,6 +729,12 @@ void DebuggerWindow2::NotifyModuleLoaded(void* module)
wxQueueEvent(this, evt);
}
void DebuggerWindow2::NotifyGraphicPacksModified()
{
auto* evt = new wxCommandEvent(wxEVT_NOTIFY_GRAPHIC_PACKS_MODIFIED);
wxQueueEvent(this, evt);
}
void DebuggerWindow2::NotifyModuleUnloaded(void* module)
{
auto* evt = new wxCommandEvent(wxEVT_NOTIFY_MODULE_UNLOADED);

View file

@ -24,6 +24,7 @@ wxDECLARE_EVENT(wxEVT_BREAKPOINT_CHANGE, wxCommandEvent);
wxDECLARE_EVENT(wxEVT_MOVE_IP, wxCommandEvent);
wxDECLARE_EVENT(wxEVT_NOTIFY_MODULE_LOADED, wxCommandEvent);
wxDECLARE_EVENT(wxEVT_NOTIFY_MODULE_UNLOADED, wxCommandEvent);
wxDECLARE_EVENT(wxEVT_NOTIFY_GRAPHIC_PACKS_MODIFIED, wxCommandEvent);
struct DebuggerConfig
{
@ -95,6 +96,7 @@ private:
void OnMoveIP(wxCommandEvent& event);
void OnNotifyModuleLoaded(wxCommandEvent& event);
void OnNotifyModuleUnloaded(wxCommandEvent& event);
void OnNotifyGraphicPacksModified(wxCommandEvent& event);
// events from DisasmCtrl
void OnDisasmCtrlGotoAddress(wxCommandEvent& event);
@ -106,6 +108,7 @@ private:
void NotifyRun() override;
void MoveIP() override;
void NotifyModuleLoaded(void* module) override;
void NotifyGraphicPacksModified() override;
void NotifyModuleUnloaded(void* module) override;
XMLDebuggerConfig m_config;