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, int mode)
227 Drawable dest_drawto;
228 int dest_xoffset, dest_yoffset;
229 int xpos, cx = DOOR_GFX_PAGEX4;
233 dest_drawto = pix[PIX_DB_DOOR];
234 dest_xoffset = DOOR_GFX_PAGEX1;
239 dest_drawto = drawto;
244 xpos = (state & BUTTON_OK ? OK_BUTTON_XPOS : NO_BUTTON_XPOS);
246 if (state & BUTTON_PRESSED)
247 cx = DOOR_GFX_PAGEX3;
249 XCopyArea(display, pix[PIX_DOOR], dest_drawto, gc,
250 cx + xpos, OK_BUTTON_GFX_YPOS,
251 OK_BUTTON_XSIZE, OK_BUTTON_YSIZE,
252 dest_xoffset + xpos, dest_yoffset + OK_BUTTON_YPOS);
254 redraw_mask |= REDRAW_DOOR_1;
257 void DrawConfirmButton(unsigned long state, int mode)
259 Drawable dest_drawto;
260 int dest_xoffset, dest_yoffset;
261 int cx = DOOR_GFX_PAGEX4;
265 dest_drawto = pix[PIX_DB_DOOR];
266 dest_xoffset = DOOR_GFX_PAGEX1;
271 dest_drawto = drawto;
276 if (state & BUTTON_PRESSED)
277 cx = DOOR_GFX_PAGEX3;
279 XCopyArea(display, pix[PIX_DOOR], dest_drawto, gc,
280 cx + CONFIRM_BUTTON_XPOS, CONFIRM_BUTTON_GFX_YPOS,
281 CONFIRM_BUTTON_XSIZE, CONFIRM_BUTTON_YSIZE,
282 dest_xoffset + CONFIRM_BUTTON_XPOS,
283 dest_yoffset + CONFIRM_BUTTON_YPOS);
285 redraw_mask |= REDRAW_DOOR_1;
288 void DrawPlayerButton(unsigned long state, int mode)
290 Drawable dest_drawto;
291 int dest_xoffset, dest_yoffset;
293 int graphic_offset = (PLAYER_BUTTON_XSIZE - TILEX/2)/2;
295 int cx = DOOR_GFX_PAGEX4, cy = 0;
299 dest_drawto = pix[PIX_DB_DOOR];
300 dest_xoffset = DOOR_GFX_PAGEX1;
305 dest_drawto = drawto;
310 if (state & BUTTON_PLAYER_1)
311 graphic = GFX_SPIELER1;
312 else if (state & BUTTON_PLAYER_2)
313 graphic = GFX_SPIELER2;
314 else if (state & BUTTON_PLAYER_3)
315 graphic = GFX_SPIELER3;
316 else if (state & BUTTON_PLAYER_4)
317 graphic = GFX_SPIELER4;
319 xpos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_3 ?
320 PLAYER_BUTTON_1_XPOS : PLAYER_BUTTON_2_XPOS);
321 ypos = (state & BUTTON_PLAYER_1 || state & BUTTON_PLAYER_2 ?
322 PLAYER_BUTTON_1_YPOS : PLAYER_BUTTON_3_YPOS);
324 if (state & BUTTON_PRESSED)
326 cx = DOOR_GFX_PAGEX3;
330 XCopyArea(display, pix[PIX_DOOR], dest_drawto, gc,
331 cx + PLAYER_BUTTON_GFX_XPOS, cy + PLAYER_BUTTON_GFX_YPOS,
332 PLAYER_BUTTON_XSIZE, PLAYER_BUTTON_YSIZE,
333 dest_xoffset + xpos, dest_yoffset + ypos);
334 DrawMiniGraphicExt(dest_drawto,gc,
335 dest_xoffset + xpos + graphic_offset,
336 dest_yoffset + ypos + graphic_offset,
339 redraw_mask |= REDRAW_DOOR_1;
342 /* several buttons in the level editor */
344 void DrawEditButton(unsigned long state)
347 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
348 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY2;
349 static int edit_pos[6][4] =
351 {ED_BUTTON_CTRL_XPOS,ED_BUTTON_CTRL_YPOS,
352 ED_BUTTON_CTRL_XSIZE,ED_BUTTON_CTRL_YSIZE},
354 {ED_BUTTON_FILL_XPOS,ED_BUTTON_FILL_YPOS,
355 ED_BUTTON_FILL_XSIZE,ED_BUTTON_FILL_YSIZE},
357 {ED_BUTTON_LEFT_XPOS,ED_BUTTON_LEFT_YPOS,
358 ED_BUTTON_LEFT_XSIZE,ED_BUTTON_LEFT_YSIZE},
360 {ED_BUTTON_UP_XPOS,ED_BUTTON_UP_YPOS,
361 ED_BUTTON_UP_XSIZE,ED_BUTTON_UP_YSIZE},
363 {ED_BUTTON_DOWN_XPOS,ED_BUTTON_DOWN_YPOS,
364 ED_BUTTON_DOWN_XSIZE,ED_BUTTON_DOWN_YSIZE},
366 {ED_BUTTON_RIGHT_XPOS,ED_BUTTON_RIGHT_YPOS,
367 ED_BUTTON_RIGHT_XSIZE,ED_BUTTON_RIGHT_YSIZE}
370 if (state & ED_BUTTON_PRESSED)
371 cx = DOOR_GFX_PAGEX5;
376 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
377 cx + edit_pos[i][xpos],
378 cy + edit_pos[i][ypos],
381 VX + edit_pos[i][xpos],
382 VY + edit_pos[i][ypos]);
385 redraw_mask |= REDRAW_DOOR_2;
388 void DrawCtrlButton(unsigned long state)
391 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
392 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY1+80;
393 static int edit_pos[4][4] =
395 {ED_BUTTON_EDIT_XPOS,ED_BUTTON_EDIT_YPOS,
396 ED_BUTTON_EDIT_XSIZE,ED_BUTTON_EDIT_YSIZE},
398 {ED_BUTTON_CLEAR_XPOS,ED_BUTTON_CLEAR_YPOS,
399 ED_BUTTON_CLEAR_XSIZE,ED_BUTTON_CLEAR_YSIZE},
401 {ED_BUTTON_UNDO_XPOS,ED_BUTTON_UNDO_YPOS,
402 ED_BUTTON_UNDO_XSIZE,ED_BUTTON_UNDO_YSIZE},
404 {ED_BUTTON_EXIT_XPOS,ED_BUTTON_EXIT_YPOS,
405 ED_BUTTON_EXIT_XSIZE,ED_BUTTON_EXIT_YSIZE}
408 if (state & ED_BUTTON_PRESSED)
409 cx = DOOR_GFX_PAGEX3;
413 if (state & (1<<(i+6)))
414 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
415 cx + edit_pos[i][xpos],
416 cy + edit_pos[i][ypos],
419 VX + edit_pos[i][xpos],
420 VY + edit_pos[i][ypos]);
423 redraw_mask |= REDRAW_DOOR_2;
426 void DrawElemButton(int button_nr, int button_state)
428 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
429 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
430 int from_x, from_y, to_x,to_y, size_x, size_y;
431 static int edit_pos[3][4] =
433 {ED_BUTTON_EUP_XPOS,ED_BUTTON_EUP_YPOS,
434 ED_BUTTON_EUP_XSIZE,ED_BUTTON_EUP_YSIZE},
436 {ED_BUTTON_EDOWN_XPOS,ED_BUTTON_EDOWN_YPOS,
437 ED_BUTTON_EDOWN_XSIZE,ED_BUTTON_EDOWN_YSIZE},
439 {ED_BUTTON_ELEM_XPOS,ED_BUTTON_ELEM_YPOS,
440 ED_BUTTON_ELEM_XSIZE,ED_BUTTON_ELEM_YSIZE}
443 if (button_nr<ED_BUTTON_ELEM)
447 from_x = cx + edit_pos[pos][xpos];
448 from_y = cy + edit_pos[pos][ypos];
449 size_x = edit_pos[pos][xsize];
450 size_y = edit_pos[pos][ysize];
451 to_x = DX + edit_pos[pos][xpos];
452 to_y = DY + edit_pos[pos][ypos];
454 if (button_state & ED_BUTTON_PRESSED)
456 if (button_nr==ED_BUTTON_EUP)
457 from_y = cy + ED_BUTTON_EUP_Y2POS;
459 from_y = cy + ED_BUTTON_EDOWN_Y2POS;
462 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
463 from_x,from_y, size_x,size_y, to_x,to_y);
467 int pos = ED_BUTTON_ELEM;
468 int elem_pos = button_nr-ED_BUTTON_ELEM;
469 int x = elem_pos % MAX_ELEM_X;
470 int y = elem_pos / MAX_ELEM_X;
474 if (elem_pos+element_shift < elements_in_list)
475 graphic = el2gfx(editor_element[elem_pos+element_shift]);
477 graphic = GFX_LEERRAUM;
479 from_x = cx + edit_pos[pos][xpos];
480 from_y = cy + edit_pos[pos][ypos];
481 size_x = edit_pos[pos][xsize];
482 size_y = edit_pos[pos][ysize];
483 to_x = DX + edit_pos[pos][xpos] + x * ED_BUTTON_ELEM_XSIZE;
484 to_y = DY + edit_pos[pos][ypos] + y * ED_BUTTON_ELEM_YSIZE;
486 if (button_state & ED_BUTTON_PRESSED)
488 from_y = ED_BUTTON_ELEM_Y2POS;
492 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
493 from_x,from_y, size_x,size_y, to_x,to_y);
495 DrawMiniGraphicExt(drawto,gc,
496 DX+ED_BUTTON_ELEM_XPOS+3+shift +
497 (elem_pos % MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
498 DY+ED_BUTTON_ELEM_YPOS+3-shift +
499 (elem_pos / MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
503 redraw_mask |= REDRAW_DOOR_1;
506 void DrawCountButton(int button_nr, int button_state)
508 int from_x, from_y, to_x,to_y, size_x, size_y;
511 DOOR_GFX_PAGEX4+(button_nr%2 ? ED_BUTTON_PLUS_XPOS : ED_BUTTON_MINUS_XPOS);
512 from_y = DOOR_GFX_PAGEY1 + ED_BUTTON_MINUS_YPOS;
513 size_x = ED_BUTTON_MINUS_XSIZE;
514 size_y = ED_BUTTON_MINUS_YSIZE;
515 to_x = (button_nr<32 ? ED_COUNT_GADGET_XPOS : ED_SIZE_GADGET_XPOS);
517 to_x += (ED_BUTTON_PLUS_XPOS - ED_BUTTON_MINUS_XPOS);
518 to_y = (button_nr<32 ? ED_COUNT_GADGET_YPOS : ED_SIZE_GADGET_YPOS) +
519 ((button_nr<32 ? button_nr : button_nr-32)/2)*ED_COUNT_GADGET_YSIZE;
521 if (button_state & ED_BUTTON_PRESSED)
524 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
525 from_x,from_y, size_x,size_y, to_x,to_y);
526 XCopyArea(display,pix[PIX_DOOR],window,gc,
527 from_x,from_y, size_x,size_y, to_x,to_y);
530 /**********************************************************************/
531 /********** checking buttons (and redrawing them, if needed) **********/
532 /**********************************************************************/
534 int CheckVideoButtons(int mx, int my, int button)
537 static int choice = -1;
538 static boolean pressed = FALSE;
539 static int video_button[5] =
541 VIDEO_PRESS_EJECT_ON,
543 VIDEO_PRESS_PAUSE_ON,
550 if (!motion_status) /* Maustaste neu gedrückt */
552 if (ON_VIDEO_BUTTON(mx,my))
554 choice = VIDEO_BUTTON(mx);
556 DrawVideoDisplay(video_button[choice],0);
559 else /* Mausbewegung bei gedrückter Maustaste */
561 if ((!ON_VIDEO_BUTTON(mx,my) || VIDEO_BUTTON(mx)!=choice) &&
562 choice>=0 && pressed)
565 DrawVideoDisplay(video_button[choice]<<1,0);
567 else if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && !pressed)
570 DrawVideoDisplay(video_button[choice],0);
574 else /* Maustaste wieder losgelassen */
576 if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && pressed)
578 DrawVideoDisplay(video_button[choice]<<1,0);
579 return_code = choice+1;
594 int CheckSoundButtons(int mx, int my, int button)
597 static int choice = -1;
598 static boolean pressed = FALSE;
601 sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * setup.sound_music);
602 sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * setup.sound_loops);
603 sound_state[2] = BUTTON_SOUND_SIMPLE | (BUTTON_ON * setup.sound_simple);
607 if (!motion_status) /* Maustaste neu gedrückt */
609 if (ON_SOUND_BUTTON(mx,my))
611 choice = SOUND_BUTTON(mx);
613 DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
616 else /* Mausbewegung bei gedrückter Maustaste */
618 if ((!ON_SOUND_BUTTON(mx,my) || SOUND_BUTTON(mx)!=choice) &&
619 choice>=0 && pressed)
622 DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
624 else if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && !pressed)
627 DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED);
631 else /* Maustaste wieder losgelassen */
633 if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && pressed)
635 DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED);
636 return_code = 1<<choice;
651 int CheckGameButtons(int mx, int my, int button)
654 static int choice = -1;
655 static boolean pressed = FALSE;
665 if (!motion_status) /* Maustaste neu gedrückt */
667 if (ON_GAME_BUTTON(mx,my))
669 choice = GAME_BUTTON(mx);
671 DrawGameButton(game_state[choice] | BUTTON_PRESSED);
674 else /* Mausbewegung bei gedrückter Maustaste */
676 if ((!ON_GAME_BUTTON(mx,my) || GAME_BUTTON(mx)!=choice) &&
677 choice>=0 && pressed)
680 DrawGameButton(game_state[choice] | BUTTON_RELEASED);
682 else if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && !pressed)
685 DrawGameButton(game_state[choice] | BUTTON_PRESSED);
689 else /* Maustaste wieder losgelassen */
691 if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && pressed)
693 DrawGameButton(game_state[choice] | BUTTON_RELEASED);
694 return_code = 1<<choice;
709 int CheckYesNoButtons(int mx, int my, int button)
712 static int choice = -1;
713 static boolean pressed = FALSE;
714 static int yesno_button[5] =
722 if (!motion_status) /* Maustaste neu gedrückt */
724 if (ON_YESNO_BUTTON(mx,my))
726 choice = YESNO_BUTTON(mx);
728 DrawYesNoButton(yesno_button[choice] | BUTTON_PRESSED, DB_NORMAL);
731 else /* Mausbewegung bei gedrückter Maustaste */
733 if ((!ON_YESNO_BUTTON(mx,my) || YESNO_BUTTON(mx)!=choice) &&
734 choice>=0 && pressed)
737 DrawYesNoButton(yesno_button[choice] | BUTTON_RELEASED, DB_NORMAL);
739 else if (ON_YESNO_BUTTON(mx,my) && YESNO_BUTTON(mx)==choice && !pressed)
742 DrawYesNoButton(yesno_button[choice] | BUTTON_PRESSED, DB_NORMAL);
746 else /* Maustaste wieder losgelassen */
748 if (ON_YESNO_BUTTON(mx,my) && YESNO_BUTTON(mx)==choice && pressed)
750 DrawYesNoButton(yesno_button[choice] | BUTTON_RELEASED, DB_NORMAL);
751 return_code = choice+1;
766 int CheckConfirmButton(int mx, int my, int button)
769 static int choice = -1;
770 static boolean pressed = FALSE;
774 if (!motion_status) /* Maustaste neu gedrückt */
776 if (ON_CONFIRM_BUTTON(mx,my))
780 DrawConfirmButton(BUTTON_PRESSED, DB_NORMAL);
783 else /* Mausbewegung bei gedrückter Maustaste */
785 if (!ON_CONFIRM_BUTTON(mx,my) && choice>=0 && pressed)
788 DrawConfirmButton(BUTTON_RELEASED, DB_NORMAL);
790 else if (ON_CONFIRM_BUTTON(mx,my) && !pressed)
793 DrawConfirmButton(BUTTON_PRESSED, DB_NORMAL);
797 else /* Maustaste wieder losgelassen */
799 if (ON_CONFIRM_BUTTON(mx,my) && pressed)
801 DrawConfirmButton(BUTTON_RELEASED, DB_NORMAL);
802 return_code = BUTTON_CONFIRM;
817 int CheckPlayerButtons(int mx, int my, int button)
820 static int choice = -1;
821 static boolean pressed = FALSE;
822 int player_state[4] =
832 if (!motion_status) /* Maustaste neu gedrückt */
834 if (ON_PLAYER_BUTTON(mx,my))
836 choice = PLAYER_BUTTON(mx,my);
838 DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
841 else /* Mausbewegung bei gedrückter Maustaste */
843 if ((!ON_PLAYER_BUTTON(mx,my) || PLAYER_BUTTON(mx,my)!=choice) &&
844 choice>=0 && pressed)
847 DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
849 else if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && !pressed)
852 DrawPlayerButton(player_state[choice] | BUTTON_PRESSED, DB_NORMAL);
856 else /* Maustaste wieder losgelassen */
858 if (ON_PLAYER_BUTTON(mx,my) && PLAYER_BUTTON(mx,my)==choice && pressed)
860 DrawPlayerButton(player_state[choice] | BUTTON_RELEASED, DB_NORMAL);
861 return_code = player_state[choice];
876 /* several buttons in the level editor */
878 int CheckEditButtons(int mx, int my, int button)
881 static int choice = -1;
882 static boolean pressed = FALSE;
883 static int edit_button[6] =
895 if (!motion_status) /* Maustaste neu gedrückt */
897 if (ON_EDIT_BUTTON(mx,my))
899 choice = EDIT_BUTTON(mx,my);
901 DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
902 if (edit_button[choice]!=ED_BUTTON_CTRL &&
903 edit_button[choice]!=ED_BUTTON_FILL)
904 return_code = 1<<choice;
907 else /* Mausbewegung bei gedrückter Maustaste */
909 if ((!ON_EDIT_BUTTON(mx,my) || EDIT_BUTTON(mx,my)!=choice) &&
910 choice>=0 && pressed)
913 DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
915 else if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice)
918 DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
920 if (edit_button[choice]!=ED_BUTTON_CTRL &&
921 edit_button[choice]!=ED_BUTTON_FILL)
922 return_code = 1<<choice;
926 else /* Maustaste wieder losgelassen */
928 if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice && pressed)
930 DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
931 if (edit_button[choice]==ED_BUTTON_CTRL ||
932 edit_button[choice]==ED_BUTTON_FILL)
933 return_code = 1<<choice;
948 int CheckCtrlButtons(int mx, int my, int button)
951 static int choice = -1;
952 static boolean pressed = FALSE;
953 static int ctrl_button[4] =
963 if (!motion_status) /* Maustaste neu gedrückt */
965 if (ON_CTRL_BUTTON(mx,my))
967 choice = CTRL_BUTTON(mx,my);
969 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
972 else /* Mausbewegung bei gedrückter Maustaste */
974 if ((!ON_CTRL_BUTTON(mx,my) || CTRL_BUTTON(mx,my)!=choice) &&
975 choice>=0 && pressed)
978 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
980 else if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && !pressed)
983 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
987 else /* Maustaste wieder losgelassen */
989 if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && pressed)
991 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
992 return_code = 1<<(choice+6);
1004 return(return_code);
1007 int CheckElemButtons(int mx, int my, int button)
1009 int return_code = -1;
1010 static int choice = -1;
1011 static boolean pressed = FALSE;
1015 if (!motion_status) /* Maustaste neu gedrückt */
1017 if (ON_ELEM_BUTTON(mx,my))
1019 choice = ELEM_BUTTON(mx,my);
1021 DrawElemButton(choice,ED_BUTTON_PRESSED);
1022 if (choice==ED_BUTTON_EUP ||
1023 choice==ED_BUTTON_EDOWN)
1024 return_code = choice;
1027 else /* Mausbewegung bei gedrückter Maustaste */
1029 if ((!ON_ELEM_BUTTON(mx,my) || ELEM_BUTTON(mx,my)!=choice) &&
1030 choice>=0 && pressed)
1033 DrawElemButton(choice,ED_BUTTON_RELEASED);
1035 else if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice)
1038 DrawElemButton(choice,ED_BUTTON_PRESSED);
1040 if (choice==ED_BUTTON_EUP ||
1041 choice==ED_BUTTON_EDOWN)
1042 return_code = choice;
1046 else /* Maustaste wieder losgelassen */
1048 if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice && pressed)
1050 DrawElemButton(choice,ED_BUTTON_RELEASED);
1051 if (choice!=ED_BUTTON_EUP &&
1052 choice!=ED_BUTTON_EDOWN)
1053 return_code = choice;
1065 return(return_code);
1068 int CheckCountButtons(int mx, int my, int button)
1070 int return_code = -1;
1071 static int choice = -1;
1072 static boolean pressed = FALSE;
1076 if (!motion_status) /* Maustaste neu gedrückt */
1078 if (ON_COUNT_BUTTON(mx,my))
1080 choice = COUNT_BUTTON(mx,my);
1082 DrawCountButton(choice,ED_BUTTON_PRESSED);
1083 return_code = choice;
1086 else /* Mausbewegung bei gedrückter Maustaste */
1088 if ((!ON_COUNT_BUTTON(mx,my) || COUNT_BUTTON(mx,my)!=choice) &&
1089 choice>=0 && pressed)
1092 DrawCountButton(choice,ED_BUTTON_RELEASED);
1094 else if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice)
1097 DrawCountButton(choice,ED_BUTTON_PRESSED);
1099 return_code = choice;
1103 else /* Maustaste wieder losgelassen */
1105 if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice && pressed)
1107 DrawCountButton(choice,ED_BUTTON_RELEASED);
1119 return(return_code);