1 #ifndef __BTANKS_WINDOW_H__ 2 #define __BTANKS_WINDOW_H__ 3 4 /* Battle Tanks Game 5 * Copyright (C) 2006-2009 Battle Tanks team 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 */ 21 22 /* 23 * Additional rights can be granted beyond the GNU General Public License 24 * on the terms provided in the Exception. If you modify this file, 25 * you may extend this exception to your version of the file, 26 * but you are not obligated to do so. If you do not wish to provide this 27 * exception without modification, you must delete this exception statement 28 * from your version and license this file solely under the GPL without exception. 29 */ 30 31 #include "sdlx/surface.h" 32 #include "sl08/sl08.h" 33 #include "sdlx/timer.h" 34 #include "export_btanks.h" 35 #include "mrt/singleton.h" 36 #include <deque> 37 38 class BTANKSAPI IWindow { 39 public: 40 DECLARE_SINGLETON(IWindow); 41 42 std::deque<SDL_Rect> resolutions; 43 44 //signals 45 sl08::signal1<void, const SDL_Event& > event_signal; 46 sl08::signal1<bool, float, sl08::exclusive_validator<bool> > tick_signal; 47 sl08::signal2<bool, const SDL_keysym, const bool, sl08::exclusive_validator<bool> > key_signal; 48 sl08::signal3<void, const int, const int, const bool> joy_button_signal; 49 sl08::signal4<bool, const int, const bool, const int, const int, sl08::exclusive_validator<bool> > mouse_signal; 50 sl08::signal5<bool, const int, const int, const int, const int, const int, sl08::exclusive_validator<bool> > mouse_motion_signal; 51 52 IWindow(); 53 void init(const int argc, char *argv[]); 54 void createMainWindow(); 55 void initSDL(); 56 void run(); running()57 const bool running() const { return _running; } stop()58 void stop() { _running = false; } 59 void deinit(); 60 virtual ~IWindow(); 61 get_size()62 const sdlx::Rect get_size() const { return _window.get_size(); } getFrameRate()63 const float getFrameRate() const { return _fr; } 64 65 void resetTimer(); get_surface()66 sdlx::Surface &get_surface() { return _window; } 67 68 void flip(); 69 70 void init_dummy(); 71 72 private: 73 sdlx::Surface _window; 74 int _fsaa; 75 bool _init_joystick; 76 bool _fullscreen, _vsync, _running; 77 #ifdef _WINDOWS 78 bool _dx; 79 #else 80 bool _opengl, _force_soft; 81 #endif 82 int _w, _h; 83 sdlx::Timer _timer; 84 float _fr; 85 }; 86 87 PUBLIC_SINGLETON(BTANKSAPI, Window, IWindow); 88 89 #endif 90