- struct GadgetScrollbar *gs = &gi->scrollbar;
- int items_max, items_visible, item_position = gs->item_position;
-
- if (id == ED_CTRL_ID_SCROLL_HORIZONTAL)
- {
- items_max = lev_fieldx + 2;
- items_visible = ED_FIELDX;
- }
- else
- {
- items_max = lev_fieldy + 2;
- items_visible = ED_FIELDY;
- }
-
- if (item_position > items_max - items_visible)
- item_position = items_max - items_visible;
-
- AdjustScrollbar(gi, items_max, item_position);
-}
-
-static void PickDrawingElement(int button, int element)
-{
- if (button < 1 || button > 3)
- return;
-
- if (button == 1)
- {
- new_element1 = element;
- DrawMiniGraphicExt(drawto, gc,
- DX + ED_WIN_MB_LEFT_XPOS,
- DY + ED_WIN_MB_LEFT_YPOS,
- el2gfx(new_element1));
- }
- else if (button == 2)
- {
- new_element2 = element;
- DrawMiniGraphicExt(drawto, gc,
- DX + ED_WIN_MB_MIDDLE_XPOS,
- DY + ED_WIN_MB_MIDDLE_YPOS,
- el2gfx(new_element2));
- }
- else
- {
- new_element3 = element;
- DrawMiniGraphicExt(drawto, gc,
- DX + ED_WIN_MB_RIGHT_XPOS,
- DY + ED_WIN_MB_RIGHT_YPOS,
- el2gfx(new_element3));
- }
-
- redraw_mask |= REDRAW_DOOR_1;
-}
-
-void LevelEd(int mx, int my, int button)
-{
- static int last_button = 0;
- static int in_field_pressed = FALSE;
- static boolean use_floodfill = FALSE;
-
-
- /*
- int x = (mx-SX)/MINI_TILEX;
- int y = (my-SY)/MINI_TILEY;
- */
-
- /*
- HandlePressedControlButtons();
- HandleDrawingFunctions(mx, my, button);
- */
-
- if (use_floodfill) /********** FLOOD FILL **********/
- {
-
-
-#if 0
-
- if (button)
- {
- if (mx>=SX && mx<SX+SXSIZE && my>=SY && my<SY+SYSIZE)
- {
- int from_x, from_y;
- int fill_element;
-
- if (x>lev_fieldx || y>lev_fieldy ||
- (x==0 && level_xpos<0) ||
- (x==ED_FIELDX-1 && level_xpos>lev_fieldx-ED_FIELDX) ||
- (y==0 && level_ypos<0) ||
- (y==ED_FIELDY-1 && level_ypos>lev_fieldy-ED_FIELDY))
- return;
-
- from_x = x+level_xpos;
- from_y = y+level_ypos;
- fill_element = (button==1 ? new_element1 :
- button==2 ? new_element2 :
- button==3 ? new_element3 : 0);
-
- FloodFill(from_x,from_y,fill_element);
- DrawMiniLevel(level_xpos,level_ypos);
- }
-
- use_floodfill = FALSE;
- CloseDoor(DOOR_CLOSE_1);
- OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
- }
- return;
-
-#endif
-
-
-
- }
- else /********** EDIT/CTRL-FENSTER **********/
- {
- static unsigned long choice_delay = 0;
- int choice = CheckElemButtons(mx,my,button);
- int elem_pos = choice-ED_BUTTON_ELEM;
-
- if (((choice == ED_BUTTON_EUP && element_shift>0) ||
- (choice == ED_BUTTON_EDOWN &&
- element_shift<elements_in_list-MAX_ELEM_X*MAX_ELEM_Y)) &&
- DelayReached(&choice_delay, GADGET_FRAME_DELAY))
- {
- int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
- int i;
-
-#if 0
- step = (button==1 ? MAX_ELEM_X : button==2 ? 5*MAX_ELEM_X :
- elements_in_list);
- element_shift += (choice==ED_BUTTON_EUP ? -step : step);
-#else
- step = step * MAX_ELEM_X * (choice == ED_BUTTON_EUP ? -1 : +1);
- element_shift += step;
-#endif
-
- if (element_shift<0)
- element_shift = 0;
- if (element_shift>elements_in_list-MAX_ELEM_X*MAX_ELEM_Y)
- element_shift = elements_in_list-MAX_ELEM_X*MAX_ELEM_Y;
- if (element_shift % MAX_ELEM_X)
- element_shift += MAX_ELEM_X-(element_shift % MAX_ELEM_X);
-
- for(i=0;i<MAX_ELEM_X*MAX_ELEM_Y;i++)
- DrawElemButton(i+2,ED_BUTTON_RELEASED);
- }
- else if (elem_pos>=0 && elem_pos<MAX_ELEM_X*MAX_ELEM_Y)
- {
- int new_element;
-
- if (elem_pos+element_shift < elements_in_list)
- new_element = editor_element[elem_pos+element_shift];
- else
- new_element = EL_LEERRAUM;
-
- PickDrawingElement(last_button, new_element);
-
- if (!HAS_CONTENT(properties_element))
- {
- properties_element = new_element;
- if (edit_mode == ED_MODE_PROPERTIES)
- DrawPropertiesWindow();
- }
- }
-
- if (edit_mode == ED_MODE_DRAWING) /********** EDIT-FENSTER **********/
- {
-
-
-
-#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;