1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef PARALLACTION_GUI_H 24 #define PARALLACTION_GUI_H 25 26 #include "common/system.h" 27 #include "common/hashmap.h" 28 29 #include "parallaction/input.h" 30 #include "parallaction/parallaction.h" 31 #include "parallaction/sound.h" 32 33 34 namespace Parallaction { 35 36 class MenuInputState; 37 38 class MenuInputHelper { 39 typedef Common::HashMap<Common::String, MenuInputState *> StateMap; 40 41 StateMap _map; 42 MenuInputState *_state; 43 MenuInputState *_newState; 44 45 public: MenuInputHelper()46 MenuInputHelper() : _state(0), _newState(0) { 47 } 48 49 ~MenuInputHelper(); 50 setState(const Common::String & name)51 void setState(const Common::String &name) { 52 // bootstrap routine 53 _newState = getState(name); 54 assert(_newState); 55 } 56 addState(const Common::String & name,MenuInputState * state)57 void addState(const Common::String &name, MenuInputState *state) { 58 _map.setVal(name, state); 59 } 60 getState(const Common::String & name)61 MenuInputState *getState(const Common::String &name) { 62 return _map[name]; 63 } 64 65 bool run(); 66 }; 67 68 class MenuInputState { 69 70 protected: 71 MenuInputHelper *_helper; 72 73 public: MenuInputState(const Common::String & name,MenuInputHelper * helper)74 MenuInputState(const Common::String &name, MenuInputHelper *helper) : _helper(helper), _name(name) { 75 debugC(3, kDebugExec, "MenuInputState(%s)", name.c_str()); 76 _helper->addState(name, this); 77 } 78 79 Common::String _name; 80 ~MenuInputState()81 virtual ~MenuInputState() { } 82 83 virtual MenuInputState* run() = 0; 84 virtual void enter() = 0; 85 }; 86 87 88 } // namespace Parallaction 89 90 #endif 91