1 #ifndef BTANKS_REDEFINE_KEYS_H__ 2 #define BTANKS_REDEFINE_KEYS_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 "container.h" 32 #include "box.h" 33 34 #include <vector> 35 #include <string> 36 #include <map> 37 38 namespace sdlx { 39 class Font; 40 class Rect; 41 } 42 43 class Button; 44 45 class RedefineKeys : public Container { 46 public: 47 RedefineKeys(); 48 49 virtual void tick(const float dt); 50 virtual void render(sdlx::Surface &surface, const int x, const int y) const; 51 virtual void get_size(int &w, int &h) const; 52 53 virtual bool onKey(const SDL_keysym sym); 54 virtual bool onMouse(const int button, const bool pressed, const int x, const int y); 55 virtual bool onMouseMotion(const int state, const int x, const int y, const int xrel, const int yrel); 56 57 void load(); 58 void revert_to_defaults(); 59 void save(); 60 61 private: 62 63 void initDefaults(); 64 65 const sdlx::Surface *_bg_table, *_selection; 66 const sdlx::Font * _font, *_small_font; 67 Box _background; 68 69 int _active_row, _active_col; 70 71 std::vector<std::string> _labels; 72 typedef std::vector<std::pair<std::string, sdlx::Rect> > Actions; 73 mutable Actions _actions; 74 75 int _keys[3][8]; 76 77 Button *_b_ok, *_b_default; 78 }; 79 80 #endif 81 82