annotate src/gtk/window.h @ 1:f9f4f1b99eed

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