-#if 0
-
- switch(CheckEditButtons(mx,my,button))
- {
- case ED_BUTTON_CTRL:
- CloseDoor(DOOR_CLOSE_2);
- DrawControlWindow();
- XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX4,DOOR_GFX_PAGEY1+80,
- VXSIZE,VYSIZE,
- DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
- OpenDoor(DOOR_OPEN_2);
- edit_mode = ED_MODE_INFO;
- break;
- case ED_BUTTON_FILL:
- Request("Caution ! Flood fill mode ! Choose area !",REQ_OPEN);
- use_floodfill = TRUE;
- return;
- break;
- case ED_BUTTON_LEFT:
- if (level_xpos>=0)
- {
- if (!DelayReached(&choice_delay, GADGET_FRAME_DELAY))
- break;
- if (lev_fieldx<ED_FIELDX-2)
- break;
-
- level_xpos -= (button==1 ? 1 : button==2 ? 5 : lev_fieldx);
- if (level_xpos<-1)
- level_xpos = -1;
- if (button==1)
- ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_RIGHT);
- else
- DrawMiniLevel(level_xpos,level_ypos);
- }
- break;
- case ED_BUTTON_RIGHT:
- if (level_xpos<=lev_fieldx-ED_FIELDX)
- {
- if (!DelayReached(&choice_delay, GADGET_FRAME_DELAY))
- break;
- if (lev_fieldx<ED_FIELDX-2)
- break;
-
- level_xpos += (button==1 ? 1 : button==2 ? 5 : lev_fieldx);
- if (level_xpos>lev_fieldx-ED_FIELDX+1)
- level_xpos = lev_fieldx-ED_FIELDX+1;
- if (button==1)
- ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_LEFT);
- else
- DrawMiniLevel(level_xpos,level_ypos);
- }
- break;
- case ED_BUTTON_UP:
- if (level_ypos>=0)
- {
- if (!DelayReached(&choice_delay, GADGET_FRAME_DELAY))
- break;
- if (lev_fieldy<ED_FIELDY-2)
- break;
-
- level_ypos -= (button==1 ? 1 : button==2 ? 5 : lev_fieldy);
- if (level_ypos<-1)
- level_ypos = -1;
- if (button==1)
- ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_DOWN);
- else
- DrawMiniLevel(level_xpos,level_ypos);
- }
- break;
- case ED_BUTTON_DOWN:
- if (level_ypos<=lev_fieldy-ED_FIELDY)
- {
- if (!DelayReached(&choice_delay, GADGET_FRAME_DELAY))
- break;
- if (lev_fieldy<ED_FIELDY-2)
- break;
-
- level_ypos += (button==1 ? 1 : button==2 ? 5 : lev_fieldy);
- if (level_ypos>lev_fieldy-ED_FIELDY+1)
- level_ypos = lev_fieldy-ED_FIELDY+1;
- if (button==1)
- ScrollMiniLevel(level_xpos,level_ypos,ED_SCROLL_UP);
- else
- DrawMiniLevel(level_xpos,level_ypos);
- }
- break;
- default:
- break;
- }
-
-#endif
-
-
-
-#if 0
-
- if (mx>=SX && mx<SX+SXSIZE && my>=SY && my<SY+SYSIZE)
- {
- int new_element;
-
- if (button && !motion_status)
- in_field_pressed = TRUE;
-
- if (!button || !in_field_pressed || button<1 || button>3 ||
- (y==0 && level_ypos<0) ||
- (y==ED_FIELDY-1 && level_ypos>lev_fieldy-ED_FIELDY) ||
- (x==0 && level_xpos<0) ||
- (x==ED_FIELDX-1 && level_xpos>lev_fieldx-ED_FIELDX) ||
- x>lev_fieldx || y>lev_fieldy)
- return;
-
- new_element = (button==1 ? new_element1 :
- button==2 ? new_element2 :
- button==3 ? new_element3 : 0);
-
- if (new_element != Feld[x+level_xpos][y+level_ypos])
- {
- if (new_element==EL_SPIELFIGUR) /* Jeder nur EINE Figur bitte... */
- {
- int x,y;
-
- for(x=0;x<lev_fieldx;x++) for(y=0;y<lev_fieldy;y++)
- {
- if (Feld[x][y]==EL_SPIELFIGUR || Feld[x][y]==EL_SPIELER1)
- {
- Feld[x][y] = EL_LEERRAUM;
- if (x-level_xpos>=0 && x-level_xpos<ED_FIELDX &&
- y-level_ypos>=0 && y-level_ypos<ED_FIELDY)
- DrawMiniElement(x-level_xpos,y-level_ypos,EL_LEERRAUM);
- }
- }
- }
-
- Feld[x+level_xpos][y+level_ypos] = new_element;
- DrawMiniElement(x,y,new_element);
- }
- }
- else if (!motion_status) /* Mauszeiger nicht im Level-Feld */
- in_field_pressed = FALSE;
-
-#endif
-
-
-
- }
- else if (edit_mode == ED_MODE_INFO)/********** KONTROLL-FENSTER **********/
- {
- int choice = CheckCountButtons(mx,my,button);
- int step = (button==1 ? 1 : button==2 ? 5 : button==3 ? 10 : 0);
-
- if (choice >= 0 && choice < 36 &&
- DelayReached(&choice_delay, GADGET_FRAME_DELAY))
- {
- if (!(choice % 2))
- step = -step;
-
- choice /= 2;
-
- if (choice<11)
- {
- level.score[choice] += step;
- if (level.score[choice]<0)
- level.score[choice] = 0;
- else if (level.score[choice]>255)
- level.score[choice] = 255;
- }
- else if (choice==11)
- {
- level.tempo_amoebe += step;
- if (level.tempo_amoebe<0)
- level.tempo_amoebe = 0;
- else if (level.tempo_amoebe>255)
- level.tempo_amoebe = 255;
- }
- else if (choice==12)
- {
- level.dauer_sieb += step;
- if (level.dauer_sieb<0)
- level.dauer_sieb = 0;
- else if (level.dauer_sieb>255)
- level.dauer_sieb = 255;
- }
- else if (choice==13)
- {
- level.dauer_ablenk += step;
- if (level.dauer_ablenk<0)
- level.dauer_ablenk = 0;
- else if (level.dauer_ablenk>255)
- level.dauer_ablenk = 255;
- }
- else if (choice==14)
- {
- level.edelsteine += step;
- if (level.edelsteine<0)
- level.edelsteine = 0;
- else if (level.edelsteine>999)
- level.edelsteine = 999;
- }
- else if (choice==15)
- {
- level.time += step;
- if (level.time<0)
- level.time = 0;
- else if (level.time>999)
- level.time = 999;
- }
- else if (choice==16)
- {
- lev_fieldx += step;
- if (lev_fieldx<MIN_LEV_FIELDX)
- lev_fieldx = MIN_LEV_FIELDX;
- else if (lev_fieldx>MAX_LEV_FIELDX)
- lev_fieldx = MAX_LEV_FIELDX;
- level.fieldx = lev_fieldx;
- }
- else if (choice==17)
- {
- lev_fieldy += step;
- if (lev_fieldy<MIN_LEV_FIELDY)
- lev_fieldy = MIN_LEV_FIELDY;
- else if (lev_fieldy>MAX_LEV_FIELDY)
- lev_fieldy = MAX_LEV_FIELDY;
- level.fieldy = lev_fieldy;
- }
-
- if (choice<11)
- DrawText(ED_COUNT_VALUE_XPOS,
- ED_COUNT_VALUE_YPOS+choice*ED_COUNT_GADGET_YSIZE,
- int2str(level.score[choice],3),FS_SMALL,FC_YELLOW);
- else if (choice==11)
- DrawText(ED_COUNT_VALUE_XPOS,
- ED_COUNT_VALUE_YPOS+11*ED_COUNT_GADGET_YSIZE,
- int2str(level.tempo_amoebe,3),FS_SMALL,FC_YELLOW);
- else if (choice==12)
- DrawText(ED_COUNT_VALUE_XPOS,
- ED_COUNT_VALUE_YPOS+12*ED_COUNT_GADGET_YSIZE,
- int2str(level.dauer_sieb,3),FS_SMALL,FC_YELLOW);
- else if (choice==13)
- DrawText(ED_COUNT_VALUE_XPOS,
- ED_COUNT_VALUE_YPOS+13*ED_COUNT_GADGET_YSIZE,
- int2str(level.dauer_ablenk,3),FS_SMALL,FC_YELLOW);
- else if (choice==14)
- DrawText(ED_COUNT_VALUE_XPOS,
- ED_COUNT_VALUE_YPOS+14*ED_COUNT_GADGET_YSIZE,
- int2str(level.edelsteine,3),FS_SMALL,FC_YELLOW);
- else if (choice==15)
- DrawText(ED_COUNT_VALUE_XPOS,
- ED_COUNT_VALUE_YPOS+15*ED_COUNT_GADGET_YSIZE,
- int2str(level.time,3),FS_SMALL,FC_YELLOW);
- else if (choice==16)
- DrawText(ED_SIZE_VALUE_XPOS,
- ED_SIZE_VALUE_YPOS+0*ED_SIZE_GADGET_YSIZE,
- int2str(level.fieldx,3),FS_SMALL,FC_YELLOW);
- else if (choice==17)
- DrawText(ED_SIZE_VALUE_XPOS,
- ED_SIZE_VALUE_YPOS+1*ED_SIZE_GADGET_YSIZE,
- int2str(level.fieldy,3),FS_SMALL,FC_YELLOW);
-
- redraw_mask &= ~REDRAW_FIELD;
- if (choice<16)
- XCopyArea(display,drawto,window,gc,
- ED_COUNT_VALUE_XPOS,
- ED_COUNT_VALUE_YPOS+choice*ED_COUNT_GADGET_YSIZE,
- 3*FONT2_XSIZE,FONT2_YSIZE,
- ED_COUNT_VALUE_XPOS,
- ED_COUNT_VALUE_YPOS+choice*ED_COUNT_GADGET_YSIZE);
- else
- XCopyArea(display,drawto,window,gc,
- ED_SIZE_VALUE_XPOS,
- ED_SIZE_VALUE_YPOS+(choice-16)*ED_SIZE_GADGET_YSIZE,
- 3*FONT2_XSIZE,FONT2_YSIZE,
- ED_SIZE_VALUE_XPOS,
- ED_SIZE_VALUE_YPOS+(choice-16)*ED_SIZE_GADGET_YSIZE);
- XFlush(display);
- }
-
-
-
-#if 0
-
- switch(CheckCtrlButtons(mx,my,button))
- {
- case ED_BUTTON_EDIT:
- CloseDoor(DOOR_CLOSE_2);
- AdjustLevelScrollPosition();
- DrawMiniLevel(level_xpos,level_ypos);
- XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
- DOOR_GFX_PAGEX6,DOOR_GFX_PAGEY2,
- VXSIZE,VYSIZE,
- DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2);
- OpenDoor(DOOR_OPEN_2);
- edit_mode = ED_MODE_DRAWING;
- break;
- case ED_BUTTON_CLEAR:
- if (Request("Are you sure to clear this level ?",REQ_ASK))
- {
- for(x=0;x<MAX_LEV_FIELDX;x++)
- for(y=0;y<MAX_LEV_FIELDY;y++)
- Feld[x][y] = EL_ERDREICH;
- DrawMiniLevel(level_xpos,level_ypos);
- }
- break;
- case ED_BUTTON_UNDO:
- if (leveldir[leveldir_nr].readonly ||
- Request("Exit without saving ?",REQ_ASK | REQ_STAY_OPEN))
- {
- CloseDoor(DOOR_CLOSE_ALL);
- game_status=MAINMENU;
- DrawMainMenu();
- }
- else
- {
- CloseDoor(DOOR_CLOSE_1);
- OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
- }
- break;
- case ED_BUTTON_EXIT:
- {
- int figur_vorhanden = FALSE;
-
- if (leveldir[leveldir_nr].readonly)
- {
- Request("This level is read only !",REQ_CONFIRM);
- break;
- }
-
- for(y=0;y<lev_fieldy;y++)
- for(x=0;x<lev_fieldx;x++)
- if (Feld[x][y] == EL_SPIELFIGUR ||
- Feld[x][y] == EL_SPIELER1 ||
- Feld[x][y] == EL_SP_MURPHY)
- figur_vorhanden = TRUE;
-
- if (!figur_vorhanden)
- Request("No Level without Gregor Mc Duffin please !",
- REQ_CONFIRM);
- else
- {
- if (Request("Save this level and kill the old ?",
- REQ_ASK | REQ_STAY_OPEN))
- {
- for(x=0;x<lev_fieldx;x++)
- for(y=0;y<lev_fieldy;y++)
- Ur[x][y]=Feld[x][y];
- SaveLevel(level_nr);
- }
- CloseDoor(DOOR_CLOSE_ALL);
- game_status=MAINMENU;
- DrawMainMenu();
- }
- }
- break;
- default:
- break;
- }
-
-#endif
-
-
-
- if (mx>=ED_COUNT_GADGET_XPOS &&
- mx<ED_COUNT_GADGET_XPOS+31*FONT2_XSIZE+10 &&
- my>=ED_COUNT_GADGET_YPOS+16*ED_COUNT_GADGET_YSIZE &&
- my<ED_COUNT_GADGET_YPOS+16*ED_COUNT_GADGET_YSIZE+ED_WIN_COUNT_YSIZE)
- {
- if (!name_typing)
- {
- name_typing = TRUE;
- DrawText(ED_COUNT_GADGET_XPOS+5,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- level.name,FS_SMALL,FC_GREEN);
- DrawText(ED_COUNT_GADGET_XPOS+5+strlen(level.name)*FONT2_XSIZE,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- "<",FS_SMALL,FC_RED);
- }
- }
- else
- {
- if (name_typing)
- {
- name_typing = FALSE;
- DrawText(ED_COUNT_GADGET_XPOS+5,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- level.name,FS_SMALL,FC_YELLOW);
- DrawText(ED_COUNT_GADGET_XPOS+5+strlen(level.name)*FONT2_XSIZE,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- " ",FS_SMALL,FC_RED);
- }
- }
-
- if (mx>=SX+29*MINI_TILEX && mx<SX+30*MINI_TILEX &&
- my>=SY+26*MINI_TILEY && my<SY+27*MINI_TILEY)
- {
- int new_element;
-
- if (!button || button<1 || button>3)
- return;
-
- new_element = (button==1 ? new_element1 :
- button==2 ? new_element2 :
- button==3 ? new_element3 : 0);
-
- if (new_element != level.amoebe_inhalt)
- {
- level.amoebe_inhalt = new_element;
- DrawMiniElement(29,26,new_element);
- }
- }
-
- if (mx>=SX+1*MINI_TILEX && mx<SX+(1+4*5)*MINI_TILEX &&
- my>=SY+2*MINI_TILEY && my<SY+(2+3)*MINI_TILEY)
- {
- int x = (mx-SX-1*MINI_TILEX)/MINI_TILEX;
- int y = (my-SY-2*MINI_TILEY)/MINI_TILEY;
- int i = x/5;
- int new_element;
-
- x = x-i*5;
- if (i>=0 && i<43 && x>=0 && x<3 && y>=0 && y<3)
- {
- if (button && !motion_status)
- in_field_pressed = TRUE;
-
- if (!button || !in_field_pressed || button<1 || button>3)
- return;
-
- new_element = (button==1 ? new_element1 :
- button==2 ? new_element2 :
- button==3 ? new_element3 : 0);
-
- if (new_element != level.mampfer_inhalt[i][x][y])
- {
- level.mampfer_inhalt[i][x][y] = new_element;
- DrawMiniElement(1+5*i+x,2+y,new_element);
- }
- }
- else if (!motion_status)/* Mauszeiger nicht im Cruncher-Feld */
- in_field_pressed = FALSE;
- }
- else if (!motion_status) /* Mauszeiger nicht im Cruncher-Feld */
- in_field_pressed = FALSE;
- }
- }
-
- last_button = button;
-
- BackToFront();
-}
-
-void LevelNameTyping(KeySym key)
-{
- unsigned char ascii = 0;
- int len = strlen(level.name);
-
- if (!name_typing)
- return;
-
- if (key>=XK_A && key<=XK_Z)
- ascii = 'A'+(char)(key-XK_A);
- else if (key>=XK_a && key<=XK_z)
- ascii = 'a'+(char)(key-XK_a);
- else if (key>=XK_0 && key<=XK_9)
- ascii = '0'+(char)(key-XK_0);
-#ifdef XK_LATIN1
- else if (key>=XK_space && key<=XK_at)
- ascii = ' '+(char)(key-XK_space);
- else if (key==XK_Adiaeresis)
- ascii = 'Ä';
- else if (key==XK_Odiaeresis)
- ascii = 'Ö';
- else if (key==XK_Udiaeresis)
- ascii = 'Ü';
- else if (key==XK_adiaeresis)
- ascii = 'ä';
- else if (key==XK_odiaeresis)
- ascii = 'ö';
- else if (key==XK_udiaeresis)
- ascii = 'ü';
- else if (key==XK_underscore)
- ascii = '_';
-#endif
-
- if (ascii && len<MAX_LEVNAMLEN-2)
- {
- level.name[len] = ascii;
- level.name[len+1] = 0;
- len++;
-
- DrawTextExt(drawto,gc,
- ED_COUNT_GADGET_XPOS+5,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- level.name,FS_SMALL,FC_GREEN);
- DrawTextExt(window,gc,
- ED_COUNT_GADGET_XPOS+5,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- level.name,FS_SMALL,FC_GREEN);
- DrawTextExt(drawto,gc,
- ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- "<",FS_SMALL,FC_RED);
- DrawTextExt(window,gc,
- ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- "<",FS_SMALL,FC_RED);
- }
- else if ((key==XK_Delete || key==XK_BackSpace) && len>0)
- {
- level.name[len-1] = 0;
- len--;
-
- DrawTextExt(drawto,gc,
- ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- "< ",FS_SMALL,FC_GREEN);
- DrawTextExt(window,gc,
- ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- "< ",FS_SMALL,FC_GREEN);
- }
- else if (key==XK_Return)
- {
- DrawTextExt(drawto,gc,
- ED_COUNT_GADGET_XPOS+5,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- level.name,FS_SMALL,FC_YELLOW);
- DrawTextExt(window,gc,
- ED_COUNT_GADGET_XPOS+5,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- level.name,FS_SMALL,FC_YELLOW);
- DrawTextExt(drawto,gc,
- ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- " ",FS_SMALL,FC_YELLOW);
- DrawTextExt(window,gc,
- ED_COUNT_GADGET_XPOS+5+len*FONT2_XSIZE,
- ED_COUNT_TEXT_YPOS+16*ED_COUNT_TEXT_YSIZE,
- " ",FS_SMALL,FC_YELLOW);
-
- name_typing = FALSE;
- }
-}
-
-static void DrawCounterValueField(int counter_id, int value)
-{
- int x = SX + counterbutton_info[counter_id].x + ED_WIN_COUNT_XPOS;
- int y = SY + counterbutton_info[counter_id].y;
-
- XCopyArea(display, pix[PIX_DOOR], drawto, gc,
- DOOR_GFX_PAGEX4 + ED_WIN_COUNT_XPOS,
- DOOR_GFX_PAGEY1 + ED_WIN_COUNT_YPOS,
- ED_WIN_COUNT_XSIZE, ED_WIN_COUNT_YSIZE,
- x, y);
-
- DrawText(x + ED_COUNT_VALUE_XOFFSET, y + ED_COUNT_VALUE_YOFFSET,
- int2str(value, 3), FS_SMALL, FC_YELLOW);
-}
-
-static void DrawDrawingWindow()
-{
- ClearWindow();
- UnmapLevelEditorWindowGadgets();
- MapMainDrawingArea();
- AdjustLevelScrollPosition();
- DrawMiniLevel(level_xpos, level_ypos);
-}
-
-static void DrawElementContentAreas()
-{
- int *num_areas = &MampferMax;
- int area_x = ED_AREA_ELEMCONT_XPOS / MINI_TILEX;
- int area_y = ED_AREA_ELEMCONT_YPOS / MINI_TILEY;
- int area_sx = SX + ED_AREA_ELEMCONT_XPOS;
- int area_sy = SY + ED_AREA_ELEMCONT_YPOS;
- int i, x, y;
-
- for (i=0; i<MAX_ELEMCONT; i++)
- for (y=0; y<3; y++)
- for (x=0; x<3; x++)
- ElementContent[i][x][y] = level.mampfer_inhalt[i][x][y];
-
- for (i=0; i<MAX_ELEMCONT; i++)
- UnmapDrawingArea(ED_CTRL_ID_ELEMCONT_0 + i);
-
- /* display counter to choose number of element content areas */
- gadget_areas_value = num_areas;
- DrawCounterValueField(ED_COUNTER_ELEMCONT, *gadget_areas_value);
- x = counterbutton_info[ED_COUNTER_ELEMCONT].x + DXSIZE;
- y = counterbutton_info[ED_COUNTER_ELEMCONT].y;
- DrawTextF(x + ED_COUNT_VALUE_XOFFSET, y + ED_COUNT_VALUE_YOFFSET,
- FC_YELLOW, "number of content areas");
- MapCounterButtons(ED_COUNTER_ELEMCONT);
-
- /* delete content areas in case of reducing number of them */
- XFillRectangle(display, backbuffer, gc,
- SX, area_sy - MINI_TILEX,
- SXSIZE, 12 * MINI_TILEY);
-
- /* draw some decorative border for the objects */
- for (i=0; i<*num_areas; i++)
- {
- for (y=0; y<4; y++)
- for (x=0; x<4; x++)
- DrawMiniElement(area_x + 5 * (i % 4) + x, area_y + 6 * (i / 4) + y,
- EL_ERDREICH);
-
- XFillRectangle(display, drawto, gc,
- area_sx + 5 * (i % 4) * MINI_TILEX + MINI_TILEX/2 - 1,
- area_sy + 6 * (i / 4) * MINI_TILEY + MINI_TILEY/2 - 1,
- 3 * MINI_TILEX + 2, 3 * MINI_TILEY + 2);
- }