diff --git a/pcsx2/gui/Debugger/DebugEvents.cpp b/pcsx2/gui/Debugger/DebugEvents.cpp index 40398d5217..8688f8f0f1 100644 --- a/pcsx2/gui/Debugger/DebugEvents.cpp +++ b/pcsx2/gui/Debugger/DebugEvents.cpp @@ -25,6 +25,7 @@ DEFINE_LOCAL_EVENT_TYPE( debEVT_MAPLOADED ) DEFINE_LOCAL_EVENT_TYPE( debEVT_STEPOVER ) DEFINE_LOCAL_EVENT_TYPE( debEVT_STEPINTO ) DEFINE_LOCAL_EVENT_TYPE( debEVT_UPDATE ) +DEFINE_LOCAL_EVENT_TYPE( debEVT_BREAKPOINTWINDOW ) bool parseExpression(const char* exp, DebugInterface* cpu, u64& dest) { diff --git a/pcsx2/gui/Debugger/DebugEvents.h b/pcsx2/gui/Debugger/DebugEvents.h index 21afcebe5b..15cd6ab583 100644 --- a/pcsx2/gui/Debugger/DebugEvents.h +++ b/pcsx2/gui/Debugger/DebugEvents.h @@ -26,5 +26,6 @@ DECLARE_LOCAL_EVENT_TYPE( debEVT_MAPLOADED, wxNewEventType() ) DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPOVER, wxNewEventType() ) DECLARE_LOCAL_EVENT_TYPE( debEVT_STEPINTO, wxNewEventType() ) DECLARE_LOCAL_EVENT_TYPE( debEVT_UPDATE, wxNewEventType() ) +DECLARE_LOCAL_EVENT_TYPE( debEVT_BREAKPOINTWINDOW, wxNewEventType() ) bool executeExpressionWindow(wxWindow* parent, DebugInterface* cpu, u64& dest, const wxString& defaultValue = wxEmptyString); diff --git a/pcsx2/gui/Debugger/DebuggerLists.cpp b/pcsx2/gui/Debugger/DebuggerLists.cpp index 385ea94575..95895e9df3 100644 --- a/pcsx2/gui/Debugger/DebuggerLists.cpp +++ b/pcsx2/gui/Debugger/DebuggerLists.cpp @@ -47,10 +47,21 @@ void resizeListViewColumns(wxListCtrl* list, GenericListViewColumn* columns, int BEGIN_EVENT_TABLE(BreakpointList, wxWindow) EVT_SIZE(BreakpointList::sizeEvent) EVT_KEY_DOWN(BreakpointList::keydownEvent) + EVT_RIGHT_DOWN(BreakpointList::mouseEvent) + EVT_RIGHT_UP(BreakpointList::mouseEvent) + EVT_LIST_ITEM_RIGHT_CLICK(wxID_ANY,BreakpointList::listEvent) END_EVENT_TABLE() enum { BPL_TYPE, BPL_OFFSET, BPL_SIZELABEL, BPL_OPCODE, BPL_CONDITION, BPL_HITS, BPL_ENABLED, BPL_COLUMNCOUNT }; +enum BreakpointListMenuIdentifiers +{ + ID_BREAKPOINTLIST_ENABLE = 1, + ID_BREAKPOINTLIST_EDIT, + ID_BREAKPOINTLIST_ADDNEW, +}; + + GenericListViewColumn breakpointColumns[BPL_COLUMNCOUNT] = { { L"Type", 0.12f }, { L"Offset", 0.12f }, @@ -189,7 +200,7 @@ wxString BreakpointList::OnGetItemText(long item, long col) const case BPL_ENABLED: { if (isMemory) { - dest.Write(L"%s",displayedMemChecks_[index].cond & MEMCHECK_BREAK ? "true" : "false"); + dest.Write(L"%s",displayedMemChecks_[index].result & MEMCHECK_BREAK ? "true" : "false"); } else { dest.Write(L"%s",displayedBreakPoints_[index].enabled ? "true" : "false"); } @@ -352,3 +363,70 @@ void BreakpointList::postEvent(wxEventType type, int value) event.SetInt(value); wxPostEvent(this,event); } + +void BreakpointList::onPopupClick(wxCommandEvent& evt) +{ + int index = GetFirstSelected(); + switch (evt.GetId()) + { + case ID_BREAKPOINTLIST_ENABLE: + toggleEnabled(index); + break; + case ID_BREAKPOINTLIST_EDIT: + editBreakpoint(index); + break; + case ID_BREAKPOINTLIST_ADDNEW: + postEvent(debEVT_BREAKPOINTWINDOW,0); + break; + default: + wxMessageBox( L"Unimplemented.", L"Unimplemented.", wxICON_INFORMATION); + break; + } +} + +void BreakpointList::showMenu(wxPoint& pos) +{ + bool isMemory; + int index = getBreakpointIndex(GetFirstSelected(),isMemory); + + wxMenu menu; + if (index != -1) + { + menu.AppendCheckItem(ID_BREAKPOINTLIST_ENABLE, L"Enable"); + menu.Append(ID_BREAKPOINTLIST_EDIT, L"Edit"); + menu.AppendSeparator(); + + // check if the breakpoint is enabled + bool enabled; + if (isMemory) + enabled = (displayedMemChecks_[index].result & MEMCHECK_BREAK) != 0; + else + enabled = displayedBreakPoints_[index].enabled; + + menu.Check(ID_BREAKPOINTLIST_ENABLE,enabled); + } + + menu.Append(ID_BREAKPOINTLIST_ADDNEW, L"Add new"); + + menu.Connect(wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&BreakpointList::onPopupClick, NULL, this); + PopupMenu(&menu,pos); +} + +void BreakpointList::mouseEvent(wxMouseEvent& evt) +{ + wxEventType type = evt.GetEventType(); + + if (type == wxEVT_RIGHT_DOWN) + { + clickPos = evt.GetPosition(); + evt.Skip(); + } else if (type == wxEVT_RIGHT_UP) + { + showMenu(evt.GetPosition()); + } +} + +void BreakpointList::listEvent(wxListEvent& evt) +{ + showMenu(clickPos); +} \ No newline at end of file diff --git a/pcsx2/gui/Debugger/DebuggerLists.h b/pcsx2/gui/Debugger/DebuggerLists.h index cee8d51a34..53635be911 100644 --- a/pcsx2/gui/Debugger/DebuggerLists.h +++ b/pcsx2/gui/Debugger/DebuggerLists.h @@ -35,9 +35,12 @@ public: DECLARE_EVENT_TABLE() protected: wxString OnGetItemText(long item, long col) const; + void onPopupClick(wxCommandEvent& evt); void sizeEvent(wxSizeEvent& evt); void keydownEvent(wxKeyEvent& evt); + void mouseEvent(wxMouseEvent& evt); + void listEvent(wxListEvent& evt); private: int getBreakpointIndex(int itemIndex, bool& isMemory) const; int getTotalBreakpointCount(); @@ -46,9 +49,11 @@ private: void gotoBreakpointAddress(int itemIndex); void removeBreakpoint(int itemIndex); void postEvent(wxEventType type, int value); + void showMenu(wxPoint& pos); std::vector displayedBreakPoints_; std::vector displayedMemChecks_; DebugInterface* cpu; CtrlDisassemblyView* disasm; + wxPoint clickPos; }; diff --git a/pcsx2/gui/Debugger/DisassemblyDialog.cpp b/pcsx2/gui/Debugger/DisassemblyDialog.cpp index 7b365c24f9..83569a8c62 100644 --- a/pcsx2/gui/Debugger/DisassemblyDialog.cpp +++ b/pcsx2/gui/Debugger/DisassemblyDialog.cpp @@ -35,6 +35,7 @@ BEGIN_EVENT_TABLE(DisassemblyDialog, wxFrame) EVT_COMMAND( wxID_ANY, debEVT_STEPOVER, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_STEPINTO, DisassemblyDialog::onDebuggerEvent ) EVT_COMMAND( wxID_ANY, debEVT_UPDATE, DisassemblyDialog::onDebuggerEvent ) + EVT_COMMAND( wxID_ANY, debEVT_BREAKPOINTWINDOW, DisassemblyDialog::onDebuggerEvent ) EVT_CLOSE( DisassemblyDialog::onClose ) END_EVENT_TABLE() @@ -414,6 +415,10 @@ void DisassemblyDialog::onDebuggerEvent(wxCommandEvent& evt) } else if (type == debEVT_UPDATE) { update(); + } else if (type == debEVT_BREAKPOINTWINDOW) + { + wxCommandEvent evt; + onBreakpointClick(evt); } }