aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche/menu.h
blob: f4833d31c422383ccccdfbd6f136530f4607dd04 (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

/*
 * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
 * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
 */

/* Original name: DROPDOWN		A customized version of Oopmenu (qv). */

#ifndef AVALANCHE_MENU_H
#define AVALANCHE_MENU_H

#include "common/str.h"

namespace Avalanche {
class AvalancheEngine;

class Menu;

typedef void (Menu::*MenuFunc)();
static const Color kMenuBackgroundColor = kColorLightgray;
static const Color kMenuBorderColor = kColorBlack;

class HeadType {
public:
	Common::String _title;
	char _trigger, _altTrigger;
	byte _position;
	int16 _xpos, _xright;
	MenuFunc _setupFunc, _chooseFunc;

	void init(char trig, char alTtrig, Common::String title, byte pos, MenuFunc setupFunc, MenuFunc chooseFunc, Menu *menu);
	void draw();
	void highlight();
	bool parseAltTrigger(char key);

private:
	Menu *_menu;
};

struct OptionType {
	Common::String _title;
	byte _trigger;
	Common::String _shortcut;
	bool _valid;
};

class MenuItem {
public:
	OptionType _options[12];
	uint16 _width, _left;
	bool _firstlix;
	int16 _flx1, _flx2, _fly;
	bool _activeNow; // Is there an active option now?
	byte _activeNum; // And if so, which is it?
	byte _choiceNum; // Your choice?

	void init(Menu *menu);
	void reset();
	void setupOption(Common::String title, char trigger, Common::String shortcut, bool valid);
	void display();
	void wipe();
	void lightUp(Common::Point cursorPos);
	void select(byte which);

private:
	byte _oldY; // used by lightUp
	byte _optionNum;
	byte _highlightNum;

	Menu *_menu;

	void displayOption(byte y, bool highlit);
	void moveHighlight(int8 inc);

	// CHECKME: Useless function?
	void parseKey(char c);
};

class MenuBar {
public:
	HeadType _menuItems[8];
	byte _menuNum;

	MenuBar();
	void init(Menu *menu);
	void createMenuItem(char trig, Common::String title, char altTrig, MenuFunc setupFunc, MenuFunc chooseFunc);
	void draw();
	void chooseMenuItem(int16 x);

private:
	Menu *_menu;

	void setupMenuItem(byte which);
	// CHECKME: Useless function
	void parseAltTrigger(char c);
};

class Menu {
public:
	friend class HeadType;
	friend class MenuItem;
	friend class MenuBar;

	MenuItem _activeMenuItem;
	MenuBar _menuBar;

	Menu(AvalancheEngine *vm);

	void update();
	void setup(); // Standard menu bar.
	bool isActive();
	void init();
	void resetVariables();

private:
	static const byte kIndent = 5;
	static const byte kSpacing = 10;

//	Checkme: Useless constants?
//	static const Color kMenuFontColor = kColorBlack;
//	static const Color kHighlightBackgroundColor = kColorBlack;
//	static const Color kHighlightFontColor = kColorWhite;
//	static const Color kDisabledColor = kColorDarkgray;

	Common::String people;
	Common::String _verbStr; // what you can do with your object. :-)
	bool _menuActive; // Kludge so we don't have to keep referring to the menu.
	People _lastPerson; // Last person to have been selected using the People menu.

	AvalancheEngine *_vm;

	Common::String selectGender(byte x); // Returns "im" for boys, and "er" for girls.
	void findWhatYouCanDoWithIt();
	void drawMenuText(int16 x, int16 y, char trigger, Common::String text, bool valid, bool highlighted);
	void bleep();

	char getThingChar(byte which);
	byte getNameChar(People whose);
	Common::String getThing(byte which);

	void setupMenuGame();
	void setupMenuFile();
	void setupMenuAction();
	void setupMenuPeople();
	void setupMenuObjects();
	void setupMenuWith();

	void runMenuGame();
	void runMenuFile();
	void runMenuAction();
	void runMenuObjects();
	void runMenuPeople();
	void runMenuWith();

	// CHECKME: Useless function?
	void parseKey(char r, char re);
};

} // End of namespace Avalanche.

#endif // AVALANCHE_MENU_H