ScummVM API documentation
menu.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef AGI_MENU_H
23 #define AGI_MENU_H
24 
25 namespace Agi {
26 
27 struct GuiMenuEntry {
28  Common::String text;
29  int16 textLen;
30 
31  int16 row;
32  int16 column;
33 
34  int16 itemCount; // total number of menu items
35  int16 firstItemNr; // first menu item number, points into _itemArray[]
36 
37  int16 selectedItemNr; // currently selected menu item
38 
39  int16 maxItemTextLen; // maximum text length of all menu items
40 };
42 
44  Common::String text;
45  int16 textLen;
46 
47  int16 row;
48  int16 column;
49 
50  bool enabled; // enabled-state, set by scripts
51  uint16 controllerSlot; // controller to trigger, when item is executed
52 };
54 
55 class GfxMenu {
56 public:
57  GfxMenu(AgiEngine *vm, GfxMgr *gfx, PictureMgr *picture, TextMgr *text);
58  ~GfxMenu();
59 
60  void addMenu(const char *menuText);
61  void addMenuItem(const char *menuText, uint16 controlCode);
62  void submit();
63  void itemEnable(uint16 controllerSlot);
64  void itemDisable(uint16 controllerSlot);
65  void itemEnableAll();
66 
67  void keyPress(uint16 newKey);
68  void mouseEvent(uint16 newKey);
69 
70  bool isAvailable();
71 
72  void accessAllow();
73  void accessDeny();
74 
75  void delayedExecuteViaKeyboard();
76  void delayedExecuteViaMouse();
77  bool delayedExecuteActive();
78  void execute();
79 
80 private:
81  void itemEnableDisable(uint16 controllerSlot, bool enabled);
82 
83  void drawMenuName(int16 menuNr, bool inverted);
84  void drawItemName(int16 itemNr, bool inverted);
85  void drawMenu(int16 selectedMenuNr, int16 selectedMenuItemNr);
86  void removeActiveMenu(int16 selectedMenuNr);
87 
88  void mouseFindMenuSelection(int16 mouseRow, int16 mouseColumn, int16 &activeMenuNr, int16 &activeMenuItemNr);
89 
90  AgiEngine *_vm;
91  GfxMgr *_gfx;
92  PictureMgr *_picture;
93  TextMgr *_text;
94 
95  bool _allowed;
96  bool _submitted;
97  bool _delayedExecuteViaKeyboard;
98  bool _delayedExecuteViaMouse;
99 
100  // for initial setup of the menu
101  int16 _setupMenuColumn;
102  int16 _setupMenuItemColumn;
103 
104  GuiMenuArray _array;
105  GuiMenuItemArray _itemArray;
106 
107  int16 _lastSelectedMenuNr; // only used for "via keyboard" mode
108 
109  int16 _drawnMenuNr;
110 
111  uint16 _drawnMenuHeight;
112  uint16 _drawnMenuWidth;
113  int16 _drawnMenuY;
114  int16 _drawnMenuX;
115 
116  // Following variables are used in "via mouse" mode
117  int16 _mouseModeItemNr;
118 };
119 
120 } // End of namespace Agi
121 
122 #endif /* AGI_MENU_H */
Definition: str.h:59
Definition: menu.h:43
Definition: menu.h:55
Definition: picture.h:66
Definition: graphics.h:58
Definition: agi.h:839
Definition: agi.h:63
Definition: menu.h:27
Definition: text.h:76