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