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 ***********************************************************/
20 /****************************************************************/
21 /********** drawing buttons and corresponding displays **********/
22 /****************************************************************/
24 void DrawVideoDisplay(unsigned long state, unsigned long value)
27 int part_label = 0, part_symbol = 1;
28 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
29 static char *monatsname[12] =
31 "JAN", "FEB", "MAR", "APR", "MAY", "JUN",
32 "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"
34 static int video_pos[10][2][4] =
36 {{ VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS,
37 VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE },
38 { VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS,
39 VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE }},
41 {{ VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS,
42 VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE },
43 { VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS,
44 VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE }},
46 {{ VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS,
47 VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE },
48 { VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS,
49 VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE }},
51 {{ VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS,
52 VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE },
53 { VIDEO_DATE_XPOS, VIDEO_DATE_YPOS,
54 VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE }},
58 { VIDEO_TIME_XPOS, VIDEO_TIME_YPOS,
59 VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE }},
61 {{ VIDEO_BUTTON_PLAY_XPOS, VIDEO_BUTTON_ANY_YPOS,
62 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
66 {{ VIDEO_BUTTON_REC_XPOS, VIDEO_BUTTON_ANY_YPOS,
67 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
71 {{ VIDEO_BUTTON_PAUSE_XPOS, VIDEO_BUTTON_ANY_YPOS,
72 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
76 {{ VIDEO_BUTTON_STOP_XPOS, VIDEO_BUTTON_ANY_YPOS,
77 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
81 {{ VIDEO_BUTTON_EJECT_XPOS, VIDEO_BUTTON_ANY_YPOS,
82 VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE },
91 int pos = i/2, cx, cy = DOOR_GFX_PAGEY2;
93 if (i%2) /* i ungerade => STATE_ON / PRESS_OFF */
96 cx = DOOR_GFX_PAGEX3; /* i gerade => STATE_OFF / PRESS_ON */
98 if (video_pos[pos][part_label][0] && value != VIDEO_DISPLAY_SYMBOL_ONLY)
99 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
100 cx + video_pos[pos][part_label][xpos],
101 cy + video_pos[pos][part_label][ypos],
102 video_pos[pos][part_label][xsize],
103 video_pos[pos][part_label][ysize],
104 VX + video_pos[pos][part_label][xpos],
105 VY + video_pos[pos][part_label][ypos]);
106 if (video_pos[pos][part_symbol][0] && value != VIDEO_DISPLAY_LABEL_ONLY)
107 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
108 cx + video_pos[pos][part_symbol][xpos],
109 cy + video_pos[pos][part_symbol][ypos],
110 video_pos[pos][part_symbol][xsize],
111 video_pos[pos][part_symbol][ysize],
112 VX + video_pos[pos][part_symbol][xpos],
113 VY + video_pos[pos][part_symbol][ypos]);
117 if (state & VIDEO_STATE_FFWD_ON)
119 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY2;
121 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
122 cx + VIDEO_PLAY_SYMBOL_XPOS,
123 cy + VIDEO_PLAY_SYMBOL_YPOS,
124 VIDEO_PLAY_SYMBOL_XSIZE - 2,
125 VIDEO_PLAY_SYMBOL_YSIZE,
126 VX + VIDEO_PLAY_SYMBOL_XPOS - 9,
127 VY + VIDEO_PLAY_SYMBOL_YPOS);
130 if (state & VIDEO_STATE_DATE_ON)
132 int tag = value % 100;
133 int monat = (value/100) % 100;
134 int jahr = (value/10000);
136 DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS,
137 int2str(tag,2),FS_SMALL,FC_SPECIAL1);
138 DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS,
139 monatsname[monat],FS_SMALL,FC_SPECIAL1);
140 DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS,
141 int2str(jahr,2),FS_SMALL,FC_SPECIAL1);
144 if (state & VIDEO_STATE_TIME_ON)
146 int min = value / 60;
147 int sec = value % 60;
149 DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS,
150 int2str(min,2),FS_SMALL,FC_SPECIAL1);
151 DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS,
152 int2str(sec,2),FS_SMALL,FC_SPECIAL1);
155 if (state & VIDEO_STATE_DATE)
156 redraw_mask |= REDRAW_VIDEO_1;
157 if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE)
158 redraw_mask |= REDRAW_VIDEO_2;
159 if (state & VIDEO_PRESS)
160 redraw_mask |= REDRAW_VIDEO_3;
163 void DrawCompleteVideoDisplay()
165 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
166 DOOR_GFX_PAGEX3,DOOR_GFX_PAGEY2, VXSIZE,VYSIZE, VX,VY);
167 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
168 DOOR_GFX_PAGEX4+VIDEO_CONTROL_XPOS,
169 DOOR_GFX_PAGEY2+VIDEO_CONTROL_YPOS,
170 VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE,
171 VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS);
173 DrawVideoDisplay(VIDEO_ALL_OFF,0);
174 if (tape.date && tape.length)
176 DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date);
177 DrawVideoDisplay(VIDEO_STATE_TIME_ON,tape.length_seconds);
180 XCopyArea(display,drawto,pix[PIX_DB_DOOR],gc,
181 VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
184 void DrawSoundDisplay(unsigned long state)
186 int pos, cx = DOOR_GFX_PAGEX4, cy = 0;
188 pos = (state & BUTTON_SOUND_MUSIC ? SOUND_BUTTON_MUSIC_XPOS :
189 state & BUTTON_SOUND_LOOPS ? SOUND_BUTTON_LOOPS_XPOS :
190 SOUND_BUTTON_SIMPLE_XPOS);
192 if (state & BUTTON_ON)
193 cy -= SOUND_BUTTON_YSIZE;
195 if (state & BUTTON_PRESSED)
196 cx = DOOR_GFX_PAGEX3;
198 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
199 cx + pos,cy + SOUND_BUTTON_ANY_YPOS,
200 SOUND_BUTTON_XSIZE,SOUND_BUTTON_YSIZE,
201 DX + pos,DY + SOUND_BUTTON_ANY_YPOS);
203 redraw_mask |= REDRAW_DOOR_1;
206 void DrawGameButton(unsigned long state)
208 int pos, cx = DOOR_GFX_PAGEX4, cy = -GAME_BUTTON_YSIZE;
210 pos = (state & BUTTON_GAME_STOP ? GAME_BUTTON_STOP_XPOS :
211 state & BUTTON_GAME_PAUSE ? GAME_BUTTON_PAUSE_XPOS :
212 GAME_BUTTON_PLAY_XPOS);
214 if (state & BUTTON_PRESSED)
215 cx = DOOR_GFX_PAGEX3;
217 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
218 cx + pos,cy + GAME_BUTTON_ANY_YPOS,
219 GAME_BUTTON_XSIZE,GAME_BUTTON_YSIZE,
220 DX + pos,DY + GAME_BUTTON_ANY_YPOS);
222 redraw_mask |= REDRAW_DOOR_1;
225 void DrawYesNoButton(unsigned long state)
227 int pos, cx = DOOR_GFX_PAGEX4, cy = 0;
229 pos = (state & BUTTON_OK ? OK_BUTTON_XPOS : NO_BUTTON_XPOS);
231 if (state & BUTTON_PRESSED)
232 cx = DOOR_GFX_PAGEX3;
234 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
235 cx + pos,cy + OK_BUTTON_GFX_YPOS,
236 OK_BUTTON_XSIZE,OK_BUTTON_YSIZE,
237 DX + pos,DY + OK_BUTTON_YPOS);
239 redraw_mask |= REDRAW_DOOR_1;
242 void DrawConfirmButton(unsigned long state)
244 int cx = DOOR_GFX_PAGEX4, cy = 0;
246 if (state & BUTTON_PRESSED)
247 cx = DOOR_GFX_PAGEX3;
249 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
250 cx + CONFIRM_BUTTON_XPOS,cy + CONFIRM_BUTTON_GFX_YPOS,
251 CONFIRM_BUTTON_XSIZE,CONFIRM_BUTTON_YSIZE,
252 DX + CONFIRM_BUTTON_XPOS,DY + CONFIRM_BUTTON_YPOS);
254 redraw_mask |= REDRAW_DOOR_1;
257 void DrawPlayerButton(unsigned long state, int mode)
259 Drawable dest_drawto;
260 int dest_xoffset, dest_yoffset;
262 int graphic_offset = (PLAYER_BUTTON_XSIZE - TILEX/2)/2;
264 int cx = DOOR_GFX_PAGEX4, cy = 0;
268 dest_drawto = pix[PIX_DB_DOOR];
269 dest_xoffset = DOOR_GFX_PAGEX1;
274 dest_drawto = drawto;
279 if (state & BUTTON_PLAYER_1)
280 graphic = GFX_SPIELER1;
281 else if (state & BUTTON_PLAYER_2)
282 graphic = GFX_SPIELER2;
283 else if (state & BUTTON_PLAYER_3)
284 graphic = GFX_SPIELER3;
285 else if (state & BUTTON_PLAYER_4)
286 graphic = GFX_SPIELER4;
288 xpos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_3 ?
289 PLAYER_BUTTON_1_XPOS : PLAYER_BUTTON_2_XPOS);
290 ypos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_2 ?
291 PLAYER_BUTTON_1_YPOS : PLAYER_BUTTON_3_YPOS);
293 if (state & BUTTON_PRESSED)
295 cx = DOOR_GFX_PAGEX3;
299 XCopyArea(display,pix[PIX_DOOR],dest_drawto,gc,
300 cx + PLAYER_BUTTON_GFX_XPOS, cy + PLAYER_BUTTON_GFX_YPOS,
301 PLAYER_BUTTON_XSIZE, PLAYER_BUTTON_YSIZE,
302 dest_xoffset + xpos, dest_yoffset + ypos);
303 DrawMiniGraphicExt(dest_drawto,gc,
304 dest_xoffset + xpos + graphic_offset,
305 dest_yoffset + ypos + graphic_offset,
308 redraw_mask |= REDRAW_DOOR_1;
311 /* several buttons in the level editor */
313 void DrawEditButton(unsigned long state)
316 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
317 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY2;
318 static int edit_pos[6][4] =
320 {ED_BUTTON_CTRL_XPOS,ED_BUTTON_CTRL_YPOS,
321 ED_BUTTON_CTRL_XSIZE,ED_BUTTON_CTRL_YSIZE},
323 {ED_BUTTON_FILL_XPOS,ED_BUTTON_FILL_YPOS,
324 ED_BUTTON_FILL_XSIZE,ED_BUTTON_FILL_YSIZE},
326 {ED_BUTTON_LEFT_XPOS,ED_BUTTON_LEFT_YPOS,
327 ED_BUTTON_LEFT_XSIZE,ED_BUTTON_LEFT_YSIZE},
329 {ED_BUTTON_UP_XPOS,ED_BUTTON_UP_YPOS,
330 ED_BUTTON_UP_XSIZE,ED_BUTTON_UP_YSIZE},
332 {ED_BUTTON_DOWN_XPOS,ED_BUTTON_DOWN_YPOS,
333 ED_BUTTON_DOWN_XSIZE,ED_BUTTON_DOWN_YSIZE},
335 {ED_BUTTON_RIGHT_XPOS,ED_BUTTON_RIGHT_YPOS,
336 ED_BUTTON_RIGHT_XSIZE,ED_BUTTON_RIGHT_YSIZE}
339 if (state & ED_BUTTON_PRESSED)
340 cx = DOOR_GFX_PAGEX5;
345 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
346 cx + edit_pos[i][xpos],
347 cy + edit_pos[i][ypos],
350 VX + edit_pos[i][xpos],
351 VY + edit_pos[i][ypos]);
354 redraw_mask |= REDRAW_DOOR_2;
357 void DrawCtrlButton(unsigned long state)
360 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
361 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY1+80;
362 static int edit_pos[4][4] =
364 {ED_BUTTON_EDIT_XPOS,ED_BUTTON_EDIT_YPOS,
365 ED_BUTTON_EDIT_XSIZE,ED_BUTTON_EDIT_YSIZE},
367 {ED_BUTTON_CLEAR_XPOS,ED_BUTTON_CLEAR_YPOS,
368 ED_BUTTON_CLEAR_XSIZE,ED_BUTTON_CLEAR_YSIZE},
370 {ED_BUTTON_UNDO_XPOS,ED_BUTTON_UNDO_YPOS,
371 ED_BUTTON_UNDO_XSIZE,ED_BUTTON_UNDO_YSIZE},
373 {ED_BUTTON_EXIT_XPOS,ED_BUTTON_EXIT_YPOS,
374 ED_BUTTON_EXIT_XSIZE,ED_BUTTON_EXIT_YSIZE}
377 if (state & ED_BUTTON_PRESSED)
378 cx = DOOR_GFX_PAGEX3;
382 if (state & (1<<(i+6)))
383 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
384 cx + edit_pos[i][xpos],
385 cy + edit_pos[i][ypos],
388 VX + edit_pos[i][xpos],
389 VY + edit_pos[i][ypos]);
392 redraw_mask |= REDRAW_DOOR_2;
395 void DrawElemButton(int button_nr, int button_state)
397 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
398 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
399 int from_x, from_y, to_x,to_y, size_x, size_y;
400 static int edit_pos[3][4] =
402 {ED_BUTTON_EUP_XPOS,ED_BUTTON_EUP_YPOS,
403 ED_BUTTON_EUP_XSIZE,ED_BUTTON_EUP_YSIZE},
405 {ED_BUTTON_EDOWN_XPOS,ED_BUTTON_EDOWN_YPOS,
406 ED_BUTTON_EDOWN_XSIZE,ED_BUTTON_EDOWN_YSIZE},
408 {ED_BUTTON_ELEM_XPOS,ED_BUTTON_ELEM_YPOS,
409 ED_BUTTON_ELEM_XSIZE,ED_BUTTON_ELEM_YSIZE}
412 if (button_nr<ED_BUTTON_ELEM)
416 from_x = cx + edit_pos[pos][xpos];
417 from_y = cy + edit_pos[pos][ypos];
418 size_x = edit_pos[pos][xsize];
419 size_y = edit_pos[pos][ysize];
420 to_x = DX + edit_pos[pos][xpos];
421 to_y = DY + edit_pos[pos][ypos];
423 if (button_state & ED_BUTTON_PRESSED)
425 if (button_nr==ED_BUTTON_EUP)
426 from_y = cy + ED_BUTTON_EUP_Y2POS;
428 from_y = cy + ED_BUTTON_EDOWN_Y2POS;
431 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
432 from_x,from_y, size_x,size_y, to_x,to_y);
436 int pos = ED_BUTTON_ELEM;
437 int elem_pos = button_nr-ED_BUTTON_ELEM;
438 int x = elem_pos % MAX_ELEM_X;
439 int y = elem_pos / MAX_ELEM_X;
443 if (elem_pos+element_shift < elements_in_list)
444 graphic = el2gfx(editor_element[elem_pos+element_shift]);
446 graphic = GFX_LEERRAUM;
448 from_x = cx + edit_pos[pos][xpos];
449 from_y = cy + edit_pos[pos][ypos];
450 size_x = edit_pos[pos][xsize];
451 size_y = edit_pos[pos][ysize];
452 to_x = DX + edit_pos[pos][xpos] + x * ED_BUTTON_ELEM_XSIZE;
453 to_y = DY + edit_pos[pos][ypos] + y * ED_BUTTON_ELEM_YSIZE;
455 if (button_state & ED_BUTTON_PRESSED)
457 from_y = ED_BUTTON_ELEM_Y2POS;
461 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
462 from_x,from_y, size_x,size_y, to_x,to_y);
464 DrawMiniGraphicExt(drawto,gc,
465 DX+ED_BUTTON_ELEM_XPOS+3+shift +
466 (elem_pos % MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
467 DY+ED_BUTTON_ELEM_YPOS+3-shift +
468 (elem_pos / MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
472 redraw_mask |= REDRAW_DOOR_1;
475 void DrawCountButton(int button_nr, int button_state)
477 int from_x, from_y, to_x,to_y, size_x, size_y;
480 DOOR_GFX_PAGEX4+(button_nr%2 ? ED_BUTTON_PLUS_XPOS : ED_BUTTON_MINUS_XPOS);
481 from_y = DOOR_GFX_PAGEY1 + ED_BUTTON_MINUS_YPOS;
482 size_x = ED_BUTTON_MINUS_XSIZE;
483 size_y = ED_BUTTON_MINUS_YSIZE;
484 to_x = (button_nr<32 ? ED_COUNT_GADGET_XPOS : ED_SIZE_GADGET_XPOS);
486 to_x += (ED_BUTTON_PLUS_XPOS - ED_BUTTON_MINUS_XPOS);
487 to_y = (button_nr<32 ? ED_COUNT_GADGET_YPOS : ED_SIZE_GADGET_YPOS) +
488 ((button_nr<32 ? button_nr : button_nr-32)/2)*ED_COUNT_GADGET_YSIZE;
490 if (button_state & ED_BUTTON_PRESSED)
493 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
494 from_x,from_y, size_x,size_y, to_x,to_y);
495 XCopyArea(display,pix[PIX_DOOR],window,gc,
496 from_x,from_y, size_x,size_y, to_x,to_y);
499 /**********************************************************************/
500 /********** checking buttons (and redrawing them, if needed) **********/
501 /**********************************************************************/
503 int CheckVideoButtons(int mx, int my, int button)
506 static int choice = -1;
507 static BOOL pressed = FALSE;
508 static int video_button[5] =
510 VIDEO_PRESS_EJECT_ON,
512 VIDEO_PRESS_PAUSE_ON,
519 if (!motion_status) /* Maustaste neu gedrückt */
521 if (ON_VIDEO_BUTTON(mx,my))
523 choice = VIDEO_BUTTON(mx);
525 DrawVideoDisplay(video_button[choice],0);
528 else /* Mausbewegung bei gedrückter Maustaste */
530 if ((!ON_VIDEO_BUTTON(mx,my) || VIDEO_BUTTON(mx)!=choice) &&
531 choice>=0 && pressed)
534 DrawVideoDisplay(video_button[choice]<<1,0);
536 else if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && !pressed)
539 DrawVideoDisplay(video_button[choice],0);
543 else /* Maustaste wieder losgelassen */
545 if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && pressed)
547 DrawVideoDisplay(video_button[choice]<<1,0);
548 return_code = choice+1;
563 int CheckSoundButtons(int mx, int my, int button)
566 static int choice = -1;
567 static BOOL pressed = FALSE;
570 sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * sound_music_on);
571 sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * sound_loops_on);
572 sound_state[2] = BUTTON_SOUND_SIMPLE | (BUTTON_ON * sound_simple_on);
576 if (!motion_status) /* Maustaste neu gedrückt */
578 if (ON_SOUND_BUTTON(mx,my))
580 choice = SOUND_BUTTON(mx);
582 DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
585 else /* Mausbewegung bei gedrückter Maustaste */
587 if ((!ON_SOUND_BUTTON(mx,my) || SOUND_BUTTON(mx)!=choice) &&
588 choice>=0 && pressed)
591 DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
593 else if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && !pressed)
596 DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
600 else /* Maustaste wieder losgelassen */
602 if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && pressed)
604 DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
605 return_code = 1<<choice;
620 int CheckGameButtons(int mx, int my, int button)
623 static int choice = -1;
624 static BOOL pressed = FALSE;
634 if (!motion_status) /* Maustaste neu gedrückt */
636 if (ON_GAME_BUTTON(mx,my))
638 choice = GAME_BUTTON(mx);
640 DrawGameButton(game_state[choice] | BUTTON_PRESSED);
643 else /* Mausbewegung bei gedrückter Maustaste */
645 if ((!ON_GAME_BUTTON(mx,my) || GAME_BUTTON(mx)!=choice) &&
646 choice>=0 && pressed)
649 DrawGameButton(game_state[choice] | BUTTON_RELEASED);
651 else if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && !pressed)
654 DrawGameButton(game_state[choice] | BUTTON_PRESSED);
658 else /* Maustaste wieder losgelassen */
660 if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && pressed)
662 DrawGameButton(game_state[choice] | BUTTON_RELEASED);
663 return_code = 1<<choice;
678 int CheckYesNoButtons(int mx, int my, int button)
681 static int choice = -1;
682 static BOOL pressed = FALSE;
683 static int yesno_button[5] =
691 if (!motion_status) /* Maustaste neu gedrückt */
693 if (ON_YESNO_BUTTON(mx,my))
695 choice = YESNO_BUTTON(mx);
697 DrawYesNoButton(yesno_button[choice] | BUTTON_PRESSED);
700 else /* Mausbewegung bei gedrückter Maustaste */
702 if ((!ON_YESNO_BUTTON(mx,my) || YESNO_BUTTON(mx)!=choice) &&
703 choice>=0 && pressed)
706 DrawYesNoButton(yesno_button[choice] | BUTTON_RELEASED);
708 else if (ON_YESNO_BUTTON(mx,my) && YESNO_BUTTON(mx)==choice && !pressed)
711 DrawYesNoButton(yesno_button[choice] | BUTTON_PRESSED);
715 else /* Maustaste wieder losgelassen */
717 if (ON_YESNO_BUTTON(mx,my) && YESNO_BUTTON(mx)==choice && pressed)
719 DrawYesNoButton(yesno_button[choice] | BUTTON_RELEASED);
720 return_code = choice+1;
735 int CheckConfirmButton(int mx, int my, int button)
738 static int choice = -1;
739 static BOOL pressed = FALSE;
743 if (!motion_status) /* Maustaste neu gedrückt */
745 if (ON_CONFIRM_BUTTON(mx,my))
749 DrawConfirmButton(BUTTON_PRESSED);
752 else /* Mausbewegung bei gedrückter Maustaste */
754 if (!ON_CONFIRM_BUTTON(mx,my) && choice>=0 && pressed)
757 DrawConfirmButton(BUTTON_RELEASED);
759 else if (ON_CONFIRM_BUTTON(mx,my) && !pressed)
762 DrawConfirmButton(BUTTON_PRESSED);
766 else /* Maustaste wieder losgelassen */
768 if (ON_CONFIRM_BUTTON(mx,my) && pressed)
770 DrawConfirmButton(BUTTON_RELEASED);
771 return_code = BUTTON_CONFIRM;
786 int CheckPlayerButtons(int mx, int my, int button)
789 static int choice = -1;
790 static BOOL pressed = FALSE;
791 int player_state[4] =
801 if (!motion_status) /* Maustaste neu gedrückt */
803 if (ON_PLAYER_BUTTON(mx,my))
805 choice = PLAYER_BUTTON(mx,my);
807 DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
810 else /* Mausbewegung bei gedrückter Maustaste */
812 if ((!ON_PLAYER_BUTTON(mx,my) || PLAYER_BUTTON(mx,my)!=choice) &&
813 choice>=0 && pressed)
816 DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
818 else if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && !pressed)
821 DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
825 else /* Maustaste wieder losgelassen */
827 if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && pressed)
829 DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
830 return_code = player_state[choice];
845 /* several buttons in the level editor */
847 int CheckEditButtons(int mx, int my, int button)
850 static int choice = -1;
851 static BOOL pressed = FALSE;
852 static int edit_button[6] =
864 if (!motion_status) /* Maustaste neu gedrückt */
866 if (ON_EDIT_BUTTON(mx,my))
868 choice = EDIT_BUTTON(mx,my);
870 DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
871 if (edit_button[choice]!=ED_BUTTON_CTRL &&
872 edit_button[choice]!=ED_BUTTON_FILL)
873 return_code = 1<<choice;
876 else /* Mausbewegung bei gedrückter Maustaste */
878 if ((!ON_EDIT_BUTTON(mx,my) || EDIT_BUTTON(mx,my)!=choice) &&
879 choice>=0 && pressed)
882 DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
884 else if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice)
887 DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
889 if (edit_button[choice]!=ED_BUTTON_CTRL &&
890 edit_button[choice]!=ED_BUTTON_FILL)
891 return_code = 1<<choice;
895 else /* Maustaste wieder losgelassen */
897 if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice && pressed)
899 DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
900 if (edit_button[choice]==ED_BUTTON_CTRL ||
901 edit_button[choice]==ED_BUTTON_FILL)
902 return_code = 1<<choice;
917 int CheckCtrlButtons(int mx, int my, int button)
920 static int choice = -1;
921 static BOOL pressed = FALSE;
922 static int ctrl_button[4] =
932 if (!motion_status) /* Maustaste neu gedrückt */
934 if (ON_CTRL_BUTTON(mx,my))
936 choice = CTRL_BUTTON(mx,my);
938 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
941 else /* Mausbewegung bei gedrückter Maustaste */
943 if ((!ON_CTRL_BUTTON(mx,my) || CTRL_BUTTON(mx,my)!=choice) &&
944 choice>=0 && pressed)
947 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
949 else if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && !pressed)
952 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
956 else /* Maustaste wieder losgelassen */
958 if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && pressed)
960 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
961 return_code = 1<<(choice+6);
976 int CheckElemButtons(int mx, int my, int button)
978 int return_code = -1;
979 static int choice = -1;
980 static BOOL pressed = FALSE;
984 if (!motion_status) /* Maustaste neu gedrückt */
986 if (ON_ELEM_BUTTON(mx,my))
988 choice = ELEM_BUTTON(mx,my);
990 DrawElemButton(choice,ED_BUTTON_PRESSED);
991 if (choice==ED_BUTTON_EUP ||
992 choice==ED_BUTTON_EDOWN)
993 return_code = choice;
996 else /* Mausbewegung bei gedrückter Maustaste */
998 if ((!ON_ELEM_BUTTON(mx,my) || ELEM_BUTTON(mx,my)!=choice) &&
999 choice>=0 && pressed)
1002 DrawElemButton(choice,ED_BUTTON_RELEASED);
1004 else if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice)
1007 DrawElemButton(choice,ED_BUTTON_PRESSED);
1009 if (choice==ED_BUTTON_EUP ||
1010 choice==ED_BUTTON_EDOWN)
1011 return_code = choice;
1015 else /* Maustaste wieder losgelassen */
1017 if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice && pressed)
1019 DrawElemButton(choice,ED_BUTTON_RELEASED);
1020 if (choice!=ED_BUTTON_EUP &&
1021 choice!=ED_BUTTON_EDOWN)
1022 return_code = choice;
1034 return(return_code);
1037 int CheckCountButtons(int mx, int my, int button)
1039 int return_code = -1;
1040 static int choice = -1;
1041 static BOOL pressed = FALSE;
1045 if (!motion_status) /* Maustaste neu gedrückt */
1047 if (ON_COUNT_BUTTON(mx,my))
1049 choice = COUNT_BUTTON(mx,my);
1051 DrawCountButton(choice,ED_BUTTON_PRESSED);
1052 return_code = choice;
1055 else /* Mausbewegung bei gedrückter Maustaste */
1057 if ((!ON_COUNT_BUTTON(mx,my) || COUNT_BUTTON(mx,my)!=choice) &&
1058 choice>=0 && pressed)
1061 DrawCountButton(choice,ED_BUTTON_RELEASED);
1063 else if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice)
1066 DrawCountButton(choice,ED_BUTTON_PRESSED);
1068 return_code = choice;
1072 else /* Maustaste wieder losgelassen */
1074 if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice && pressed)
1076 DrawCountButton(choice,ED_BUTTON_RELEASED);
1088 return(return_code);