home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Freeware / Utilitare / VisualBoyAdvance-1.7.2 / src / win32 / MainWndCheats.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-05-13  |  4.0 KB  |  166 lines

  1. // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
  2. // Copyright (C) 1999-2003 Forgotten
  3. // Copyright (C) 2004 Forgotten and the VBA development team
  4.  
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 2, or(at your option)
  8. // any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software Foundation,
  17. // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18.  
  19. #include "stdafx.h"
  20. #include "MainWnd.h"
  21.  
  22. #include "FileDlg.h"
  23. #include "GBACheats.h"
  24. #include "GBCheatsDlg.h"
  25. #include "Reg.h"
  26. #include "WinResUtil.h"
  27.  
  28. #include "../GBA.h"
  29. #include "../Globals.h"
  30. #include "../gb/gbCheats.h"
  31.  
  32. extern int emulating;
  33.  
  34. void MainWnd::OnCheatsSearchforcheats() 
  35. {
  36.   theApp.winCheckFullscreen();
  37.   if(theApp.cartridgeType == 0) {
  38.     GBACheatSearch dlg;
  39.     dlg.DoModal();
  40.   } else {
  41.     GBCheatSearch dlg;
  42.     dlg.DoModal();
  43.   }
  44. }
  45.  
  46. void MainWnd::OnUpdateCheatsSearchforcheats(CCmdUI* pCmdUI) 
  47. {
  48.   pCmdUI->Enable(emulating);
  49. }
  50.  
  51. void MainWnd::OnCheatsCheatlist() 
  52. {
  53.   theApp.winCheckFullscreen();
  54.   if(theApp.cartridgeType == 0) {
  55.     GBACheatList dlg;
  56.     dlg.DoModal();
  57.   } else {
  58.     GBCheatList dlg;
  59.     dlg.DoModal();
  60.   }
  61. }
  62.  
  63. void MainWnd::OnUpdateCheatsCheatlist(CCmdUI* pCmdUI) 
  64. {
  65.   pCmdUI->Enable(emulating);
  66. }
  67.  
  68. void MainWnd::OnCheatsAutomaticsaveloadcheats() 
  69. {
  70.   theApp.autoSaveLoadCheatList = !theApp.autoSaveLoadCheatList;
  71. }
  72.  
  73. void MainWnd::OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI) 
  74. {
  75.   pCmdUI->SetCheck(theApp.autoSaveLoadCheatList);
  76. }
  77.  
  78. void MainWnd::OnCheatsLoadcheatlist() 
  79. {
  80.   theApp.winCheckFullscreen();
  81.   CString buffer;
  82.   CString filename;
  83.  
  84.   int index = theApp.filename.ReverseFind('\\');
  85.  
  86.   if(index != -1)
  87.     buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1);
  88.   else
  89.     buffer = theApp.filename;
  90.  
  91.   CString saveDir = regQueryStringValue("saveDir", NULL);
  92.  
  93.   if(saveDir.IsEmpty())
  94.     saveDir = getDirFromFile(theApp.filename);
  95.  
  96.   if(isDriveRoot(saveDir))
  97.     filename.Format("%s%s.clt", saveDir, buffer);
  98.   else
  99.     filename.Format("%s\\%s.clt", saveDir, buffer);
  100.  
  101.   LPCTSTR exts[] = { ".clt" };
  102.   CString filter = winLoadFilter(IDS_FILTER_CHEAT_LIST);
  103.   CString title = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME);
  104.  
  105.   FileDlg dlg(this, filename, filter, 0, "CLT", exts, saveDir, title, false);
  106.  
  107.   if(dlg.DoModal() == IDOK) {
  108.     winLoadCheatList(dlg.GetPathName());
  109.   }
  110. }
  111.  
  112. void MainWnd::OnUpdateCheatsLoadcheatlist(CCmdUI* pCmdUI) 
  113. {
  114.   pCmdUI->Enable(emulating);
  115. }
  116.  
  117. void MainWnd::OnCheatsSavecheatlist() 
  118. {
  119.   theApp.winCheckFullscreen();
  120.   CString buffer;
  121.   CString filename;
  122.  
  123.   int index = theApp.filename.ReverseFind('\\');
  124.  
  125.   if(index != -1)
  126.     buffer = theApp.filename.Right(theApp.filename.GetLength()-index-1);
  127.   else
  128.     buffer = theApp.filename;
  129.  
  130.   CString saveDir = regQueryStringValue("saveDir", NULL);
  131.  
  132.   if(saveDir.IsEmpty())
  133.     saveDir = getDirFromFile(theApp.filename);
  134.  
  135.   if(isDriveRoot(saveDir))
  136.     filename.Format("%s%s.clt", saveDir, buffer);
  137.   else
  138.     filename.Format("%s\\%s.clt", saveDir, buffer);
  139.  
  140.   LPCTSTR exts[] = { ".clt" };
  141.   CString filter = winLoadFilter(IDS_FILTER_CHEAT_LIST);
  142.   CString title = winResLoadString(IDS_SELECT_CHEAT_LIST_NAME);
  143.  
  144.   FileDlg dlg(this, filename, filter, 0, "CLT", exts, saveDir, title, true);
  145.  
  146.   if(dlg.DoModal() == IDOK) {
  147.     winSaveCheatList(dlg.GetPathName());
  148.   }
  149. }
  150.  
  151. void MainWnd::OnUpdateCheatsSavecheatlist(CCmdUI* pCmdUI) 
  152. {
  153.   pCmdUI->Enable(emulating);
  154. }
  155.  
  156. void MainWnd::OnCheatsDisablecheats() 
  157. {
  158.   cheatsEnabled = !cheatsEnabled;
  159. }
  160.  
  161. void MainWnd::OnUpdateCheatsDisablecheats(CCmdUI* pCmdUI) 
  162. {
  163.   pCmdUI->SetCheck(!cheatsEnabled);
  164. }
  165.  
  166.