rnd-19981217-2
[rocksndiamonds.git] / src / buttons.h
1 /***********************************************************
2 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
3 *----------------------------------------------------------*
4 *  (c) 1995-98 Artsoft Entertainment                       *
5 *              Holger Schemel                              *
6 *              Oststrasse 11a                              *
7 *              33604 Bielefeld                             *
8 *              phone: ++49 +521 290471                     *
9 *              email: aeglos@valinor.owl.de                *
10 *----------------------------------------------------------*
11 *  buttons.h                                               *
12 ***********************************************************/
13
14 #ifndef BUTTONS_H
15 #define BUTTONS_H
16
17 #include "main.h"
18
19 /* the following definitions are also used by tools.c */
20
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)
34
35 /* values for requests */
36 #define BUTTON_OK               (1L<<0)
37 #define BUTTON_NO               (1L<<1)
38 #define BUTTON_CONFIRM          (1L<<2)
39
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)
45
46 /* for DrawPlayerButton() */
47 #define DB_INIT                 0
48 #define DB_NORMAL               1
49
50 /* the following definitions are also used by screens.c */
51
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
58
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)
90
91 /* special */
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)
98
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
103
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)
110 #define BUTTON_OFF              0
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)
118
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)
123
124 /* the following definitions are also used by game.c */
125
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)
133
134 /* the following definitions are also used by editor.c */
135
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
149
150 #define ED_BUTTON_EUP_Y2POS     140
151 #define ED_BUTTON_EDOWN_Y2POS   165
152 #define ED_BUTTON_ELEM_Y2POS    190
153
154 #define ED_BUTTON_CTRL_XPOS     5
155 #define ED_BUTTON_CTRL_YPOS     5
156 #define ED_BUTTON_CTRL_XSIZE    90
157 #define ED_BUTTON_CTRL_YSIZE    30
158 #define ED_BUTTON_FILL_XPOS     5
159 #define ED_BUTTON_FILL_YPOS     35
160 #define ED_BUTTON_FILL_XSIZE    90
161 #define ED_BUTTON_FILL_YSIZE    20
162 #define ED_BUTTON_LEFT_XPOS     5
163 #define ED_BUTTON_LEFT_YPOS     65
164 #define ED_BUTTON_LEFT_XSIZE    30
165 #define ED_BUTTON_LEFT_YSIZE    20
166 #define ED_BUTTON_UP_XPOS       35
167 #define ED_BUTTON_UP_YPOS       55
168 #define ED_BUTTON_UP_XSIZE      30
169 #define ED_BUTTON_UP_YSIZE      20
170 #define ED_BUTTON_DOWN_XPOS     35
171 #define ED_BUTTON_DOWN_YPOS     75
172 #define ED_BUTTON_DOWN_XSIZE    30
173 #define ED_BUTTON_DOWN_YSIZE    20
174 #define ED_BUTTON_RIGHT_XPOS    65
175 #define ED_BUTTON_RIGHT_YPOS    65
176 #define ED_BUTTON_RIGHT_XSIZE   30
177 #define ED_BUTTON_RIGHT_YSIZE   20
178
179 #define ED_BUTTON_EDIT_XPOS     5
180 #define ED_BUTTON_EDIT_YPOS     5
181 #define ED_BUTTON_EDIT_XSIZE    90
182 #define ED_BUTTON_EDIT_YSIZE    30
183 #define ED_BUTTON_CLEAR_XPOS    5
184 #define ED_BUTTON_CLEAR_YPOS    35
185 #define ED_BUTTON_CLEAR_XSIZE   90
186 #define ED_BUTTON_CLEAR_YSIZE   20
187 #define ED_BUTTON_UNDO_XPOS     5
188 #define ED_BUTTON_UNDO_YPOS     55
189 #define ED_BUTTON_UNDO_XSIZE    90
190 #define ED_BUTTON_UNDO_YSIZE    20
191 #define ED_BUTTON_EXIT_XPOS     5
192 #define ED_BUTTON_EXIT_YPOS     75
193 #define ED_BUTTON_EXIT_XSIZE    90
194 #define ED_BUTTON_EXIT_YSIZE    20
195
196 #define ED_BUTTON_COUNT_YPOS    60
197 #define ED_BUTTON_COUNT_XSIZE   20
198 #define ED_BUTTON_COUNT_YSIZE   20
199 #define ED_BUTTON_MINUS_XPOS    2
200 #define ED_BUTTON_MINUS_YPOS    ED_BUTTON_COUNT_YPOS
201 #define ED_BUTTON_MINUS_XSIZE   ED_BUTTON_COUNT_XSIZE
202 #define ED_BUTTON_MINUS_YSIZE   ED_BUTTON_COUNT_YSIZE
203 #define ED_WIN_COUNT_XPOS       (ED_BUTTON_MINUS_XPOS+ED_BUTTON_MINUS_XSIZE+2)
204 #define ED_WIN_COUNT_YPOS       ED_BUTTON_COUNT_YPOS
205 #define ED_WIN_COUNT_XSIZE      52
206 #define ED_WIN_COUNT_YSIZE      ED_BUTTON_COUNT_YSIZE
207 #define ED_BUTTON_PLUS_XPOS     (ED_WIN_COUNT_XPOS+ED_WIN_COUNT_XSIZE+2)
208 #define ED_BUTTON_PLUS_YPOS     ED_BUTTON_COUNT_YPOS
209 #define ED_BUTTON_PLUS_XSIZE    ED_BUTTON_COUNT_XSIZE
210 #define ED_BUTTON_PLUS_YSIZE    ED_BUTTON_COUNT_YSIZE
211
212 #define ED_COUNT_GADGET_XPOS    16
213 #define ED_COUNT_GADGET_YPOS    (16+3*MINI_TILEY+64)
214 #define ED_COUNT_GADGET_YSIZE   (ED_BUTTON_MINUS_YSIZE+4)
215 #define ED_COUNT_TEXT_XPOS      (ED_COUNT_GADGET_XPOS+DXSIZE+10)
216 #define ED_COUNT_TEXT_YPOS      (ED_COUNT_GADGET_YPOS+3)
217 #define ED_COUNT_TEXT_YSIZE     ED_COUNT_GADGET_YSIZE
218 #define ED_COUNT_VALUE_XPOS     (ED_COUNT_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
219 #define ED_COUNT_VALUE_YPOS     ED_COUNT_TEXT_YPOS
220 #define ED_SIZE_GADGET_XPOS     (SX+21*MINI_TILEX)
221 #define ED_SIZE_GADGET_YPOS     (SY+4*MINI_TILEY)
222 #define ED_SIZE_GADGET_YSIZE    (ED_BUTTON_MINUS_YSIZE+4)
223 #define ED_SIZE_TEXT_XPOS       (ED_SIZE_GADGET_XPOS+DXSIZE+10)
224 #define ED_SIZE_TEXT_YPOS       (ED_SIZE_GADGET_YPOS+3)
225 #define ED_SIZE_TEXT_YSIZE      ED_COUNT_GADGET_YSIZE
226 #define ED_SIZE_VALUE_XPOS      (ED_SIZE_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7)
227 #define ED_SIZE_VALUE_YPOS      ED_SIZE_TEXT_YPOS
228
229 /* values for asking control */
230 #define ED_BUTTON_CTRL          (1L<<0)
231 #define ED_BUTTON_FILL          (1L<<1)
232 #define ED_BUTTON_LEFT          (1L<<2)
233 #define ED_BUTTON_UP            (1L<<3)
234 #define ED_BUTTON_DOWN          (1L<<4)
235 #define ED_BUTTON_RIGHT         (1L<<5)
236 #define ED_BUTTON_EDIT          (1L<<6)
237 #define ED_BUTTON_CLEAR         (1L<<7)
238 #define ED_BUTTON_UNDO          (1L<<8)
239 #define ED_BUTTON_EXIT          (1L<<9)
240
241 #define ED_BUTTON_PRESSED       (1L<<10)
242 #define ED_BUTTON_RELEASED      (1L<<11)
243
244 #define ED_BUTTON_EUP           0
245 #define ED_BUTTON_EDOWN         1
246 #define ED_BUTTON_ELEM          2
247
248 void DrawVideoDisplay(unsigned long, unsigned long);
249 void DrawCompleteVideoDisplay(void);
250 void DrawSoundDisplay(unsigned long);
251 void DrawGameButton(unsigned long);
252 void DrawYesNoButton(unsigned long, int);
253 void DrawConfirmButton(unsigned long, int);
254 void DrawPlayerButton(unsigned long, int);
255 void DrawEditButton(unsigned long state);
256 void DrawCtrlButton(unsigned long state);
257 void DrawElemButton(int, int);
258 void DrawCountButton(int, int);
259 int CheckVideoButtons(int, int, int);
260 int CheckSoundButtons(int, int, int);
261 int CheckGameButtons(int, int, int);
262 int CheckYesNoButtons(int, int, int);
263 int CheckConfirmButton(int, int, int);
264 int CheckPlayerButtons(int, int, int);
265 int CheckEditButtons(int, int, int);
266 int CheckCtrlButtons(int, int, int);
267 int CheckElemButtons(int, int, int);
268 int CheckCountButtons(int, int, int);
269
270
271 /* NEW GADGET STUFF -------------------------------------------------------- */
272
273
274 /* gadget types */
275 #define GD_TYPE_NORMAL_BUTTON           (1<<0)
276 #define GD_TYPE_TWO_STATE_BUTTON        (1<<1)
277 #define GD_TYPE_DRAWING_AREA            (1<<2)
278 #define GD_TYPE_TEXTINPUT               (1<<3)
279 #define GD_TYPE_TEXTOUTPUT              (1<<4)
280 #define GD_TYPE_NUMBERINPUT             (1<<5)
281 #define GD_TYPE_NUMBEROUTPUT            (1<<6)
282 #define GD_TYPE_SCROLLBAR_VERTICAL      (1<<7)
283 #define GD_TYPE_SCROLLBAR_HORIZONTAL    (1<<8)
284
285 /* gadget events */
286 #define GD_EVENT_PRESSED                (1<<0)
287 #define GD_EVENT_RELEASED               (1<<1)
288 #define GD_EVENT_MOVING                 (1<<2)
289 #define GD_EVENT_REPEATED               (1<<3)
290
291 /* gadget button states */
292 #define GD_BUTTON_UNPRESSED             0
293 #define GD_BUTTON_PRESSED               1
294
295 /* gadget structure constants */
296 #define MAX_GADGET_TEXTSIZE             1024
297
298 /* gadget creation tags */
299 #define GDI_END                         0
300 #define GDI_CUSTOM_ID                   1
301 #define GDI_X                           2
302 #define GDI_Y                           3
303 #define GDI_WIDTH                       4
304 #define GDI_HEIGHT                      5
305 #define GDI_TYPE                        6
306 #define GDI_STATE                       7
307 #define GDI_ALT_STATE                   8
308 #define GDI_NUMBER_VALUE                9
309 #define GDI_TEXT_VALUE                  10
310 #define GDI_DESIGN_UNPRESSED            11
311 #define GDI_DESIGN_PRESSED              12
312 #define GDI_ALT_DESIGN_UNPRESSED        13
313 #define GDI_ALT_DESIGN_PRESSED          14
314 #define GDI_EVENT_MASK                  15
315 #define GDI_EVENT                       16
316 #define GDI_CALLBACK                    17
317 #define GDI_AREA_SIZE                   18
318 #define GDI_ITEM_SIZE                   19
319
320 typedef void (*gadget_callback_function)(void *);
321
322 struct GadgetDesign
323 {
324   Pixmap pixmap;                        /* Pixmap with gadget surface */
325   int x, y;                             /* position of rectangle in Pixmap */
326 };
327
328 struct GadgetEvent
329 {
330   unsigned long type;                   /* event type */
331   int button;                           /* button number for button events */
332   int x, y;                             /* gadget position at event time */
333   boolean off_borders;                  /* mouse pointer outside gadget? */
334 };
335
336 struct GadgetDrawingArea
337 {
338   int area_xsize, area_ysize;           /* size of drawing area (in items) */
339   int item_xsize, item_ysize;           /* size of each item in drawing area */
340 };
341
342 struct GadgetInfo
343 {
344   int id;                               /* internal gadget identifier */
345   int custom_id;                        /* custom gadget identifier */
346   int x, y;                             /* gadget position */
347   int width, height;                    /* gadget size */
348   unsigned long type;                   /* type (button, text input, ...) */
349   unsigned long state;                  /* state (pressed, released, ...) */
350   boolean alt_state;                    /* alternative state */
351   boolean mapped;                       /* gadget is active */
352   long number_value;
353   char text_value[MAX_GADGET_TEXTSIZE];
354   struct GadgetDesign design[2];        /* 0: normal; 1: pressed */
355   struct GadgetDesign alt_design[2];    /* alternative design */
356   unsigned long event_mask;             /* possible events for this gadget */
357   struct GadgetEvent event;             /* actual gadget event */
358   gadget_callback_function callback;
359   struct GadgetDrawingArea drawing;     /* fields for drawing area gadget */
360   struct GadgetInfo *next;              /* next list entry */
361 };
362
363 struct GadgetInfo *CreateGadget(int, ...);
364 void FreeGadget(struct GadgetInfo *);
365
366 void MapGadget(struct GadgetInfo *);
367 void UnmapGadget(struct GadgetInfo *);
368
369 void HandleGadgets(int, int, int);
370
371 #endif