view src/gtk/window.h @ 5:8fe0c57e53d2

concentrating on lua first
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:39:40 -0600
parents f9f4f1b99eed
children
line wrap: on
line source
1 // -*- C++ -*-
2 // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
3 // Copyright (C) 1999-2003 Forgotten
4 // Copyright (C) 2004 Forgotten and the VBA development team
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2, or(at your option)
9 // any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __VBA_WINDOW_H__
21 #define __VBA_WINDOW_H__
23 #include <sys/types.h>
24 #include <stdarg.h>
26 #include <libglademm.h>
27 #include <gtkmm.h>
29 #ifndef GTKMM20
30 # include "sigccompat.h"
31 #endif // ! GTKMM20
33 #include <string>
34 #include <vector>
35 #include <list>
37 #include "../common/System.h"
39 #include "configfile.h"
40 #include "screenarea.h"
41 #include "filters.h"
42 #include "input.h"
43 #include "joypadconfig.h"
45 namespace VBA
46 {
48 class Window : public Gtk::Window
49 {
50 friend class Gnome::Glade::Xml;
52 public:
53 virtual ~Window();
55 inline static Window * poGetInstance() { return m_poInstance; }
57 enum ECartridge
58 {
59 CartridgeNone,
60 CartridgeGB,
61 CartridgeGBA
62 };
64 // GB/GBA screen sizes
65 const int m_iGBScreenWidth;
66 const int m_iGBScreenHeight;
67 const int m_iSGBScreenWidth;
68 const int m_iSGBScreenHeight;
69 const int m_iGBAScreenWidth;
70 const int m_iGBAScreenHeight;
72 bool bLoadROM(const std::string & _rsFile);
73 void vPopupError(const char * _csFormat, ...);
74 void vPopupErrorV(const char * _csFormat, va_list _args);
75 void vDrawScreen();
76 void vComputeFrameskip(int _iRate);
77 void vShowSpeed(int _iSpeed);
78 void vCaptureScreen(int _iNum);
79 u32 uiReadJoypad();
81 inline ECartridge eGetCartridge() const { return m_eCartridge; }
82 inline int iGetThrottle() const { return m_iThrottle; }
84 protected:
85 Window(GtkWindow * _pstWindow,
86 const Glib::RefPtr<Gnome::Glade::Xml> & _poXml);
88 enum EShowSpeed
89 {
90 ShowNone,
91 ShowPercentage,
92 ShowDetailed
93 };
95 enum ESaveType
96 {
97 SaveAuto,
98 SaveEEPROM,
99 SaveSRAM,
100 SaveFlash,
101 SaveEEPROMSensor,
102 SaveNone
103 };
105 enum ESoundStatus
106 {
107 SoundOff,
108 SoundMute,
109 SoundOn
110 };
112 enum ESoundQuality
113 {
114 Sound44K = 1,
115 Sound22K = 2,
116 Sound11K = 4
117 };
119 enum ESoundVolume
120 {
121 Sound100,
122 Sound200,
123 Sound300,
124 Sound400,
125 Sound25,
126 Sound50
127 };
129 enum EEmulatorType
130 {
131 EmulatorAuto,
132 EmulatorCGB,
133 EmulatorSGB,
134 EmulatorGB,
135 EmulatorGBA,
136 EmulatorSGB2
137 };
139 virtual void vOnFileOpen();
140 virtual void vOnFileLoad();
141 virtual void vOnFileSave();
142 virtual void vOnLoadGameMostRecent();
143 virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI);
144 virtual void vOnLoadGame(int _iSlot);
145 virtual void vOnSaveGameOldest();
146 virtual void vOnSaveGame(int _iSlot);
147 virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI);
148 virtual void vOnFileReset();
149 virtual void vOnRecentReset();
150 virtual void vOnRecentFreezeToggled(Gtk::CheckMenuItem * _poCMI);
151 virtual void vOnRecentFile(std::string _sFile);
152 virtual void vOnImportBatteryFile();
153 virtual void vOnExportBatteryFile();
154 virtual void vOnFileScreenCapture();
155 virtual void vOnFileClose();
156 virtual void vOnFileExit();
157 virtual void vOnFrameskipToggled(Gtk::CheckMenuItem * _poCMI, int _iValue);
158 virtual void vOnThrottleToggled(Gtk::CheckMenuItem * _poCMI, int _iPercent);
159 virtual void vOnThrottleOther(Gtk::CheckMenuItem * _poCMI);
160 virtual void vOnVideoScaleToggled(Gtk::CheckMenuItem * _poCMI, int _iScale);
161 virtual void vOnLayerToggled(Gtk::CheckMenuItem * _poCMI, int _iLayer);
162 virtual void vOnDirectories();
163 virtual void vOnDirectoryReset(Gtk::Entry * _poEntry);
164 virtual void vOnDirectorySelect(Gtk::Entry * _poEntry);
165 virtual void vOnPauseWhenInactiveToggled(Gtk::CheckMenuItem * _poCMI);
166 virtual void vOnSelectBios();
167 virtual void vOnUseBiosToggled(Gtk::CheckMenuItem * _poCMI);
168 virtual void vOnShowSpeedToggled(Gtk::CheckMenuItem * _poCMI, int _iShowSpeed);
169 virtual void vOnSaveTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iSaveType);
170 virtual void vOnFlashSizeToggled(Gtk::CheckMenuItem * _poCMI, int _iFlashSize);
171 virtual void vOnScreenshotFormatToggled(Gtk::CheckMenuItem * _poCMI, std::string _sFormat);
172 virtual void vOnSoundStatusToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundStatus);
173 virtual void vOnSoundEchoToggled(Gtk::CheckMenuItem * _poCMI);
174 virtual void vOnSoundLowPassToggled(Gtk::CheckMenuItem * _poCMI);
175 virtual void vOnSoundReverseToggled(Gtk::CheckMenuItem * _poCMI);
176 virtual void vOnSoundChannelToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundChannel);
177 virtual void vOnSoundQualityToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundQuality);
178 virtual void vOnSoundVolumeToggled(Gtk::CheckMenuItem * _poCMI, int _iSoundVolume);
179 virtual void vOnGBBorderToggled(Gtk::CheckMenuItem * _poCMI);
180 virtual void vOnGBPrinterToggled(Gtk::CheckMenuItem * _poCMI);
181 virtual void vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType);
182 virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x);
183 virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB);
184 #ifdef MMX
185 virtual void vOnDisableMMXToggled(Gtk::CheckMenuItem * _poCMI);
186 #endif // MMX
187 virtual void vOnJoypadConfigure(int _iJoypad);
188 virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad);
189 virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag);
190 virtual void vOnGDBWait();
191 virtual void vOnGDBLoadAndWait();
192 virtual void vOnGDBBreak();
193 virtual void vOnGDBDisconnect();
194 virtual void vOnHelpAbout();
195 virtual bool bOnEmuIdle();
197 virtual bool on_focus_in_event(GdkEventFocus * _pstEvent);
198 virtual bool on_focus_out_event(GdkEventFocus * _pstEvent);
199 virtual bool on_key_press_event(GdkEventKey * _pstEvent);
200 virtual bool on_key_release_event(GdkEventKey * _pstEvent);
202 private:
203 // Config limits
204 const int m_iFrameskipMin;
205 const int m_iFrameskipMax;
206 const int m_iThrottleMin;
207 const int m_iThrottleMax;
208 const int m_iScaleMin;
209 const int m_iScaleMax;
210 const int m_iShowSpeedMin;
211 const int m_iShowSpeedMax;
212 const int m_iSaveTypeMin;
213 const int m_iSaveTypeMax;
214 const int m_iSoundQualityMin;
215 const int m_iSoundQualityMax;
216 const int m_iSoundVolumeMin;
217 const int m_iSoundVolumeMax;
218 const int m_iEmulatorTypeMin;
219 const int m_iEmulatorTypeMax;
220 const int m_iFilter2xMin;
221 const int m_iFilter2xMax;
222 const int m_iFilterIBMin;
223 const int m_iFilterIBMax;
224 const int m_iJoypadMin;
225 const int m_iJoypadMax;
227 static Window * m_poInstance;
229 Glib::RefPtr<Gnome::Glade::Xml> m_poXml;
231 std::string m_sUserDataDir;
232 std::string m_sConfigFile;
233 Config::File m_oConfig;
234 Config::Section * m_poHistoryConfig;
235 Config::Section * m_poDirConfig;
236 Config::Section * m_poCoreConfig;
237 Config::Section * m_poDisplayConfig;
238 Config::Section * m_poSoundConfig;
239 Config::Section * m_poInputConfig;
241 #ifdef GTKMM20
242 Gtk::FileSelection * m_poFileOpenDialog;
243 #else // ! GTKMM20
244 Gtk::FileChooserDialog * m_poFileOpenDialog;
245 #endif // ! GTKMM20
246 ScreenArea * m_poScreenArea;
247 Gtk::Menu * m_poRecentMenu;
248 Gtk::MenuItem * m_poRecentResetItem;
249 Gtk::CheckMenuItem * m_poFilePauseItem;
250 Gtk::CheckMenuItem * m_poUseBiosItem;
251 Gtk::CheckMenuItem * m_poSoundOffItem;
253 struct SGameSlot
254 {
255 bool m_bEmpty;
256 std::string m_sFile;
257 time_t m_uiTime;
258 };
260 Gtk::MenuItem * m_apoLoadGameItem[10];
261 Gtk::MenuItem * m_apoSaveGameItem[10];
262 SGameSlot m_astGameSlot[10];
264 std::list<std::string> m_listHistory;
266 std::list<Gtk::Widget *> m_listSensitiveWhenPlaying;
268 Gtk::Tooltips m_oTooltips;
270 SigC::connection m_oEmuSig;
272 std::vector<JoypadConfig> m_oJoypads;
273 Keymap * m_poKeymap;
275 int m_iScreenWidth;
276 int m_iScreenHeight;
278 std::string m_sRomFile;
279 ECartridge m_eCartridge;
280 EmulatedSystem m_stEmulator;
281 u32 m_uiJoypadState;
282 u32 m_uiAutofireState;
283 bool m_bAutofireToggle;
284 bool m_bPaused;
285 bool m_bWasEmulating;
286 bool m_bAutoFrameskip;
287 int m_iThrottle;
288 u32 m_uiThrottleLastTime;
289 u32 m_uiThrottleDelay;
290 EShowSpeed m_eShowSpeed;
291 ESoundQuality m_eSoundQuality;
293 void vInitSystem();
294 void vInitSDL();
295 void vInitConfig();
296 void vCheckConfig();
297 void vLoadConfig(const std::string & _rsFile);
298 void vSaveConfig(const std::string & _rsFile);
299 void vLoadHistoryFromConfig();
300 void vSaveHistoryToConfig();
301 void vHistoryAdd(const std::string & _rsFile);
302 void vClearHistoryMenu();
303 void vUpdateHistoryMenu();
304 void vLoadJoypadsFromConfig();
305 void vSaveJoypadsToConfig();
306 void vUpdateScreen();
307 void vDrawDefaultScreen();
308 void vSetDefaultTitle();
309 void vCreateFileOpenDialog();
310 void vLoadBattery();
311 void vSaveBattery();
312 void vStartEmu();
313 void vStopEmu();
314 void vSetThrottle(int _iPercent);
315 void vSelectBestThrottleItem();
316 void vUpdateGameSlots();
317 };
319 } // namespace VBA
322 #endif // __VBA_WINDOW_H__