1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * ©1995 Artsoft Development *
6 * 33659 Bielefeld-Senne *
7 * Telefon: (0521) 493245 *
8 * eMail: aeglos@valinor.owl.de *
9 * aeglos@uni-paderborn.de *
10 * q99492@pbhrzx.uni-paderborn.de *
11 *----------------------------------------------------------*
14 * Letzte Aenderung: 15.06.1995 *
15 ***********************************************************/
23 static int level_xpos,level_ypos;
24 static BOOL edit_mode;
25 static BOOL name_typing;
26 static int element_shift;
27 static int new_element1 = EL_MAUERWERK;
28 static int new_element2 = EL_LEERRAUM;
29 static int new_element3 = EL_ERDREICH;
30 static int editor_element[] =
192 static int elements_in_list = sizeof(editor_element)/sizeof(int);
204 CloseDoor(DOOR_CLOSE_2);
206 DrawMiniLevel(level_xpos,level_ypos);
209 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
210 DOOR_GFX_PAGEX6,DOOR_GFX_PAGEY1,
212 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY1);
213 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
214 DOOR_GFX_PAGEX6+ED_BUTTON_ELEM_XPOS,
215 DOOR_GFX_PAGEY1+ED_BUTTON_ELEM_YPOS,
216 4*ED_BUTTON_ELEM_XSIZE,5*ED_BUTTON_ELEM_YSIZE,
217 DOOR_GFX_PAGEX1+ED_BUTTON_ELEM_XPOS,
218 DOOR_GFX_PAGEY1+ED_BUTTON_EUP_Y2POS);
220 for(i=0;i<MAX_ELEM_X*MAX_ELEM_Y;i++)
222 if (i < elements_in_list)
223 graphic = el2gfx(editor_element[i]);
225 graphic = GFX_LEERRAUM;
227 DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
228 DOOR_GFX_PAGEX1+ED_BUTTON_ELEM_XPOS+3 +
229 (i%MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
230 DOOR_GFX_PAGEY1+ED_BUTTON_ELEM_YPOS+3 +
231 (i/MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
235 DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
236 DOOR_GFX_PAGEX1+ED_WIN_MB_LEFT_XPOS,
237 DOOR_GFX_PAGEY1+ED_WIN_MB_LEFT_YPOS,
238 el2gfx(new_element1));
239 DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
240 DOOR_GFX_PAGEX1+ED_WIN_MB_MIDDLE_XPOS,
241 DOOR_GFX_PAGEY1+ED_WIN_MB_MIDDLE_YPOS,
242 el2gfx(new_element2));
243 DrawMiniGraphicExtHiRes(pix[PIX_DB_DOOR],gc,
244 DOOR_GFX_PAGEX1+ED_WIN_MB_RIGHT_XPOS,
245 DOOR_GFX_PAGEY1+ED_WIN_MB_RIGHT_YPOS,
246 el2gfx(new_element3));
247 DrawTextExt(pix[PIX_DB_DOOR],gc,
248 DOOR_GFX_PAGEX2+ED_WIN_LEVELNR_XPOS,
249 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS,
250 int2str(level_nr,2),FS_SMALL,FC_SPECIAL1);
251 XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc,
252 DOOR_GFX_PAGEX2+ED_WIN_LEVELNR_XPOS+3,
253 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS,
255 DOOR_GFX_PAGEX1+ED_WIN_LEVELNR_XPOS,
256 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS);
257 XCopyArea(display,pix[PIX_DB_DOOR],pix[PIX_DB_DOOR],gc,
258 DOOR_GFX_PAGEX2+ED_WIN_LEVELNR_XPOS+14,
259 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS,
261 DOOR_GFX_PAGEX1+ED_WIN_LEVELNR_XPOS+9,
262 DOOR_GFX_PAGEY1+ED_WIN_LEVELNR_YPOS);
264 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
265 DOOR_GFX_PAGEX6,DOOR_GFX_PAGEY2,
267 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
269 OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2);
272 void DrawControlWindow()
278 DrawText(ED_COUNT_GADGET_XPOS+1,SY+6,
279 "Contents of a smashed cruncher:",FS_SMALL,FC_YELLOW);
280 for(i=0;i<4;i++) for(y=0;y<4;y++) for(x=0;x<4;x++)
282 DrawMiniElement(1+5*i+x,2+y,EL_ERDREICH);
283 XFillRectangle(display,drawto,gc,
284 SX+(2+5*i)*MINI_TILEX-MINI_TILEX/2-1,
285 SY+(3)*MINI_TILEY-MINI_TILEY/2-1,
286 3*MINI_TILEX+2,3*MINI_TILEY+2);
288 XCopyArea(display,drawto,drawto,gc,
289 SX+MINI_TILEX,SY+2*MINI_TILEY,
290 4*5*MINI_TILEX,5*MINI_TILEY,
291 SX+MINI_TILEX-MINI_TILEX/2,SY+2*MINI_TILEY-MINI_TILEY/2);
294 for(y=0;y<3;y++) for(x=0;x<3;x++)
295 DrawMiniElement(1+5*i+x,2+y,level.mampfer_inhalt[i][x][y]);
297 DrawText(SX+MINI_TILEX+(5*i+1)*MINI_TILEX+1,
298 SY+2*MINI_TILEY+(4)*MINI_TILEY-4,
299 int2str(i+1,1),FS_SMALL,FC_YELLOW);
302 for(i=0;i<11+3+2;i++)
304 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
305 DOOR_GFX_PAGEX4+ED_BUTTON_MINUS_XPOS,
306 DOOR_GFX_PAGEY1+ED_BUTTON_MINUS_YPOS,
307 DXSIZE-4,ED_BUTTON_MINUS_YSIZE,
308 ED_COUNT_GADGET_XPOS,
309 ED_COUNT_GADGET_YPOS+i*ED_COUNT_GADGET_YSIZE);
312 DrawText(ED_COUNT_VALUE_XPOS,
313 ED_COUNT_VALUE_YPOS+i*ED_COUNT_GADGET_YSIZE,
314 int2str(level.score[i],3),FS_SMALL,FC_YELLOW);
316 DrawText(ED_COUNT_VALUE_XPOS,
317 ED_COUNT_VALUE_YPOS+11*ED_COUNT_GADGET_YSIZE,
318 int2str(level.tempo_amoebe,3),FS_SMALL,FC_YELLOW);
320 DrawText(ED_COUNT_VALUE_XPOS,
321 ED_COUNT_VALUE_YPOS+12*ED_COUNT_GADGET_YSIZE,
322 int2str(level.dauer_sieb,3),FS_SMALL,FC_YELLOW);
324 DrawText(ED_COUNT_VALUE_XPOS,
325 ED_COUNT_VALUE_YPOS+13*ED_COUNT_GADGET_YSIZE,
326 int2str(level.dauer_ablenk,3),FS_SMALL,FC_YELLOW);
328 DrawText(ED_COUNT_VALUE_XPOS,
329 ED_COUNT_VALUE_YPOS+14*ED_COUNT_GADGET_YSIZE,
330 int2str(level.edelsteine,3),FS_SMALL,FC_YELLOW);
332 DrawText(ED_COUNT_VALUE_XPOS,
333 ED_COUNT_VALUE_YPOS+15*ED_COUNT_GADGET_YSIZE,
334 int2str(level.time,3),FS_SMALL,FC_YELLOW);
337 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+0*ED_COUNT_TEXT_YSIZE,
338 "Score for Emerald",FS_SMALL,FC_YELLOW);
339 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+1*ED_COUNT_TEXT_YSIZE,
340 "Score for Diamond",FS_SMALL,FC_YELLOW);
341 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+2*ED_COUNT_TEXT_YSIZE,
342 "Score for smashing a Bug",FS_SMALL,FC_YELLOW);
343 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+3*ED_COUNT_TEXT_YSIZE,
344 "Score for smashing a Spaceship",FS_SMALL,FC_YELLOW);
345 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+4*ED_COUNT_TEXT_YSIZE,
346 "Score for smashing a Cruncher",FS_SMALL,FC_YELLOW);
347 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+5*ED_COUNT_TEXT_YSIZE,
348 "Score for smashing an Alien",FS_SMALL,FC_YELLOW);
349 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+6*ED_COUNT_TEXT_YSIZE,
350 "Score for smashing a Pacman",FS_SMALL,FC_YELLOW);
351 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+7*ED_COUNT_TEXT_YSIZE,
352 "Score for cracking a nut",FS_SMALL,FC_YELLOW);
353 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+8*ED_COUNT_TEXT_YSIZE,
354 "Score for dynamite",FS_SMALL,FC_YELLOW);
355 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+9*ED_COUNT_TEXT_YSIZE,
356 "Score for key",FS_SMALL,FC_YELLOW);
357 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+10*ED_COUNT_TEXT_YSIZE,
358 "Score for each 10 seconds left",FS_SMALL,FC_YELLOW);
359 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+11*ED_COUNT_TEXT_YSIZE,
360 "Speed of the amoeba",FS_SMALL,FC_YELLOW);
361 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+12*ED_COUNT_TEXT_YSIZE,
362 "Time for magic wall",FS_SMALL,FC_YELLOW);
363 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+13*ED_COUNT_TEXT_YSIZE,
364 "Time for wheel",FS_SMALL,FC_YELLOW);
365 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+14*ED_COUNT_TEXT_YSIZE,
366 "Emeralds needed in this level",FS_SMALL,FC_YELLOW);
367 DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+15*ED_COUNT_TEXT_YSIZE,
368 "Time available for this level",FS_SMALL,FC_YELLOW);
370 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
371 DOOR_GFX_PAGEX4+ED_WIN_COUNT_XPOS,
372 DOOR_GFX_PAGEY1+ED_WIN_COUNT_YPOS,
373 ED_WIN_COUNT_XSIZE,ED_WIN_COUNT_YSIZE,
374 ED_COUNT_GADGET_XPOS,
375 ED_COUNT_GADGET_YPOS+16*ED_COUNT_GADGET_YSIZE);
377 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
378 DOOR_GFX_PAGEX4+ED_WIN_COUNT_XPOS+3+2*FONT2_XSIZE,
379 DOOR_GFX_PAGEY1+ED_WIN_COUNT_YPOS,
380 ED_WIN_COUNT_XSIZE-3-2*FONT2_XSIZE,ED_WIN_COUNT_YSIZE,
381 ED_COUNT_GADGET_XPOS+3+i*FONT2_XSIZE,
382 ED_COUNT_GADGET_YPOS+16*ED_COUNT_GADGET_YSIZE);
383 DrawText(ED_COUNT_GADGET_XPOS+5,
384 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
385 level.name,FS_SMALL,FC_YELLOW);
386 DrawText(ED_COUNT_GADGET_XPOS+(30+3)*FONT2_XSIZE-5,
387 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
388 "Title",FS_SMALL,FC_YELLOW);
390 DrawText(ED_SIZE_GADGET_XPOS,ED_SIZE_GADGET_YPOS-18,
391 "Playfield size:",FS_SMALL,FC_YELLOW);
392 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
393 DOOR_GFX_PAGEX4+ED_BUTTON_MINUS_XPOS,
394 DOOR_GFX_PAGEY1+ED_BUTTON_MINUS_YPOS,
395 DXSIZE-4,ED_BUTTON_MINUS_YSIZE,
397 ED_SIZE_GADGET_YPOS+0*ED_COUNT_GADGET_YSIZE);
398 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
399 DOOR_GFX_PAGEX4+ED_BUTTON_MINUS_XPOS,
400 DOOR_GFX_PAGEY1+ED_BUTTON_MINUS_YPOS,
401 DXSIZE-4,ED_BUTTON_MINUS_YSIZE,
403 ED_SIZE_GADGET_YPOS+1*ED_COUNT_GADGET_YSIZE);
404 DrawText(ED_SIZE_TEXT_XPOS,ED_SIZE_TEXT_YPOS+0*ED_SIZE_TEXT_YSIZE,
405 "Width",FS_SMALL,FC_YELLOW);
406 DrawText(ED_SIZE_TEXT_XPOS,ED_SIZE_TEXT_YPOS+1*ED_SIZE_TEXT_YSIZE,
407 "Height",FS_SMALL,FC_YELLOW);
408 DrawText(ED_SIZE_VALUE_XPOS,ED_SIZE_VALUE_YPOS+0*ED_SIZE_GADGET_YSIZE,
409 int2str(level.fieldx,3),FS_SMALL,FC_YELLOW);
410 DrawText(ED_SIZE_VALUE_XPOS,ED_SIZE_VALUE_YPOS+1*ED_SIZE_GADGET_YSIZE,
411 int2str(level.fieldy,3),FS_SMALL,FC_YELLOW);
414 void ScrollMiniLevel(int from_x, int from_y, int scroll)
417 int dx = (scroll==ED_SCROLL_LEFT ? -1 : scroll==ED_SCROLL_RIGHT ? 1 : 0);
418 int dy = (scroll==ED_SCROLL_UP ? -1 : scroll==ED_SCROLL_DOWN ? 1 : 0);
420 XCopyArea(display,drawto,drawto,gc,
421 SX+MINI_TILEX*(dx==-1),SY+MINI_TILEY*(dy==-1),
422 SXSIZE-MINI_TILEX*ABS(dx),SYSIZE-MINI_TILEY*ABS(dy),
423 SX+MINI_TILEX*(dx==+1),SY+MINI_TILEY*(dy==+1));
426 x = (dx==1 ? 0 : 2*SCR_FIELDX-1);
427 for(y=0;y<2*SCR_FIELDY;y++)
428 DrawMiniElementOrWall(x,y,from_x,from_y);
432 y = (dy==1 ? 0 : 2*SCR_FIELDY-1);
433 for(x=0;x<2*SCR_FIELDX;x++)
434 DrawMiniElementOrWall(x,y,from_x,from_y);
437 redraw_mask |= REDRAW_FIELD;
441 void AdjustLevelScrollPosition()
445 if (level_xpos>lev_fieldx-2*SCR_FIELDX+1)
446 level_xpos = lev_fieldx-2*SCR_FIELDX+1;
447 if (lev_fieldx<2*SCR_FIELDX-2)
452 if (level_ypos>lev_fieldy-2*SCR_FIELDY+1)
453 level_ypos = lev_fieldy-2*SCR_FIELDY+1;
454 if (lev_fieldy<2*SCR_FIELDY-2)
458 void FloodFill(int from_x, int from_y, int fill_element)
462 static int check[4][2] = { -1,0, 0,-1, 1,0, 0,1 };
463 static int safety = 0;
467 if (safety>lev_fieldx*lev_fieldy)
469 fprintf(stderr,"Something went wrong in 'FloodFill()'. Please debug.\n");
473 old_element = Feld[from_x][from_y];
474 Feld[from_x][from_y] = fill_element;
478 x = from_x+check[i][0];
479 y = from_y+check[i][1];
481 if (IN_LEV_FIELD(x,y) && Feld[x][y]==old_element)
482 FloodFill(x,y,fill_element);
488 void LevelEd(int mx, int my, int button)
490 static int last_button = 0;
491 static int in_field_pressed = FALSE;
492 static BOOL use_floodfill = FALSE;
493 int x = (mx-SX)/MINI_TILEX;
494 int y = (my-SY)/MINI_TILEY;
496 if (use_floodfill) /********** FLOOD FILL **********/
500 if (mx>=SX && mx<SX+SXSIZE && my>=SY && my<SY+SYSIZE)
505 if (x>lev_fieldx || y>lev_fieldy ||
506 (x==0 && level_xpos<0) ||
507 (x==2*SCR_FIELDX-1 && level_xpos>lev_fieldx-2*SCR_FIELDX) ||
508 (y==0 && level_ypos<0) ||
509 (y==2*SCR_FIELDY-1 && level_ypos>lev_fieldy-2*SCR_FIELDY))
512 from_x = x+level_xpos;
513 from_y = y+level_ypos;
514 fill_element = (button==1 ? new_element1 :
515 button==2 ? new_element2 :
516 button==3 ? new_element3 : 0);
518 FloodFill(from_x,from_y,fill_element);
519 DrawMiniLevel(level_xpos,level_ypos);
522 use_floodfill = FALSE;
523 CloseDoor(DOOR_CLOSE_1);
524 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
528 else /********** EDIT/CTRL-FENSTER **********/
530 int choice = CheckElemButtons(mx,my,button);
531 int elem_pos = choice-ED_BUTTON_ELEM;
536 case ED_BUTTON_EDOWN:
537 if ((choice==ED_BUTTON_EUP && element_shift>0) ||
538 (choice==ED_BUTTON_EDOWN &&
539 element_shift<elements_in_list-MAX_ELEM_X*MAX_ELEM_Y))
543 step = (button==1 ? MAX_ELEM_X : button==2 ? 5*MAX_ELEM_X :
545 element_shift += (choice==ED_BUTTON_EUP ? -step : step);
548 if (element_shift>elements_in_list-MAX_ELEM_X*MAX_ELEM_Y)
549 element_shift = elements_in_list-MAX_ELEM_X*MAX_ELEM_Y;
550 if (element_shift % MAX_ELEM_X)
551 element_shift += MAX_ELEM_X-(element_shift % MAX_ELEM_X);
553 for(i=0;i<MAX_ELEM_X*MAX_ELEM_Y;i++)
554 DrawElemButton(i+2,ED_BUTTON_RELEASED);
560 if (elem_pos>=0 && elem_pos<MAX_ELEM_X*MAX_ELEM_Y)
564 if (elem_pos+element_shift < elements_in_list)
565 new_element = editor_element[elem_pos+element_shift];
567 new_element = EL_LEERRAUM;
570 new_element1 = new_element;
571 else if (last_button==2)
572 new_element2 = new_element;
573 else if (last_button==3)
574 new_element3 = new_element;
576 DrawMiniGraphicExtHiRes(drawto,gc,
577 DX+ED_WIN_MB_LEFT_XPOS,
578 DY+ED_WIN_MB_LEFT_YPOS,
579 el2gfx(new_element1));
580 DrawMiniGraphicExtHiRes(drawto,gc,
581 DX+ED_WIN_MB_MIDDLE_XPOS,
582 DY+ED_WIN_MB_MIDDLE_YPOS,
583 el2gfx(new_element2));
584 DrawMiniGraphicExtHiRes(drawto,gc,
585 DX+ED_WIN_MB_RIGHT_XPOS,
586 DY+ED_WIN_MB_RIGHT_YPOS,
587 el2gfx(new_element3));
588 redraw_mask |= REDRAW_DOOR_1;
593 if (edit_mode) /********** EDIT-FENSTER **********/
595 switch(CheckEditButtons(mx,my,button))
598 CloseDoor(DOOR_CLOSE_2);
600 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
601 DOOR_GFX_PAGEX4,DOOR_GFX_PAGEY1+80,
603 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
604 OpenDoor(DOOR_OPEN_2);
608 AreYouSure("Caution ! Flood fill mode ! Choose area !",AYS_OPEN);
609 use_floodfill = TRUE;
615 if (lev_fieldx<2*SCR_FIELDX-2)
618 level_xpos -= (button==1 ? 1 : button==2 ? 5 : lev_fieldx);
622 ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_RIGHT);
624 DrawMiniLevel(level_xpos,level_ypos);
629 case ED_BUTTON_RIGHT:
630 if (level_xpos<=lev_fieldx-2*SCR_FIELDX)
632 if (lev_fieldx<2*SCR_FIELDX-2)
635 level_xpos += (button==1 ? 1 : button==2 ? 5 : lev_fieldx);
636 if (level_xpos>lev_fieldx-2*SCR_FIELDX+1)
637 level_xpos = lev_fieldx-2*SCR_FIELDX+1;
639 ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_LEFT);
641 DrawMiniLevel(level_xpos,level_ypos);
649 if (lev_fieldy<2*SCR_FIELDY-2)
652 level_ypos -= (button==1 ? 1 : button==2 ? 5 : lev_fieldy);
656 ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_DOWN);
658 DrawMiniLevel(level_xpos,level_ypos);
664 if (level_ypos<=lev_fieldy-2*SCR_FIELDY)
666 if (lev_fieldy<2*SCR_FIELDY-2)
669 level_ypos += (button==1 ? 1 : button==2 ? 5 : lev_fieldy);
670 if (level_ypos>lev_fieldy-2*SCR_FIELDY+1)
671 level_ypos = lev_fieldy-2*SCR_FIELDY+1;
673 ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_UP);
675 DrawMiniLevel(level_xpos,level_ypos);
684 if (mx>=SX && mx<SX+SXSIZE && my>=SY && my<SY+SYSIZE)
688 if (button && !motion_status)
689 in_field_pressed = TRUE;
691 if (!button || !in_field_pressed || button<1 || button>3 ||
692 (y==0 && level_ypos<0) ||
693 (y==2*SCR_FIELDY-1 && level_ypos>lev_fieldy-2*SCR_FIELDY) ||
694 (x==0 && level_xpos<0) ||
695 (x==2*SCR_FIELDX-1 && level_xpos>lev_fieldx-2*SCR_FIELDX) ||
696 x>lev_fieldx || y>lev_fieldy)
699 new_element = (button==1 ? new_element1 :
700 button==2 ? new_element2 :
701 button==3 ? new_element3 : 0);
703 if (new_element != Feld[x+level_xpos][y+level_ypos])
705 if (new_element==EL_SPIELFIGUR) /* Jeder nur EINE Figur bitte... */
709 for(x=0;x<lev_fieldx;x++) for(y=0;y<lev_fieldy;y++)
711 if (Feld[x][y]==EL_SPIELFIGUR || Feld[x][y]==EL_SPIELER1)
713 Feld[x][y] = EL_LEERRAUM;
714 if (x-level_xpos>=0 && x-level_xpos<2*SCR_FIELDX &&
715 y-level_ypos>=0 && y-level_ypos<2*SCR_FIELDY)
716 DrawMiniElement(x-level_xpos,y-level_ypos,EL_LEERRAUM);
721 Feld[x+level_xpos][y+level_ypos] = new_element;
722 DrawMiniElement(x,y,new_element);
725 else if (!motion_status) /* Mauszeiger nicht im Level-Feld */
726 in_field_pressed = FALSE;
728 else /********** KONTROLL-FENSTER **********/
730 static int choice_delay = 0;
731 int choice = CheckCountButtons(mx,my,button);
732 int step = (button==1 ? 1 : button==2 ? 5 : button==3 ? 10 : 0);
734 if (choice>=0 && choice<36 && DelayReached(&choice_delay,10))
743 level.score[choice] += step;
744 if (level.score[choice]<0)
745 level.score[choice] = 0;
746 else if (level.score[choice]>255)
747 level.score[choice] = 255;
751 level.tempo_amoebe += step;
752 if (level.tempo_amoebe<0)
753 level.tempo_amoebe = 0;
754 else if (level.tempo_amoebe>255)
755 level.tempo_amoebe = 255;
759 level.dauer_sieb += step;
760 if (level.dauer_sieb<0)
761 level.dauer_sieb = 0;
762 else if (level.dauer_sieb>255)
763 level.dauer_sieb = 255;
767 level.dauer_ablenk += step;
768 if (level.dauer_ablenk<0)
769 level.dauer_ablenk = 0;
770 else if (level.dauer_ablenk>255)
771 level.dauer_ablenk = 255;
775 level.edelsteine += step;
776 if (level.edelsteine<0)
777 level.edelsteine = 0;
778 else if (level.edelsteine>999)
779 level.edelsteine = 999;
786 else if (level.time>999)
792 if (lev_fieldx<MIN_LEV_FIELDX)
793 lev_fieldx = MIN_LEV_FIELDX;
794 else if (lev_fieldx>MAX_LEV_FIELDX)
795 lev_fieldx = MAX_LEV_FIELDX;
796 level.fieldx = lev_fieldx;
801 if (lev_fieldy<MIN_LEV_FIELDY)
802 lev_fieldy = MIN_LEV_FIELDY;
803 else if (lev_fieldy>MAX_LEV_FIELDY)
804 lev_fieldy = MAX_LEV_FIELDY;
805 level.fieldy = lev_fieldy;
809 DrawText(ED_COUNT_VALUE_XPOS,
810 ED_COUNT_VALUE_YPOS+choice*ED_COUNT_GADGET_YSIZE,
811 int2str(level.score[choice],3),FS_SMALL,FC_YELLOW);
813 DrawText(ED_COUNT_VALUE_XPOS,
814 ED_COUNT_VALUE_YPOS+11*ED_COUNT_GADGET_YSIZE,
815 int2str(level.tempo_amoebe,3),FS_SMALL,FC_YELLOW);
817 DrawText(ED_COUNT_VALUE_XPOS,
818 ED_COUNT_VALUE_YPOS+12*ED_COUNT_GADGET_YSIZE,
819 int2str(level.dauer_sieb,3),FS_SMALL,FC_YELLOW);
821 DrawText(ED_COUNT_VALUE_XPOS,
822 ED_COUNT_VALUE_YPOS+13*ED_COUNT_GADGET_YSIZE,
823 int2str(level.dauer_ablenk,3),FS_SMALL,FC_YELLOW);
825 DrawText(ED_COUNT_VALUE_XPOS,
826 ED_COUNT_VALUE_YPOS+14*ED_COUNT_GADGET_YSIZE,
827 int2str(level.edelsteine,3),FS_SMALL,FC_YELLOW);
829 DrawText(ED_COUNT_VALUE_XPOS,
830 ED_COUNT_VALUE_YPOS+15*ED_COUNT_GADGET_YSIZE,
831 int2str(level.time,3),FS_SMALL,FC_YELLOW);
833 DrawText(ED_SIZE_VALUE_XPOS,
834 ED_SIZE_VALUE_YPOS+0*ED_SIZE_GADGET_YSIZE,
835 int2str(level.fieldx,3),FS_SMALL,FC_YELLOW);
837 DrawText(ED_SIZE_VALUE_XPOS,
838 ED_SIZE_VALUE_YPOS+1*ED_SIZE_GADGET_YSIZE,
839 int2str(level.fieldy,3),FS_SMALL,FC_YELLOW);
841 redraw_mask &= ~REDRAW_FIELD;
843 XCopyArea(display,drawto,window,gc,
845 ED_COUNT_VALUE_YPOS+choice*ED_COUNT_GADGET_YSIZE,
846 3*FONT2_XSIZE,FONT2_YSIZE,
848 ED_COUNT_VALUE_YPOS+choice*ED_COUNT_GADGET_YSIZE);
850 XCopyArea(display,drawto,window,gc,
852 ED_SIZE_VALUE_YPOS+(choice-16)*ED_SIZE_GADGET_YSIZE,
853 3*FONT2_XSIZE,FONT2_YSIZE,
855 ED_SIZE_VALUE_YPOS+(choice-16)*ED_SIZE_GADGET_YSIZE);
859 switch(CheckCtrlButtons(mx,my,button))
862 CloseDoor(DOOR_CLOSE_2);
863 AdjustLevelScrollPosition();
864 DrawMiniLevel(level_xpos,level_ypos);
865 XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
866 DOOR_GFX_PAGEX6,DOOR_GFX_PAGEY2,
868 DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
869 OpenDoor(DOOR_OPEN_2);
872 case ED_BUTTON_CLEAR:
873 if (AreYouSure("Are you sure to clear this level ?",AYS_ASK))
875 for(x=0;x<MAX_LEV_FIELDX;x++)
876 for(y=0;y<MAX_LEV_FIELDY;y++)
877 Feld[x][y] = EL_ERDREICH;
878 DrawMiniLevel(level_xpos,level_ypos);
882 if (AreYouSure("Exit without saving ?",AYS_ASK | AYS_STAY_OPEN))
884 CloseDoor(DOOR_CLOSE_BOTH);
885 game_status=MAINMENU;
890 CloseDoor(DOOR_CLOSE_1);
891 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
896 int figur_vorhanden = FALSE;
897 for(y=0;y<lev_fieldy;y++)
898 for(x=0;x<lev_fieldx;x++)
899 if (Feld[x][y]==EL_SPIELFIGUR || Feld[x][y]==EL_SPIELER1)
900 figur_vorhanden = TRUE;
902 if (!figur_vorhanden)
903 AreYouSure("No Level without Gregor Mc Duffin please !",
907 if (AreYouSure("Save this level and kill the old ?",
908 AYS_ASK | AYS_STAY_OPEN))
910 for(x=0;x<lev_fieldx;x++)
911 for(y=0;y<lev_fieldy;y++)
915 CloseDoor(DOOR_CLOSE_BOTH);
916 game_status=MAINMENU;
925 if (mx>=ED_COUNT_GADGET_XPOS &&
926 mx<ED_COUNT_GADGET_XPOS+31*FONT2_XSIZE+10 &&
927 my>=ED_COUNT_GADGET_YPOS+16*ED_COUNT_GADGET_YSIZE &&
928 my<ED_COUNT_GADGET_YPOS+16*ED_COUNT_GADGET_YSIZE+ED_WIN_COUNT_YSIZE)
933 DrawText(ED_COUNT_GADGET_XPOS+5,
934 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
935 level.name,FS_SMALL,FC_GREEN);
936 DrawText(ED_COUNT_GADGET_XPOS+5+strlen(level.name)*FONT2_XSIZE,
937 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
938 "<",FS_SMALL,FC_RED);
946 DrawText(ED_COUNT_GADGET_XPOS+5,
947 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
948 level.name,FS_SMALL,FC_YELLOW);
949 DrawText(ED_COUNT_GADGET_XPOS+5+strlen(level.name)*FONT2_XSIZE,
950 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
951 " ",FS_SMALL,FC_RED);
955 if (mx>=SX+1*MINI_TILEX && mx<SX+(1+4*5)*MINI_TILEX &&
956 my>=SY+2*MINI_TILEY && my<SY+(2+3)*MINI_TILEY)
958 int x = (mx-SX-1*MINI_TILEX)/MINI_TILEX;
959 int y = (my-SY-2*MINI_TILEY)/MINI_TILEY;
964 if (i>=0 && i<43 && x>=0 && x<3 && y>=0 && y<3)
966 if (button && !motion_status)
967 in_field_pressed = TRUE;
969 if (!button || !in_field_pressed || button<1 || button>3)
972 new_element = (button==1 ? new_element1 :
973 button==2 ? new_element2 :
974 button==3 ? new_element3 : 0);
976 if (new_element != level.mampfer_inhalt[i][x][y])
978 level.mampfer_inhalt[i][x][y] = new_element;
979 DrawMiniElement(1+5*i+x,2+y,level.mampfer_inhalt[i][x][y]);
982 else if (!motion_status)/* Mauszeiger nicht im Cruncher-Feld */
983 in_field_pressed = FALSE;
985 else if (!motion_status) /* Mauszeiger nicht im Cruncher-Feld */
986 in_field_pressed = FALSE;
990 last_button = button;
995 void LevelNameTyping(KeySym key)
997 unsigned char ascii = 0;
998 int len = strlen(level.name);
1003 if (key>=XK_A && key<=XK_Z)
1004 ascii = 'A'+(char)(key-XK_A);
1005 else if (key>=XK_a && key<=XK_z)
1006 ascii = 'a'+(char)(key-XK_a);
1007 else if (key>=XK_0 && key<=XK_9)
1008 ascii = '0'+(char)(key-XK_0);
1010 else if (key>=XK_space && key<=XK_at)
1011 ascii = ' '+(char)(key-XK_space);
1012 else if (key==XK_Adiaeresis)
1014 else if (key==XK_Odiaeresis)
1016 else if (key==XK_Udiaeresis)
1018 else if (key==XK_adiaeresis)
1020 else if (key==XK_odiaeresis)
1022 else if (key==XK_udiaeresis)
1024 else if (key==XK_underscore)
1028 if (ascii && len<MAX_LEVNAMLEN-2)
1030 level.name[len] = ascii;
1031 level.name[len+1] = 0;
1034 DrawTextExt(drawto,gc,
1035 ED_COUNT_GADGET_XPOS+5,
1036 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1037 level.name,FS_SMALL,FC_GREEN);
1038 DrawTextExt(window,gc,
1039 ED_COUNT_GADGET_XPOS+5,
1040 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1041 level.name,FS_SMALL,FC_GREEN);
1042 DrawTextExt(drawto,gc,
1043 ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
1044 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1045 "<",FS_SMALL,FC_RED);
1046 DrawTextExt(window,gc,
1047 ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
1048 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1049 "<",FS_SMALL,FC_RED);
1051 else if (key==XK_Delete && len>0)
1053 level.name[len-1] = 0;
1056 DrawTextExt(drawto,gc,
1057 ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
1058 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1059 "< ",FS_SMALL,FC_GREEN);
1060 DrawTextExt(window,gc,
1061 ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
1062 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1063 "< ",FS_SMALL,FC_GREEN);
1065 else if (key==XK_Return)
1067 DrawTextExt(drawto,gc,
1068 ED_COUNT_GADGET_XPOS+5,
1069 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1070 level.name,FS_SMALL,FC_YELLOW);
1071 DrawTextExt(window,gc,
1072 ED_COUNT_GADGET_XPOS+5,
1073 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1074 level.name,FS_SMALL,FC_YELLOW);
1075 DrawTextExt(drawto,gc,
1076 ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
1077 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1078 " ",FS_SMALL,FC_YELLOW);
1079 DrawTextExt(window,gc,
1080 ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
1081 ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
1082 " ",FS_SMALL,FC_YELLOW);
1084 name_typing = FALSE;
1088 void DrawEditButton(unsigned int state)
1091 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
1092 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY2;
1093 static int edit_pos[6][4] =
1095 ED_BUTTON_CTRL_XPOS,ED_BUTTON_CTRL_YPOS,
1096 ED_BUTTON_CTRL_XSIZE,ED_BUTTON_CTRL_YSIZE,
1098 ED_BUTTON_FILL_XPOS,ED_BUTTON_FILL_YPOS,
1099 ED_BUTTON_FILL_XSIZE,ED_BUTTON_FILL_YSIZE,
1101 ED_BUTTON_LEFT_XPOS,ED_BUTTON_LEFT_YPOS,
1102 ED_BUTTON_LEFT_XSIZE,ED_BUTTON_LEFT_YSIZE,
1104 ED_BUTTON_UP_XPOS,ED_BUTTON_UP_YPOS,
1105 ED_BUTTON_UP_XSIZE,ED_BUTTON_UP_YSIZE,
1107 ED_BUTTON_DOWN_XPOS,ED_BUTTON_DOWN_YPOS,
1108 ED_BUTTON_DOWN_XSIZE,ED_BUTTON_DOWN_YSIZE,
1110 ED_BUTTON_RIGHT_XPOS,ED_BUTTON_RIGHT_YPOS,
1111 ED_BUTTON_RIGHT_XSIZE,ED_BUTTON_RIGHT_YSIZE
1114 if (state & ED_BUTTON_PRESSED)
1115 cx = DOOR_GFX_PAGEX5;
1120 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
1121 cx + edit_pos[i][xpos],
1122 cy + edit_pos[i][ypos],
1125 VX + edit_pos[i][xpos],
1126 VY + edit_pos[i][ypos]);
1129 redraw_mask |= REDRAW_DOOR_2;
1132 void DrawCtrlButton(unsigned int state)
1135 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
1136 int cx = DOOR_GFX_PAGEX4, cy = DOOR_GFX_PAGEY1+80;
1137 static int edit_pos[4][4] =
1139 ED_BUTTON_EDIT_XPOS,ED_BUTTON_EDIT_YPOS,
1140 ED_BUTTON_EDIT_XSIZE,ED_BUTTON_EDIT_YSIZE,
1142 ED_BUTTON_CLEAR_XPOS,ED_BUTTON_CLEAR_YPOS,
1143 ED_BUTTON_CLEAR_XSIZE,ED_BUTTON_CLEAR_YSIZE,
1145 ED_BUTTON_UNDO_XPOS,ED_BUTTON_UNDO_YPOS,
1146 ED_BUTTON_UNDO_XSIZE,ED_BUTTON_UNDO_YSIZE,
1148 ED_BUTTON_EXIT_XPOS,ED_BUTTON_EXIT_YPOS,
1149 ED_BUTTON_EXIT_XSIZE,ED_BUTTON_EXIT_YSIZE
1152 if (state & ED_BUTTON_PRESSED)
1153 cx = DOOR_GFX_PAGEX3;
1157 if (state & (1<<(i+6)))
1158 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
1159 cx + edit_pos[i][xpos],
1160 cy + edit_pos[i][ypos],
1163 VX + edit_pos[i][xpos],
1164 VY + edit_pos[i][ypos]);
1167 redraw_mask |= REDRAW_DOOR_2;
1170 void DrawElemButton(int button_nr, int button_state)
1172 int xpos = 0, ypos = 1, xsize = 2, ysize = 3;
1173 int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY1;
1174 int from_x, from_y, to_x,to_y, size_x, size_y;
1175 static int edit_pos[3][4] =
1177 ED_BUTTON_EUP_XPOS,ED_BUTTON_EUP_YPOS,
1178 ED_BUTTON_EUP_XSIZE,ED_BUTTON_EUP_YSIZE,
1180 ED_BUTTON_EDOWN_XPOS,ED_BUTTON_EDOWN_YPOS,
1181 ED_BUTTON_EDOWN_XSIZE,ED_BUTTON_EDOWN_YSIZE,
1183 ED_BUTTON_ELEM_XPOS,ED_BUTTON_ELEM_YPOS,
1184 ED_BUTTON_ELEM_XSIZE,ED_BUTTON_ELEM_YSIZE
1187 if (button_nr<ED_BUTTON_ELEM)
1189 int pos = button_nr;
1191 from_x = cx + edit_pos[pos][xpos];
1192 from_y = cy + edit_pos[pos][ypos];
1193 size_x = edit_pos[pos][xsize];
1194 size_y = edit_pos[pos][ysize];
1195 to_x = DX + edit_pos[pos][xpos];
1196 to_y = DY + edit_pos[pos][ypos];
1198 if (button_state & ED_BUTTON_PRESSED)
1200 if (button_nr==ED_BUTTON_EUP)
1201 from_y = cy + ED_BUTTON_EUP_Y2POS;
1203 from_y = cy + ED_BUTTON_EDOWN_Y2POS;
1206 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
1207 from_x,from_y, size_x,size_y, to_x,to_y);
1211 int pos = ED_BUTTON_ELEM;
1212 int elem_pos = button_nr-ED_BUTTON_ELEM;
1213 int x = elem_pos % MAX_ELEM_X;
1214 int y = elem_pos / MAX_ELEM_X;
1218 if (elem_pos+element_shift < elements_in_list)
1219 graphic = el2gfx(editor_element[elem_pos+element_shift]);
1221 graphic = GFX_LEERRAUM;
1223 from_x = cx + edit_pos[pos][xpos];
1224 from_y = cy + edit_pos[pos][ypos];
1225 size_x = edit_pos[pos][xsize];
1226 size_y = edit_pos[pos][ysize];
1227 to_x = DX + edit_pos[pos][xpos] + x * ED_BUTTON_ELEM_XSIZE;
1228 to_y = DY + edit_pos[pos][ypos] + y * ED_BUTTON_ELEM_YSIZE;
1230 if (button_state & ED_BUTTON_PRESSED)
1232 from_y = ED_BUTTON_ELEM_Y2POS;
1236 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
1237 from_x,from_y, size_x,size_y, to_x,to_y);
1239 DrawMiniGraphicExtHiRes(drawto,gc,
1240 DX+ED_BUTTON_ELEM_XPOS+3+shift +
1241 (elem_pos % MAX_ELEM_X)*ED_BUTTON_ELEM_XSIZE,
1242 DY+ED_BUTTON_ELEM_YPOS+3-shift +
1243 (elem_pos / MAX_ELEM_X)*ED_BUTTON_ELEM_YSIZE,
1247 redraw_mask |= REDRAW_DOOR_1;
1250 void DrawCountButton(int button_nr, int button_state)
1252 int from_x, from_y, to_x,to_y, size_x, size_y;
1255 DOOR_GFX_PAGEX4+(button_nr%2 ? ED_BUTTON_PLUS_XPOS : ED_BUTTON_MINUS_XPOS);
1256 from_y = DOOR_GFX_PAGEY1 + ED_BUTTON_MINUS_YPOS;
1257 size_x = ED_BUTTON_MINUS_XSIZE;
1258 size_y = ED_BUTTON_MINUS_YSIZE;
1259 to_x = (button_nr<32 ? ED_COUNT_GADGET_XPOS : ED_SIZE_GADGET_XPOS);
1261 to_x += (ED_BUTTON_PLUS_XPOS - ED_BUTTON_MINUS_XPOS);
1262 to_y = (button_nr<32 ? ED_COUNT_GADGET_YPOS : ED_SIZE_GADGET_YPOS) +
1263 ((button_nr<32 ? button_nr : button_nr-32)/2)*ED_COUNT_GADGET_YSIZE;
1265 if (button_state & ED_BUTTON_PRESSED)
1268 XCopyArea(display,pix[PIX_DOOR],drawto,gc,
1269 from_x,from_y, size_x,size_y, to_x,to_y);
1270 XCopyArea(display,pix[PIX_DOOR],window,gc,
1271 from_x,from_y, size_x,size_y, to_x,to_y);
1274 int CheckEditButtons(int mx, int my, int button)
1276 int return_code = 0;
1277 static int choice = -1;
1278 static BOOL pressed = FALSE;
1279 static int edit_button[6] =
1291 if (!motion_status) /* Maustaste neu gedrückt */
1293 if (ON_EDIT_BUTTON(mx,my))
1295 choice = EDIT_BUTTON(mx,my);
1297 DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
1298 if (edit_button[choice]!=ED_BUTTON_CTRL &&
1299 edit_button[choice]!=ED_BUTTON_FILL)
1300 return_code = 1<<choice;
1303 else /* Mausbewegung bei gedrückter Maustaste */
1305 if ((!ON_EDIT_BUTTON(mx,my) || EDIT_BUTTON(mx,my)!=choice) &&
1306 choice>=0 && pressed)
1309 DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
1311 else if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice)
1314 DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED);
1316 if (edit_button[choice]!=ED_BUTTON_CTRL &&
1317 edit_button[choice]!=ED_BUTTON_FILL)
1318 return_code = 1<<choice;
1322 else /* Maustaste wieder losgelassen */
1324 if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice && pressed)
1326 DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED);
1327 if (edit_button[choice]==ED_BUTTON_CTRL ||
1328 edit_button[choice]==ED_BUTTON_FILL)
1329 return_code = 1<<choice;
1341 return(return_code);
1344 int CheckCtrlButtons(int mx, int my, int button)
1346 int return_code = 0;
1347 static int choice = -1;
1348 static BOOL pressed = FALSE;
1349 static int ctrl_button[4] =
1359 if (!motion_status) /* Maustaste neu gedrückt */
1361 if (ON_CTRL_BUTTON(mx,my))
1363 choice = CTRL_BUTTON(mx,my);
1365 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
1368 else /* Mausbewegung bei gedrückter Maustaste */
1370 if ((!ON_CTRL_BUTTON(mx,my) || CTRL_BUTTON(mx,my)!=choice) &&
1371 choice>=0 && pressed)
1374 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
1376 else if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && !pressed)
1379 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED);
1383 else /* Maustaste wieder losgelassen */
1385 if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && pressed)
1387 DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED);
1388 return_code = 1<<(choice+6);
1400 return(return_code);
1403 int CheckElemButtons(int mx, int my, int button)
1405 int return_code = -1;
1406 static int choice = -1;
1407 static BOOL pressed = FALSE;
1411 if (!motion_status) /* Maustaste neu gedrückt */
1413 if (ON_ELEM_BUTTON(mx,my))
1415 choice = ELEM_BUTTON(mx,my);
1417 DrawElemButton(choice,ED_BUTTON_PRESSED);
1418 if (choice==ED_BUTTON_EUP ||
1419 choice==ED_BUTTON_EDOWN)
1420 return_code = choice;
1423 else /* Mausbewegung bei gedrückter Maustaste */
1425 if ((!ON_ELEM_BUTTON(mx,my) || ELEM_BUTTON(mx,my)!=choice) &&
1426 choice>=0 && pressed)
1429 DrawElemButton(choice,ED_BUTTON_RELEASED);
1431 else if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice)
1434 DrawElemButton(choice,ED_BUTTON_PRESSED);
1436 if (choice==ED_BUTTON_EUP ||
1437 choice==ED_BUTTON_EDOWN)
1438 return_code = choice;
1442 else /* Maustaste wieder losgelassen */
1444 if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice && pressed)
1446 DrawElemButton(choice,ED_BUTTON_RELEASED);
1447 if (choice!=ED_BUTTON_EUP &&
1448 choice!=ED_BUTTON_EDOWN)
1449 return_code = choice;
1461 return(return_code);
1464 int CheckCountButtons(int mx, int my, int button)
1466 int return_code = -1;
1467 static int choice = -1;
1468 static BOOL pressed = FALSE;
1472 if (!motion_status) /* Maustaste neu gedrückt */
1474 if (ON_COUNT_BUTTON(mx,my))
1476 choice = COUNT_BUTTON(mx,my);
1478 DrawCountButton(choice,ED_BUTTON_PRESSED);
1479 return_code = choice;
1482 else /* Mausbewegung bei gedrückter Maustaste */
1484 if ((!ON_COUNT_BUTTON(mx,my) || COUNT_BUTTON(mx,my)!=choice) &&
1485 choice>=0 && pressed)
1488 DrawCountButton(choice,ED_BUTTON_RELEASED);
1490 else if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice)
1493 DrawCountButton(choice,ED_BUTTON_PRESSED);
1495 return_code = choice;
1499 else /* Maustaste wieder losgelassen */
1501 if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice && pressed)
1503 DrawCountButton(choice,ED_BUTTON_RELEASED);
1515 return(return_code);