ScummVM API documentation
dropdown.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/*
23 * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
24 * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
25 */
26
27/* Original name: DROPDOWN A customized version of Oopmenu (qv). */
28
29#ifndef AVALANCHE_DROPDOWN_H
30#define AVALANCHE_DROPDOWN_H
31
32#include "common/str.h"
33
34namespace Avalanche {
35class AvalancheEngine;
36
37class DropDownMenu;
38
39typedef void (DropDownMenu::*MenuFunc)();
40static const Color kMenuBackgroundColor = kColorLightgray;
41static const Color kMenuBorderColor = kColorBlack;
42
43class HeadType {
44public:
45 Common::String _title;
46 char _trigger, _altTrigger;
47 byte _position;
48 int16 _xpos, _xright;
49 MenuFunc _setupFunc, _chooseFunc;
50
51 void init(char trig, char alTtrig, Common::String title, byte pos, MenuFunc setupFunc, MenuFunc chooseFunc, DropDownMenu *menu);
52 void draw();
53 void highlight();
54 bool parseAltTrigger(char key);
55
56private:
57 DropDownMenu *_dropdown;
58};
59
60struct OptionType {
61 Common::String _title;
62 byte _trigger;
63 Common::String _shortcut;
64 bool _valid;
65};
66
67class MenuItem {
68public:
69 OptionType _options[12];
70 uint16 _width, _left;
71 bool _firstlix;
72 int16 _flx1, _flx2, _fly;
73 bool _activeNow; // Is there an active option now?
74 byte _activeNum; // And if so, which is it?
75 byte _choiceNum; // Your choice?
76
77 void init(DropDownMenu *menu);
78 void reset();
79 void setupOption(Common::String title, char trigger, Common::String shortcut, bool valid);
80 void display();
81 void wipe();
82 void lightUp(Common::Point cursorPos);
83 void select(byte which);
84
85private:
86 byte _oldY; // used by lightUp
87 byte _optionNum;
88 byte _highlightNum;
89
90 DropDownMenu *_dropdown;
91
92 void displayOption(byte y, bool highlit);
93 void moveHighlight(int8 inc);
94
95 // CHECKME: Useless function?
96 void parseKey(char c);
97};
98
99class MenuBar {
100public:
101 HeadType _menuItems[8];
102 byte _menuNum;
103
104 MenuBar();
105 void init(DropDownMenu *menu);
106 void createMenuItem(char trig, Common::String title, char altTrig, MenuFunc setupFunc, MenuFunc chooseFunc);
107 void draw();
108 void chooseMenuItem(int16 x);
109
110private:
111 DropDownMenu *_dropdown;
112
113 void setupMenuItem(byte which);
114 // CHECKME: Useless function
115 void parseAltTrigger(char c);
116};
117
119public:
120 friend class HeadType;
121 friend class MenuItem;
122 friend class MenuBar;
123
124 MenuItem _activeMenuItem;
125 MenuBar _menuBar;
126
128
129 void update();
130 void setup(); // Standard menu bar.
131 bool isActive();
132 void init();
133 void resetVariables();
134
135private:
136 static const byte kIndent = 5;
137 static const byte kSpacing = 10;
138
139// Checkme: Useless constants?
140// static const Color kMenuFontColor = kColorBlack;
141// static const Color kHighlightBackgroundColor = kColorBlack;
142// static const Color kHighlightFontColor = kColorWhite;
143// static const Color kDisabledColor = kColorDarkgray;
144
145 Common::String people;
146 Common::String _verbStr; // what you can do with your object. :-)
147 bool _menuActive; // Kludge so we don't have to keep referring to the menu.
148 People _lastPerson; // Last person to have been selected using the People menu.
149
150 AvalancheEngine *_vm;
151
152 Common::String selectGender(byte x); // Returns "im" for boys, and "er" for girls.
153 void findWhatYouCanDoWithIt();
154 void drawMenuText(int16 x, int16 y, char trigger, Common::String text, bool valid, bool highlighted);
155 void bleep();
156
157 char getThingChar(byte which);
158 byte getNameChar(People whose);
159 Common::String getThing(byte which);
160
161 void setupMenuGame();
162 void setupMenuFile();
163 void setupMenuAction();
164 void setupMenuPeople();
165 void setupMenuObjects();
166 void setupMenuWith();
167
168 void runMenuGame();
169 void runMenuFile();
170 void runMenuAction();
171 void runMenuObjects();
172 void runMenuPeople();
173 void runMenuWith();
174
175 // CHECKME: Useless function?
176 void parseKey(char r, char re);
177};
178
179} // End of namespace Avalanche.
180
181#endif // AVALANCHE_DROPDOWN_H
Definition: avalanche.h:78
Definition: dropdown.h:118
Definition: dropdown.h:43
Definition: dropdown.h:99
Definition: dropdown.h:67
Definition: str.h:59
Definition: dropdown.h:60
Definition: rect.h:144