wx: remove duplicated code for the GUI menu

We have a fair chunk of duplicated code to build the GUI
menus, remove the monolithic one in favour of the one
splitted in smaller functions.

From: Jan Bücken (nooris), #3301520
This commit is contained in:
riccardom 2011-06-03 16:28:57 +00:00
parent 1cbd6afa28
commit 1d43b346fe
1 changed files with 1 additions and 115 deletions

View File

@ -162,125 +162,11 @@ DesmumeFrame::DesmumeFrame(const wxString& title)
{
history = new wxFileHistory;
wxMenuBar *menuBar = new wxMenuBar();
wxMenu *fileMenu = new wxMenu;
wxMenu *emulationMenu = new wxMenu;
wxMenu *viewMenu = new wxMenu;
wxMenu *configMenu = new wxMenu;
wxMenu *toolsMenu = new wxMenu;
wxMenu *helpMenu = new wxMenu;
wxMenu *recentMenu = new wxMenu;
wxMenu *saves(MakeStatesSubMenu(wSaveState01));
wxMenu *loads(MakeStatesSubMenu(wLoadState01));
wxMenu *layersMenu = new wxMenu;
wxMenu *rotateMenu = new wxMenu;
wxMenu *audiodriverMenu = new wxMenu;
wxMenu *spumodeMenu = new wxMenu;
LoadSettings();
menuBar->Append(fileMenu, _T("&File"));
menuBar->Append(emulationMenu, _T("&Emulation"));
menuBar->Append(viewMenu, _T("&View"));
menuBar->Append(configMenu, _T("&Config"));
menuBar->Append(toolsMenu, _T("&Tools"));
menuBar->Append(helpMenu, _T("&Help"));
fileMenu->Append(wxID_OPEN, _T("Load R&om\tAlt-R"));
fileMenu->AppendSubMenu(recentMenu, _T("Recent files"));
fileMenu->Append(wCloseRom, _T("Close Rom"));
fileMenu->AppendSeparator();
fileMenu->Append(wSaveStateAs, _T("Save State As..."));
fileMenu->Append(wLoadStateFrom, _T("Load State From..."));
fileMenu->AppendSubMenu(saves, _T("Save State"));
fileMenu->AppendSubMenu(loads, _T("Load State"));
fileMenu->AppendSeparator();
fileMenu->Append(wImportBackupMemory, _T("Import Backup Memory..."));
fileMenu->Append(wExportBackupMemory, _T("Export Backup Memory..."));
fileMenu->AppendSeparator();
fileMenu->Append(wSaveScreenshotAs, _T("Save Screenshot As"));
fileMenu->Append(wQuickScreenshot, _T("Quick Screenshot"));
fileMenu->AppendSeparator();
fileMenu->Append(wPlayMovie, _T("Play Movie"));
fileMenu->Append(wRecordMovie, _T("Record Movie"));
fileMenu->Append(wStopMovie, _T("Stop Movie"));
fileMenu->AppendSeparator();
fileMenu->Append(wLuaWindow, _T("New Lua Script Window..."));
fileMenu->AppendSeparator();
fileMenu->Append(wxID_EXIT, _T("E&xit\tAlt-X"), _T("Quit this program"));
emulationMenu->Append(wPause, _T("&Pause\tAlt-P"), _T("Pause Emulation"));
emulationMenu->Append(wReset, _T("&Reset\tAlt-R"), _T("Reset Emulation"));
emulationMenu->AppendSeparator();
emulationMenu->AppendSubMenu(audiodriverMenu, _T("&Audio Driver"));
audiodriverMenu->AppendRadioItem(wAUDIODRIVER_SDL, _T("&SDL"));
audiodriverMenu->AppendRadioItem(wAUDIODRIVER_DISABLE, _T("&Disable Sound"));
emulationMenu->AppendSubMenu(spumodeMenu, _T("&SPU Mode"));
spumodeMenu->AppendRadioItem(wSPUMODE_DUALASYNC, _T("&Dual Asynchronous"));
spumodeMenu->AppendRadioItem(wSPUMODE_SYNCN, _T("Synchronous (&N)"));
spumodeMenu->AppendRadioItem(wSPUMODE_SYNCZ, _T("Synchronous (&Z)"));
#ifdef HAVE_SPUMODE_SYNCP
spumodeMenu->AppendRadioItem(wSPUMODE_SYNCP, _T("Synchronous (&P)"));
#endif
configMenu->Append(wConfigureControls, _T("Controls"));
toolsMenu->Append(w3dView, _T("&3d Viewer"));
toolsMenu->AppendSeparator();
toolsMenu->AppendSubMenu(layersMenu, _T("View Layers"));
layersMenu->AppendCheckItem(wMainGPU, _T("Main GPU"));
layersMenu->Check(wMainGPU, true);
layersMenu->AppendCheckItem(wMainBG0, _T("Main BG 0"));
layersMenu->Check(wMainBG0, true);
layersMenu->AppendCheckItem(wMainBG1, _T("Main BG 1"));
layersMenu->Check(wMainBG1, true);
layersMenu->AppendCheckItem(wMainBG2, _T("Main BG 2"));
layersMenu->Check(wMainBG2, true);
layersMenu->AppendCheckItem(wMainBG3, _T("Main BG 3"));
layersMenu->Check(wMainBG3, true);
layersMenu->AppendSeparator();
layersMenu->AppendCheckItem(wSubGPU, _T("Sub GPU"));
layersMenu->Check(wSubGPU, true);
layersMenu->AppendCheckItem(wSubBG0, _T("Sub BG 0"));
layersMenu->Check(wSubBG0, true);
layersMenu->AppendCheckItem(wSubBG1, _T("Sub BG 1"));
layersMenu->Check(wSubBG1, true);
layersMenu->AppendCheckItem(wSubBG2, _T("Sub BG 2"));
layersMenu->Check(wSubBG2, true);
layersMenu->AppendCheckItem(wSubBG3, _T("Sub BG 3"));
layersMenu->Check(wSubBG3, true);
helpMenu->Append(wWebsite, _T("&Website"));
helpMenu->Append(wForums, _T("&Forums"));
helpMenu->Append(wSubmitABugReport, _T("&Submit A Bug Report"));
helpMenu->Append(wxID_ABOUT);
viewMenu->AppendSubMenu(rotateMenu, _T("Rotate"));
viewMenu->AppendSeparator();
viewMenu->Append(wSetHUDFont, _T("&Set HUD Font"));
viewMenu->AppendCheckItem(wFrameCounter, _T("&Display Frame Counter"));
viewMenu->AppendCheckItem(wFPS, _T("&Display FPS"));
viewMenu->AppendCheckItem(wDisplayInput, _T("&Display Input"));
viewMenu->AppendCheckItem(wDisplayGraphicalInput, _T("&Display Graphical Input"));
viewMenu->AppendCheckItem(wDisplayLagCounter, _T("&Display Lag Counter"));
viewMenu->AppendCheckItem(wDisplayMicrophone, _T("&Display Microphone"));
rotateMenu->AppendRadioItem(wRot0, _T("0"));
rotateMenu->AppendRadioItem(wRot90, _T("90"));
rotateMenu->AppendRadioItem(wRot180, _T("180"));
rotateMenu->AppendRadioItem(wRot270, _T("270"));
rotateMenu->Check(wRot0+(nds_screen_rotation_angle/90), true);
/*
loadfileMenu(fileMenu);
loademulationMenu(emulationMenu);
loadconfigMenu(configMenu);
loadtoolsMenu(toolsMenu);
loadhelpMenu(helpMenu);
loadviewMenu(viewMenu);
loadmenuBar(menuBar);
*/
ChangeRotation(nds_screen_rotation_angle, false);
SetMenuBar(menuBar);
}