view src/win32/MainWndFile.cpp @ 7:c0a590a394c3

ignore generated files
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:50:33 -0600
parents f9f4f1b99eed
children
line wrap: on
line source
1 #include "stdafx.h"
2 #include "resource.h"
3 #include "MainWnd.h"
4 #include "ExportGSASnapshot.h"
5 #include "FileDlg.h"
6 #include "GSACodeSelect.h"
7 #include "RomInfo.h"
8 #include "Reg.h"
9 #include "WinResUtil.h"
10 #include "WinMiscUtil.h"
11 #include "LuaOpenDialog.h"
12 #include "ram_search.h"
13 #include "ramwatch.h"
14 #include "Sound.h"
15 #include "VBA.h"
17 #include "../NLS.h"
18 #include "../version.h"
19 #include "../gba/GBA.h"
20 #include "../gba/GBAGlobals.h"
21 #include "../gba/EEprom.h"
22 #include "../gba/GBASound.h"
23 #include "../gb/GB.h"
24 #include "../gb/gbGlobals.h"
25 #include "../common/movie.h"
26 #include "../common/vbalua.h"
28 void MainWnd::OnFileOpen()
29 {
30 theApp.winCheckFullscreen();
31 if (winFileOpenSelect(0))
32 {
33 winFileRun();
34 }
35 }
37 void MainWnd::OnFileOpenGBx()
38 {
39 theApp.winCheckFullscreen();
40 if (winFileOpenSelect(1))
41 {
42 winFileRun();
43 }
44 }
46 void MainWnd::OnFilePause()
47 {
48 systemSetPause(!theApp.paused);
49 }
51 void MainWnd::OnUpdateFilePause(CCmdUI *pCmdUI)
52 {
53 pCmdUI->SetCheck(theApp.paused);
54 }
56 void MainWnd::OnFileReset()
57 {
58 if (emulating)
59 {
60 if (VBAMovieGetState() == MOVIE_STATE_PLAY)
61 {
62 OnToolsPlayRestart(); // HACK: shortcut
63 }
64 else
65 {
66 theApp.emulator.emuReset(true);
67 systemScreenMessage(winResLoadString(IDS_RESET));
68 }
69 }
70 }
72 void MainWnd::OnUpdateFileReset(CCmdUI *pCmdUI)
73 {
74 pCmdUI->Enable(emulating);
75 }
77 void MainWnd::OnFileRecentFreeze()
78 {
79 theApp.recentFreeze = !theApp.recentFreeze;
80 }
82 void MainWnd::OnUpdateFileRecentFreeze(CCmdUI *pCmdUI)
83 {
84 pCmdUI->SetCheck(theApp.recentFreeze);
85 }
87 void MainWnd::OnFileRecentReset()
88 {
89 theApp.winCheckFullscreen();
90 systemSoundClearBuffer();
91 if (MessageBox("Really clear your recent ROMs list?", //winResLoadString(IDS_REALLY_CLEAR),
92 winResLoadString(IDS_CONFIRM_ACTION),
93 MB_YESNO | MB_DEFBUTTON2) == IDNO)
94 return;
96 for (int i = 0; i < 10; ++i)
97 theApp.recentFiles[i] = "";
98 }
100 BOOL MainWnd::OnFileRecentFile(UINT nID)
101 {
102 if (theApp.recentFiles[(nID & 0xFFFF) - ID_FILE_MRU_FILE1].GetLength())
103 {
104 theApp.romFilename = theApp.recentFiles[(nID & 0xFFFF) - ID_FILE_MRU_FILE1];
105 winFileRun();
106 }
107 return TRUE;
108 }
110 void MainWnd::OnUpdateFileRecentFile(CCmdUI *pCmdUI)
111 {
112 int fileID = pCmdUI->m_nID - ID_FILE_MRU_FILE1;
114 bool bExist = !theApp.recentFiles[fileID].IsEmpty();
116 if (pCmdUI->m_pMenu != NULL)
117 {
118 CString p = theApp.recentFiles[fileID];
120 int index = max(p.ReverseFind('/'), max(p.ReverseFind('\\'), p.ReverseFind('|')));
122 if (index != -1)
123 {
124 p.Delete(0, index + 1);
125 }
127 p.Replace("&", "&&");
129 CString number("1&0 - ");
130 if (fileID < 9)
131 number.Format("&%d - ", fileID + 1);
133 if (p.IsEmpty())
134 {
135 p = "No Recent ROM";
136 bExist = false;
137 }
139 pCmdUI->SetText(number + p);
140 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
141 }
143 pCmdUI->Enable(bExist);
144 }
146 void MainWnd::OnFileExit()
147 {
148 if (AskSave())
149 SendMessage(WM_CLOSE);
150 }
152 void MainWnd::OnFileClose()
153 {
154 // save battery file before we change the filename...
155 CloseRamWindows();
156 winFileClose();
157 }
159 void MainWnd::OnUpdateFileClose(CCmdUI *pCmdUI)
160 {
161 pCmdUI->Enable(emulating);
162 }
164 void MainWnd::OnFileLoad()
165 {
166 theApp.winCheckFullscreen();
168 LPCTSTR exts[] = { ".sgm", NULL };
169 CString filter = winResLoadFilter(IDS_FILTER_SGM);
170 CString title = winResLoadString(IDS_SELECT_SAVE_GAME_NAME);
172 CString saveName = winGetDestFilename(theApp.gameFilename, IDS_SAVE_DIR, exts[0]);
173 CString saveDir = winGetDestDir(IDS_SAVE_DIR);
175 FileDlg dlg(this, saveName, filter, 0, "SGM", exts, saveDir, title, false, true);
177 if (dlg.DoModal() == IDOK)
178 {
179 bool res = winReadSaveGame(dlg.GetPathName());
181 theApp.rewindCount = 0;
182 theApp.rewindCounter = 0;
183 theApp.rewindSaveNeeded = false;
185 if (res)
186 {
187 if (VBAMovieActive() && !VBAMovieReadOnly())
188 {
189 VBAMovieSwitchToRecording();
190 }
191 systemScreenMessage(winResLoadString(IDS_LOADED_STATE));
192 }
193 }
194 }
196 void MainWnd::OnUpdateFileLoad(CCmdUI *pCmdUI)
197 {
198 pCmdUI->Enable(emulating);
199 }
201 BOOL MainWnd::OnFileLoadSlot(UINT nID)
202 {
203 nID = nID + 1 - ID_FILE_LOADGAME_SLOT1;
205 CString filename = winGetSavestateFilename(theApp.gameFilename, nID);
207 bool res = winReadSaveGame(filename);
209 // deleting rewinds because you loaded a save state is stupid
210 /// theApp.rewindCount = 0;
211 /// theApp.rewindCounter = 0;
212 /// theApp.rewindSaveNeeded = false;
214 if (res)
215 {
216 CString format;
217 if (VBAMovieActive())
218 {
219 if (VBAMovieReadOnly())
220 {
221 format = winResLoadString(IDS_REPLAYED_STATE_N);
222 }
223 else
224 {
225 VBAMovieSwitchToRecording();
226 format = winResLoadString(IDS_RERECORDED_STATE_N);
227 }
228 }
229 else
230 {
231 format = winResLoadString(IDS_LOADED_STATE_N);
232 }
234 CString buffer;
235 buffer.Format(format, nID);
236 systemScreenMessage(buffer);
238 int lastSlot = theApp.currentSlot;
240 if (theApp.loadMakesRecent)
241 {
242 // to update the file's modification date
243 SYSTEMTIME st;
244 FILETIME ft;
245 GetSystemTime(&st);
246 SystemTimeToFileTime(&st, &ft);
247 HANDLE fh = CreateFile(filename,
248 GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
249 NULL,
250 OPEN_EXISTING,
251 0,
252 NULL);
253 if (fh != INVALID_HANDLE_VALUE)
254 SetFileTime(fh, NULL, NULL, &ft);
255 CloseHandle(fh);
256 }
258 if (theApp.loadMakesCurrent)
259 theApp.currentSlot = nID - 1;
260 else
261 theApp.currentSlot = lastSlot; // restore value in case the call to OnFileSaveSlot changed it
263 theApp.frameSearching = false;
264 theApp.frameSearchSkipping = false;
265 }
267 return res;
268 }
270 void MainWnd::OnFileSave()
271 {
272 theApp.winCheckFullscreen();
274 LPCTSTR exts[] = { ".sgm", NULL };
275 CString filter = winResLoadFilter(IDS_FILTER_SGM);
276 CString title = winResLoadString(IDS_SELECT_SAVE_GAME_NAME);
278 CString saveName = winGetDestFilename(theApp.gameFilename, IDS_SAVE_DIR, exts[0]);
279 CString saveDir = winGetDestDir(IDS_SAVE_DIR);
281 FileDlg dlg(this, saveName, filter, 0, "SGM", exts, saveDir, title, true);
283 if (dlg.DoModal() == IDOK)
284 {
285 bool res = winWriteSaveGame(dlg.GetPathName());
286 if (res)
287 systemScreenMessage(winResLoadString(IDS_WROTE_STATE));
288 }
289 }
291 void MainWnd::OnUpdateFileSave(CCmdUI *pCmdUI)
292 {
293 pCmdUI->Enable(emulating);
294 }
296 BOOL MainWnd::OnFileSaveSlot(UINT nID)
297 {
298 nID = nID + 1 - ID_FILE_SAVEGAME_SLOT1;
300 if (theApp.saveMakesCurrent)
301 theApp.currentSlot = nID - 1;
303 CString filename = winGetSavestateFilename(theApp.gameFilename, nID);
305 bool res = winWriteSaveGame(filename);
307 CString format = winResLoadString(IDS_WROTE_STATE_N);
308 CString buffer;
309 buffer.Format(format, nID);
311 systemScreenMessage(buffer);
313 return res;
314 }
316 BOOL MainWnd::OnSelectSlot(UINT nID)
317 {
318 nID -= ID_SELECT_SLOT1;
319 theApp.currentSlot = nID;
321 CString buffer;
322 buffer.Format("Slot %d selected", nID + 1);
323 systemScreenMessage(buffer, 0);
325 return true;
326 }
328 void MainWnd::OnFileImportBatteryfile()
329 {
330 theApp.winCheckFullscreen();
332 LPCTSTR exts[] = { ".sav", NULL };
333 CString filter = winResLoadFilter(IDS_FILTER_SAV);
334 CString title = winResLoadString(IDS_SELECT_BATTERY_FILE);
336 CString batteryName = winGetDestFilename(theApp.gameFilename, IDS_BATTERY_DIR, exts[0]);
337 CString batteryDir = winGetDestDir(IDS_BATTERY_DIR);
339 FileDlg dlg(this, batteryName, filter, 0, "SAV", exts, batteryDir, title, false, true);
341 if (dlg.DoModal() == IDCANCEL)
342 return;
344 CString str1 = winResLoadString(IDS_SAVE_WILL_BE_LOST);
345 CString str2 = winResLoadString(IDS_CONFIRM_ACTION);
347 systemSoundClearBuffer();
348 if (MessageBox(str1,
349 str2,
350 MB_OKCANCEL) == IDCANCEL)
351 return;
353 bool res = false;
355 res = theApp.emulator.emuReadBattery(dlg.GetPathName());
357 if (!res)
358 systemMessage(MSG_CANNOT_OPEN_FILE, "Cannot open file %s", dlg.GetPathName());
359 else
360 {
361 theApp.emulator.emuReset(true);
362 }
363 }
365 void MainWnd::OnUpdateFileImportBatteryfile(CCmdUI *pCmdUI)
366 {
367 // we allow this as we allow using cheats during recording
368 pCmdUI->Enable(emulating /*&& !VBAMovieActive()*/);
369 }
371 void MainWnd::OnFileImportGamesharkcodefile()
372 {
373 theApp.winCheckFullscreen();
375 LPCTSTR exts[] = { NULL };
376 CString filter = systemCartridgeType == 0 ? winResLoadFilter(IDS_FILTER_SPC) : winResLoadFilter(IDS_FILTER_GCF);
377 CString title = winResLoadString(IDS_SELECT_CODE_FILE);
379 FileDlg dlg(this, "", filter, 0, "", exts, "", title, false, true);
381 if (dlg.DoModal() == IDCANCEL)
382 return;
384 CString str1 = winResLoadString(IDS_CODES_WILL_BE_LOST);
385 CString str2 = winResLoadString(IDS_CONFIRM_ACTION);
387 systemSoundClearBuffer();
388 if (MessageBox(str1,
389 str2,
390 MB_OKCANCEL) == IDCANCEL)
391 return;
393 CString file = dlg.GetPathName();
394 bool res = winImportGSACodeFile(file);
395 }
397 void MainWnd::OnUpdateFileImportGamesharkcodefile(CCmdUI *pCmdUI)
398 {
399 pCmdUI->Enable(emulating /*&& !VBAMovieActive()*/);
400 }
402 void MainWnd::OnFileImportGamesharksnapshot()
403 {
404 theApp.winCheckFullscreen();
406 LPCTSTR exts[] = { NULL };
407 CString filter = systemCartridgeType == 1 ? winResLoadFilter(IDS_FILTER_GBS) : winResLoadFilter(IDS_FILTER_SPS);
408 CString title = winResLoadString(IDS_SELECT_SNAPSHOT_FILE);
410 FileDlg dlg(this, "", filter, 0, "", exts, "", title, false, true);
412 if (dlg.DoModal() == IDCANCEL)
413 return;
415 CString str1 = winResLoadString(IDS_SAVE_WILL_BE_LOST);
416 CString str2 = winResLoadString(IDS_CONFIRM_ACTION);
418 systemSoundClearBuffer();
419 if (MessageBox(str1,
420 str2,
421 MB_OKCANCEL) == IDCANCEL)
422 return;
424 if (systemCartridgeType == 1)
425 gbReadGSASnapshot(dlg.GetPathName());
426 else
427 CPUReadGSASnapshot(dlg.GetPathName());
428 }
430 void MainWnd::OnUpdateFileImportGamesharksnapshot(CCmdUI *pCmdUI)
431 {
432 pCmdUI->Enable(emulating /*&& !VBAMovieActive()*/);
433 }
435 void MainWnd::OnFileExportBatteryfile()
436 {
437 theApp.winCheckFullscreen();
439 LPCTSTR exts[] = { ".sav", ".dat", NULL };
440 CString filter = winResLoadFilter(IDS_FILTER_SAV);
441 CString title = winResLoadString(IDS_SELECT_BATTERY_FILE);
443 CString batteryName = winGetDestFilename(theApp.gameFilename, IDS_BATTERY_DIR, exts[0]);
444 CString batteryDir = winGetDestDir(IDS_BATTERY_DIR);
446 FileDlg dlg(this, batteryName, filter, 1, "SAV", exts, batteryDir, title, true);
448 if (dlg.DoModal() == IDCANCEL)
449 {
450 return;
451 }
453 bool result = false;
455 if (systemCartridgeType == 1)
456 {
457 result = gbWriteBatteryFile(dlg.GetPathName(), false);
458 }
459 else
460 result = theApp.emulator.emuWriteBattery(dlg.GetPathName());
462 if (!result)
463 systemMessage(MSG_ERROR_CREATING_FILE, "Error creating file %s",
464 dlg.GetPathName());
465 }
467 void MainWnd::OnUpdateFileExportBatteryfile(CCmdUI *pCmdUI)
468 {
469 pCmdUI->Enable(emulating);
470 }
472 void MainWnd::OnFileExportGamesharksnapshot()
473 {
474 theApp.winCheckFullscreen();
475 if (eepromInUse)
476 {
477 systemMessage(IDS_EEPROM_NOT_SUPPORTED, "EEPROM saves cannot be exported");
478 return;
479 }
481 LPCTSTR exts[] = { ".sps", NULL };
483 CString filter = winResLoadFilter(IDS_FILTER_SPS);
484 CString title = winResLoadString(IDS_SELECT_SNAPSHOT_FILE);
486 CString name = winGetDestFilename(theApp.gameFilename, CString(), exts[0]);
488 FileDlg dlg(this, name, filter, 1, "SPS", exts, "", title, true);
490 if (dlg.DoModal() == IDCANCEL)
491 return;
493 char buffer[16];
494 strncpy(buffer, (const char *)&rom[0xa0], 12);
495 buffer[12] = 0;
497 ExportGSASnapshot dlg2(dlg.GetPathName(), buffer, this);
498 dlg2.DoModal();
499 }
501 void MainWnd::OnUpdateFileExportGamesharksnapshot(CCmdUI *pCmdUI)
502 {
503 pCmdUI->Enable(emulating && systemCartridgeType == 0);
504 }
506 void MainWnd::OnFileQuickScreencapture()
507 {
508 extern int32 captureNumber; // GBAGlobals.cpp
509 captureNumber = winScreenCapture(captureNumber);
510 }
512 void MainWnd::OnFileScreencapture()
513 {
514 theApp.winCheckFullscreen();
516 LPCTSTR exts[] = { ".png", ".bmp", NULL };
518 CString filter = winResLoadFilter(IDS_FILTER_PNG);
519 CString title = winResLoadString(IDS_SELECT_CAPTURE_NAME);
521 CString ext;
523 if (theApp.captureFormat != 0)
524 ext.Format(".bmp");
525 else
526 ext.Format(".png");
528 CString captureName = winGetDestFilename(theApp.gameFilename, IDS_CAPTURE_DIR, ext);
529 CString captureDir = winGetDestDir(IDS_CAPTURE_DIR);
531 FileDlg dlg(this,
532 captureName,
533 filter,
534 theApp.captureFormat ? 2 : 1,
535 theApp.captureFormat ? "BMP" : "PNG",
536 exts,
537 captureDir,
538 title,
539 true);
541 if (dlg.DoModal() == IDCANCEL)
542 return;
544 if (dlg.getFilterIndex() == 2)
545 theApp.emulator.emuWriteBMP(dlg.GetPathName());
546 else
547 theApp.emulator.emuWritePNG(dlg.GetPathName());
549 systemScreenMessage(winResLoadString(IDS_SCREEN_CAPTURE));
550 }
552 void MainWnd::OnUpdateFileScreencapture(CCmdUI *pCmdUI)
553 {
554 pCmdUI->Enable(emulating);
555 }
557 void MainWnd::OnFileRominformation()
558 {
559 theApp.winCheckFullscreen();
560 if (systemCartridgeType == 0)
561 {
562 RomInfoGBA dlg(rom);
563 dlg.DoModal();
564 }
565 else
566 {
567 RomInfoGB dlg(gbRom);
568 dlg.DoModal();
569 }
570 }
572 void MainWnd::OnUpdateFileRominformation(CCmdUI *pCmdUI)
573 {
574 pCmdUI->Enable(emulating);
575 }
577 void MainWnd::OnFileTogglemenu()
578 {
579 theApp.menuToggle = !theApp.menuToggle;
581 if (theApp.menuToggle)
582 {
583 SetMenu(&theApp.m_menu);
584 if (theApp.tripleBuffering)
585 {
586 if (theApp.display)
587 theApp.display->renderMenu();
588 }
589 }
590 else
591 {
592 SetMenu(NULL);
593 }
595 theApp.adjustDestRect();
596 }
598 void MainWnd::OnUpdateFileTogglemenu(CCmdUI *pCmdUI)
599 {
600 pCmdUI->Enable(theApp.videoOption > VIDEO_4X);
601 }
603 void MainWnd::OnFileSavegameOldestslot()
604 {
605 if (!emulating)
606 return;
608 CFileStatus status;
609 CString str;
610 time_t time = -1;
611 int found = -1;
613 for (int i = 0; i < 10; i++)
614 {
615 if (CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, i + 1), status))
616 {
617 if (time - status.m_mtime.GetTime() > 0 || time == -1)
618 {
619 time = (time_t)status.m_mtime.GetTime();
620 found = i;
621 }
622 }
623 else
624 {
625 found = i;
626 break;
627 }
628 }
630 OnFileSaveSlot(ID_FILE_SAVEGAME_SLOT1 + found);
631 }
633 void MainWnd::OnUpdateFileSavegameOldestslot(CCmdUI *pCmdUI)
634 {
635 bool enabled = emulating;
636 if (pCmdUI->m_pMenu != NULL)
637 {
638 CFileStatus status;
639 time_t time = -1;
640 int found = -1;
642 if (emulating)
643 {
644 for (int i = 0; i < 10; i++)
645 {
646 if (CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, i + 1), status))
647 {
648 if (time - status.m_mtime.GetTime() > 0 || time == -1)
649 {
650 time = (time_t)status.m_mtime.GetTime();
651 found = i;
652 }
653 }
654 else
655 {
656 found = i;
657 break;
658 }
659 }
660 }
662 CString str;
663 enabled = (found != -1);
664 if (enabled)
665 str.Format("&Oldest Slot (#%d)", found + 1);
666 else
667 str.Format("&Oldest Slot", found + 1);
669 pCmdUI->SetText(str);
671 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
672 }
674 pCmdUI->Enable(enabled);
675 }
677 void MainWnd::OnFileLoadgameMostrecent()
678 {
679 if (!emulating)
680 return;
682 CFileStatus status;
683 CString str;
684 time_t time = 0;
685 int found = -1;
687 for (int i = 0; i < 10; i++)
688 {
689 if (CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, i + 1), status))
690 {
691 if (status.m_mtime.GetTime() > time)
692 {
693 time = (time_t)status.m_mtime.GetTime();
694 found = i;
695 }
696 }
697 }
699 if (found != -1)
700 {
701 OnFileLoadSlot(ID_FILE_LOADGAME_SLOT1 + found);
702 }
703 }
705 void MainWnd::OnUpdateFileLoadgameMostrecent(CCmdUI *pCmdUI)
706 {
707 bool enabled = emulating;
708 if (pCmdUI->m_pMenu != NULL)
709 {
710 CFileStatus status;
711 int found = -1;
713 time_t time = 0;
714 if (emulating)
715 {
716 for (int i = 0; i < 10; i++)
717 {
718 if (CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, i + 1), status))
719 {
720 if (status.m_mtime.GetTime() > time)
721 {
722 time = (time_t)status.m_mtime.GetTime();
723 found = i;
724 }
725 }
726 }
727 }
729 CString str;
730 enabled = (found != -1);
731 if (enabled)
732 str.Format("Most &Recent Slot (#%d)", found + 1);
733 else
734 str.Format("Most &Recent Slot", found + 1);
736 pCmdUI->SetText(str);
738 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
739 }
741 pCmdUI->Enable(enabled);
742 }
744 void MainWnd::OnUpdateFileLoadSlot(CCmdUI *pCmdUI)
745 {
746 int slotID = pCmdUI->m_nID - ID_FILE_LOADGAME_SLOT1 + 1;
748 if (pCmdUI->m_pMenu != NULL)
749 {
750 pCmdUI->SetText(winGetSavestateMenuString(theApp.gameFilename, slotID));
752 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
753 }
755 pCmdUI->Enable(emulating && winFileExists(winGetSavestateFilename(theApp.gameFilename, slotID)));
756 }
758 void MainWnd::OnUpdateFileSaveSlot(CCmdUI *pCmdUI)
759 {
760 if (pCmdUI->m_pMenu != NULL)
761 {
762 int slotID = pCmdUI->m_nID - ID_FILE_SAVEGAME_SLOT1 + 1;
764 pCmdUI->SetText(winGetSavestateMenuString(theApp.gameFilename, slotID));
766 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
767 }
769 pCmdUI->Enable(emulating);
770 }
772 void MainWnd::OnUpdateSelectSlot(CCmdUI *pCmdUI)
773 {
774 if (pCmdUI->m_pMenu != NULL)
775 {
776 int slot = pCmdUI->m_nID - ID_SELECT_SLOT1;
778 pCmdUI->SetText(winGetSavestateMenuString(theApp.gameFilename, slot + 1));
780 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
782 pCmdUI->SetCheck(slot == theApp.currentSlot);
783 }
784 }
786 void MainWnd::OnFileLoadgameAutoloadmostrecent()
787 {
788 theApp.autoLoadMostRecent = !theApp.autoLoadMostRecent;
789 }
791 void MainWnd::OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI *pCmdUI)
792 {
793 pCmdUI->SetCheck(theApp.autoLoadMostRecent);
794 }
796 void MainWnd::OnFileLoadgameMakeRecent()
797 {
798 theApp.loadMakesRecent = !theApp.loadMakesRecent;
799 }
801 void MainWnd::OnUpdateFileLoadgameMakeRecent(CCmdUI *pCmdUI)
802 {
803 pCmdUI->SetCheck(theApp.loadMakesRecent);
804 }
806 void MainWnd::OnFileSavegameCurrent()
807 {
808 OnFileSaveSlot(ID_FILE_SAVEGAME_SLOT1 + theApp.currentSlot);
809 }
811 void MainWnd::OnUpdateFileSavegameCurrent(CCmdUI *pCmdUI)
812 {
813 if (pCmdUI->m_pMenu != NULL)
814 {
815 int slotID = theApp.currentSlot + 1;
817 CString str;
818 str.Format("&Current Slot (#%d)", slotID);
820 pCmdUI->SetText(str);
822 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
823 }
825 pCmdUI->Enable(emulating);
826 }
828 void MainWnd::OnFileLoadgameCurrent()
829 {
830 OnFileLoadSlot(ID_FILE_LOADGAME_SLOT1 + theApp.currentSlot);
831 }
833 void MainWnd::OnUpdateFileLoadgameCurrent(CCmdUI *pCmdUI)
834 {
835 int slotID = theApp.currentSlot + 1;
837 if (pCmdUI->m_pMenu != NULL)
838 {
839 CString str;
840 str.Format("&Current Slot (#%d)", slotID);
842 pCmdUI->SetText(str);
844 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
845 }
847 CFileStatus status;
848 pCmdUI->Enable(emulating && CFile::GetStatus(winGetSavestateFilename(theApp.gameFilename, slotID), status));
849 }
851 void MainWnd::OnFileLoadgameMakeCurrent()
852 {
853 theApp.loadMakesCurrent = !theApp.loadMakesCurrent;
854 }
856 void MainWnd::OnUpdateFileLoadgameMakeCurrent(CCmdUI *pCmdUI)
857 {
858 pCmdUI->SetCheck(theApp.loadMakesCurrent);
859 }
861 void MainWnd::OnFileSavegameMakeCurrent()
862 {
863 theApp.saveMakesCurrent = !theApp.saveMakesCurrent;
864 }
866 void MainWnd::OnUpdateFileSavegameMakeCurrent(CCmdUI *pCmdUI)
867 {
868 pCmdUI->SetCheck(theApp.saveMakesCurrent);
869 }
871 void MainWnd::OnFileSavegameIncrementSlot()
872 {
873 theApp.currentSlot = (theApp.currentSlot + 1) % 10;
875 char str [32];
876 sprintf(str, "Current Slot: %d", theApp.currentSlot + 1);
877 systemScreenMessage(str, 0);
878 }
880 void MainWnd::OnUpdateFileSavegameIncrementSlot(CCmdUI *pCmdUI)
881 {
882 if (pCmdUI->m_pMenu != NULL)
883 {
884 int slotID = theApp.currentSlot + 1;
886 CString str;
887 str.Format("&Increase Current Slot (#%d -> #%d)", slotID, slotID % 10 + 1);
889 pCmdUI->SetText(str);
891 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
892 }
893 }
895 void MainWnd::OnFileSavegameDecrementSlot()
896 {
897 theApp.currentSlot = (theApp.currentSlot + 9) % 10;
899 char str [32];
900 sprintf(str, "Current Slot: %d", theApp.currentSlot + 1);
901 systemScreenMessage(str, 0);
902 }
904 void MainWnd::OnUpdateFileSavegameDecrementSlot(CCmdUI *pCmdUI)
905 {
906 if (pCmdUI->m_pMenu != NULL)
907 {
908 int slotID = theApp.currentSlot + 1;
910 CString str;
911 str.Format("&Decrease Current Slot (#%d -> #%d)", slotID, (slotID + 8) % 10 + 1);
913 pCmdUI->SetText(str);
915 theApp.winAccelMgr.UpdateMenu(pCmdUI->m_pMenu->GetSafeHmenu());
916 }
917 }
919 void MainWnd::OnFileSlotDisplayModificationTime()
920 {
921 theApp.showSlotTime = !theApp.showSlotTime;
922 }
924 void MainWnd::OnUpdateFileSlotDisplayModificationTime(CCmdUI *pCmdUI)
925 {
926 pCmdUI->SetCheck(theApp.showSlotTime);
927 }
929 void MainWnd::OnFileLuaOpen()
930 {
931 theApp.winCheckFullscreen();
933 if (!LuaConsoleHWnd)
934 {
935 LuaConsoleHWnd = ::CreateDialog(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDD_LUA), AfxGetMainWnd()->GetSafeHwnd(), (DLGPROC) DlgLuaScriptDialog);
936 }
937 else
938 ::SetForegroundWindow(LuaConsoleHWnd);
939 }
941 void MainWnd::OnUpdateFileLuaOpen(CCmdUI *pCmdUI)
942 {
943 pCmdUI->SetCheck(LuaConsoleHWnd != NULL);
944 pCmdUI->Enable(true);
945 }
947 void MainWnd::OnFileLuaCloseAll()
948 {
949 if (LuaConsoleHWnd)
950 ::PostMessage(LuaConsoleHWnd, WM_CLOSE, 0, 0);
951 }
953 void MainWnd::OnFileLuaReload()
954 {
955 VBAReloadLuaCode();
956 }
958 void MainWnd::OnFileLuaStop()
959 {
960 VBALuaStop();
961 }
963 void MainWnd::OnFileRamSearch()
964 {
965 theApp.winCheckFullscreen();
967 if (!RamSearchHWnd)
968 {
969 reset_address_info();
970 LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
971 ::CreateDialog(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDD_RAMSEARCH), AfxGetMainWnd()->GetSafeHwnd(), (DLGPROC) RamSearchProc);
972 }
973 else
974 ::SetForegroundWindow(RamSearchHWnd);
975 }
977 void MainWnd::OnUpdateFileRamSearch(CCmdUI *pCmdUI)
978 {
979 pCmdUI->Enable(TRUE);
980 }
982 void MainWnd::OnFileRamWatch()
983 {
984 theApp.winCheckFullscreen();
986 if (!RamWatchHWnd)
987 {
988 LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
989 RamWatchHWnd = ::CreateDialog(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDD_RAMWATCH), AfxGetMainWnd()->GetSafeHwnd(), (DLGPROC) RamWatchProc);
990 }
991 else
992 ::SetForegroundWindow(RamWatchHWnd);
993 }
995 void MainWnd::OnUpdateFileRamWatch(CCmdUI *pCmdUI)
996 {
997 pCmdUI->Enable(TRUE);
998 }
1000 void MainWnd::OnUpdateFileLuaCloseAll(CCmdUI *pCmdUI)
1002 pCmdUI->Enable(LuaConsoleHWnd != NULL);