-void HandlePressedControlButtons()
-{
- static unsigned long button_delay = 0;
- int i = 0;
-
- /* buttons with action when held pressed */
- int gadget_id[] =
- {
- ED_CTRL_ID_WRAP_UP,
- ED_CTRL_ID_WRAP_LEFT,
- ED_CTRL_ID_WRAP_RIGHT,
- ED_CTRL_ID_WRAP_DOWN,
- -1
- };
-
- if (!DelayReached(&button_delay, CHOICE_DELAY_VALUE))
- return;
-
- while (gadget_id[i] != -1)
- {
- int id = gadget_id[i++];
- int state = control_button_gadget[id]->state;
- int button = control_button_gadget[id]->event.button;
- int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
-
- if (state != GD_BUTTON_PRESSED)
- continue;
-
- switch (id)
- {
- case ED_CTRL_ID_WRAP_LEFT:
- if (level_xpos >= 0)
- {
- if (lev_fieldx < 2*SCR_FIELDX - 2)
- break;
-
- level_xpos -= step;
- 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_CTRL_ID_WRAP_RIGHT:
- if (level_xpos <= lev_fieldx - 2*SCR_FIELDX)
- {
- if (lev_fieldx < 2*SCR_FIELDX - 2)
- break;
-
- level_xpos += step;
- if (level_xpos > lev_fieldx - 2*SCR_FIELDX + 1)
- level_xpos = lev_fieldx - 2*SCR_FIELDX + 1;
- if (button == 1)
- ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_LEFT);
- else
- DrawMiniLevel(level_xpos, level_ypos);
- }
- break;
-
- case ED_CTRL_ID_WRAP_UP:
- if (level_ypos >= 0)
- {
- if (lev_fieldy < 2*SCR_FIELDY - 2)
- break;
-
- level_ypos -= step;
- 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_CTRL_ID_WRAP_DOWN:
- if (level_ypos <= lev_fieldy - 2*SCR_FIELDY)
- {
- if (lev_fieldy < 2*SCR_FIELDY - 2)
- break;
-
- level_ypos += step;
- if (level_ypos > lev_fieldy - 2*SCR_FIELDY + 1)
- level_ypos = lev_fieldy - 2*SCR_FIELDY + 1;
- if (button == 1)
- ScrollMiniLevel(level_xpos, level_ypos, ED_SCROLL_UP);
- else
- DrawMiniLevel(level_xpos, level_ypos);
- }
- break;
-
- default:
- break;
- }
- }
-}
-
-void HandleLevelEditorControlButtons(struct GadgetInfo *gi)
-{
- int event_type = gi->event.type;
-
- /*
- int button = gi->event.button;
- */
-
- int id;
- int i, x, y;
-
- /* get the button id */
- for (i=0; i<ED_NUM_CTRL_BUTTONS; i++)
- if (gi->id == control_button_gadget[i]->id)
- id = i;
-
- switch (id)
- {
- case ED_CTRL_ID_SINGLE_ITEMS:
- case ED_CTRL_ID_CONNECTED_ITEMS:
- case ED_CTRL_ID_LINE:
- case ED_CTRL_ID_TEXT:
- case ED_CTRL_ID_RECTANGLE:
- case ED_CTRL_ID_FILLED_BOX:
- case ED_CTRL_ID_FLOOD_FILL:
- case ED_CTRL_ID_RANDOM_PLACEMENT:
- case ED_CTRL_ID_BRUSH:
- drawing_function = id;
- break;
-
- case ED_CTRL_ID_UNDO:
- if (undo_buffer_steps == 0)
- {
- Request("Undo buffer empty !", REQ_CONFIRM);
- break;
- }
-
- undo_buffer_position =
- (undo_buffer_position - 1 + NUM_UNDO_STEPS) % NUM_UNDO_STEPS;
- undo_buffer_steps--;
-
- for(x=0; x<lev_fieldx; x++)
- for(y=0; y<lev_fieldy; y++)
- Feld[x][y] = UndoBuffer[undo_buffer_position][x][y];
- DrawMiniLevel(level_xpos,level_ypos);
- break;
-
- case ED_CTRL_ID_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_CTRL_ID_SAVE:
- {
- int player_present = 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)
- player_present = TRUE;
-
- if (!player_present)
- Request("No Level without Gregor Mc Duffin please !", REQ_CONFIRM);
- else
- {
- if (Request("Save this level and kill the old ?", REQ_ASK))
- {
- for(x=0; x<lev_fieldx; x++)
- for(y=0; y<lev_fieldy; y++)
- Ur[x][y] = Feld[x][y];
- SaveLevel(level_nr);
- }
- }
- }
- break;
-
- case ED_CTRL_ID_EXIT:
- if (Request("Exit level editor ?", REQ_ASK | REQ_STAY_OPEN))
- {
- CloseDoor(DOOR_CLOSE_1);
-
- /*
- CloseDoor(DOOR_CLOSE_BOTH);
- */
-
- /* draw smaller door */
- XCopyArea(display, pix[PIX_DOOR], drawto, gc,
- DOOR_GFX_PAGEX7, 64,
- 108, 64,
- EX - 4, EY - 12);
- redraw_mask |= REDRAW_ALL;
-
- game_status = MAINMENU;
- DrawMainMenu();
- }
- else
- {
- CloseDoor(DOOR_CLOSE_1);
- XCopyArea(display, pix[PIX_DB_DOOR], pix[PIX_DB_DOOR], gc,
- DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1, DXSIZE,DYSIZE,
- DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
- OpenDoor(DOOR_OPEN_1);
- }
- break;
-
- default:
- if (event_type == GD_EVENT_PRESSED)
- printf("test_func2: GD_EVENT_PRESSED\n");
- else if (event_type == GD_EVENT_RELEASED)
- printf("test_func2: GD_EVENT_RELEASED\n");
- else
- printf("test_func2: ?\n");
- break;
- }
-}
-