From 2abb85a05da94eda83b6d2f97170e9fcb20116f4 Mon Sep 17 00:00:00 2001 From: p989 Date: Tue, 15 Dec 2009 08:50:30 +0000 Subject: [PATCH] wx: savestate menu items --- desmume/src/wx/wxMain.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/desmume/src/wx/wxMain.cpp b/desmume/src/wx/wxMain.cpp index 441c1e09b..86c3cfe95 100644 --- a/desmume/src/wx/wxMain.cpp +++ b/desmume/src/wx/wxMain.cpp @@ -313,6 +313,19 @@ case 88://x new wxLuaWindow(this, wxDefaultPosition, wxSize(600, 390)); } + wxMenu* MakeStatesSubMenu( int baseid ) const + { + wxMenu* mnuSubstates = new wxMenu(); + + for (int i = 0; i < 10; i++) + { + mnuSubstates->Append( baseid+i+1, wxString::Format("Slot %d", i) ); + } + return mnuSubstates; + } + void Menu_SaveStates(wxCommandEvent &event); + void Menu_LoadStates(wxCommandEvent &event); + private: DECLARE_EVENT_TABLE() }; @@ -354,9 +367,14 @@ enum wStopMovie, wSaveScreenshotAs, wQuickScreenshot, - wLuaWindow + wLuaWindow, + wLoadState01, + wSaveState01 = wLoadState01+20 }; +void DesmumeFrame::Menu_SaveStates(wxCommandEvent &event){savestate_slot(event.GetId() - wSaveState01 - 1);} +void DesmumeFrame::Menu_LoadStates(wxCommandEvent &event){loadstate_slot(event.GetId() - wLoadState01 - 1);} + BEGIN_EVENT_TABLE(DesmumeFrame, wxFrame) EVT_PAINT(DesmumeFrame::onPaint) EVT_IDLE(DesmumeFrame::onIdle) @@ -453,6 +471,16 @@ DesmumeFrame::DesmumeFrame(const wxString& title) fileMenu->AppendSeparator(); fileMenu->Append(wSaveStateAs, "Save State As..."); fileMenu->Append(wLoadStateFrom, "Load State From..."); + { + wxMenu* saves(DesmumeFrame::MakeStatesSubMenu(wSaveState01)); + wxMenu* loads(DesmumeFrame::MakeStatesSubMenu(wLoadState01)); + fileMenu->AppendSubMenu(saves,"Save State"); + fileMenu->AppendSubMenu(loads,"Load State"); +#define ConnectMenuRange( id_start, inc, handler ) \ + Connect( id_start, id_start + inc, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(DesmumeFrame::handler) ) + ConnectMenuRange(wLoadState01+1, 10, Menu_LoadStates); + ConnectMenuRange(wSaveState01+1, 10, Menu_SaveStates); + } fileMenu->AppendSeparator(); fileMenu->Append(wImportBackupMemory, "Import Backup Memory..."); fileMenu->Append(wExportBackupMemory, "Export Backup Memory...");