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 SCI_GRAPHICS_MENU_H
23 #define SCI_GRAPHICS_MENU_H
24 
25 namespace Sci {
26 
27 enum {
28  SCI_MENU_ATTRIBUTE_SAID = 0x6d,
29  SCI_MENU_ATTRIBUTE_TEXT = 0x6e,
30  SCI_MENU_ATTRIBUTE_KEYPRESS = 0x6f,
31  SCI_MENU_ATTRIBUTE_ENABLED = 0x70,
32  SCI_MENU_ATTRIBUTE_TAG = 0x71
33 };
34 
35 enum {
36  SCI_MENU_REPLACE_ONCONTROL = 0x03,
37  SCI_MENU_REPLACE_ONALT = 0x02,
38  SCI_MENU_REPLACE_ONFUNCTION = 'F'
39 };
40 
41 struct GuiMenuEntry {
42  uint16 id;
43  Common::String text;
44  Common::String textSplit;
45  int16 textWidth;
46 
47  GuiMenuEntry(uint16 curId)
48  : id(curId), textWidth(0) { }
49 };
51 
53  uint16 menuId;
54  uint16 id;
55  bool enabled;
56  uint16 tag;
57  uint16 keyPress;
58  uint16 keyModifier;
59  bool separatorLine;
60  reg_t saidVmPtr;
61  Common::String text;
62  Common::String textSplit;
63  reg_t textVmPtr;
64  int16 textWidth;
65  Common::String textRightAligned;
66  int16 textRightAlignedWidth;
67 
68  GuiMenuItemEntry(uint16 curMenuId, uint16 curId)
69  : menuId(curMenuId), id(curId),
70  enabled(true), tag(0), keyPress(0), keyModifier(0), separatorLine(false), textWidth(0), textRightAlignedWidth(0) {
71  saidVmPtr = NULL_REG;
72  textVmPtr = NULL_REG;
73  }
74 };
76 
80 class GfxMenu {
81 public:
82  GfxMenu(EventManager *event, SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen, GfxCursor *cursor);
83  ~GfxMenu();
84 
85  void reset();
86  void kernelAddEntry(const Common::String &title, Common::String content, reg_t contentVmPtr);
87  void kernelSetAttribute(uint16 menuId, uint16 itemId, uint16 attributeId, reg_t value);
88  reg_t kernelGetAttribute(uint16 menuId, uint16 itemId, uint16 attributeId);
89 
90  void drawBar();
91  reg_t kernelSelect(reg_t eventObject, bool pauseSound);
92 
93  void kernelDrawStatus(const char *text, int16 colorPen, int16 colorBack);
94  void kernelDrawMenuBar(bool clear);
95 
96 private:
97  GuiMenuItemEntry *findItem(uint16 menuId, uint16 itemId);
98  void calculateMenuWidth();
99  void calculateMenuAndItemWidth();
100  void drawMenu(uint16 oldMenuId, uint16 newMenuId);
101  void invertMenuSelection(uint16 itemId);
102  void interactiveStart(bool pauseSound);
103  void interactiveEnd(bool pauseSound);
104  GuiMenuItemEntry *interactiveWithKeyboard();
105  GuiMenuItemEntry *interactiveWithMouse();
106  uint16 mouseFindMenuSelection(Common::Point mousePosition);
107  uint16 mouseFindMenuItemSelection(Common::Point mousePosition, uint16 menuId);
108  GuiMenuItemEntry *interactiveGetItem(uint16 menuId, uint16 itemId, bool menuChanged);
109 
110  EventManager *_event;
111  SegManager *_segMan;
112  GfxPorts *_ports;
113  GfxPaint16 *_paint16;
114  GfxText16 *_text16;
115  GfxScreen *_screen;
116  GfxCursor *_cursor;
117 
118  GuiMenuList _list;
119  GuiMenuItemList _itemList;
120 
121  uint16 _curMenuId;
122  uint16 _curItemId;
123 
124  Port *_oldPort;
125  reg_t _barSaveHandle;
126  reg_t _menuSaveHandle;
127  Common::Rect _menuRect;
128 
129  bool _mouseOldState;
130 };
131 
132 } // End of namespace Sci
133 
134 #endif // SCI_GRAPHICS_MENU_H
Definition: paint16.h:36
Definition: ports.h:52
Definition: str.h:59
Definition: menu.h:52
Definition: rect.h:144
Definition: menu.h:80
Definition: rect.h:45
Definition: console.h:28
Definition: seg_manager.h:48
Definition: text16.h:45
Definition: cursor.h:54
Definition: screen.h:68
Definition: event.h:151
Definition: vm_types.h:39
Definition: helpers.h:56
Definition: menu.h:41