FrameTools.cpp 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023
  1. // Copyright 2008 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #include <cstdarg>
  5. #include <cstdio>
  6. #include <mutex>
  7. #include <string>
  8. #include <vector>
  9. #include <wx/app.h>
  10. #include <wx/bitmap.h>
  11. #include <wx/filedlg.h>
  12. #include <wx/filefn.h>
  13. #include <wx/menu.h>
  14. #include <wx/msgdlg.h>
  15. #include <wx/panel.h>
  16. #include <wx/progdlg.h>
  17. #include <wx/statusbr.h>
  18. #include <wx/thread.h>
  19. #include <wx/toolbar.h>
  20. #include <wx/toplevel.h>
  21. #include <wx/aui/framemanager.h>
  22. #ifdef __APPLE__
  23. #include <AppKit/AppKit.h>
  24. #endif
  25. #include "Common/CDUtils.h"
  26. #include "Common/CommonTypes.h"
  27. #include "Common/FileSearch.h"
  28. #include "Common/FileUtil.h"
  29. #include "Common/NandPaths.h"
  30. #include "Core/BootManager.h"
  31. #include "Core/ConfigManager.h"
  32. #include "Core/Core.h"
  33. #include "Core/CoreParameter.h"
  34. #include "Core/Host.h"
  35. #include "Core/HotkeyManager.h"
  36. #include "Core/Movie.h"
  37. #include "Core/State.h"
  38. #include "Core/HW/CPU.h"
  39. #include "Core/HW/DVDInterface.h"
  40. #include "Core/HW/GCKeyboard.h"
  41. #include "Core/HW/GCPad.h"
  42. #include "Core/HW/ProcessorInterface.h"
  43. #include "Core/HW/SI_Device.h"
  44. #include "Core/HW/Wiimote.h"
  45. #include "Core/HW/WiiSaveCrypted.h"
  46. #include "Core/IPC_HLE/WII_IPC_HLE_Device_usb.h"
  47. #include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h"
  48. #include "Core/PowerPC/PowerPC.h"
  49. #include "Core/PowerPC/PPCSymbolDB.h"
  50. #include "DiscIO/NANDContentLoader.h"
  51. #include "DolphinWX/AboutDolphin.h"
  52. #include "DolphinWX/ControllerConfigDiag.h"
  53. #include "DolphinWX/FifoPlayerDlg.h"
  54. #include "DolphinWX/Frame.h"
  55. #include "DolphinWX/GameListCtrl.h"
  56. #include "DolphinWX/Globals.h"
  57. #include "DolphinWX/InputConfigDiag.h"
  58. #include "DolphinWX/ISOFile.h"
  59. #include "DolphinWX/LogWindow.h"
  60. #include "DolphinWX/MemcardManager.h"
  61. #include "DolphinWX/TASInputDlg.h"
  62. #include "DolphinWX/WXInputBase.h"
  63. #include "DolphinWX/WxUtils.h"
  64. #include "DolphinWX/Cheats/CheatsWindow.h"
  65. #include "DolphinWX/Config/ConfigMain.h"
  66. #include "DolphinWX/Debugger/BreakpointWindow.h"
  67. #include "DolphinWX/Debugger/CodeWindow.h"
  68. #include "DolphinWX/Debugger/WatchWindow.h"
  69. #include "DolphinWX/NetPlay/NetPlaySetupFrame.h"
  70. #include "DolphinWX/NetPlay/NetWindow.h"
  71. #include "InputCommon/ControllerInterface/ControllerInterface.h"
  72. #include "VideoBackends/Software/SWVideoConfig.h"
  73. #include "VideoCommon/VideoBackendBase.h"
  74. #include "VideoCommon/VideoConfig.h"
  75. #ifdef _WIN32
  76. #ifndef SM_XVIRTUALSCREEN
  77. #define SM_XVIRTUALSCREEN 76
  78. #endif
  79. #ifndef SM_YVIRTUALSCREEN
  80. #define SM_YVIRTUALSCREEN 77
  81. #endif
  82. #ifndef SM_CXVIRTUALSCREEN
  83. #define SM_CXVIRTUALSCREEN 78
  84. #endif
  85. #ifndef SM_CYVIRTUALSCREEN
  86. #define SM_CYVIRTUALSCREEN 79
  87. #endif
  88. #endif
  89. // Resources
  90. extern "C" {
  91. #include "DolphinWX/resources/Dolphin.c" // NOLINT: Dolphin icon
  92. };
  93. class InputConfig;
  94. class wxFrame;
  95. // This override allows returning a fake menubar object while removing the real one from the screen
  96. wxMenuBar* CFrame::GetMenuBar() const
  97. {
  98. if (m_frameMenuBar)
  99. {
  100. return m_frameMenuBar;
  101. }
  102. else
  103. {
  104. return m_menubar_shadow;
  105. }
  106. }
  107. // Create menu items
  108. // ---------------------
  109. wxMenuBar* CFrame::CreateMenu()
  110. {
  111. wxMenuBar* menubar = new wxMenuBar();
  112. // file menu
  113. wxMenu* fileMenu = new wxMenu;
  114. fileMenu->Append(wxID_OPEN, GetMenuLabel(HK_OPEN));
  115. fileMenu->Append(IDM_CHANGE_DISC, GetMenuLabel(HK_CHANGE_DISC));
  116. wxMenu *externalDrive = new wxMenu;
  117. fileMenu->Append(IDM_DRIVES, _("&Boot from DVD Backup..."), externalDrive);
  118. drives = cdio_get_devices();
  119. // Windows Limitation of 24 character drives
  120. for (unsigned int i = 0; i < drives.size() && i < 24; i++)
  121. {
  122. externalDrive->Append(IDM_DRIVE1 + i, StrToWxStr(drives[i]));
  123. }
  124. fileMenu->AppendSeparator();
  125. fileMenu->Append(wxID_REFRESH, GetMenuLabel(HK_REFRESH_LIST));
  126. fileMenu->AppendSeparator();
  127. fileMenu->Append(IDM_BROWSE, _("&Browse for ISOs..."));
  128. fileMenu->AppendSeparator();
  129. fileMenu->Append(wxID_EXIT, _("E&xit") + wxString("\tAlt+F4"));
  130. menubar->Append(fileMenu, _("&File"));
  131. // Emulation menu
  132. wxMenu* emulationMenu = new wxMenu;
  133. emulationMenu->Append(IDM_PLAY, GetMenuLabel(HK_PLAY_PAUSE));
  134. emulationMenu->Append(IDM_STOP, GetMenuLabel(HK_STOP));
  135. emulationMenu->Append(IDM_RESET, GetMenuLabel(HK_RESET));
  136. emulationMenu->AppendSeparator();
  137. emulationMenu->Append(IDM_TOGGLE_FULLSCREEN, GetMenuLabel(HK_FULLSCREEN));
  138. emulationMenu->Append(IDM_FRAMESTEP, GetMenuLabel(HK_FRAME_ADVANCE), wxEmptyString);
  139. wxMenu *skippingMenu = new wxMenu;
  140. emulationMenu->AppendSubMenu(skippingMenu, _("Frame S&kipping"));
  141. for (int i = 0; i < 10; i++)
  142. skippingMenu->AppendRadioItem(IDM_FRAME_SKIP_0 + i, wxString::Format("%i", i));
  143. skippingMenu->Check(IDM_FRAME_SKIP_0 + SConfig::GetInstance().m_FrameSkip, true);
  144. Movie::SetFrameSkipping(SConfig::GetInstance().m_FrameSkip);
  145. emulationMenu->AppendSeparator();
  146. emulationMenu->Append(IDM_SCREENSHOT, GetMenuLabel(HK_SCREENSHOT));
  147. emulationMenu->AppendSeparator();
  148. wxMenu *saveMenu = new wxMenu;
  149. wxMenu *loadMenu = new wxMenu;
  150. wxMenu *slotSelectMenu = new wxMenu;
  151. emulationMenu->Append(IDM_LOAD_STATE, _("&Load State"), loadMenu);
  152. emulationMenu->Append(IDM_SAVE_STATE, _("Sa&ve State"), saveMenu);
  153. emulationMenu->Append(IDM_SELECT_SLOT, _("Select State slot"), slotSelectMenu);
  154. saveMenu->Append(IDM_SAVE_STATE_FILE, GetMenuLabel(HK_SAVE_STATE_FILE));
  155. saveMenu->Append(IDM_SAVE_SELECTED_SLOT, GetMenuLabel(HK_SAVE_STATE_SLOT_SELECTED));
  156. saveMenu->Append(IDM_SAVE_FIRST_STATE, GetMenuLabel(HK_SAVE_FIRST_STATE));
  157. saveMenu->Append(IDM_UNDO_SAVE_STATE, GetMenuLabel(HK_UNDO_SAVE_STATE));
  158. saveMenu->AppendSeparator();
  159. loadMenu->Append(IDM_LOAD_STATE_FILE, GetMenuLabel(HK_LOAD_STATE_FILE));
  160. loadMenu->Append(IDM_LOAD_SELECTED_SLOT, GetMenuLabel(HK_LOAD_STATE_SLOT_SELECTED));
  161. loadMenu->Append(IDM_UNDO_LOAD_STATE, GetMenuLabel(HK_UNDO_LOAD_STATE));
  162. loadMenu->AppendSeparator();
  163. for (unsigned int i = 0; i < State::NUM_STATES; i++)
  164. {
  165. loadMenu->Append(IDM_LOAD_SLOT_1 + i, GetMenuLabel(HK_LOAD_STATE_SLOT_1 + i));
  166. saveMenu->Append(IDM_SAVE_SLOT_1 + i, GetMenuLabel(HK_SAVE_STATE_SLOT_1 + i));
  167. slotSelectMenu->Append(IDM_SELECT_SLOT_1 + i, GetMenuLabel(HK_SELECT_STATE_SLOT_1 + i));
  168. }
  169. loadMenu->AppendSeparator();
  170. for (unsigned int i = 0; i < State::NUM_STATES; i++)
  171. loadMenu->Append(IDM_LOAD_LAST_1 + i, GetMenuLabel(HK_LOAD_LAST_STATE_1 + i));
  172. menubar->Append(emulationMenu, _("&Emulation"));
  173. // Movie menu
  174. wxMenu* movieMenu = new wxMenu;
  175. movieMenu->Append(IDM_RECORD, GetMenuLabel(HK_START_RECORDING));
  176. movieMenu->Append(IDM_PLAY_RECORD, GetMenuLabel(HK_PLAY_RECORDING));
  177. movieMenu->Append(IDM_RECORD_EXPORT, GetMenuLabel(HK_EXPORT_RECORDING));
  178. movieMenu->Append(IDM_RECORD_READ_ONLY, GetMenuLabel(HK_READ_ONLY_MODE), wxEmptyString, wxITEM_CHECK);
  179. movieMenu->Append(IDM_TAS_INPUT, _("TAS Input"));
  180. movieMenu->AppendSeparator();
  181. movieMenu->AppendCheckItem(IDM_TOGGLE_PAUSE_MOVIE, _("Pause at End of Movie"));
  182. movieMenu->Check(IDM_TOGGLE_PAUSE_MOVIE, SConfig::GetInstance().m_PauseMovie);
  183. movieMenu->AppendCheckItem(IDM_SHOW_LAG, _("Show Lag Counter"));
  184. movieMenu->Check(IDM_SHOW_LAG, SConfig::GetInstance().m_ShowLag);
  185. movieMenu->AppendCheckItem(IDM_SHOW_FRAME_COUNT, _("Show Frame Counter"));
  186. movieMenu->Check(IDM_SHOW_FRAME_COUNT, SConfig::GetInstance().m_ShowFrameCount);
  187. movieMenu->Check(IDM_RECORD_READ_ONLY, true);
  188. movieMenu->AppendCheckItem(IDM_SHOW_INPUT_DISPLAY, _("Show Input Display"));
  189. movieMenu->Check(IDM_SHOW_INPUT_DISPLAY, SConfig::GetInstance().m_ShowInputDisplay);
  190. movieMenu->AppendSeparator();
  191. movieMenu->AppendCheckItem(IDM_TOGGLE_DUMP_FRAMES, _("Dump Frames"));
  192. movieMenu->Check(IDM_TOGGLE_DUMP_FRAMES, SConfig::GetInstance().m_DumpFrames);
  193. movieMenu->AppendCheckItem(IDM_TOGGLE_DUMP_AUDIO, _("Dump Audio"));
  194. movieMenu->Check(IDM_TOGGLE_DUMP_AUDIO, SConfig::GetInstance().m_DumpAudio);
  195. menubar->Append(movieMenu, _("&Movie"));
  196. // Options menu
  197. wxMenu* pOptionsMenu = new wxMenu;
  198. pOptionsMenu->Append(wxID_PREFERENCES, _("Co&nfigure..."));
  199. pOptionsMenu->AppendSeparator();
  200. pOptionsMenu->Append(IDM_CONFIG_GFX_BACKEND, _("&Graphics Settings"));
  201. pOptionsMenu->Append(IDM_CONFIG_AUDIO, _("&Audio Settings"));
  202. pOptionsMenu->Append(IDM_CONFIG_CONTROLLERS, _("&Controller Settings"));
  203. pOptionsMenu->Append(IDM_CONFIG_HOTKEYS, _("&Hotkey Settings"));
  204. if (g_pCodeWindow)
  205. {
  206. pOptionsMenu->AppendSeparator();
  207. g_pCodeWindow->CreateMenuOptions(pOptionsMenu);
  208. }
  209. menubar->Append(pOptionsMenu, _("&Options"));
  210. // Tools menu
  211. wxMenu* toolsMenu = new wxMenu;
  212. toolsMenu->Append(IDM_MEMCARD, _("&Memcard Manager (GC)"));
  213. toolsMenu->Append(IDM_IMPORT_SAVE, _("Import Wii Save"));
  214. toolsMenu->Append(IDM_EXPORT_ALL_SAVE, _("Export All Wii Saves"));
  215. toolsMenu->Append(IDM_CHEATS, _("&Cheat Manager"));
  216. toolsMenu->Append(IDM_NETPLAY, _("Start &NetPlay"));
  217. toolsMenu->Append(IDM_MENU_INSTALL_WAD, _("Install WAD"));
  218. UpdateWiiMenuChoice(toolsMenu->Append(IDM_LOAD_WII_MENU, "Dummy string to keep wxw happy"));
  219. toolsMenu->Append(IDM_FIFOPLAYER, _("Fifo Player"));
  220. toolsMenu->AppendSeparator();
  221. wxMenu* wiimoteMenu = new wxMenu;
  222. toolsMenu->AppendSubMenu(wiimoteMenu, _("Connect Wiimotes"));
  223. wiimoteMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE1, GetMenuLabel(HK_WIIMOTE1_CONNECT));
  224. wiimoteMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE2, GetMenuLabel(HK_WIIMOTE2_CONNECT));
  225. wiimoteMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE3, GetMenuLabel(HK_WIIMOTE3_CONNECT));
  226. wiimoteMenu->AppendCheckItem(IDM_CONNECT_WIIMOTE4, GetMenuLabel(HK_WIIMOTE4_CONNECT));
  227. wiimoteMenu->AppendSeparator();
  228. wiimoteMenu->AppendCheckItem(IDM_CONNECT_BALANCEBOARD, GetMenuLabel(HK_BALANCEBOARD_CONNECT));
  229. menubar->Append(toolsMenu, _("&Tools"));
  230. wxMenu* viewMenu = new wxMenu;
  231. viewMenu->AppendCheckItem(IDM_TOGGLE_TOOLBAR, _("Show &Toolbar"));
  232. viewMenu->Check(IDM_TOGGLE_TOOLBAR, SConfig::GetInstance().m_InterfaceToolbar);
  233. viewMenu->AppendCheckItem(IDM_TOGGLE_STATUSBAR, _("Show &Statusbar"));
  234. viewMenu->Check(IDM_TOGGLE_STATUSBAR, SConfig::GetInstance().m_InterfaceStatusbar);
  235. viewMenu->AppendSeparator();
  236. viewMenu->AppendCheckItem(IDM_LOG_WINDOW, _("Show &Log"));
  237. viewMenu->AppendCheckItem(IDM_LOG_CONFIG_WINDOW, _("Show Log &Configuration"));
  238. viewMenu->AppendSeparator();
  239. if (g_pCodeWindow)
  240. {
  241. viewMenu->Check(IDM_LOG_WINDOW, g_pCodeWindow->bShowOnStart[0]);
  242. static const wxString menu_text[] = {
  243. _("&Registers"),
  244. _("&Watch"),
  245. _("&Breakpoints"),
  246. _("&Memory"),
  247. _("&JIT"),
  248. _("&Sound"),
  249. _("&Video")
  250. };
  251. for (int i = IDM_REGISTER_WINDOW; i <= IDM_VIDEO_WINDOW; i++)
  252. {
  253. viewMenu->AppendCheckItem(i, menu_text[i - IDM_REGISTER_WINDOW]);
  254. viewMenu->Check(i, g_pCodeWindow->bShowOnStart[i - IDM_LOG_WINDOW]);
  255. }
  256. viewMenu->AppendSeparator();
  257. }
  258. else
  259. {
  260. viewMenu->Check(IDM_LOG_WINDOW, SConfig::GetInstance().m_InterfaceLogWindow);
  261. viewMenu->Check(IDM_LOG_CONFIG_WINDOW, SConfig::GetInstance().m_InterfaceLogConfigWindow);
  262. }
  263. wxMenu *platformMenu = new wxMenu;
  264. viewMenu->AppendSubMenu(platformMenu, _("Show Platforms"));
  265. platformMenu->AppendCheckItem(IDM_LIST_WII, _("Show Wii"));
  266. platformMenu->Check(IDM_LIST_WII, SConfig::GetInstance().m_ListWii);
  267. platformMenu->AppendCheckItem(IDM_LIST_GC, _("Show GameCube"));
  268. platformMenu->Check(IDM_LIST_GC, SConfig::GetInstance().m_ListGC);
  269. platformMenu->AppendCheckItem(IDM_LIST_WAD, _("Show Wad"));
  270. platformMenu->Check(IDM_LIST_WAD, SConfig::GetInstance().m_ListWad);
  271. wxMenu *regionMenu = new wxMenu;
  272. viewMenu->AppendSubMenu(regionMenu, _("Show Regions"));
  273. regionMenu->AppendCheckItem(IDM_LIST_JAP, _("Show JAP"));
  274. regionMenu->Check(IDM_LIST_JAP, SConfig::GetInstance().m_ListJap);
  275. regionMenu->AppendCheckItem(IDM_LIST_PAL, _("Show PAL"));
  276. regionMenu->Check(IDM_LIST_PAL, SConfig::GetInstance().m_ListPal);
  277. regionMenu->AppendCheckItem(IDM_LIST_USA, _("Show USA"));
  278. regionMenu->Check(IDM_LIST_USA, SConfig::GetInstance().m_ListUsa);
  279. regionMenu->AppendSeparator();
  280. regionMenu->AppendCheckItem(IDM_LIST_AUSTRALIA, _("Show Australia"));
  281. regionMenu->Check(IDM_LIST_AUSTRALIA, SConfig::GetInstance().m_ListAustralia);
  282. regionMenu->AppendCheckItem(IDM_LIST_FRANCE, _("Show France"));
  283. regionMenu->Check(IDM_LIST_FRANCE, SConfig::GetInstance().m_ListFrance);
  284. regionMenu->AppendCheckItem(IDM_LIST_GERMANY, _("Show Germany"));
  285. regionMenu->Check(IDM_LIST_GERMANY, SConfig::GetInstance().m_ListGermany);
  286. regionMenu->AppendCheckItem(IDM_LIST_ITALY, _("Show Italy"));
  287. regionMenu->Check(IDM_LIST_ITALY, SConfig::GetInstance().m_ListItaly);
  288. regionMenu->AppendCheckItem(IDM_LIST_KOREA, _("Show Korea"));
  289. regionMenu->Check(IDM_LIST_KOREA, SConfig::GetInstance().m_ListKorea);
  290. regionMenu->AppendCheckItem(IDM_LIST_NETHERLANDS, _("Show Netherlands"));
  291. regionMenu->Check(IDM_LIST_NETHERLANDS, SConfig::GetInstance().m_ListNetherlands);
  292. regionMenu->AppendCheckItem(IDM_LIST_RUSSIA, _("Show Russia"));
  293. regionMenu->Check(IDM_LIST_RUSSIA, SConfig::GetInstance().m_ListRussia);
  294. regionMenu->AppendCheckItem(IDM_LIST_SPAIN, _("Show Spain"));
  295. regionMenu->Check(IDM_LIST_SPAIN, SConfig::GetInstance().m_ListSpain);
  296. regionMenu->AppendCheckItem(IDM_LIST_TAIWAN, _("Show Taiwan"));
  297. regionMenu->Check(IDM_LIST_TAIWAN, SConfig::GetInstance().m_ListTaiwan);
  298. regionMenu->AppendCheckItem(IDM_LIST_WORLD, _("Show World"));
  299. regionMenu->Check(IDM_LIST_WORLD, SConfig::GetInstance().m_ListWorld);
  300. regionMenu->AppendCheckItem(IDM_LIST_UNKNOWN, _("Show Unknown"));
  301. regionMenu->Check(IDM_LIST_UNKNOWN, SConfig::GetInstance().m_ListUnknown);
  302. viewMenu->AppendCheckItem(IDM_LIST_DRIVES, _("Show Drives"));
  303. viewMenu->Check(IDM_LIST_DRIVES, SConfig::GetInstance().m_ListDrives);
  304. viewMenu->Append(IDM_PURGE_CACHE, _("Purge Cache"));
  305. wxMenu *columnsMenu = new wxMenu;
  306. viewMenu->AppendSubMenu(columnsMenu, _("Select Columns"));
  307. columnsMenu->AppendCheckItem(IDM_SHOW_SYSTEM, _("Platform"));
  308. columnsMenu->Check(IDM_SHOW_SYSTEM, SConfig::GetInstance().m_showSystemColumn);
  309. columnsMenu->AppendCheckItem(IDM_SHOW_BANNER, _("Banner"));
  310. columnsMenu->Check(IDM_SHOW_BANNER, SConfig::GetInstance().m_showBannerColumn);
  311. columnsMenu->AppendCheckItem(IDM_SHOW_MAKER, _("Maker"));
  312. columnsMenu->Check(IDM_SHOW_MAKER, SConfig::GetInstance().m_showMakerColumn);
  313. columnsMenu->AppendCheckItem(IDM_SHOW_ID, _("Game ID"));
  314. columnsMenu->Check(IDM_SHOW_ID, SConfig::GetInstance().m_showIDColumn);
  315. columnsMenu->AppendCheckItem(IDM_SHOW_REGION, _("Region"));
  316. columnsMenu->Check(IDM_SHOW_REGION, SConfig::GetInstance().m_showRegionColumn);
  317. columnsMenu->AppendCheckItem(IDM_SHOW_SIZE, _("File Size"));
  318. columnsMenu->Check(IDM_SHOW_SIZE, SConfig::GetInstance().m_showSizeColumn);
  319. columnsMenu->AppendCheckItem(IDM_SHOW_STATE, _("State"));
  320. columnsMenu->Check(IDM_SHOW_STATE, SConfig::GetInstance().m_showStateColumn);
  321. menubar->Append(viewMenu, _("&View"));
  322. if (g_pCodeWindow)
  323. {
  324. g_pCodeWindow->CreateMenu(SConfig::GetInstance().m_LocalCoreStartupParameter, menubar);
  325. }
  326. // Help menu
  327. wxMenu* helpMenu = new wxMenu;
  328. // Re-enable when there's something useful to display */
  329. // helpMenu->Append(wxID_HELP, _("&Help"));
  330. helpMenu->Append(IDM_HELP_WEBSITE, _("&Website"));
  331. helpMenu->Append(IDM_HELP_ONLINE_DOCS, _("Online &Documentation"));
  332. helpMenu->Append(IDM_HELP_GITHUB, _("&GitHub Repository"));
  333. helpMenu->AppendSeparator();
  334. helpMenu->Append(wxID_ABOUT, _("&About..."));
  335. menubar->Append(helpMenu, _("&Help"));
  336. return menubar;
  337. }
  338. wxString CFrame::GetMenuLabel(int Id)
  339. {
  340. wxString Label;
  341. switch (Id)
  342. {
  343. case HK_OPEN:
  344. Label = _("&Open...");
  345. break;
  346. case HK_CHANGE_DISC:
  347. Label = _("Change &Disc...");
  348. break;
  349. case HK_REFRESH_LIST:
  350. Label = _("&Refresh List");
  351. break;
  352. case HK_PLAY_PAUSE:
  353. if (Core::GetState() == Core::CORE_RUN)
  354. Label = _("&Pause");
  355. else
  356. Label = _("&Play");
  357. break;
  358. case HK_STOP:
  359. Label = _("&Stop");
  360. break;
  361. case HK_RESET:
  362. Label = _("&Reset");
  363. break;
  364. case HK_FRAME_ADVANCE:
  365. Label = _("&Frame Advance");
  366. break;
  367. case HK_START_RECORDING:
  368. Label = _("Start Re&cording Input");
  369. break;
  370. case HK_PLAY_RECORDING:
  371. Label = _("P&lay Input Recording...");
  372. break;
  373. case HK_EXPORT_RECORDING:
  374. Label = _("Export Recording...");
  375. break;
  376. case HK_READ_ONLY_MODE:
  377. Label = _("&Read-Only Mode");
  378. break;
  379. case HK_FULLSCREEN:
  380. Label = _("&Fullscreen");
  381. break;
  382. case HK_SCREENSHOT:
  383. Label = _("Take Screenshot");
  384. break;
  385. case HK_EXIT:
  386. Label = _("Exit");
  387. break;
  388. case HK_WIIMOTE1_CONNECT:
  389. case HK_WIIMOTE2_CONNECT:
  390. case HK_WIIMOTE3_CONNECT:
  391. case HK_WIIMOTE4_CONNECT:
  392. Label = wxString::Format(_("Connect Wiimote %i"),
  393. Id - HK_WIIMOTE1_CONNECT + 1);
  394. break;
  395. case HK_BALANCEBOARD_CONNECT:
  396. Label = _("Connect Balance Board");
  397. break;
  398. case HK_LOAD_STATE_SLOT_1:
  399. case HK_LOAD_STATE_SLOT_2:
  400. case HK_LOAD_STATE_SLOT_3:
  401. case HK_LOAD_STATE_SLOT_4:
  402. case HK_LOAD_STATE_SLOT_5:
  403. case HK_LOAD_STATE_SLOT_6:
  404. case HK_LOAD_STATE_SLOT_7:
  405. case HK_LOAD_STATE_SLOT_8:
  406. case HK_LOAD_STATE_SLOT_9:
  407. case HK_LOAD_STATE_SLOT_10:
  408. Label = wxString::Format(_("Slot %i"),
  409. Id - HK_LOAD_STATE_SLOT_1 + 1);
  410. break;
  411. case HK_SAVE_STATE_SLOT_1:
  412. case HK_SAVE_STATE_SLOT_2:
  413. case HK_SAVE_STATE_SLOT_3:
  414. case HK_SAVE_STATE_SLOT_4:
  415. case HK_SAVE_STATE_SLOT_5:
  416. case HK_SAVE_STATE_SLOT_6:
  417. case HK_SAVE_STATE_SLOT_7:
  418. case HK_SAVE_STATE_SLOT_8:
  419. case HK_SAVE_STATE_SLOT_9:
  420. case HK_SAVE_STATE_SLOT_10:
  421. Label = wxString::Format(_("Slot %i"),
  422. Id - HK_SAVE_STATE_SLOT_1 + 1);
  423. break;
  424. case HK_SAVE_STATE_FILE:
  425. Label = _("Save State...");
  426. break;
  427. case HK_LOAD_LAST_STATE_1:
  428. case HK_LOAD_LAST_STATE_2:
  429. case HK_LOAD_LAST_STATE_3:
  430. case HK_LOAD_LAST_STATE_4:
  431. case HK_LOAD_LAST_STATE_5:
  432. case HK_LOAD_LAST_STATE_6:
  433. case HK_LOAD_LAST_STATE_7:
  434. case HK_LOAD_LAST_STATE_8:
  435. Label = wxString::Format(_("Last %i"),
  436. Id - HK_LOAD_LAST_STATE_1 + 1);
  437. break;
  438. case HK_LOAD_STATE_FILE:
  439. Label = _("Load State...");
  440. break;
  441. case HK_SAVE_FIRST_STATE: Label = _("Save Oldest State"); break;
  442. case HK_UNDO_LOAD_STATE: Label = _("Undo Load State"); break;
  443. case HK_UNDO_SAVE_STATE: Label = _("Undo Save State"); break;
  444. case HK_SAVE_STATE_SLOT_SELECTED:
  445. Label = _("Save state to selected slot");
  446. break;
  447. case HK_LOAD_STATE_SLOT_SELECTED:
  448. Label = _("Load state from selected slot");
  449. break;
  450. case HK_SELECT_STATE_SLOT_1:
  451. case HK_SELECT_STATE_SLOT_2:
  452. case HK_SELECT_STATE_SLOT_3:
  453. case HK_SELECT_STATE_SLOT_4:
  454. case HK_SELECT_STATE_SLOT_5:
  455. case HK_SELECT_STATE_SLOT_6:
  456. case HK_SELECT_STATE_SLOT_7:
  457. case HK_SELECT_STATE_SLOT_8:
  458. case HK_SELECT_STATE_SLOT_9:
  459. case HK_SELECT_STATE_SLOT_10:
  460. Label = wxString::Format(_("Select Slot %i"), Id - HK_SELECT_STATE_SLOT_1 + 1);
  461. break;
  462. default:
  463. Label = wxString::Format(_("Undefined %i"), Id);
  464. }
  465. return Label;
  466. }
  467. // Create toolbar items
  468. // ---------------------
  469. void CFrame::PopulateToolbar(wxToolBar* ToolBar)
  470. {
  471. int w = m_Bitmaps[Toolbar_FileOpen].GetWidth(),
  472. h = m_Bitmaps[Toolbar_FileOpen].GetHeight();
  473. ToolBar->SetToolBitmapSize(wxSize(w, h));
  474. WxUtils::AddToolbarButton(ToolBar, wxID_OPEN, _("Open"), m_Bitmaps[Toolbar_FileOpen], _("Open file..."));
  475. WxUtils::AddToolbarButton(ToolBar, wxID_REFRESH, _("Refresh"), m_Bitmaps[Toolbar_Refresh], _("Refresh game list"));
  476. WxUtils::AddToolbarButton(ToolBar, IDM_BROWSE, _("Browse"), m_Bitmaps[Toolbar_Browse], _("Browse for an ISO directory..."));
  477. ToolBar->AddSeparator();
  478. WxUtils::AddToolbarButton(ToolBar, IDM_PLAY, _("Play"), m_Bitmaps[Toolbar_Play], _("Play"));
  479. WxUtils::AddToolbarButton(ToolBar, IDM_STOP, _("Stop"), m_Bitmaps[Toolbar_Stop], _("Stop"));
  480. WxUtils::AddToolbarButton(ToolBar, IDM_TOGGLE_FULLSCREEN, _("FullScr"), m_Bitmaps[Toolbar_FullScreen], _("Toggle Fullscreen"));
  481. WxUtils::AddToolbarButton(ToolBar, IDM_SCREENSHOT, _("ScrShot"), m_Bitmaps[Toolbar_Screenshot], _("Take Screenshot"));
  482. ToolBar->AddSeparator();
  483. WxUtils::AddToolbarButton(ToolBar, wxID_PREFERENCES, _("Config"), m_Bitmaps[Toolbar_ConfigMain], _("Configure..."));
  484. WxUtils::AddToolbarButton(ToolBar, IDM_CONFIG_GFX_BACKEND, _("Graphics"), m_Bitmaps[Toolbar_ConfigGFX], _("Graphics settings"));
  485. WxUtils::AddToolbarButton(ToolBar, IDM_CONFIG_AUDIO, _("Audio"), m_Bitmaps[Toolbar_ConfigAudio], _("Audio settings"));
  486. WxUtils::AddToolbarButton(ToolBar, IDM_CONFIG_CONTROLLERS, _("Controllers"), m_Bitmaps[Toolbar_Controller], _("Controller settings"));
  487. }
  488. // Delete and recreate the toolbar
  489. void CFrame::RecreateToolbar()
  490. {
  491. static const long TOOLBAR_STYLE = wxTB_DEFAULT_STYLE | wxTB_TEXT;
  492. if (m_ToolBar != nullptr)
  493. {
  494. m_ToolBar->Destroy();
  495. m_ToolBar = nullptr;
  496. }
  497. m_ToolBar = CreateToolBar(TOOLBAR_STYLE, wxID_ANY);
  498. if (g_pCodeWindow)
  499. {
  500. g_pCodeWindow->PopulateToolbar(m_ToolBar);
  501. m_ToolBar->AddSeparator();
  502. }
  503. PopulateToolbar(m_ToolBar);
  504. // after adding the buttons to the toolbar, must call Realize() to reflect
  505. // the changes
  506. m_ToolBar->Realize();
  507. UpdateGUI();
  508. }
  509. void CFrame::InitBitmaps()
  510. {
  511. auto const dir = StrToWxStr(File::GetThemeDir(SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name));
  512. m_Bitmaps[Toolbar_FileOpen ].LoadFile(dir + "open.png", wxBITMAP_TYPE_PNG);
  513. m_Bitmaps[Toolbar_Refresh ].LoadFile(dir + "refresh.png", wxBITMAP_TYPE_PNG);
  514. m_Bitmaps[Toolbar_Browse ].LoadFile(dir + "browse.png", wxBITMAP_TYPE_PNG);
  515. m_Bitmaps[Toolbar_Play ].LoadFile(dir + "play.png", wxBITMAP_TYPE_PNG);
  516. m_Bitmaps[Toolbar_Stop ].LoadFile(dir + "stop.png", wxBITMAP_TYPE_PNG);
  517. m_Bitmaps[Toolbar_Pause ].LoadFile(dir + "pause.png", wxBITMAP_TYPE_PNG);
  518. m_Bitmaps[Toolbar_ConfigMain ].LoadFile(dir + "config.png", wxBITMAP_TYPE_PNG);
  519. m_Bitmaps[Toolbar_ConfigGFX ].LoadFile(dir + "graphics.png", wxBITMAP_TYPE_PNG);
  520. m_Bitmaps[Toolbar_ConfigAudio].LoadFile(dir + "audio.png", wxBITMAP_TYPE_PNG);
  521. m_Bitmaps[Toolbar_Controller ].LoadFile(dir + "classic.png", wxBITMAP_TYPE_PNG);
  522. m_Bitmaps[Toolbar_Screenshot ].LoadFile(dir + "screenshot.png", wxBITMAP_TYPE_PNG);
  523. m_Bitmaps[Toolbar_FullScreen ].LoadFile(dir + "fullscreen.png", wxBITMAP_TYPE_PNG);
  524. // Update in case the bitmap has been updated
  525. if (m_ToolBar != nullptr)
  526. RecreateToolbar();
  527. }
  528. // Menu items
  529. // Start the game or change the disc.
  530. // Boot priority:
  531. // 1. Show the game list and boot the selected game.
  532. // 2. Default ISO
  533. // 3. Boot last selected game
  534. void CFrame::BootGame(const std::string& filename)
  535. {
  536. std::string bootfile = filename;
  537. SCoreStartupParameter& StartUp = SConfig::GetInstance().m_LocalCoreStartupParameter;
  538. if (Core::GetState() != Core::CORE_UNINITIALIZED)
  539. return;
  540. // Start filename if non empty.
  541. // Start the selected ISO, or try one of the saved paths.
  542. // If all that fails, ask to add a dir and don't boot
  543. if (bootfile.empty())
  544. {
  545. if (m_GameListCtrl->GetSelectedISO() != nullptr)
  546. {
  547. if (m_GameListCtrl->GetSelectedISO()->IsValid())
  548. bootfile = m_GameListCtrl->GetSelectedISO()->GetFileName();
  549. }
  550. else if (!StartUp.m_strDefaultISO.empty() &&
  551. File::Exists(StartUp.m_strDefaultISO))
  552. {
  553. bootfile = StartUp.m_strDefaultISO;
  554. }
  555. else
  556. {
  557. if (!SConfig::GetInstance().m_LastFilename.empty() &&
  558. File::Exists(SConfig::GetInstance().m_LastFilename))
  559. {
  560. bootfile = SConfig::GetInstance().m_LastFilename;
  561. }
  562. else
  563. {
  564. m_GameListCtrl->BrowseForDirectory();
  565. return;
  566. }
  567. }
  568. }
  569. if (!bootfile.empty())
  570. {
  571. StartGame(bootfile);
  572. if (UseDebugger && g_pCodeWindow)
  573. {
  574. if (g_pCodeWindow->m_WatchWindow)
  575. g_pCodeWindow->m_WatchWindow->LoadAll();
  576. if (g_pCodeWindow->m_BreakpointWindow)
  577. g_pCodeWindow->m_BreakpointWindow->LoadAll();
  578. }
  579. }
  580. }
  581. // Open file to boot
  582. void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event))
  583. {
  584. if (Core::GetState() == Core::CORE_UNINITIALIZED)
  585. DoOpen(true);
  586. }
  587. void CFrame::DoOpen(bool Boot)
  588. {
  589. std::string currentDir = File::GetCurrentDir();
  590. wxString path = wxFileSelector(
  591. _("Select the file to load"),
  592. wxEmptyString, wxEmptyString, wxEmptyString,
  593. _("All GC/Wii files (elf, dol, gcm, iso, wbfs, ciso, gcz, wad)") +
  594. wxString::Format("|*.elf;*.dol;*.gcm;*.iso;*.wbfs;*.ciso;*.gcz;*.wad;*.dff;*.tmd|%s",
  595. wxGetTranslation(wxALL_FILES)),
  596. wxFD_OPEN | wxFD_FILE_MUST_EXIST,
  597. this);
  598. if (path.IsEmpty())
  599. return;
  600. std::string currentDir2 = File::GetCurrentDir();
  601. if (currentDir != currentDir2)
  602. {
  603. PanicAlertT("Current directory changed from %s to %s after wxFileSelector!",
  604. currentDir.c_str(), currentDir2.c_str());
  605. File::SetCurrentDir(currentDir);
  606. }
  607. // Should we boot a new game or just change the disc?
  608. if (Boot && !path.IsEmpty())
  609. {
  610. BootGame(WxStrToStr(path));
  611. }
  612. else
  613. {
  614. DVDInterface::ChangeDisc(WxStrToStr(path));
  615. }
  616. }
  617. void CFrame::OnRecordReadOnly(wxCommandEvent& event)
  618. {
  619. Movie::SetReadOnly(event.IsChecked());
  620. }
  621. void CFrame::OnTASInput(wxCommandEvent& event)
  622. {
  623. for (int i = 0; i < 4; ++i)
  624. {
  625. if (SConfig::GetInstance().m_SIDevice[i] != SIDEVICE_NONE && SConfig::GetInstance().m_SIDevice[i] != SIDEVICE_GC_GBA)
  626. {
  627. g_TASInputDlg[i]->CreateGCLayout();
  628. g_TASInputDlg[i]->Show();
  629. g_TASInputDlg[i]->SetTitle(wxString::Format(_("TAS Input - Controller %d"), i + 1));
  630. }
  631. if (g_wiimote_sources[i] == WIIMOTE_SRC_EMU && !(Core::IsRunning() && !SConfig::GetInstance().m_LocalCoreStartupParameter.bWii))
  632. {
  633. g_TASInputDlg[i+4]->CreateWiiLayout(i);
  634. g_TASInputDlg[i+4]->Show();
  635. g_TASInputDlg[i+4]->SetTitle(wxString::Format(_("TAS Input - Wiimote %d"), i + 1));
  636. }
  637. }
  638. }
  639. void CFrame::OnTogglePauseMovie(wxCommandEvent& WXUNUSED (event))
  640. {
  641. SConfig::GetInstance().m_PauseMovie = !SConfig::GetInstance().m_PauseMovie;
  642. SConfig::GetInstance().SaveSettings();
  643. }
  644. void CFrame::OnToggleDumpFrames(wxCommandEvent& WXUNUSED(event))
  645. {
  646. SConfig::GetInstance().m_DumpFrames = !SConfig::GetInstance().m_DumpFrames;
  647. SConfig::GetInstance().SaveSettings();
  648. }
  649. void CFrame::OnToggleDumpAudio(wxCommandEvent& WXUNUSED(event))
  650. {
  651. SConfig::GetInstance().m_DumpAudio = !SConfig::GetInstance().m_DumpAudio;
  652. }
  653. void CFrame::OnShowLag(wxCommandEvent& WXUNUSED (event))
  654. {
  655. SConfig::GetInstance().m_ShowLag = !SConfig::GetInstance().m_ShowLag;
  656. SConfig::GetInstance().SaveSettings();
  657. }
  658. void CFrame::OnShowFrameCount(wxCommandEvent& WXUNUSED (event))
  659. {
  660. SConfig::GetInstance().m_ShowFrameCount = !SConfig::GetInstance().m_ShowFrameCount;
  661. SConfig::GetInstance().SaveSettings();
  662. }
  663. void CFrame::OnShowInputDisplay(wxCommandEvent& WXUNUSED(event))
  664. {
  665. SConfig::GetInstance().m_ShowInputDisplay = !SConfig::GetInstance().m_ShowInputDisplay;
  666. SConfig::GetInstance().SaveSettings();
  667. }
  668. void CFrame::OnFrameStep(wxCommandEvent& event)
  669. {
  670. bool wasPaused = (Core::GetState() == Core::CORE_PAUSE);
  671. Movie::DoFrameStep();
  672. bool isPaused = (Core::GetState() == Core::CORE_PAUSE);
  673. if (isPaused && !wasPaused) // don't update on unpause, otherwise the status would be wrong when pausing next frame
  674. UpdateGUI();
  675. }
  676. void CFrame::OnChangeDisc(wxCommandEvent& WXUNUSED (event))
  677. {
  678. DoOpen(false);
  679. }
  680. void CFrame::OnRecord(wxCommandEvent& WXUNUSED (event))
  681. {
  682. if ((!Core::IsRunningAndStarted() && Core::IsRunning()) || Movie::IsRecordingInput() || Movie::IsPlayingInput())
  683. return;
  684. int controllers = 0;
  685. if (Movie::IsReadOnly())
  686. {
  687. // The user just chose to record a movie, so that should take precedence
  688. Movie::SetReadOnly(false);
  689. GetMenuBar()->FindItem(IDM_RECORD_READ_ONLY)->Check(false);
  690. }
  691. for (int i = 0; i < 4; i++)
  692. {
  693. if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER || SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_TARUKONGA)
  694. controllers |= (1 << i);
  695. if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE)
  696. controllers |= (1 << (i + 4));
  697. }
  698. if (Movie::BeginRecordingInput(controllers))
  699. BootGame("");
  700. }
  701. void CFrame::OnPlayRecording(wxCommandEvent& WXUNUSED (event))
  702. {
  703. wxString path = wxFileSelector(
  704. _("Select The Recording File"),
  705. wxEmptyString, wxEmptyString, wxEmptyString,
  706. _("Dolphin TAS Movies (*.dtm)") +
  707. wxString::Format("|*.dtm|%s", wxGetTranslation(wxALL_FILES)),
  708. wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
  709. this);
  710. if (path.IsEmpty())
  711. return;
  712. if (!Movie::IsReadOnly())
  713. {
  714. // let's make the read-only flag consistent at the start of a movie.
  715. Movie::SetReadOnly(true);
  716. GetMenuBar()->FindItem(IDM_RECORD_READ_ONLY)->Check();
  717. }
  718. if (Movie::PlayInput(WxStrToStr(path)))
  719. BootGame("");
  720. }
  721. void CFrame::OnRecordExport(wxCommandEvent& WXUNUSED (event))
  722. {
  723. DoRecordingSave();
  724. }
  725. void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
  726. {
  727. if (Core::IsRunning())
  728. {
  729. // Core is initialized and emulator is running
  730. if (UseDebugger)
  731. {
  732. if (CCPU::IsStepping())
  733. CCPU::EnableStepping(false);
  734. else
  735. CCPU::EnableStepping(true); // Break
  736. wxThread::Sleep(20);
  737. g_pCodeWindow->JumpToAddress(PC);
  738. g_pCodeWindow->Update();
  739. // Update toolbar with Play/Pause status
  740. UpdateGUI();
  741. }
  742. else
  743. {
  744. DoPause();
  745. }
  746. }
  747. else
  748. {
  749. // Core is uninitialized, start the game
  750. BootGame("");
  751. }
  752. }
  753. void CFrame::OnRenderParentClose(wxCloseEvent& event)
  754. {
  755. // Before closing the window we need to shut down the emulation core.
  756. // We'll try to close this window again once that is done.
  757. if (Core::GetState() != Core::CORE_UNINITIALIZED)
  758. {
  759. DoStop();
  760. if (event.CanVeto())
  761. {
  762. event.Veto();
  763. }
  764. return;
  765. }
  766. event.Skip();
  767. }
  768. void CFrame::OnRenderParentMove(wxMoveEvent& event)
  769. {
  770. if (Core::GetState() != Core::CORE_UNINITIALIZED &&
  771. !RendererIsFullscreen() && !m_RenderFrame->IsMaximized() && !m_RenderFrame->IsIconized())
  772. {
  773. SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos = m_RenderFrame->GetPosition().x;
  774. SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos = m_RenderFrame->GetPosition().y;
  775. }
  776. event.Skip();
  777. }
  778. void CFrame::OnRenderParentResize(wxSizeEvent& event)
  779. {
  780. if (Core::GetState() != Core::CORE_UNINITIALIZED)
  781. {
  782. int width, height;
  783. if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
  784. !RendererIsFullscreen() && !m_RenderFrame->IsMaximized() && !m_RenderFrame->IsIconized())
  785. {
  786. m_RenderFrame->GetClientSize(&width, &height);
  787. SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth = width;
  788. SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight = height;
  789. }
  790. m_LogWindow->Refresh();
  791. m_LogWindow->Update();
  792. }
  793. event.Skip();
  794. }
  795. void CFrame::ToggleDisplayMode(bool bFullscreen)
  796. {
  797. #ifdef _WIN32
  798. if (bFullscreen && SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution != "Auto")
  799. {
  800. DEVMODE dmScreenSettings;
  801. memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
  802. dmScreenSettings.dmSize = sizeof(dmScreenSettings);
  803. sscanf(SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution.c_str(),
  804. "%dx%d", &dmScreenSettings.dmPelsWidth, &dmScreenSettings.dmPelsHeight);
  805. dmScreenSettings.dmBitsPerPel = 32;
  806. dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
  807. // Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
  808. ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
  809. }
  810. else
  811. {
  812. // Change to default resolution
  813. ChangeDisplaySettings(nullptr, CDS_FULLSCREEN);
  814. }
  815. #elif defined(HAVE_XRANDR) && HAVE_XRANDR
  816. if (SConfig::GetInstance().m_LocalCoreStartupParameter.strFullscreenResolution != "Auto")
  817. m_XRRConfig->ToggleDisplayMode(bFullscreen);
  818. #endif
  819. }
  820. // Prepare the GUI to start the game.
  821. void CFrame::StartGame(const std::string& filename)
  822. {
  823. if (m_bGameLoading)
  824. return;
  825. m_bGameLoading = true;
  826. if (m_ToolBar)
  827. m_ToolBar->EnableTool(IDM_PLAY, false);
  828. GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);
  829. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
  830. {
  831. // Game has been started, hide the game list
  832. m_GameListCtrl->Disable();
  833. m_GameListCtrl->Hide();
  834. m_RenderParent = m_Panel;
  835. m_RenderFrame = this;
  836. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bKeepWindowOnTop)
  837. m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() | wxSTAY_ON_TOP);
  838. else
  839. m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP);
  840. // No, I really don't want TAB_TRAVERSAL being set behind my back,
  841. // thanks. (Note that calling DisableSelfFocus would prevent this flag
  842. // from being set for new children, but wouldn't reset the existing
  843. // flag.)
  844. m_RenderParent->SetWindowStyle(m_RenderParent->GetWindowStyle() & ~wxTAB_TRAVERSAL);
  845. }
  846. else
  847. {
  848. wxPoint position(SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowXPos,
  849. SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowYPos);
  850. #ifdef __APPLE__
  851. // On OS X, the render window's title bar is not visible,
  852. // and the window therefore not easily moved, when the
  853. // position is 0,0. Weed out the 0's from existing configs.
  854. if (position == wxPoint(0, 0))
  855. position = wxDefaultPosition;
  856. #endif
  857. wxSize size(SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowWidth,
  858. SConfig::GetInstance().m_LocalCoreStartupParameter.iRenderWindowHeight);
  859. #ifdef _WIN32
  860. // Out of desktop check
  861. int leftPos = GetSystemMetrics(SM_XVIRTUALSCREEN);
  862. int topPos = GetSystemMetrics(SM_YVIRTUALSCREEN);
  863. int width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
  864. int height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
  865. if ((leftPos + width) < (position.x + size.GetWidth()) || leftPos > position.x || (topPos + height) < (position.y + size.GetHeight()) || topPos > position.y)
  866. position.x = position.y = wxDefaultCoord;
  867. #endif
  868. m_RenderFrame = new CRenderFrame((wxFrame*)this, wxID_ANY, _("Dolphin"), position);
  869. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bKeepWindowOnTop)
  870. m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() | wxSTAY_ON_TOP);
  871. else
  872. m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP);
  873. m_RenderFrame->SetBackgroundColour(*wxBLACK);
  874. m_RenderFrame->SetClientSize(size.GetWidth(), size.GetHeight());
  875. m_RenderFrame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::OnRenderParentClose, this);
  876. m_RenderFrame->Bind(wxEVT_ACTIVATE, &CFrame::OnActive, this);
  877. m_RenderFrame->Bind(wxEVT_MOVE, &CFrame::OnRenderParentMove, this);
  878. #ifdef _WIN32
  879. // The renderer should use a top-level window for exclusive fullscreen support.
  880. m_RenderParent = m_RenderFrame;
  881. #else
  882. // To capture key events on Linux and Mac OS X the frame needs at least one child.
  883. m_RenderParent = new wxPanel(m_RenderFrame, IDM_MPANEL, wxDefaultPosition, wxDefaultSize, 0);
  884. #endif
  885. m_RenderFrame->Show();
  886. }
  887. #if defined(__APPLE__)
  888. NSView *view = (NSView *) m_RenderFrame->GetHandle();
  889. NSWindow *window = [view window];
  890. [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
  891. #endif
  892. wxBeginBusyCursor();
  893. DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
  894. if (!BootManager::BootCore(filename))
  895. {
  896. DoFullscreen(false);
  897. // Destroy the renderer frame when not rendering to main
  898. if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
  899. m_RenderFrame->Destroy();
  900. m_RenderParent = nullptr;
  901. m_bGameLoading = false;
  902. UpdateGUI();
  903. }
  904. else
  905. {
  906. #if defined(HAVE_X11) && HAVE_X11
  907. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver)
  908. X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()),
  909. X11Utils::XWindowFromHandle(GetHandle()), true);
  910. #endif
  911. m_RenderParent->SetFocus();
  912. wxTheApp->Bind(wxEVT_KEY_DOWN, &CFrame::OnKeyDown, this);
  913. wxTheApp->Bind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this);
  914. wxTheApp->Bind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this);
  915. wxTheApp->Bind(wxEVT_MIDDLE_DOWN, &CFrame::OnMouse, this);
  916. wxTheApp->Bind(wxEVT_MIDDLE_UP, &CFrame::OnMouse, this);
  917. wxTheApp->Bind(wxEVT_MOTION, &CFrame::OnMouse, this);
  918. wxTheApp->Bind(wxEVT_SET_FOCUS, &CFrame::OnFocusChange, this);
  919. wxTheApp->Bind(wxEVT_KILL_FOCUS, &CFrame::OnFocusChange, this);
  920. m_RenderParent->Bind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this);
  921. }
  922. wxEndBusyCursor();
  923. }
  924. void CFrame::OnBootDrive(wxCommandEvent& event)
  925. {
  926. BootGame(drives[event.GetId()-IDM_DRIVE1]);
  927. }
  928. // Refresh the file list and browse for a favorites directory
  929. void CFrame::OnRefresh(wxCommandEvent& WXUNUSED (event))
  930. {
  931. if (m_GameListCtrl)
  932. {
  933. m_GameListCtrl->Update();
  934. }
  935. }
  936. void CFrame::OnBrowse(wxCommandEvent& WXUNUSED (event))
  937. {
  938. if (m_GameListCtrl)
  939. {
  940. m_GameListCtrl->BrowseForDirectory();
  941. }
  942. }
  943. // Create screenshot
  944. void CFrame::OnScreenshot(wxCommandEvent& WXUNUSED (event))
  945. {
  946. Core::SaveScreenShot();
  947. }
  948. // Pause the emulation
  949. void CFrame::DoPause()
  950. {
  951. if (Core::GetState() == Core::CORE_RUN)
  952. {
  953. Core::SetState(Core::CORE_PAUSE);
  954. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
  955. m_RenderParent->SetCursor(wxNullCursor);
  956. Core::UpdateTitle();
  957. }
  958. else
  959. {
  960. Core::SetState(Core::CORE_RUN);
  961. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor &&
  962. RendererHasFocus())
  963. m_RenderParent->SetCursor(wxCURSOR_BLANK);
  964. }
  965. UpdateGUI();
  966. }
  967. // Stop the emulation
  968. void CFrame::DoStop()
  969. {
  970. if (!Core::IsRunningAndStarted())
  971. return;
  972. if (m_confirmStop)
  973. return;
  974. // don't let this function run again until it finishes, or is aborted.
  975. m_confirmStop = true;
  976. m_bGameLoading = false;
  977. if (Core::GetState() != Core::CORE_UNINITIALIZED ||
  978. m_RenderParent != nullptr)
  979. {
  980. #if defined __WXGTK__
  981. wxMutexGuiLeave();
  982. std::lock_guard<std::recursive_mutex> lk(keystate_lock);
  983. wxMutexGuiEnter();
  984. #endif
  985. // Ask for confirmation in case the user accidentally clicked Stop / Escape
  986. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop)
  987. {
  988. // Exit fullscreen to ensure it does not cover the stop dialog.
  989. DoFullscreen(false);
  990. // Pause the state during confirmation and restore it afterwards
  991. Core::EState state = Core::GetState();
  992. // If exclusive fullscreen is not enabled then we can pause the emulation
  993. // before we've exited fullscreen. If not then we need to exit fullscreen first.
  994. if (!RendererIsFullscreen() || !g_Config.ExclusiveFullscreenEnabled() ||
  995. SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
  996. {
  997. Core::SetState(Core::CORE_PAUSE);
  998. }
  999. wxMessageDialog m_StopDlg(
  1000. this,
  1001. _("Do you want to stop the current emulation?"),
  1002. _("Please confirm..."),
  1003. wxYES_NO | wxSTAY_ON_TOP | wxICON_EXCLAMATION,
  1004. wxDefaultPosition);
  1005. HotkeyManagerEmu::Enable(false);
  1006. int Ret = m_StopDlg.ShowModal();
  1007. HotkeyManagerEmu::Enable(true);
  1008. if (Ret != wxID_YES)
  1009. {
  1010. Core::SetState(state);
  1011. m_confirmStop = false;
  1012. return;
  1013. }
  1014. }
  1015. if (UseDebugger && g_pCodeWindow)
  1016. {
  1017. if (g_pCodeWindow->m_WatchWindow)
  1018. {
  1019. g_pCodeWindow->m_WatchWindow->SaveAll();
  1020. PowerPC::watches.Clear();
  1021. }
  1022. if (g_pCodeWindow->m_BreakpointWindow)
  1023. {
  1024. g_pCodeWindow->m_BreakpointWindow->SaveAll();
  1025. PowerPC::breakpoints.Clear();
  1026. PowerPC::memchecks.Clear();
  1027. g_pCodeWindow->m_BreakpointWindow->NotifyUpdate();
  1028. }
  1029. g_symbolDB.Clear();
  1030. Host_NotifyMapLoaded();
  1031. }
  1032. // TODO: Show the author/description dialog here
  1033. if (Movie::IsRecordingInput())
  1034. DoRecordingSave();
  1035. if (Movie::IsMovieActive())
  1036. Movie::EndPlayInput(false);
  1037. if (NetPlayDialog::GetNetPlayClient())
  1038. NetPlayDialog::GetNetPlayClient()->Stop();
  1039. BootManager::Stop();
  1040. UpdateGUI();
  1041. }
  1042. }
  1043. void CFrame::OnStopped()
  1044. {
  1045. m_confirmStop = false;
  1046. #if defined(HAVE_X11) && HAVE_X11
  1047. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bDisableScreenSaver)
  1048. X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()),
  1049. X11Utils::XWindowFromHandle(GetHandle()), false);
  1050. #endif
  1051. m_RenderFrame->SetTitle(StrToWxStr(scm_rev_str));
  1052. // Destroy the renderer frame when not rendering to main
  1053. m_RenderParent->Unbind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this);
  1054. // Mouse
  1055. wxTheApp->Unbind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this);
  1056. wxTheApp->Unbind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this);
  1057. wxTheApp->Unbind(wxEVT_MIDDLE_DOWN, &CFrame::OnMouse, this);
  1058. wxTheApp->Unbind(wxEVT_MIDDLE_UP, &CFrame::OnMouse, this);
  1059. wxTheApp->Unbind(wxEVT_MOTION, &CFrame::OnMouse, this);
  1060. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
  1061. m_RenderParent->SetCursor(wxNullCursor);
  1062. DoFullscreen(false);
  1063. if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain)
  1064. {
  1065. m_RenderFrame->Destroy();
  1066. }
  1067. else
  1068. {
  1069. #if defined(__APPLE__)
  1070. // Disable the full screen button when not in a game.
  1071. NSView *view = (NSView *)m_RenderFrame->GetHandle();
  1072. NSWindow *window = [view window];
  1073. [window setCollectionBehavior : NSWindowCollectionBehaviorDefault];
  1074. #endif
  1075. // Make sure the window is not longer set to stay on top
  1076. m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP);
  1077. }
  1078. m_RenderParent = nullptr;
  1079. // Clean framerate indications from the status bar.
  1080. GetStatusBar()->SetStatusText(" ", 0);
  1081. // Clear wiimote connection status from the status bar.
  1082. GetStatusBar()->SetStatusText(" ", 1);
  1083. // If batch mode was specified on the command-line or we were already closing, exit now.
  1084. if (m_bBatchMode || m_bClosing)
  1085. Close(true);
  1086. // If using auto size with render to main, reset the application size.
  1087. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain &&
  1088. SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderWindowAutoSize)
  1089. SetSize(SConfig::GetInstance().m_LocalCoreStartupParameter.iWidth,
  1090. SConfig::GetInstance().m_LocalCoreStartupParameter.iHeight);
  1091. m_GameListCtrl->Enable();
  1092. m_GameListCtrl->Show();
  1093. m_GameListCtrl->SetFocus();
  1094. UpdateGUI();
  1095. }
  1096. void CFrame::DoRecordingSave()
  1097. {
  1098. bool paused = (Core::GetState() == Core::CORE_PAUSE);
  1099. if (!paused)
  1100. DoPause();
  1101. wxString path = wxFileSelector(
  1102. _("Select The Recording File"),
  1103. wxEmptyString, wxEmptyString, wxEmptyString,
  1104. _("Dolphin TAS Movies (*.dtm)") +
  1105. wxString::Format("|*.dtm|%s", wxGetTranslation(wxALL_FILES)),
  1106. wxFD_SAVE | wxFD_PREVIEW | wxFD_OVERWRITE_PROMPT,
  1107. this);
  1108. if (path.IsEmpty())
  1109. return;
  1110. Movie::SaveRecording(WxStrToStr(path));
  1111. if (!paused)
  1112. DoPause();
  1113. }
  1114. void CFrame::OnStop(wxCommandEvent& WXUNUSED (event))
  1115. {
  1116. DoStop();
  1117. }
  1118. void CFrame::OnReset(wxCommandEvent& WXUNUSED (event))
  1119. {
  1120. if (Movie::IsRecordingInput())
  1121. Movie::g_bReset = true;
  1122. ProcessorInterface::ResetButton_Tap();
  1123. }
  1124. void CFrame::OnConfigMain(wxCommandEvent& WXUNUSED (event))
  1125. {
  1126. CConfigMain ConfigMain(this);
  1127. HotkeyManagerEmu::Enable(false);
  1128. if (ConfigMain.ShowModal() == wxID_OK)
  1129. m_GameListCtrl->Update();
  1130. HotkeyManagerEmu::Enable(true);
  1131. UpdateGUI();
  1132. }
  1133. void CFrame::OnConfigGFX(wxCommandEvent& WXUNUSED (event))
  1134. {
  1135. HotkeyManagerEmu::Enable(false);
  1136. if (g_video_backend)
  1137. g_video_backend->ShowConfig(this);
  1138. HotkeyManagerEmu::Enable(true);
  1139. }
  1140. void CFrame::OnConfigAudio(wxCommandEvent& WXUNUSED (event))
  1141. {
  1142. CConfigMain ConfigMain(this);
  1143. ConfigMain.SetSelectedTab(CConfigMain::ID_AUDIOPAGE);
  1144. HotkeyManagerEmu::Enable(false);
  1145. if (ConfigMain.ShowModal() == wxID_OK)
  1146. m_GameListCtrl->Update();
  1147. HotkeyManagerEmu::Enable(true);
  1148. }
  1149. void CFrame::OnConfigControllers(wxCommandEvent& WXUNUSED (event))
  1150. {
  1151. ControllerConfigDiag config_dlg(this);
  1152. HotkeyManagerEmu::Enable(false);
  1153. config_dlg.ShowModal();
  1154. HotkeyManagerEmu::Enable(true);
  1155. }
  1156. void CFrame::OnConfigHotkey(wxCommandEvent& WXUNUSED (event))
  1157. {
  1158. InputConfig* const hotkey_plugin = HotkeyManagerEmu::GetConfig();
  1159. // check if game is running
  1160. bool game_running = false;
  1161. if (Core::GetState() == Core::CORE_RUN)
  1162. {
  1163. Core::SetState(Core::CORE_PAUSE);
  1164. game_running = true;
  1165. }
  1166. HotkeyManagerEmu::Enable(false);
  1167. InputConfigDialog m_ConfigFrame(this, *hotkey_plugin, _("Dolphin Hotkeys"));
  1168. m_ConfigFrame.ShowModal();
  1169. // Update references in case controllers were refreshed
  1170. Wiimote::LoadConfig();
  1171. Keyboard::LoadConfig();
  1172. Pad::LoadConfig();
  1173. HotkeyManagerEmu::LoadConfig();
  1174. HotkeyManagerEmu::Enable(true);
  1175. // if game isn't running
  1176. if (game_running)
  1177. {
  1178. Core::SetState(Core::CORE_RUN);
  1179. }
  1180. // Update the GUI in case menu accelerators were changed
  1181. UpdateGUI();
  1182. }
  1183. void CFrame::OnHelp(wxCommandEvent& event)
  1184. {
  1185. switch (event.GetId())
  1186. {
  1187. case wxID_ABOUT:
  1188. {
  1189. AboutDolphin frame(this);
  1190. HotkeyManagerEmu::Enable(false);
  1191. frame.ShowModal();
  1192. HotkeyManagerEmu::Enable(true);
  1193. }
  1194. break;
  1195. case IDM_HELP_WEBSITE:
  1196. WxUtils::Launch("https://dolphin-emu.org/");
  1197. break;
  1198. case IDM_HELP_ONLINE_DOCS:
  1199. WxUtils::Launch("https://dolphin-emu.org/docs/guides/");
  1200. break;
  1201. case IDM_HELP_GITHUB:
  1202. WxUtils::Launch("https://github.com/dolphin-emu/dolphin");
  1203. break;
  1204. }
  1205. }
  1206. void CFrame::ClearStatusBar()
  1207. {
  1208. if (this->GetStatusBar()->IsEnabled())
  1209. {
  1210. this->GetStatusBar()->SetStatusText("", 0);
  1211. }
  1212. }
  1213. void CFrame::StatusBarMessage(const char * Text, ...)
  1214. {
  1215. const int MAX_BYTES = 1024 * 10;
  1216. char Str[MAX_BYTES];
  1217. va_list ArgPtr;
  1218. va_start(ArgPtr, Text);
  1219. vsnprintf(Str, MAX_BYTES, Text, ArgPtr);
  1220. va_end(ArgPtr);
  1221. if (this->GetStatusBar()->IsEnabled())
  1222. {
  1223. this->GetStatusBar()->SetStatusText(StrToWxStr(Str), 0);
  1224. }
  1225. }
  1226. // Miscellaneous menus
  1227. // ---------------------
  1228. // NetPlay stuff
  1229. void CFrame::OnNetPlay(wxCommandEvent& WXUNUSED (event))
  1230. {
  1231. if (!g_NetPlaySetupDiag)
  1232. {
  1233. if (NetPlayDialog::GetInstance() != nullptr)
  1234. NetPlayDialog::GetInstance()->Raise();
  1235. else
  1236. g_NetPlaySetupDiag = new NetPlaySetupFrame(this, m_GameListCtrl);
  1237. }
  1238. else
  1239. {
  1240. g_NetPlaySetupDiag->Raise();
  1241. }
  1242. }
  1243. void CFrame::OnMemcard(wxCommandEvent& WXUNUSED (event))
  1244. {
  1245. CMemcardManager MemcardManager(this);
  1246. HotkeyManagerEmu::Enable(false);
  1247. MemcardManager.ShowModal();
  1248. HotkeyManagerEmu::Enable(true);
  1249. }
  1250. void CFrame::OnExportAllSaves(wxCommandEvent& WXUNUSED (event))
  1251. {
  1252. CWiiSaveCrypted::ExportAllSaves();
  1253. }
  1254. void CFrame::OnImportSave(wxCommandEvent& WXUNUSED (event))
  1255. {
  1256. wxString path = wxFileSelector(_("Select the save file"),
  1257. wxEmptyString, wxEmptyString, wxEmptyString,
  1258. _("Wii save files (*.bin)|*.bin"),
  1259. wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
  1260. this);
  1261. if (!path.IsEmpty())
  1262. {
  1263. CWiiSaveCrypted::ImportWiiSave(WxStrToStr(path));
  1264. }
  1265. }
  1266. void CFrame::OnShowCheatsWindow(wxCommandEvent& WXUNUSED (event))
  1267. {
  1268. if (!g_CheatsWindow)
  1269. g_CheatsWindow = new wxCheatsWindow(this);
  1270. else
  1271. g_CheatsWindow->Raise();
  1272. }
  1273. void CFrame::OnLoadWiiMenu(wxCommandEvent& WXUNUSED(event))
  1274. {
  1275. BootGame(Common::GetTitleContentPath(TITLEID_SYSMENU));
  1276. }
  1277. void CFrame::OnInstallWAD(wxCommandEvent& event)
  1278. {
  1279. std::string fileName;
  1280. switch (event.GetId())
  1281. {
  1282. case IDM_LIST_INSTALL_WAD:
  1283. {
  1284. const GameListItem *iso = m_GameListCtrl->GetSelectedISO();
  1285. if (!iso)
  1286. return;
  1287. fileName = iso->GetFileName();
  1288. break;
  1289. }
  1290. case IDM_MENU_INSTALL_WAD:
  1291. {
  1292. wxString path = wxFileSelector(
  1293. _("Select a Wii WAD file to install"),
  1294. wxEmptyString, wxEmptyString, wxEmptyString,
  1295. "Wii WAD file (*.wad)|*.wad",
  1296. wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
  1297. this);
  1298. fileName = WxStrToStr(path);
  1299. break;
  1300. }
  1301. default:
  1302. return;
  1303. }
  1304. wxProgressDialog dialog(_("Installing WAD..."),
  1305. _("Working..."),
  1306. 1000,
  1307. this,
  1308. wxPD_APP_MODAL |
  1309. wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | wxPD_REMAINING_TIME |
  1310. wxPD_SMOOTH
  1311. );
  1312. u64 titleID = DiscIO::CNANDContentManager::Access().Install_WiiWAD(fileName);
  1313. if (titleID == TITLEID_SYSMENU)
  1314. {
  1315. UpdateWiiMenuChoice();
  1316. }
  1317. }
  1318. void CFrame::UpdateWiiMenuChoice(wxMenuItem *WiiMenuItem)
  1319. {
  1320. if (!WiiMenuItem)
  1321. {
  1322. WiiMenuItem = GetMenuBar()->FindItem(IDM_LOAD_WII_MENU);
  1323. }
  1324. const DiscIO::INANDContentLoader & SysMenu_Loader = DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU, true);
  1325. if (SysMenu_Loader.IsValid())
  1326. {
  1327. int sysmenuVersion = SysMenu_Loader.GetTitleVersion();
  1328. char sysmenuRegion = SysMenu_Loader.GetCountryChar();
  1329. WiiMenuItem->Enable();
  1330. WiiMenuItem->SetItemLabel(wxString::Format(_("Load Wii System Menu %d%c"), sysmenuVersion, sysmenuRegion));
  1331. }
  1332. else
  1333. {
  1334. WiiMenuItem->Enable(false);
  1335. WiiMenuItem->SetItemLabel(_("Load Wii System Menu"));
  1336. }
  1337. }
  1338. void CFrame::OnFifoPlayer(wxCommandEvent& WXUNUSED (event))
  1339. {
  1340. if (m_FifoPlayerDlg)
  1341. {
  1342. m_FifoPlayerDlg->Show();
  1343. m_FifoPlayerDlg->SetFocus();
  1344. }
  1345. else
  1346. {
  1347. m_FifoPlayerDlg = new FifoPlayerDlg(this);
  1348. }
  1349. }
  1350. void CFrame::ConnectWiimote(int wm_idx, bool connect)
  1351. {
  1352. if (Core::IsRunning() && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
  1353. {
  1354. bool was_unpaused = Core::PauseAndLock(true);
  1355. GetUsbPointer()->AccessWiiMote(wm_idx | 0x100)->Activate(connect);
  1356. wxString msg(wxString::Format(_("Wiimote %i %s"), wm_idx + 1,
  1357. connect ? _("Connected") : _("Disconnected")));
  1358. Core::DisplayMessage(WxStrToStr(msg), 3000);
  1359. Host_UpdateMainFrame();
  1360. Core::PauseAndLock(false, was_unpaused);
  1361. }
  1362. }
  1363. void CFrame::OnConnectWiimote(wxCommandEvent& event)
  1364. {
  1365. bool was_unpaused = Core::PauseAndLock(true);
  1366. ConnectWiimote(event.GetId() - IDM_CONNECT_WIIMOTE1, !GetUsbPointer()->AccessWiiMote((event.GetId() - IDM_CONNECT_WIIMOTE1) | 0x100)->IsConnected());
  1367. Core::PauseAndLock(false, was_unpaused);
  1368. }
  1369. // Toggle fullscreen. In Windows the fullscreen mode is accomplished by expanding the m_Panel to cover
  1370. // the entire screen (when we render to the main window).
  1371. void CFrame::OnToggleFullscreen(wxCommandEvent& WXUNUSED (event))
  1372. {
  1373. DoFullscreen(!RendererIsFullscreen());
  1374. }
  1375. void CFrame::OnToggleDualCore(wxCommandEvent& WXUNUSED (event))
  1376. {
  1377. SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread = !SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread;
  1378. SConfig::GetInstance().SaveSettings();
  1379. }
  1380. void CFrame::OnToggleSkipIdle(wxCommandEvent& WXUNUSED (event))
  1381. {
  1382. SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle = !SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle;
  1383. SConfig::GetInstance().SaveSettings();
  1384. }
  1385. void CFrame::OnLoadStateFromFile(wxCommandEvent& WXUNUSED (event))
  1386. {
  1387. wxString path = wxFileSelector(
  1388. _("Select the state to load"),
  1389. wxEmptyString, wxEmptyString, wxEmptyString,
  1390. _("All Save States (sav, s##)") +
  1391. wxString::Format("|*.sav;*.s??|%s", wxGetTranslation(wxALL_FILES)),
  1392. wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST,
  1393. this);
  1394. if (!path.IsEmpty())
  1395. State::LoadAs(WxStrToStr(path));
  1396. }
  1397. void CFrame::OnSaveStateToFile(wxCommandEvent& WXUNUSED (event))
  1398. {
  1399. wxString path = wxFileSelector(
  1400. _("Select the state to save"),
  1401. wxEmptyString, wxEmptyString, wxEmptyString,
  1402. _("All Save States (sav, s##)") +
  1403. wxString::Format("|*.sav;*.s??|%s", wxGetTranslation(wxALL_FILES)),
  1404. wxFD_SAVE,
  1405. this);
  1406. if (!path.IsEmpty())
  1407. State::SaveAs(WxStrToStr(path));
  1408. }
  1409. void CFrame::OnLoadLastState(wxCommandEvent& event)
  1410. {
  1411. if (Core::IsRunningAndStarted())
  1412. {
  1413. int id = event.GetId();
  1414. int slot = id - IDM_LOAD_LAST_1 + 1;
  1415. State::LoadLastSaved(slot);
  1416. }
  1417. }
  1418. void CFrame::OnSaveFirstState(wxCommandEvent& WXUNUSED(event))
  1419. {
  1420. if (Core::IsRunningAndStarted())
  1421. State::SaveFirstSaved();
  1422. }
  1423. void CFrame::OnUndoLoadState(wxCommandEvent& WXUNUSED (event))
  1424. {
  1425. if (Core::IsRunningAndStarted())
  1426. State::UndoLoadState();
  1427. }
  1428. void CFrame::OnUndoSaveState(wxCommandEvent& WXUNUSED (event))
  1429. {
  1430. if (Core::IsRunningAndStarted())
  1431. State::UndoSaveState();
  1432. }
  1433. void CFrame::OnLoadState(wxCommandEvent& event)
  1434. {
  1435. if (Core::IsRunningAndStarted())
  1436. {
  1437. int id = event.GetId();
  1438. int slot = id - IDM_LOAD_SLOT_1 + 1;
  1439. State::Load(slot);
  1440. }
  1441. }
  1442. void CFrame::OnSaveState(wxCommandEvent& event)
  1443. {
  1444. if (Core::IsRunningAndStarted())
  1445. {
  1446. int id = event.GetId();
  1447. int slot = id - IDM_SAVE_SLOT_1 + 1;
  1448. State::Save(slot);
  1449. }
  1450. }
  1451. void CFrame::OnFrameSkip(wxCommandEvent& event)
  1452. {
  1453. int amount = event.GetId() - IDM_FRAME_SKIP_0;
  1454. Movie::SetFrameSkipping((unsigned int)amount);
  1455. SConfig::GetInstance().m_FrameSkip = amount;
  1456. }
  1457. void CFrame::OnSelectSlot(wxCommandEvent& event)
  1458. {
  1459. g_saveSlot = event.GetId() - IDM_SELECT_SLOT_1 + 1;
  1460. Core::DisplayMessage(StringFromFormat("Selected slot %d", g_saveSlot), 1000);
  1461. }
  1462. void CFrame::OnLoadCurrentSlot(wxCommandEvent& event)
  1463. {
  1464. if (Core::IsRunningAndStarted())
  1465. {
  1466. State::Load(g_saveSlot);
  1467. }
  1468. }
  1469. void CFrame::OnSaveCurrentSlot(wxCommandEvent& event)
  1470. {
  1471. if (Core::IsRunningAndStarted())
  1472. {
  1473. State::Save(g_saveSlot);
  1474. }
  1475. }
  1476. // GUI
  1477. // ---------------------
  1478. // Update the enabled/disabled status
  1479. void CFrame::UpdateGUI()
  1480. {
  1481. // Save status
  1482. bool Initialized = Core::IsRunning();
  1483. bool Running = Core::GetState() == Core::CORE_RUN;
  1484. bool Paused = Core::GetState() == Core::CORE_PAUSE;
  1485. bool Stopping = Core::GetState() == Core::CORE_STOPPING;
  1486. bool RunningWii = Initialized && SConfig::GetInstance().m_LocalCoreStartupParameter.bWii;
  1487. // Make sure that we have a toolbar
  1488. if (m_ToolBar)
  1489. {
  1490. // Enable/disable the Config and Stop buttons
  1491. m_ToolBar->EnableTool(wxID_OPEN, !Initialized);
  1492. // Don't allow refresh when we don't show the list
  1493. m_ToolBar->EnableTool(wxID_REFRESH, !Initialized);
  1494. m_ToolBar->EnableTool(IDM_STOP, Running || Paused);
  1495. m_ToolBar->EnableTool(IDM_TOGGLE_FULLSCREEN, Running || Paused);
  1496. m_ToolBar->EnableTool(IDM_SCREENSHOT, Running || Paused);
  1497. }
  1498. // File
  1499. GetMenuBar()->FindItem(wxID_OPEN)->Enable(!Initialized);
  1500. GetMenuBar()->FindItem(IDM_DRIVES)->Enable(!Initialized);
  1501. GetMenuBar()->FindItem(wxID_REFRESH)->Enable(!Initialized);
  1502. GetMenuBar()->FindItem(IDM_BROWSE)->Enable(!Initialized);
  1503. // Emulation
  1504. GetMenuBar()->FindItem(IDM_STOP)->Enable(Running || Paused);
  1505. GetMenuBar()->FindItem(IDM_RESET)->Enable(Running || Paused);
  1506. GetMenuBar()->FindItem(IDM_RECORD)->Enable(!Movie::IsRecordingInput());
  1507. GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable(!Initialized);
  1508. GetMenuBar()->FindItem(IDM_RECORD_EXPORT)->Enable(Movie::IsMovieActive());
  1509. GetMenuBar()->FindItem(IDM_FRAMESTEP)->Enable(Running || Paused);
  1510. GetMenuBar()->FindItem(IDM_SCREENSHOT)->Enable(Running || Paused);
  1511. GetMenuBar()->FindItem(IDM_TOGGLE_FULLSCREEN)->Enable(Running || Paused);
  1512. // Update Key Shortcuts
  1513. for (unsigned int i = 0; i < NUM_HOTKEYS; i++)
  1514. {
  1515. if (GetCmdForHotkey(i) == -1)
  1516. continue;
  1517. if (GetMenuBar()->FindItem(GetCmdForHotkey(i)))
  1518. GetMenuBar()->FindItem(GetCmdForHotkey(i))->SetItemLabel(GetMenuLabel(i));
  1519. }
  1520. GetMenuBar()->FindItem(IDM_LOAD_STATE)->Enable(Initialized);
  1521. GetMenuBar()->FindItem(IDM_SAVE_STATE)->Enable(Initialized);
  1522. // Misc
  1523. GetMenuBar()->FindItem(IDM_CHANGE_DISC)->Enable(Initialized);
  1524. if (DiscIO::CNANDContentManager::Access().GetNANDLoader(TITLEID_SYSMENU).IsValid())
  1525. GetMenuBar()->FindItem(IDM_LOAD_WII_MENU)->Enable(!Initialized);
  1526. // Tools
  1527. GetMenuBar()->FindItem(IDM_CHEATS)->Enable(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats);
  1528. GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->Enable(RunningWii);
  1529. GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->Enable(RunningWii);
  1530. GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->Enable(RunningWii);
  1531. GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE4)->Enable(RunningWii);
  1532. GetMenuBar()->FindItem(IDM_CONNECT_BALANCEBOARD)->Enable(RunningWii);
  1533. if (RunningWii)
  1534. {
  1535. bool was_unpaused = Core::PauseAndLock(true);
  1536. GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE1)->Check(GetUsbPointer()->
  1537. AccessWiiMote(0x0100)->IsConnected());
  1538. GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE2)->Check(GetUsbPointer()->
  1539. AccessWiiMote(0x0101)->IsConnected());
  1540. GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE3)->Check(GetUsbPointer()->
  1541. AccessWiiMote(0x0102)->IsConnected());
  1542. GetMenuBar()->FindItem(IDM_CONNECT_WIIMOTE4)->Check(GetUsbPointer()->
  1543. AccessWiiMote(0x0103)->IsConnected());
  1544. GetMenuBar()->FindItem(IDM_CONNECT_BALANCEBOARD)->Check(GetUsbPointer()->
  1545. AccessWiiMote(0x0104)->IsConnected());
  1546. Core::PauseAndLock(false, was_unpaused);
  1547. }
  1548. if (m_ToolBar)
  1549. {
  1550. // Get the tool that controls pausing/playing
  1551. wxToolBarToolBase * PlayTool = m_ToolBar->FindById(IDM_PLAY);
  1552. if (PlayTool)
  1553. {
  1554. if (Running)
  1555. {
  1556. PlayTool->SetLabel(_("Pause"));
  1557. PlayTool->SetShortHelp(_("Pause"));
  1558. m_ToolBar->SetToolNormalBitmap(IDM_PLAY, m_Bitmaps[Toolbar_Pause]);
  1559. }
  1560. else
  1561. {
  1562. PlayTool->SetLabel(_("Play"));
  1563. PlayTool->SetShortHelp(_("Play"));
  1564. m_ToolBar->SetToolNormalBitmap(IDM_PLAY, m_Bitmaps[Toolbar_Play]);
  1565. }
  1566. }
  1567. }
  1568. GetMenuBar()->FindItem(IDM_RECORD_READ_ONLY)->Enable(Running || Paused);
  1569. if (!Initialized && !m_bGameLoading)
  1570. {
  1571. if (m_GameListCtrl->IsEnabled())
  1572. {
  1573. // Prepare to load Default ISO, enable play button
  1574. if (!SConfig::GetInstance().m_LocalCoreStartupParameter.m_strDefaultISO.empty())
  1575. {
  1576. if (m_ToolBar)
  1577. m_ToolBar->EnableTool(IDM_PLAY, true);
  1578. GetMenuBar()->FindItem(IDM_PLAY)->Enable();
  1579. GetMenuBar()->FindItem(IDM_RECORD)->Enable();
  1580. GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable();
  1581. }
  1582. // Prepare to load last selected file, enable play button
  1583. else if (!SConfig::GetInstance().m_LastFilename.empty() &&
  1584. File::Exists(SConfig::GetInstance().m_LastFilename))
  1585. {
  1586. if (m_ToolBar)
  1587. m_ToolBar->EnableTool(IDM_PLAY, true);
  1588. GetMenuBar()->FindItem(IDM_PLAY)->Enable();
  1589. GetMenuBar()->FindItem(IDM_RECORD)->Enable();
  1590. GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable();
  1591. }
  1592. else
  1593. {
  1594. // No game has been selected yet, disable play button
  1595. if (m_ToolBar)
  1596. m_ToolBar->EnableTool(IDM_PLAY, false);
  1597. GetMenuBar()->FindItem(IDM_PLAY)->Enable(false);
  1598. GetMenuBar()->FindItem(IDM_RECORD)->Enable(false);
  1599. GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable(false);
  1600. }
  1601. }
  1602. // Game has not started, show game list
  1603. if (!m_GameListCtrl->IsShown())
  1604. {
  1605. m_GameListCtrl->Enable();
  1606. m_GameListCtrl->Show();
  1607. }
  1608. // Game has been selected but not started, enable play button
  1609. if (m_GameListCtrl->GetSelectedISO() != nullptr && m_GameListCtrl->IsEnabled())
  1610. {
  1611. if (m_ToolBar)
  1612. m_ToolBar->EnableTool(IDM_PLAY, true);
  1613. GetMenuBar()->FindItem(IDM_PLAY)->Enable();
  1614. GetMenuBar()->FindItem(IDM_RECORD)->Enable();
  1615. GetMenuBar()->FindItem(IDM_PLAY_RECORD)->Enable();
  1616. }
  1617. }
  1618. else if (Initialized)
  1619. {
  1620. // Game has been loaded, enable the pause button
  1621. if (m_ToolBar)
  1622. m_ToolBar->EnableTool(IDM_PLAY, !Stopping);
  1623. GetMenuBar()->FindItem(IDM_PLAY)->Enable(!Stopping);
  1624. // Reset game loading flag
  1625. m_bGameLoading = false;
  1626. }
  1627. // Refresh toolbar
  1628. if (m_ToolBar)
  1629. {
  1630. m_ToolBar->Refresh();
  1631. }
  1632. // Commit changes to manager
  1633. m_Mgr->Update();
  1634. // Update non-modal windows
  1635. if (g_CheatsWindow)
  1636. {
  1637. if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats)
  1638. g_CheatsWindow->UpdateGUI();
  1639. else
  1640. g_CheatsWindow->Close();
  1641. }
  1642. }
  1643. void CFrame::UpdateGameList()
  1644. {
  1645. m_GameListCtrl->Update();
  1646. }
  1647. void CFrame::GameListChanged(wxCommandEvent& event)
  1648. {
  1649. switch (event.GetId())
  1650. {
  1651. case IDM_LIST_WII:
  1652. SConfig::GetInstance().m_ListWii = event.IsChecked();
  1653. break;
  1654. case IDM_LIST_GC:
  1655. SConfig::GetInstance().m_ListGC = event.IsChecked();
  1656. break;
  1657. case IDM_LIST_WAD:
  1658. SConfig::GetInstance().m_ListWad = event.IsChecked();
  1659. break;
  1660. case IDM_LIST_JAP:
  1661. SConfig::GetInstance().m_ListJap = event.IsChecked();
  1662. break;
  1663. case IDM_LIST_PAL:
  1664. SConfig::GetInstance().m_ListPal = event.IsChecked();
  1665. break;
  1666. case IDM_LIST_USA:
  1667. SConfig::GetInstance().m_ListUsa = event.IsChecked();
  1668. break;
  1669. case IDM_LIST_AUSTRALIA:
  1670. SConfig::GetInstance().m_ListAustralia = event.IsChecked();
  1671. break;
  1672. case IDM_LIST_FRANCE:
  1673. SConfig::GetInstance().m_ListFrance = event.IsChecked();
  1674. break;
  1675. case IDM_LIST_GERMANY:
  1676. SConfig::GetInstance().m_ListGermany = event.IsChecked();
  1677. break;
  1678. case IDM_LIST_ITALY:
  1679. SConfig::GetInstance().m_ListItaly = event.IsChecked();
  1680. break;
  1681. case IDM_LIST_KOREA:
  1682. SConfig::GetInstance().m_ListKorea = event.IsChecked();
  1683. break;
  1684. case IDM_LIST_NETHERLANDS:
  1685. SConfig::GetInstance().m_ListNetherlands = event.IsChecked();
  1686. break;
  1687. case IDM_LIST_RUSSIA:
  1688. SConfig::GetInstance().m_ListRussia = event.IsChecked();
  1689. break;
  1690. case IDM_LIST_SPAIN:
  1691. SConfig::GetInstance().m_ListSpain = event.IsChecked();
  1692. break;
  1693. case IDM_LIST_TAIWAN:
  1694. SConfig::GetInstance().m_ListTaiwan = event.IsChecked();
  1695. break;
  1696. case IDM_LIST_WORLD:
  1697. SConfig::GetInstance().m_ListWorld = event.IsChecked();
  1698. break;
  1699. case IDM_LIST_UNKNOWN:
  1700. SConfig::GetInstance().m_ListUnknown = event.IsChecked();
  1701. break;
  1702. case IDM_LIST_DRIVES:
  1703. SConfig::GetInstance().m_ListDrives = event.IsChecked();
  1704. break;
  1705. case IDM_PURGE_CACHE:
  1706. std::vector<std::string> rFilenames = DoFileSearch({"*.cache"}, {File::GetUserPath(D_CACHE_IDX)});
  1707. for (const std::string& rFilename : rFilenames)
  1708. {
  1709. File::Delete(rFilename);
  1710. }
  1711. break;
  1712. }
  1713. // Update gamelist
  1714. if (m_GameListCtrl)
  1715. {
  1716. m_GameListCtrl->Update();
  1717. }
  1718. }
  1719. // Enable and disable the toolbar
  1720. void CFrame::OnToggleToolbar(wxCommandEvent& event)
  1721. {
  1722. SConfig::GetInstance().m_InterfaceToolbar = event.IsChecked();
  1723. DoToggleToolbar(event.IsChecked());
  1724. }
  1725. void CFrame::DoToggleToolbar(bool _show)
  1726. {
  1727. GetToolBar()->Show(_show);
  1728. m_Mgr->Update();
  1729. }
  1730. // Enable and disable the status bar
  1731. void CFrame::OnToggleStatusbar(wxCommandEvent& event)
  1732. {
  1733. SConfig::GetInstance().m_InterfaceStatusbar = event.IsChecked();
  1734. GetStatusBar()->Show(event.IsChecked());
  1735. SendSizeEvent();
  1736. }
  1737. void CFrame::OnChangeColumnsVisible(wxCommandEvent& event)
  1738. {
  1739. switch (event.GetId())
  1740. {
  1741. case IDM_SHOW_SYSTEM:
  1742. SConfig::GetInstance().m_showSystemColumn = !SConfig::GetInstance().m_showSystemColumn;
  1743. break;
  1744. case IDM_SHOW_BANNER:
  1745. SConfig::GetInstance().m_showBannerColumn = !SConfig::GetInstance().m_showBannerColumn;
  1746. break;
  1747. case IDM_SHOW_MAKER:
  1748. SConfig::GetInstance().m_showMakerColumn = !SConfig::GetInstance().m_showMakerColumn;
  1749. break;
  1750. case IDM_SHOW_ID:
  1751. SConfig::GetInstance().m_showIDColumn = !SConfig::GetInstance().m_showIDColumn;
  1752. break;
  1753. case IDM_SHOW_REGION:
  1754. SConfig::GetInstance().m_showRegionColumn = !SConfig::GetInstance().m_showRegionColumn;
  1755. break;
  1756. case IDM_SHOW_SIZE:
  1757. SConfig::GetInstance().m_showSizeColumn = !SConfig::GetInstance().m_showSizeColumn;
  1758. break;
  1759. case IDM_SHOW_STATE:
  1760. SConfig::GetInstance().m_showStateColumn = !SConfig::GetInstance().m_showStateColumn;
  1761. break;
  1762. default: return;
  1763. }
  1764. m_GameListCtrl->Update();
  1765. SConfig::GetInstance().SaveSettings();
  1766. }