- if (game_status == GAME_MODE_MAIN)
- DoAnimation();
-
- WaitUntilDelayReached(&door_delay, door_delay_value);
- }
- }
- }
-
- if (door_state & DOOR_ACTION_1)
- door1 = door_state & DOOR_ACTION_1;
- if (door_state & DOOR_ACTION_2)
- door2 = door_state & DOOR_ACTION_2;
-
- return (door1 | door2);
-}
-
-#endif
-
-void DrawSpecialEditorDoor()
-{
-#if 1
- struct GraphicInfo *gfx1 = &graphic_info[IMG_DOOR_2_TOP_BORDER_CORRECTION];
- int top_border_width = gfx1->width;
- int top_border_height = gfx1->height;
- int outer_border = viewport.door_2[GAME_MODE_EDITOR].border_size;
- int ex = EX - outer_border;
- int ey = EY - outer_border;
- int vy = VY - outer_border;
- int exsize = EXSIZE + 2 * outer_border;
-
- CloseDoor(DOOR_CLOSE_2);
-
- /* draw bigger level editor toolbox window */
- BlitBitmap(gfx1->bitmap, drawto, gfx1->src_x, gfx1->src_y,
- top_border_width, top_border_height, ex, ey - top_border_height);
- BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto, ex, vy,
- exsize, EYSIZE - VYSIZE + outer_border, ex, ey);
-#else
- /* draw bigger level editor toolbox window */
- BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
- DOOR_GFX_PAGEX7, 0, EXSIZE + 8, 8,
- EX - 4, EY - 12);
- BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto,
- EX - 6, VY - 4, EXSIZE + 12, EYSIZE - VYSIZE + 4,
- EX - 6, EY - 4);
-#endif
-
- redraw_mask |= REDRAW_ALL;
-}
-
-void UndrawSpecialEditorDoor()
-{
-#if 1
- struct GraphicInfo *gfx1 = &graphic_info[IMG_DOOR_2_TOP_BORDER_CORRECTION];
- int top_border_width = gfx1->width;
- int top_border_height = gfx1->height;
- int outer_border = viewport.door_2[GAME_MODE_EDITOR].border_size;
- int ex = EX - outer_border;
- int ey = EY - outer_border;
- int ey_top = ey - top_border_height;
- int exsize = EXSIZE + 2 * outer_border;
- int eysize = EYSIZE + 2 * outer_border;
-
- /* draw normal tape recorder window */
- if (graphic_info[IMG_GLOBAL_BORDER].bitmap)
- {
- BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto,
- ex, ey_top, top_border_width, top_border_height,
- ex, ey_top);
- BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto,
- ex, ey, exsize, eysize, ex, ey);
- }
- else
- {
- // if screen background is set to "[NONE]", clear editor toolbox window
- ClearRectangle(drawto, ex, ey_top, top_border_width, top_border_height);
- ClearRectangle(drawto, ex, ey, exsize, eysize);
- }
-#else
- /* draw normal tape recorder window */
- BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, drawto,
- EX - 6, EY - 12, EXSIZE + 12, EYSIZE - VYSIZE + 12,
- EX - 6, EY - 12);
-#endif
-
- redraw_mask |= REDRAW_ALL;
-}
-
-
-/* ---------- new tool button stuff ---------------------------------------- */
-
-#if 1
-
-static struct
-{
- int graphic;
- struct TextPosInfo *pos;
- int gadget_id;
- char *infotext;
-} toolbutton_info[NUM_TOOL_BUTTONS] =
-{
- {
- IMG_REQUEST_BUTTON_GFX_YES, &request.button.yes,
- TOOL_CTRL_ID_YES, "yes"
- },
- {
- IMG_REQUEST_BUTTON_GFX_NO, &request.button.no,
- TOOL_CTRL_ID_NO, "no"
- },
- {
- IMG_REQUEST_BUTTON_GFX_CONFIRM, &request.button.confirm,
- TOOL_CTRL_ID_CONFIRM, "confirm"
- },
- {
- IMG_REQUEST_BUTTON_GFX_PLAYER_1, &request.button.player_1,
- TOOL_CTRL_ID_PLAYER_1, "player 1"
- },
- {
- IMG_REQUEST_BUTTON_GFX_PLAYER_2, &request.button.player_2,
- TOOL_CTRL_ID_PLAYER_2, "player 2"
- },
- {
- IMG_REQUEST_BUTTON_GFX_PLAYER_3, &request.button.player_3,
- TOOL_CTRL_ID_PLAYER_3, "player 3"
- },
- {
- IMG_REQUEST_BUTTON_GFX_PLAYER_4, &request.button.player_4,
- TOOL_CTRL_ID_PLAYER_4, "player 4"
- }
-};
-
-void CreateToolButtons()
-{
- int i;
-
- for (i = 0; i < NUM_TOOL_BUTTONS; i++)
- {
- struct GraphicInfo *gfx = &graphic_info[toolbutton_info[i].graphic];
- struct TextPosInfo *pos = toolbutton_info[i].pos;
- struct GadgetInfo *gi;
- Bitmap *deco_bitmap = None;
- int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
- unsigned int event_mask = GD_EVENT_RELEASED;
- int dx = DX;
- int dy = DY;
- int gd_x = gfx->src_x;
- int gd_y = gfx->src_y;
- int gd_xp = gfx->src_x + gfx->pressed_xoffset;
- int gd_yp = gfx->src_y + gfx->pressed_yoffset;
- int id = i;
-
- if (global.use_envelope_request)
- setRequestPosition(&dx, &dy, TRUE);
-
- if (id >= TOOL_CTRL_ID_PLAYER_1 && id <= TOOL_CTRL_ID_PLAYER_4)
- {
- int player_nr = id - TOOL_CTRL_ID_PLAYER_1;
-
- getSizedGraphicSource(PLAYER_NR_GFX(IMG_PLAYER_1, player_nr), 0,
- pos->size, &deco_bitmap, &deco_x, &deco_y);
- deco_xpos = (gfx->width - pos->size) / 2;
- deco_ypos = (gfx->height - pos->size) / 2;
- }
-
- gi = CreateGadget(GDI_CUSTOM_ID, id,
- GDI_INFO_TEXT, toolbutton_info[i].infotext,
- GDI_X, dx + pos->x,
- GDI_Y, dy + pos->y,
- GDI_WIDTH, gfx->width,
- GDI_HEIGHT, gfx->height,
- GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
- GDI_STATE, GD_BUTTON_UNPRESSED,
- GDI_DESIGN_UNPRESSED, gfx->bitmap, gd_x, gd_y,
- GDI_DESIGN_PRESSED, gfx->bitmap, gd_xp, gd_yp,
- GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
- GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
- GDI_DECORATION_SIZE, pos->size, pos->size,
- GDI_DECORATION_SHIFTING, 1, 1,
- GDI_DIRECT_DRAW, FALSE,
- GDI_EVENT_MASK, event_mask,
- GDI_CALLBACK_ACTION, HandleToolButtons,
- GDI_END);
-
- if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
-
- tool_gadget[id] = gi;
- }
-}
-
-#else
-
-/* graphic position values for tool buttons */
-#define TOOL_BUTTON_YES_XPOS 2
-#define TOOL_BUTTON_YES_YPOS 250
-#define TOOL_BUTTON_YES_GFX_YPOS 0
-#define TOOL_BUTTON_YES_XSIZE 46
-#define TOOL_BUTTON_YES_YSIZE 28
-#define TOOL_BUTTON_NO_XPOS 52
-#define TOOL_BUTTON_NO_YPOS TOOL_BUTTON_YES_YPOS
-#define TOOL_BUTTON_NO_GFX_YPOS TOOL_BUTTON_YES_GFX_YPOS
-#define TOOL_BUTTON_NO_XSIZE TOOL_BUTTON_YES_XSIZE
-#define TOOL_BUTTON_NO_YSIZE TOOL_BUTTON_YES_YSIZE
-#define TOOL_BUTTON_CONFIRM_XPOS TOOL_BUTTON_YES_XPOS
-#define TOOL_BUTTON_CONFIRM_YPOS TOOL_BUTTON_YES_YPOS
-#define TOOL_BUTTON_CONFIRM_GFX_YPOS 30
-#define TOOL_BUTTON_CONFIRM_XSIZE 96
-#define TOOL_BUTTON_CONFIRM_YSIZE TOOL_BUTTON_YES_YSIZE
-#define TOOL_BUTTON_PLAYER_XSIZE 30
-#define TOOL_BUTTON_PLAYER_YSIZE 30
-#define TOOL_BUTTON_PLAYER_GFX_XPOS 5
-#define TOOL_BUTTON_PLAYER_GFX_YPOS 185
-#define TOOL_BUTTON_PLAYER_XPOS (5 + TOOL_BUTTON_PLAYER_XSIZE / 2)
-#define TOOL_BUTTON_PLAYER_YPOS (215 - TOOL_BUTTON_PLAYER_YSIZE / 2)
-#define TOOL_BUTTON_PLAYER1_XPOS (TOOL_BUTTON_PLAYER_XPOS \
- + 0 * TOOL_BUTTON_PLAYER_XSIZE)
-#define TOOL_BUTTON_PLAYER2_XPOS (TOOL_BUTTON_PLAYER_XPOS \
- + 1 * TOOL_BUTTON_PLAYER_XSIZE)
-#define TOOL_BUTTON_PLAYER3_XPOS (TOOL_BUTTON_PLAYER_XPOS \
- + 0 * TOOL_BUTTON_PLAYER_XSIZE)
-#define TOOL_BUTTON_PLAYER4_XPOS (TOOL_BUTTON_PLAYER_XPOS \
- + 1 * TOOL_BUTTON_PLAYER_XSIZE)
-#define TOOL_BUTTON_PLAYER1_YPOS (TOOL_BUTTON_PLAYER_YPOS \
- + 0 * TOOL_BUTTON_PLAYER_YSIZE)
-#define TOOL_BUTTON_PLAYER2_YPOS (TOOL_BUTTON_PLAYER_YPOS \
- + 0 * TOOL_BUTTON_PLAYER_YSIZE)
-#define TOOL_BUTTON_PLAYER3_YPOS (TOOL_BUTTON_PLAYER_YPOS \
- + 1 * TOOL_BUTTON_PLAYER_YSIZE)
-#define TOOL_BUTTON_PLAYER4_YPOS (TOOL_BUTTON_PLAYER_YPOS \
- + 1 * TOOL_BUTTON_PLAYER_YSIZE)
-
-static struct
-{
- int xpos, ypos;
- int x, y;
- int width, height;
- int gadget_id;
- char *infotext;
-} toolbutton_info[NUM_TOOL_BUTTONS] =
-{
- {
- TOOL_BUTTON_YES_XPOS, TOOL_BUTTON_YES_GFX_YPOS,
- TOOL_BUTTON_YES_XPOS, TOOL_BUTTON_YES_YPOS,
- TOOL_BUTTON_YES_XSIZE, TOOL_BUTTON_YES_YSIZE,
- TOOL_CTRL_ID_YES,
- "yes"
- },
- {
- TOOL_BUTTON_NO_XPOS, TOOL_BUTTON_NO_GFX_YPOS,
- TOOL_BUTTON_NO_XPOS, TOOL_BUTTON_NO_YPOS,
- TOOL_BUTTON_NO_XSIZE, TOOL_BUTTON_NO_YSIZE,
- TOOL_CTRL_ID_NO,
- "no"
- },
- {
- TOOL_BUTTON_CONFIRM_XPOS, TOOL_BUTTON_CONFIRM_GFX_YPOS,
- TOOL_BUTTON_CONFIRM_XPOS, TOOL_BUTTON_CONFIRM_YPOS,
- TOOL_BUTTON_CONFIRM_XSIZE, TOOL_BUTTON_CONFIRM_YSIZE,
- TOOL_CTRL_ID_CONFIRM,
- "confirm"
- },
- {
- TOOL_BUTTON_PLAYER_GFX_XPOS,TOOL_BUTTON_PLAYER_GFX_YPOS,
- TOOL_BUTTON_PLAYER1_XPOS, TOOL_BUTTON_PLAYER1_YPOS,
- TOOL_BUTTON_PLAYER_XSIZE, TOOL_BUTTON_PLAYER_YSIZE,
- TOOL_CTRL_ID_PLAYER_1,
- "player 1"
- },
- {
- TOOL_BUTTON_PLAYER_GFX_XPOS,TOOL_BUTTON_PLAYER_GFX_YPOS,
- TOOL_BUTTON_PLAYER2_XPOS, TOOL_BUTTON_PLAYER2_YPOS,
- TOOL_BUTTON_PLAYER_XSIZE, TOOL_BUTTON_PLAYER_YSIZE,
- TOOL_CTRL_ID_PLAYER_2,
- "player 2"
- },
- {
- TOOL_BUTTON_PLAYER_GFX_XPOS,TOOL_BUTTON_PLAYER_GFX_YPOS,
- TOOL_BUTTON_PLAYER3_XPOS, TOOL_BUTTON_PLAYER3_YPOS,
- TOOL_BUTTON_PLAYER_XSIZE, TOOL_BUTTON_PLAYER_YSIZE,
- TOOL_CTRL_ID_PLAYER_3,
- "player 3"
- },
- {
- TOOL_BUTTON_PLAYER_GFX_XPOS,TOOL_BUTTON_PLAYER_GFX_YPOS,
- TOOL_BUTTON_PLAYER4_XPOS, TOOL_BUTTON_PLAYER4_YPOS,
- TOOL_BUTTON_PLAYER_XSIZE, TOOL_BUTTON_PLAYER_YSIZE,
- TOOL_CTRL_ID_PLAYER_4,
- "player 4"
- }
-};
-
-void CreateToolButtons()
-{
- int i;
-
- for (i = 0; i < NUM_TOOL_BUTTONS; i++)
- {
- Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
- Bitmap *deco_bitmap = None;
- int deco_x = 0, deco_y = 0, deco_xpos = 0, deco_ypos = 0;
- struct GadgetInfo *gi;
- unsigned int event_mask;
- int gd_xoffset, gd_yoffset;
- int gd_x1, gd_x2, gd_y;
- int id = i;
-
- event_mask = GD_EVENT_RELEASED;
-
- gd_xoffset = toolbutton_info[i].xpos;
- gd_yoffset = toolbutton_info[i].ypos;
- gd_x1 = DOOR_GFX_PAGEX4 + gd_xoffset;
- gd_x2 = DOOR_GFX_PAGEX3 + gd_xoffset;
- gd_y = DOOR_GFX_PAGEY1 + gd_yoffset;
-
- if (id >= TOOL_CTRL_ID_PLAYER_1 && id <= TOOL_CTRL_ID_PLAYER_4)
- {
- int player_nr = id - TOOL_CTRL_ID_PLAYER_1;
-
- getMiniGraphicSource(PLAYER_NR_GFX(IMG_PLAYER_1, player_nr),
- &deco_bitmap, &deco_x, &deco_y);
- deco_xpos = (toolbutton_info[i].width - MINI_TILEX) / 2;
- deco_ypos = (toolbutton_info[i].height - MINI_TILEY) / 2;
- }
-
- gi = CreateGadget(GDI_CUSTOM_ID, id,
- GDI_INFO_TEXT, toolbutton_info[i].infotext,
- GDI_X, DX + toolbutton_info[i].x,
- GDI_Y, DY + toolbutton_info[i].y,
- GDI_WIDTH, toolbutton_info[i].width,
- GDI_HEIGHT, toolbutton_info[i].height,
- GDI_TYPE, GD_TYPE_NORMAL_BUTTON,
- GDI_STATE, GD_BUTTON_UNPRESSED,
- GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
- GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
- GDI_DECORATION_DESIGN, deco_bitmap, deco_x, deco_y,
- GDI_DECORATION_POSITION, deco_xpos, deco_ypos,
- GDI_DECORATION_SIZE, MINI_TILEX, MINI_TILEY,
- GDI_DECORATION_SHIFTING, 1, 1,
- GDI_DIRECT_DRAW, FALSE,
- GDI_EVENT_MASK, event_mask,
- GDI_CALLBACK_ACTION, HandleToolButtons,
- GDI_END);
-
- if (gi == NULL)
- Error(ERR_EXIT, "cannot create gadget");
-
- tool_gadget[id] = gi;
- }
-}
-
-#endif
-
-void FreeToolButtons()
-{
- int i;
-
- for (i = 0; i < NUM_TOOL_BUTTONS; i++)
- FreeGadget(tool_gadget[i]);
-}
-
-static void UnmapToolButtons()
-{
- int i;
-
- for (i = 0; i < NUM_TOOL_BUTTONS; i++)
- UnmapGadget(tool_gadget[i]);
-}