1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
19 /* the following definitions are also used by tools.c */
21 /* some positions in the video tape control window */
22 #define VIDEO_DISPLAY1_XPOS 5
23 #define VIDEO_DISPLAY1_YPOS 5
24 #define VIDEO_DISPLAY2_XPOS 5
25 #define VIDEO_DISPLAY2_YPOS 41
26 #define VIDEO_DISPLAY_XSIZE 90
27 #define VIDEO_DISPLAY_YSIZE 31
28 #define VIDEO_BUTTON_XSIZE 18
29 #define VIDEO_BUTTON_YSIZE 18
30 #define VIDEO_CONTROL_XPOS 5
31 #define VIDEO_CONTROL_YPOS 77
32 #define VIDEO_CONTROL_XSIZE (VIDEO_DISPLAY_XSIZE)
33 #define VIDEO_CONTROL_YSIZE (VIDEO_BUTTON_YSIZE)
35 /* values for requests */
36 #define BUTTON_OK (1L<<0)
37 #define BUTTON_NO (1L<<1)
38 #define BUTTON_CONFIRM (1L<<2)
40 /* values for choosing network player */
41 #define BUTTON_PLAYER_1 (1L<<10)
42 #define BUTTON_PLAYER_2 (1L<<11)
43 #define BUTTON_PLAYER_3 (1L<<12)
44 #define BUTTON_PLAYER_4 (1L<<13)
46 /* for DrawPlayerButton() */
50 /* the following definitions are also used by screens.c */
52 /* buttons of the video tape player */
53 #define BUTTON_VIDEO_EJECT 1
54 #define BUTTON_VIDEO_STOP 2
55 #define BUTTON_VIDEO_PAUSE 3
56 #define BUTTON_VIDEO_REC 4
57 #define BUTTON_VIDEO_PLAY 5
59 /* values for video tape control */
60 #define VIDEO_STATE_PLAY_OFF (1L<<0)
61 #define VIDEO_STATE_PLAY_ON (1L<<1)
62 #define VIDEO_STATE_PLAY (VIDEO_STATE_PLAY_OFF | VIDEO_STATE_PLAY_ON)
63 #define VIDEO_STATE_REC_OFF (1L<<2)
64 #define VIDEO_STATE_REC_ON (1L<<3)
65 #define VIDEO_STATE_REC (VIDEO_STATE_REC_OFF | VIDEO_STATE_REC_ON)
66 #define VIDEO_STATE_PAUSE_OFF (1L<<4)
67 #define VIDEO_STATE_PAUSE_ON (1L<<5)
68 #define VIDEO_STATE_PAUSE (VIDEO_STATE_PAUSE_OFF | VIDEO_STATE_PAUSE_ON)
69 #define VIDEO_STATE_DATE_OFF (1L<<6)
70 #define VIDEO_STATE_DATE_ON (1L<<7)
71 #define VIDEO_STATE_DATE (VIDEO_STATE_DATE_OFF | VIDEO_STATE_DATE_ON)
72 #define VIDEO_STATE_TIME_OFF (1L<<8)
73 #define VIDEO_STATE_TIME_ON (1L<<9)
74 #define VIDEO_STATE_TIME (VIDEO_STATE_TIME_OFF | VIDEO_STATE_TIME_ON)
75 #define VIDEO_PRESS_PLAY_ON (1L<<10)
76 #define VIDEO_PRESS_PLAY_OFF (1L<<11)
77 #define VIDEO_PRESS_PLAY (VIDEO_PRESS_PLAY_OFF | VIDEO_PRESS_PLAY_ON)
78 #define VIDEO_PRESS_REC_ON (1L<<12)
79 #define VIDEO_PRESS_REC_OFF (1L<<13)
80 #define VIDEO_PRESS_REC (VIDEO_PRESS_REC_OFF | VIDEO_PRESS_REC_ON)
81 #define VIDEO_PRESS_PAUSE_ON (1L<<14)
82 #define VIDEO_PRESS_PAUSE_OFF (1L<<15)
83 #define VIDEO_PRESS_PAUSE (VIDEO_PRESS_PAUSE_OFF | VIDEO_PRESS_PAUSE_ON)
84 #define VIDEO_PRESS_STOP_ON (1L<<16)
85 #define VIDEO_PRESS_STOP_OFF (1L<<17)
86 #define VIDEO_PRESS_STOP (VIDEO_PRESS_STOP_OFF | VIDEO_PRESS_STOP_ON)
87 #define VIDEO_PRESS_EJECT_ON (1L<<18)
88 #define VIDEO_PRESS_EJECT_OFF (1L<<19)
89 #define VIDEO_PRESS_EJECT (VIDEO_PRESS_EJECT_OFF | VIDEO_PRESS_EJECT_ON)
92 #define VIDEO_STATE_FFWD_OFF ((1L<<20) | VIDEO_STATE_PAUSE_OFF)
93 #define VIDEO_STATE_FFWD_ON (1L<<21)
94 #define VIDEO_STATE_FFWD (VIDEO_STATE_FFWD_OFF | VIDEO_STATE_FFWD_ON)
95 #define VIDEO_STATE_PBEND_OFF (1L<<22)
96 #define VIDEO_STATE_PBEND_ON (1L<<23)
97 #define VIDEO_STATE_PBEND (VIDEO_STATE_PBEND_OFF | VIDEO_STATE_PBEND_ON)
99 /* tags to draw video display labels or symbols only */
100 #define VIDEO_DISPLAY_DEFAULT 0
101 #define VIDEO_DISPLAY_LABEL_ONLY 1
102 #define VIDEO_DISPLAY_SYMBOL_ONLY 2
104 /* values for sound control */
105 #define BUTTON_SOUND_MUSIC (1L<<0)
106 #define BUTTON_SOUND_LOOPS (1L<<1)
107 #define BUTTON_SOUND_SIMPLE (1L<<2)
108 #define BUTTON_RELEASED 0
109 #define BUTTON_PRESSED (1L<<3)
111 #define BUTTON_ON (1L<<4)
112 #define BUTTON_SOUND_MUSIC_OFF (BUTTON_SOUND_MUSIC | BUTTON_OFF)
113 #define BUTTON_SOUND_LOOPS_OFF (BUTTON_SOUND_LOOPS | BUTTON_OFF)
114 #define BUTTON_SOUND_SIMPLE_OFF (BUTTON_SOUND_SIMPLE | BUTTON_OFF)
115 #define BUTTON_SOUND_MUSIC_ON (BUTTON_SOUND_MUSIC | BUTTON_ON)
116 #define BUTTON_SOUND_LOOPS_ON (BUTTON_SOUND_LOOPS | BUTTON_ON)
117 #define BUTTON_SOUND_SIMPLE_ON (BUTTON_SOUND_SIMPLE | BUTTON_ON)
119 /* values for game control */
120 #define BUTTON_GAME_STOP (1L<<0)
121 #define BUTTON_GAME_PAUSE (1L<<1)
122 #define BUTTON_GAME_PLAY (1L<<2)
124 /* the following definitions are also used by game.c */
126 /* some positions in the game control window */
127 #define GAME_BUTTON_XSIZE 30
128 #define GAME_BUTTON_YSIZE 30
129 #define GAME_CONTROL_XPOS 5
130 #define GAME_CONTROL_YPOS 215
131 #define GAME_CONTROL_XSIZE (3*GAME_BUTTON_XSIZE)
132 #define GAME_CONTROL_YSIZE (1*GAME_BUTTON_YSIZE)
134 /* the following definitions are also used by editor.c */
136 /* some positions in the editor control window */
137 #define ED_BUTTON_EUP_XPOS 35
138 #define ED_BUTTON_EUP_YPOS 5
139 #define ED_BUTTON_EUP_XSIZE 30
140 #define ED_BUTTON_EUP_YSIZE 25
141 #define ED_BUTTON_EDOWN_XPOS 35
142 #define ED_BUTTON_EDOWN_YPOS 250
143 #define ED_BUTTON_EDOWN_XSIZE 30
144 #define ED_BUTTON_EDOWN_YSIZE 25
145 #define ED_BUTTON_ELEM_XPOS 6
146 #define ED_BUTTON_ELEM_YPOS 30
147 #define ED_BUTTON_ELEM_XSIZE 22
148 #define ED_BUTTON_ELEM_YSIZE 22
150 #define ED_BUTTON_EUP_Y2POS 140
151 #define ED_BUTTON_EDOWN_Y2POS 165
152 #define ED_BUTTON_ELEM_Y2POS 190
154 #define ED_CURSORBUTTON_XSIZE 30
155 #define ED_CURSORBUTTON_YSIZE 20
157 #define ED_BUTTON_CTRL_XPOS 5
158 #define ED_BUTTON_CTRL_YPOS 5
159 #define ED_BUTTON_CTRL_XSIZE 90
160 #define ED_BUTTON_CTRL_YSIZE 30
161 #define ED_BUTTON_FILL_XPOS 5
162 #define ED_BUTTON_FILL_YPOS 35
163 #define ED_BUTTON_FILL_XSIZE 90
164 #define ED_BUTTON_FILL_YSIZE 20
165 #define ED_BUTTON_LEFT_XPOS 5
166 #define ED_BUTTON_LEFT_YPOS 65
167 #define ED_BUTTON_LEFT_XSIZE ED_CURSORBUTTON_XSIZE
168 #define ED_BUTTON_LEFT_YSIZE ED_CURSORBUTTON_YSIZE
169 #define ED_BUTTON_UP_XPOS 35
170 #define ED_BUTTON_UP_YPOS 55
171 #define ED_BUTTON_UP_XSIZE ED_CURSORBUTTON_XSIZE
172 #define ED_BUTTON_UP_YSIZE ED_CURSORBUTTON_YSIZE
173 #define ED_BUTTON_DOWN_XPOS 35
174 #define ED_BUTTON_DOWN_YPOS 75
175 #define ED_BUTTON_DOWN_XSIZE ED_CURSORBUTTON_XSIZE
176 #define ED_BUTTON_DOWN_YSIZE ED_CURSORBUTTON_YSIZE
177 #define ED_BUTTON_RIGHT_XPOS 65
178 #define ED_BUTTON_RIGHT_YPOS 65
179 #define ED_BUTTON_RIGHT_XSIZE ED_CURSORBUTTON_XSIZE
180 #define ED_BUTTON_RIGHT_YSIZE ED_CURSORBUTTON_YSIZE
182 #define ED_BUTTON_EDIT_XPOS 5
183 #define ED_BUTTON_EDIT_YPOS 5
184 #define ED_BUTTON_EDIT_XSIZE 90
185 #define ED_BUTTON_EDIT_YSIZE 30
186 #define ED_BUTTON_CLEAR_XPOS 5
187 #define ED_BUTTON_CLEAR_YPOS 35
188 #define ED_BUTTON_CLEAR_XSIZE 90
189 #define ED_BUTTON_CLEAR_YSIZE 20
190 #define ED_BUTTON_UNDO_XPOS 5
191 #define ED_BUTTON_UNDO_YPOS 55
192 #define ED_BUTTON_UNDO_XSIZE 90
193 #define ED_BUTTON_UNDO_YSIZE 20
194 #define ED_BUTTON_EXIT_XPOS 5
195 #define ED_BUTTON_EXIT_YPOS 75
196 #define ED_BUTTON_EXIT_XSIZE 90
197 #define ED_BUTTON_EXIT_YSIZE 20
199 #define ED_BUTTON_COUNT_YPOS 60
200 #define ED_BUTTON_COUNT_XSIZE 20
201 #define ED_BUTTON_COUNT_YSIZE 20
202 #define ED_BUTTON_MINUS_XPOS 2
203 #define ED_BUTTON_MINUS_YPOS ED_BUTTON_COUNT_YPOS
204 #define ED_BUTTON_MINUS_XSIZE ED_BUTTON_COUNT_XSIZE
205 #define ED_BUTTON_MINUS_YSIZE ED_BUTTON_COUNT_YSIZE
206 #define ED_WIN_COUNT_XPOS (ED_BUTTON_MINUS_XPOS+ED_BUTTON_MINUS_XSIZE+2)
207 #define ED_WIN_COUNT_YPOS ED_BUTTON_COUNT_YPOS
208 #define ED_WIN_COUNT_XSIZE 52
209 #define ED_WIN_COUNT_YSIZE ED_BUTTON_COUNT_YSIZE
210 #define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS+ED_WIN_COUNT_XSIZE+2)
211 #define ED_BUTTON_PLUS_YPOS ED_BUTTON_COUNT_YPOS
212 #define ED_BUTTON_PLUS_XSIZE ED_BUTTON_COUNT_XSIZE
213 #define ED_BUTTON_PLUS_YSIZE ED_BUTTON_COUNT_YSIZE
215 #define ED_COUNT_GADGET_XPOS 16
216 #define ED_COUNT_GADGET_YPOS (16+3*MINI_TILEY+64)
217 #define ED_COUNT_GADGET_YSIZE (ED_BUTTON_MINUS_YSIZE+4)
218 #define ED_COUNT_TEXT_XPOS (ED_COUNT_GADGET_XPOS+DXSIZE+10)
219 #define ED_COUNT_TEXT_YPOS (ED_COUNT_GADGET_YPOS+3)
220 #define ED_COUNT_TEXT_YSIZE ED_COUNT_GADGET_YSIZE
221 #define ED_COUNT_VALUE_XPOS (ED_COUNT_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
222 #define ED_COUNT_VALUE_YPOS ED_COUNT_TEXT_YPOS
223 #define ED_SIZE_GADGET_XPOS (SX+21*MINI_TILEX)
224 #define ED_SIZE_GADGET_YPOS (SY+4*MINI_TILEY)
225 #define ED_SIZE_GADGET_YSIZE (ED_BUTTON_MINUS_YSIZE+4)
226 #define ED_SIZE_TEXT_XPOS (ED_SIZE_GADGET_XPOS+DXSIZE+10)
227 #define ED_SIZE_TEXT_YPOS (ED_SIZE_GADGET_YPOS+3)
228 #define ED_SIZE_TEXT_YSIZE ED_COUNT_GADGET_YSIZE
229 #define ED_SIZE_VALUE_XPOS (ED_SIZE_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
230 #define ED_SIZE_VALUE_YPOS ED_SIZE_TEXT_YPOS
232 /* values for asking control */
233 #define ED_BUTTON_CTRL (1L<<0)
234 #define ED_BUTTON_FILL (1L<<1)
235 #define ED_BUTTON_LEFT (1L<<2)
236 #define ED_BUTTON_UP (1L<<3)
237 #define ED_BUTTON_DOWN (1L<<4)
238 #define ED_BUTTON_RIGHT (1L<<5)
239 #define ED_BUTTON_EDIT (1L<<6)
240 #define ED_BUTTON_CLEAR (1L<<7)
241 #define ED_BUTTON_UNDO (1L<<8)
242 #define ED_BUTTON_EXIT (1L<<9)
244 #define ED_BUTTON_PRESSED (1L<<10)
245 #define ED_BUTTON_RELEASED (1L<<11)
247 #define ED_BUTTON_EUP 0
248 #define ED_BUTTON_EDOWN 1
249 #define ED_BUTTON_ELEM 2
251 void DrawVideoDisplay(unsigned long, unsigned long);
252 void DrawCompleteVideoDisplay(void);
253 void DrawSoundDisplay(unsigned long);
254 void DrawGameButton(unsigned long);
255 void DrawYesNoButton(unsigned long, int);
256 void DrawConfirmButton(unsigned long, int);
257 void DrawPlayerButton(unsigned long, int);
258 void DrawEditButton(unsigned long state);
259 void DrawCtrlButton(unsigned long state);
260 void DrawElemButton(int, int);
261 void DrawCountButton(int, int);
262 int CheckVideoButtons(int, int, int);
263 int CheckSoundButtons(int, int, int);
264 int CheckGameButtons(int, int, int);
265 int CheckYesNoButtons(int, int, int);
266 int CheckConfirmButton(int, int, int);
267 int CheckPlayerButtons(int, int, int);
268 int CheckEditButtons(int, int, int);
269 int CheckCtrlButtons(int, int, int);
270 int CheckElemButtons(int, int, int);
271 int CheckCountButtons(int, int, int);
274 /* NEW GADGET STUFF -------------------------------------------------------- */
278 #define GD_TYPE_NORMAL_BUTTON (1 << 0)
279 #define GD_TYPE_CHECK_BUTTON (1 << 1)
280 #define GD_TYPE_RADIO_BUTTON (1 << 2)
281 #define GD_TYPE_DRAWING_AREA (1 << 3)
282 #define GD_TYPE_TEXTINPUT_ALPHANUMERIC (1 << 4)
283 #define GD_TYPE_TEXTINPUT_NUMERIC (1 << 5)
284 #define GD_TYPE_SCROLLBAR_VERTICAL (1 << 6)
285 #define GD_TYPE_SCROLLBAR_HORIZONTAL (1 << 7)
287 #define GD_TYPE_BUTTON (GD_TYPE_NORMAL_BUTTON | \
288 GD_TYPE_CHECK_BUTTON | \
289 GD_TYPE_RADIO_BUTTON)
290 #define GD_TYPE_SCROLLBAR (GD_TYPE_SCROLLBAR_VERTICAL | \
291 GD_TYPE_SCROLLBAR_HORIZONTAL)
292 #define GD_TYPE_TEXTINPUT (GD_TYPE_TEXTINPUT_ALPHANUMERIC | \
293 GD_TYPE_TEXTINPUT_NUMERIC)
296 #define GD_EVENT_PRESSED (1 << 0)
297 #define GD_EVENT_RELEASED (1 << 1)
298 #define GD_EVENT_MOVING (1 << 2)
299 #define GD_EVENT_REPEATED (1 << 3)
300 #define GD_EVENT_OFF_BORDERS (1 << 4)
301 #define GD_EVENT_TEXT_RETURN (1 << 5)
302 #define GD_EVENT_TEXT_LEAVING (1 << 6)
304 /* gadget button states */
305 #define GD_BUTTON_UNPRESSED 0
306 #define GD_BUTTON_PRESSED 1
308 /* gadget structure constants */
309 #define MAX_GADGET_TEXTSIZE 1024
310 #define MAX_INFO_TEXTSIZE 1024
312 /* gadget creation tags */
314 #define GDI_CUSTOM_ID 1
321 #define GDI_CHECKED 8
322 #define GDI_RADIO_NR 9
323 #define GDI_NUMBER_VALUE 10
324 #define GDI_NUMBER_MIN 11
325 #define GDI_NUMBER_MAX 12
326 #define GDI_TEXT_VALUE 13
327 #define GDI_TEXT_SIZE 14
328 #define GDI_DESIGN_UNPRESSED 15
329 #define GDI_DESIGN_PRESSED 16
330 #define GDI_ALT_DESIGN_UNPRESSED 17
331 #define GDI_ALT_DESIGN_PRESSED 18
332 #define GDI_DESIGN_BORDER 19
333 #define GDI_DECORATION_DESIGN 20
334 #define GDI_DECORATION_POSITION 22
335 #define GDI_DECORATION_SIZE 21
336 #define GDI_DECORATION_SHIFTING 23
337 #define GDI_EVENT_MASK 24
339 #define GDI_CALLBACK_INFO 26
340 #define GDI_CALLBACK_ACTION 27
341 #define GDI_AREA_SIZE 28
342 #define GDI_ITEM_SIZE 29
343 #define GDI_SCROLLBAR_ITEMS_MAX 30
344 #define GDI_SCROLLBAR_ITEMS_VISIBLE 31
345 #define GDI_SCROLLBAR_ITEM_POSITION 32
346 #define GDI_INFO_TEXT 33
348 typedef void (*gadget_function)(void *);
352 Pixmap pixmap; /* Pixmap with gadget surface */
353 int x, y; /* position of rectangle in Pixmap */
356 struct GadgetDecoration
358 struct GadgetDesign design; /* decoration design structure */
359 int x, y; /* position of deco on the gadget */
360 int width, height; /* width and height of decoration */
361 int xshift, yshift; /* deco shifting when gadget pressed */
366 unsigned long type; /* event type */
367 int button; /* button number for button events */
368 int x, y; /* gadget position at event time */
369 boolean off_borders; /* mouse pointer outside gadget? */
370 int item_x, item_y, item_position; /* new item position */
373 struct GadgetDrawingArea
375 int area_xsize, area_ysize; /* size of drawing area (in items) */
376 int item_xsize, item_ysize; /* size of each item in drawing area */
379 struct GadgetTextInput
381 char value[MAX_GADGET_TEXTSIZE]; /* text string in input field */
382 int number_value; /* integer value, if numeric */
383 int number_min; /* minimal allowed numeric value */
384 int number_max; /* maximal allowed numeric value */
385 int size; /* maximal size of input text */
386 int cursor_position; /* actual cursor position */
389 struct GadgetScrollbar
391 int items_max; /* number of items to access */
392 int items_visible; /* number of visible items */
393 int item_position; /* actual item position */
394 int size_max; /* this is either width or height */
395 int size; /* scrollbar size on screen */
396 int position; /* scrollbar position on screen */
397 int position_max; /* bottom/right scrollbar position */
398 int drag_position; /* drag position on scrollbar */
403 int id; /* internal gadget identifier */
404 int custom_id; /* custom gadget identifier */
405 char info_text[MAX_INFO_TEXTSIZE]; /* short popup info text */
406 int x, y; /* gadget position */
407 int width, height; /* gadget size */
408 unsigned long type; /* type (button, text input, ...) */
409 unsigned long state; /* state (pressed, released, ...) */
410 boolean checked; /* check/radio button state */
411 int radio_nr; /* number of radio button series */
412 boolean mapped; /* gadget is active */
413 struct GadgetDesign design[2]; /* 0: normal; 1: pressed */
414 struct GadgetDesign alt_design[2]; /* alternative design */
415 struct GadgetDecoration deco; /* decoration on top of gadget */
416 int design_border; /* border size of gadget decoration */
417 unsigned long event_mask; /* possible events for this gadget */
418 struct GadgetEvent event; /* actual gadget event */
419 gadget_function callback_info; /* function for pop-up info text */
420 gadget_function callback_action; /* function for gadget action */
421 struct GadgetDrawingArea drawing; /* fields for drawing area gadget */
422 struct GadgetTextInput text; /* fields for text input gadget */
423 struct GadgetScrollbar scrollbar; /* fields for scrollbar gadget */
424 struct GadgetInfo *next; /* next list entry */
427 struct GadgetInfo *CreateGadget(int, ...);
428 void FreeGadget(struct GadgetInfo *);
430 void ClickOnGadget(struct GadgetInfo *);
431 void AdjustScrollbar(struct GadgetInfo *, int, int);
432 void ModifyTextInputTextValue(struct GadgetInfo *, char *);
433 void ModifyTextInputNumberValue(struct GadgetInfo *, int);
435 void MapGadget(struct GadgetInfo *);
436 void UnmapGadget(struct GadgetInfo *);
437 void UnmapAllGadgets();
438 void RemapAllGadgets();
440 void HandleGadgets(int, int, int);
441 void HandleGadgetsKeyInput(KeySym);