File: menusystem.h

package info (click to toggle)
qonk 0.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,076 kB
  • ctags: 2,026
  • sloc: cpp: 14,978; sh: 3,464; makefile: 200
file content (89 lines) | stat: -rw-r--r-- 1,764 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// menusystem.h
//
// (c) Robert Schuster, 2007
//
// Licensed under GNU GPL version 2 or, at your option, any later version.

#ifndef MENUSYSTEM_H
#define MENUSYSTEM_H

#include <map>

#include "guichan/guichan.hpp"
#include "guichan/guichan/sdl.hpp"

#include "menu.h"

/**
 * MenuSystem cares for all the low-level interaction of the menu system with
 * guichan.
 *
 * It is only supposed to be called through MenuManager.
 */
class MenuSystem
{
  class KeyListener : public gcn::KeyListener
  {
    MenuSystem &system;

    public:
    KeyListener(MenuSystem &menuSystem);

    virtual void keyReleased(gcn::KeyEvent &);
  };

  gcn::Gui *gui;

  gcn::ImageFont *normal;
  gcn::ImageFont *highlighted;

  gcn::Container *top;

  std::map< Menu::Id, Menu * > *menus;

  Menu *currentMenu, *nextMenu;

  KeyListener *menuKeyListener;

  static gcn::ImageFont *loadFont(std::string);

  static gcn::Image *loadImage(std::string);

  public:
    MenuSystem(gcn::SDLInput *);
    ~MenuSystem();

    void render();

    bool update();

    void resize();

    void addMenu(Menu::Id, Menu *);

    void enter(Menu::Id = Menu::MAIN);

    /** Cancels whatever operation is currently in progress.
     * 
     * At the moment the following operations are known:
     * <ul>
     * <li>A widget may have initiated the input sensing mode. If it is
     * canceled the input mapping will not change.</li>
     * 
     * <li>A certain submenu is open. On canceling it will get close and
     * enter its parent menu.</li>
     * 
     * <li>The main menu is open. On canceling it will be hidden.</li> 
     */  
    void cancel();

    void invoke();

    bool isVisible() const;

    gcn::ImageFont *getNormalFont();

    gcn::ImageFont *getHighlightedFont();
};

#endif