1 // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
2 // Copyright (C) 1999-2003 Forgotten
3 // Copyright (C) 2004 Forgotten and the VBA development team
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)
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.
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.
23 #include "GBACheats.h"
24 #include "GBCheatsDlg.h"
26 #include "WinResUtil.h"
29 #include "../Globals.h"
30 #include "../gb/gbCheats.h"
34 void MainWnd::OnCheatsSearchforcheats()
36 theApp
.winCheckFullscreen();
37 if(theApp
.cartridgeType
== 0) {
46 void MainWnd::OnUpdateCheatsSearchforcheats(CCmdUI
* pCmdUI
)
48 pCmdUI
->Enable(emulating
);
51 void MainWnd::OnCheatsCheatlist()
53 theApp
.winCheckFullscreen();
54 if(theApp
.cartridgeType
== 0) {
63 void MainWnd::OnUpdateCheatsCheatlist(CCmdUI
* pCmdUI
)
65 pCmdUI
->Enable(emulating
);
68 void MainWnd::OnCheatsAutomaticsaveloadcheats()
70 theApp
.autoSaveLoadCheatList
= !theApp
.autoSaveLoadCheatList
;
73 void MainWnd::OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI
* pCmdUI
)
75 pCmdUI
->SetCheck(theApp
.autoSaveLoadCheatList
);
78 void MainWnd::OnCheatsLoadcheatlist()
80 theApp
.winCheckFullscreen();
84 int index
= theApp
.filename
.ReverseFind('\\');
87 buffer
= theApp
.filename
.Right(theApp
.filename
.GetLength()-index
-1);
89 buffer
= theApp
.filename
;
91 CString saveDir
= regQueryStringValue("saveDir", NULL
);
94 saveDir
= getDirFromFile(theApp
.filename
);
96 if(isDriveRoot(saveDir
))
97 filename
.Format("%s%s.clt", saveDir
, buffer
);
99 filename
.Format("%s\\%s.clt", saveDir
, buffer
);
101 LPCTSTR exts
[] = { ".clt" };
102 CString filter
= winLoadFilter(IDS_FILTER_CHEAT_LIST
);
103 CString title
= winResLoadString(IDS_SELECT_CHEAT_LIST_NAME
);
105 FileDlg
dlg(this, filename
, filter
, 0, "CLT", exts
, saveDir
, title
, false);
107 if(dlg
.DoModal() == IDOK
) {
108 winLoadCheatList(dlg
.GetPathName());
112 void MainWnd::OnUpdateCheatsLoadcheatlist(CCmdUI
* pCmdUI
)
114 pCmdUI
->Enable(emulating
);
117 void MainWnd::OnCheatsSavecheatlist()
119 theApp
.winCheckFullscreen();
123 int index
= theApp
.filename
.ReverseFind('\\');
126 buffer
= theApp
.filename
.Right(theApp
.filename
.GetLength()-index
-1);
128 buffer
= theApp
.filename
;
130 CString saveDir
= regQueryStringValue("saveDir", NULL
);
132 if(saveDir
.IsEmpty())
133 saveDir
= getDirFromFile(theApp
.filename
);
135 if(isDriveRoot(saveDir
))
136 filename
.Format("%s%s.clt", saveDir
, buffer
);
138 filename
.Format("%s\\%s.clt", saveDir
, buffer
);
140 LPCTSTR exts
[] = { ".clt" };
141 CString filter
= winLoadFilter(IDS_FILTER_CHEAT_LIST
);
142 CString title
= winResLoadString(IDS_SELECT_CHEAT_LIST_NAME
);
144 FileDlg
dlg(this, filename
, filter
, 0, "CLT", exts
, saveDir
, title
, true);
146 if(dlg
.DoModal() == IDOK
) {
147 winSaveCheatList(dlg
.GetPathName());
151 void MainWnd::OnUpdateCheatsSavecheatlist(CCmdUI
* pCmdUI
)
153 pCmdUI
->Enable(emulating
);
156 void MainWnd::OnCheatsDisablecheats()
158 cheatsEnabled
= !cheatsEnabled
;
161 void MainWnd::OnUpdateCheatsDisablecheats(CCmdUI
* pCmdUI
)
163 pCmdUI
->SetCheck(!cheatsEnabled
);