| 1 |
// menusystem.h |
| 2 |
// |
| 3 |
// (c) Robert Schuster, 2007 |
| 4 |
// |
| 5 |
// Licensed under GNU GPL version 2 or, at your option, any later version. |
| 6 |
|
| 7 |
#ifndef MENUSYSTEM_H |
| 8 |
#define MENUSYSTEM_H |
| 9 |
|
| 10 |
#include <map> |
| 11 |
|
| 12 |
#include "guichan/guichan.hpp" |
| 13 |
#include "guichan/guichan/sdl.hpp" |
| 14 |
|
| 15 |
#include "menu.h" |
| 16 |
|
| 17 |
/** |
| 18 |
* MenuSystem cares for all the low-level interaction of the menu system with |
| 19 |
* guichan. |
| 20 |
* |
| 21 |
* It is only supposed to be called through MenuManager. |
| 22 |
*/ |
| 23 |
class MenuSystem |
| 24 |
{ |
| 25 |
class KeyListener : public gcn::KeyListener |
| 26 |
{ |
| 27 |
MenuSystem &system; |
| 28 |
|
| 29 |
public: |
| 30 |
KeyListener(MenuSystem &menuSystem); |
| 31 |
|
| 32 |
virtual void keyReleased(gcn::KeyEvent &); |
| 33 |
}; |
| 34 |
|
| 35 |
gcn::Gui *gui; |
| 36 |
|
| 37 |
gcn::ImageFont *normal; |
| 38 |
gcn::ImageFont *highlighted; |
| 39 |
|
| 40 |
gcn::Container *top; |
| 41 |
|
| 42 |
std::map< Menu::Id, Menu * > *menus; |
| 43 |
|
| 44 |
Menu *currentMenu, *nextMenu; |
| 45 |
|
| 46 |
KeyListener *menuKeyListener; |
| 47 |
|
| 48 |
static gcn::ImageFont *loadFont(std::string); |
| 49 |
|
| 50 |
static gcn::Image *loadImage(std::string); |
| 51 |
|
| 52 |
public: |
| 53 |
MenuSystem(gcn::SDLInput *); |
| 54 |
~MenuSystem(); |
| 55 |
|
| 56 |
void render(); |
| 57 |
|
| 58 |
bool update(); |
| 59 |
|
| 60 |
void resize(); |
| 61 |
|
| 62 |
void addMenu(Menu::Id, Menu *); |
| 63 |
|
| 64 |
void enter(Menu::Id = Menu::MAIN); |
| 65 |
|
| 66 |
/** Cancels whatever operation is currently in progress. |
| 67 |
* |
| 68 |
* At the moment the following operations are known: |
| 69 |
* <ul> |
| 70 |
* <li>A widget may have initiated the input sensing mode. If it is |
| 71 |
* canceled the input mapping will not change.</li> |
| 72 |
* |
| 73 |
* <li>A certain submenu is open. On canceling it will get close and |
| 74 |
* enter its parent menu.</li> |
| 75 |
* |
| 76 |
* <li>The main menu is open. On canceling it will be hidden.</li> |
| 77 |
*/ |
| 78 |
void cancel(); |
| 79 |
|
| 80 |
void invoke(); |
| 81 |
|
| 82 |
bool isVisible() const; |
| 83 |
|
| 84 |
gcn::ImageFont *getNormalFont(); |
| 85 |
|
| 86 |
gcn::ImageFont *getHighlightedFont(); |
| 87 |
}; |
| 88 |
|
| 89 |
#endif |