aboutsummaryrefslogtreecommitdiff
path: root/engines/hdb/window.h
blob: f2175d4296d000ef8f9b2720e054780b1f37a3fa (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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
/* 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.
 *
 */

#ifndef HDB_WINDOW_H
#define HDB_WINDOW_H

namespace HDB {

enum {
	kDialogTextLeft = 64,
	kDialogTextRight = (kDialogTextLeft + kTileWidth * 9),
	kOpenDialogTextLeft = kDialogTextLeft,
	kOpenDialogTextRight = (kDialogTextRight + kTileWidth * 2),
	kMaxMsgQueue = 10,
	kWeaponX = (480 - 34),
	kWeaponY = 2,
	kInvItemSpaceX = 48,
	kInvItemSpaceY = 40,
	kInvItemPerLine = 3,
	kDlvItemSpaceX = 48,
	kDlvItemSpaceY = (kTileHeight * 2 + 16),
	kDlvItemPerLine = 3,
	kDlvItemTextY = (kScreenHeight - 30),
	kNumCrazy = 37,
	kTextOutCenterX = ((kScreenWidth - kTileWidth * 5) / 2),
	kPauseY = (kScreenHeight / 2 - 64)
};

struct DialogInfo {
	char		title[64];				// TITLE string
	int			tileIndex;					// this is for a character picture
	char		string[160];			// actual text in the dialog

	bool		active;					// is it drawing or not?
	int			x, y;					// where to draw dialog
	int			width, height;			// size of the dialog itself
	int			titleWidth;
	Picture		*gfx;					// character tile (picture)
	int			more;					// whether we want to draw the MORE icon or not
	int			el, er, et, eb;			// saves the text edges
	char		luaMore[64];			// the name of the function to call after clicking the MORE button

	DialogInfo() : tileIndex(0), active(false), x(0), y(0),
		width(0), height(0), titleWidth(0), gfx(NULL), more(0), el(0), er(0), et(0),
		eb(0) {
			title[0] = 0;
			string[0] = 0;
			luaMore[0] = 0;
		}
};

struct DialogChoiceInfo {
	char		title[64];				// TITLE string
	char		text[160];				// actual text in the dialog
	char		func[64];				// function to call with result

	bool		active;					// is it drawing or not?
	int			x, y;					// where to draw dialog
	int			width, height;			// size of the dialog itself
	int			textHeight;				// height of everything above choices
	int			titleWidth;
	int			el, er, et, eb;			// saves the text edges
	uint32		timeout;				// timeout value!

	int			selection;				// which choice we've made
	int			numChoices;			// how many choices possible
	char		choices[10][64];		// ptrs to choice text

	DialogChoiceInfo() : active(false), x(0), y(0),
		width(0), height(0), textHeight(0), titleWidth(0), el(0), er(0), et(0),
		eb(0), timeout(0), selection(0), numChoices(0) {
		title[0] = 0;
		text[0] = 0;
		func[0] = 0;
		for (int i = 0; i < 10; i++)
			choices[i][0] = 0;
	}
};

struct MessageInfo {
	bool		active;
	char		title[128];
	int			timer;
	int			x, y;
	int			width, height;

	MessageInfo() : active(false), timer(0), x(0), y(0), width(0), height(0) {
		title[0] = 0;
	}
};

struct InvWinInfo {
	int x, y;
	int width, height;
	int selection;
	bool active;

	InvWinInfo() : x(0), y(0), width(0), height(0), selection(0), active(false) {}
};

struct DlvsInfo {
	int x, y;
	int width, height;
	bool active;
	int selected;
	bool animate;
	uint32 delay1, delay2, delay3;
	bool go1, go2, go3;

	DlvsInfo() : x(0), y(0), width(0), height(0), active(false), selected(0), animate(false), delay1(0), delay2(0), delay3(0), go1(false), go2(false), go3(false) {}
};

struct TOut {
	char text[128];
	int x, y;
	uint32 timer;

	TOut() : x(0), y(0), timer(0) {
		text[0] = 0;
	}
};

class Window {
public:

	bool init();
	void restartSystem();
	void setInfobarDark(int value);

	void closeAll();

	// Pause Functions
	void drawPause();
	void checkPause(uint x, uint y);

	// Dialog Functions

	void openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore);
	void drawDialog();
	void closeDialog();
	bool checkDialogClose(int x, int y);
	void drawBorder(int x, int y, int width, int height, bool guyTalking);
	void setDialogDelay(int delay);
	uint32 getDialogDelay() {
		return _dialogDelay;
	}
	bool dialogActive() {
		return _dialogInfo.active;
	}

	// Dialog Choice Functions

	void openDialogChoice(const char *title, const char *text, const char *func, int numChoices, const char *choices[10]);
	void drawDialogChoice();
	void closeDialogChoice();
	bool checkDialogChoiceClose(int x, int y);
	void dialogChoiceMoveup();
	void dialogChoiceMovedown();
	bool dialogChoiceActive() {
		return _dialogChoiceInfo.active;
	}

	// MessageBar Functions
	void openMessageBar(const char *title, int time);
	void drawMessageBar();
	bool checkMsgClose(int x, int y);
	void nextMsgQueued();
	void closeMsg();
	bool msgBarActive() {
		return _msgInfo.active;
	}

	// Inventory Functions
	void drawInventory();
	void setInvSelect(int status) {
		_invWinInfo.selection = status;
	}
	int getInvSelect() {
		return _invWinInfo.selection;
	}
	void checkInvSelect(int x, int y);
	bool inventoryActive() {
		return _invWinInfo.active;
	}

	// Deliveries Functions
	void openDeliveries(bool animate);
	void drawDeliveries();
	void setSelectedDelivery(int which);
	int getSelectedDelivery() {
		return _dlvsInfo.selected;
	}
	bool animatingDelivery() {
		return _dlvsInfo.animate;
	}
	void checkDlvSelect(int x, int y);

	// TextOut functions
	void textOut(const char *text, int x, int y, int timer);
	void centerTextOut(const char *text, int y, int timer);
	void drawTextOut();
	int textOutActive() {
		return (_textOutList.size());
	}
	void closeTextOut();
private:

	DialogInfo _dialogInfo;
	uint32 _dialogDelay;	// Used for Cinematics

	DialogChoiceInfo _dialogChoiceInfo;

	MessageInfo _msgInfo;

	InvWinInfo _invWinInfo;
	Common::Array<TOut *> _textOutList;
	DlvsInfo _dlvsInfo;

	char _msgQueueStr[kMaxMsgQueue][128];
	int _msgQueueWait[kMaxMsgQueue];
	int _numMsgQueue;

	// Windows GFX
	Picture *_gfxTL, *_gfxTM, *_gfxTR;
	Picture *_gfxL, *_gfxM, *_gfxR;
	Picture *_gfxBL, *_gfxBM, *_gfxBR;
	Picture *_gfxTitleL, *_gfxTitleM, *_gfxTitleR;
	Picture *_gGfxTL, *_gGfxTM, *_gGfxTR;
	Picture *_gGfxL, *_gGfxM, *_gGfxR;
	Picture *_gGfxBL, *_gGfxBM, *_gGfxBR;
	Picture *_gGfxTitleL, *_gGfxTitleM, *_gGfxTitleR;
	Picture *_gfxResources, *_gfxDeliveries;
	Picture *_gfxIndent, *_gfxArrowTo, *_gfxHandright;
	Picture *_gfxTry, *_gfxAgain, *_gfxInvSelect;
	Tile *_gfxMonkeystone;
	Picture *_gfxLevelRestart, *_gfxPausePlaque;
	Tile *_gemGfx;
	Picture *_mstoneGfx;

	// Info Bar
	Picture *_gfxInfobar, *_gfxDarken;
	int _infobarDimmed;
};

} // End of Namespace

#endif // !HDB_WINDOW_H