aboutsummaryrefslogtreecommitdiff
path: root/saga/interface.h
blob: 908b629a7adb6d7440c168bde38476c6fcc6225b (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
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2004 The ScummVM project
 *
 * The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header$
 *
 */

// Game interface module private header file

#ifndef SAGA_INTERFACE_H__
#define SAGA_INTERFACE_H__

#include "saga/sprite.h"
#include "saga/script.h"

namespace Saga {

enum INTERFACE_UPDATE_FLAGS {
	UPDATE_MOUSEMOVE = 1,
	UPDATE_MOUSECLICK
};

#define ITE_INVENTORY_SIZE 24

#define VERB_STRLIMIT 32

#define STATUS_TEXT_LEN 128

#define COMMAND_DEFAULT_BUTTON 1

// Inherit the Earth interface values
#define ITE_STATUS_Y      137
#define ITE_STATUS_W      320
#define ITE_STATUS_H      12
#define ITE_STATUS_TEXT_Y 2
#define ITE_STATUS_TXTCOL 186
#define ITE_STATUS_BGCOL  15

#define ITE_CMD_TEXT_COL       147
#define ITE_CMD_TEXT_SHADOWCOL 15
#define ITE_CMD_TEXT_HILITECOL 96

#define ITE_LPORTRAIT_X 5
#define ITE_LPORTRAIT_Y 4
#define ITE_RPORTRAIT_X 274
#define ITE_RPORTRAIT_Y 4

#define ITE_INVENTORY_XSTART 181
#define ITE_INVENTORY_YSTART 155
#define ITE_INVENTORY_ROWS 2
#define ITE_INVENTORY_COLUMNS 4
#define ITE_INVENTORY_ICON_WIDTH 29
#define ITE_INVENTORY_ICON_HEIGHT 20
#define ITE_INVENTORY_ICON_XOFFSET 1
#define ITE_INVENTORY_ICON_YOFFSET 0
#define ITE_INVENTORY_XSPACING 3
#define ITE_INVENTORY_YSPACING 1

// IHNMAIMS interface values
#define IHNM_STATUS_Y      304
#define IHNM_STATUS_W      640
#define IHNM_STATUS_H      24
#define IHNM_STATUS_TEXT_Y 8
#define IHNM_STATUS_TXTCOL 186
#define IHNM_STATUS_BGCOL  11

#define IHNM_CMD_TEXT_COL       147
#define IHNM_CMD_TEXT_SHADOWCOL 15
#define IHNM_CMD_TEXT_HILITECOL 96

#define IHNM_LPORTRAIT_X 5
#define IHNM_LPORTRAIT_Y 4
#define IHNM_RPORTRAIT_X -1
#define IHNM_RPORTRAIT_Y -1

// TODO
#define IHNM_INVENTORY_XSTART 0
#define IHNM_INVENTORY_YSTART 0
#define IHNM_INVENTORY_ROWS 0
#define IHNM_INVENTORY_COLUMNS 0
#define IHNM_INVENTORY_ICON_WIDTH 0
#define IHNM_INVENTORY_ICON_HEIGHT 0
#define IHNM_INVENTORY_ICON_XOFFSET 0
#define IHNM_INVENTORY_ICON_YOFFSET 0
#define IHNM_INVENTORY_XSPACING 0
#define IHNM_INVENTORY_YSPACING 0

enum PANEL_MODES {
	kPanelNone,
	kPanelCommand,
	kPanelDialogue
};

enum BUTTON_FLAGS {
	BUTTON_NONE = 0x0,
	BUTTON_LABEL = 0x01,
	BUTTON_BITMAP = 0x02,
	BUTTON_SET = 0x04
};

#define BUTTON_VERB ( BUTTON_LABEL | BUTTON_BITMAP | BUTTON_SET )

struct INTERFACE_BUTTON {
	int x1;
	int y1;
	int x2;
	int y2;
	const char *label;
	int inactive_sprite;
	int active_sprite;
	int flags;
	int data;
};

struct INTERFACE_PANEL {
	byte *res;
	size_t res_len;
	int x;
	int y;
	byte *img;
	size_t img_len;
	int img_w;
	int img_h;
	int set_button;
	int nbuttons;
	INTERFACE_BUTTON *buttons;
	SPRITELIST *sprites;
};

struct INTERFACE_DESC {
	int status_y;
	int status_w;
	int status_h;
	int status_txt_y;
	int status_txt_col;
	int status_bgcol;
	int cmd_txt_col;
	int cmd_txt_shadowcol;
	int cmd_txt_hilitecol;
	int cmd_defaultbutton;
	int lportrait_x;
	int lportrait_y;
	int rportrait_x;
	int rportrait_y;
	int inv_xstart;
	int inv_ystart;
	int inv_rows;
	int inv_columns;
	int inv_icon_width;
	int inv_icon_height;
	int inv_icon_xoffset;
	int inv_icon_yoffset;
	int inv_xspacing;
	int inv_yspacing;
};

struct INTERFACE_MODULE {
};

enum INTERFACE_VERBS {
	I_VERB_WALKTO,
	I_VERB_LOOKAT,
	I_VERB_PICKUP,
	I_VERB_TALKTO,
	I_VERB_OPEN,
	I_VERB_CLOSE,
	I_VERB_USE,
	I_VERB_GIVE
};

struct VERB_DATA {
	int i_verb;
	const char *verb_cvar;
	char verb_str[VERB_STRLIMIT];
	int s_verb;
};

class Interface {
public:
	Interface(SagaEngine *vm);
	~Interface(void);

	int registerLang();
	int activate();
	int deactivate();
	int setMode(int mode);
	int getMode(void) { return _panelMode; }
	int setStatusText(const char *new_txt);
	int loadScenePortraits(int res);
	int setLeftPortrait(int portrait);
	int setRightPortrait(int portrait);
	int draw();
	int update(const Point& imousePt, int update_flag);

	void addToInventory(int sprite);
	void removeFromInventory(int sprite);
	void drawInventory();
	int inventoryTest(const Point& imousePt, int *ibutton);
private:
	int hitTest(const Point& imousePt, int *ibutton);
	int drawStatusBar(SURFACE *ds);
	int handleCommandUpdate(SURFACE *ds, const Point& imousePt);
	int handleCommandClick(SURFACE *ds, const Point& imousePt);
	int handlePlayfieldUpdate(SURFACE *ds, const Point& imousePt);
	int handlePlayfieldClick(SURFACE *ds, const Point& imousePt);

private:
	SagaEngine *_vm;

	bool _initialized;
	int _active;
	RSCFILE_CONTEXT *_interfaceContext;
	INTERFACE_DESC _iDesc;
	int _panelMode;
	INTERFACE_PANEL _cPanel;
	INTERFACE_PANEL _dPanel;
	char _statusText[STATUS_TEXT_LEN];
	int _leftPortrait;
	int _rightPortrait;
	SPRITELIST *_defPortraits;
	SPRITELIST *_scenePortraits;
	int _activeVerb;
	SCRIPT_THREAD *_iThread;

	uint16 *_inventory;
	int _inventorySize;
	byte _inventoryCount;
};

} // End of namespace Saga

#endif				/* INTERFACE_H__ */
/* end "r_interface.h" */