X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftools.c;h=1095dd52e18f3f1d9aacc563c53f9fcb0b7885ad;hp=2505f402bc83c843e2b265c2ea5eaeb35064db04;hb=65bfe5289ae5bcb4c1ea9bee97ebc619e1ecfc16;hpb=8a17d8c0525010b08531f8b9ee33173ce944b252 diff --git a/src/tools.c b/src/tools.c index 2505f402..1095dd52 100644 --- a/src/tools.c +++ b/src/tools.c @@ -35,8 +35,11 @@ #define TOOL_CTRL_ID_PLAYER_2 4 #define TOOL_CTRL_ID_PLAYER_3 5 #define TOOL_CTRL_ID_PLAYER_4 6 +#define TOOL_CTRL_ID_TOUCH_YES 7 +#define TOOL_CTRL_ID_TOUCH_NO 8 +#define TOOL_CTRL_ID_TOUCH_CONFIRM 9 -#define NUM_TOOL_BUTTONS 7 +#define NUM_TOOL_BUTTONS 10 // constants for number of doors and door parts #define NUM_DOORS 2 @@ -208,18 +211,19 @@ int correctLevelPosY_EM(int ly) return ly; } -static int getFieldbufferOffsetX_RND(void) +int getFieldbufferOffsetX_RND(int dir, int pos) { int full_lev_fieldx = lev_fieldx + (BorderElement != EL_EMPTY ? 2 : 0); - int dx = (ScreenMovDir & (MV_LEFT | MV_RIGHT) ? ScreenGfxPos : 0); + int dx = (dir & MV_HORIZONTAL ? pos : 0); int dx_var = dx * TILESIZE_VAR / TILESIZE; int fx = FX; if (EVEN(SCR_FIELDX)) { - int ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; + int sbx_right = SBX_Right + (BorderElement != EL_EMPTY ? 1 : 0); + int ffx = (scroll_x - SBX_Left) * TILEX_VAR + dx_var; - if (ffx < SBX_Right * TILEX_VAR + TILEX_VAR / 2 + TILEX_VAR) + if (ffx < sbx_right * TILEX_VAR + TILEX_VAR / 2) fx += dx_var - MIN(ffx, TILEX_VAR / 2) + TILEX_VAR; else fx += (dx_var > 0 ? TILEX_VAR : 0); @@ -240,18 +244,19 @@ static int getFieldbufferOffsetX_RND(void) return fx; } -static int getFieldbufferOffsetY_RND(void) +int getFieldbufferOffsetY_RND(int dir, int pos) { int full_lev_fieldy = lev_fieldy + (BorderElement != EL_EMPTY ? 2 : 0); - int dy = (ScreenMovDir & (MV_UP | MV_DOWN) ? ScreenGfxPos : 0); + int dy = (dir & MV_VERTICAL ? pos : 0); int dy_var = dy * TILESIZE_VAR / TILESIZE; int fy = FY; if (EVEN(SCR_FIELDY)) { + int sby_lower = SBY_Lower + (BorderElement != EL_EMPTY ? 1 : 0); int ffy = (scroll_y - SBY_Upper) * TILEY_VAR + dy_var; - if (ffy < SBY_Lower * TILEY_VAR + TILEY_VAR / 2 + TILEY_VAR) + if (ffy < sby_lower * TILEY_VAR + TILEY_VAR / 2) fy += dy_var - MIN(ffy, TILEY_VAR / 2) + TILEY_VAR; else fy += (dy_var > 0 ? TILEY_VAR : 0); @@ -274,7 +279,7 @@ static int getFieldbufferOffsetY_RND(void) static int getLevelFromScreenX_RND(int sx) { - int fx = getFieldbufferOffsetX_RND(); + int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos); int dx = fx - FX; int px = sx - SX; int lx = LEVELX((px + dx) / TILESIZE_VAR); @@ -284,7 +289,7 @@ static int getLevelFromScreenX_RND(int sx) static int getLevelFromScreenY_RND(int sy) { - int fy = getFieldbufferOffsetY_RND(); + int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos); int dy = fy - FY; int py = sy - SY; int ly = LEVELY((py + dy) / TILESIZE_VAR); @@ -689,12 +694,17 @@ void DrawTileCursor(int draw_target) dst_x, dst_y); } +void BlitScreenToBitmapExt_RND(Bitmap *target_bitmap, int fx, int fy) +{ + BlitBitmap(drawto_field, target_bitmap, fx, fy, SXSIZE, SYSIZE, SX, SY); +} + void BlitScreenToBitmap_RND(Bitmap *target_bitmap) { - int fx = getFieldbufferOffsetX_RND(); - int fy = getFieldbufferOffsetY_RND(); + int fx = getFieldbufferOffsetX_RND(ScreenMovDir, ScreenGfxPos); + int fy = getFieldbufferOffsetY_RND(ScreenMovDir, ScreenGfxPos); - BlitBitmap(drawto_field, target_bitmap, fx, fy, SXSIZE, SYSIZE, SX, SY); + BlitScreenToBitmapExt_RND(target_bitmap, fx, fy); } void BlitScreenToBitmap(Bitmap *target_bitmap) @@ -1057,7 +1067,8 @@ void FadeIn(int fade_mask) void FadeOut(int fade_mask) { // update screen if areas covered by "fade_mask" and "redraw_mask" differ - if (!equalRedrawMasks(fade_mask, redraw_mask)) + if (!equalRedrawMasks(fade_mask, redraw_mask) && + fade_type_skip != FADE_MODE_SKIP_FADE_OUT) BackToFront(); SetScreenStates_BeforeFadingOut(); @@ -2838,7 +2849,7 @@ void ShowEnvelope(int envelope_nr) AnimateEnvelope(envelope_nr, main_anim_mode, ACTION_OPENING); if (tape.playing) - Delay(wait_delay_value); + Delay_WithScreenUpdates(wait_delay_value); else WaitForEventToContinue(); @@ -3125,10 +3136,13 @@ static void ShowEnvelopeRequest(char *text, unsigned int req_state, int action) { MapGadget(tool_gadget[TOOL_CTRL_ID_YES]); MapGadget(tool_gadget[TOOL_CTRL_ID_NO]); + MapGadget(tool_gadget[TOOL_CTRL_ID_TOUCH_YES]); + MapGadget(tool_gadget[TOOL_CTRL_ID_TOUCH_NO]); } else if (req_state & REQ_CONFIRM) { MapGadget(tool_gadget[TOOL_CTRL_ID_CONFIRM]); + MapGadget(tool_gadget[TOOL_CTRL_ID_TOUCH_CONFIRM]); } else if (req_state & REQ_PLAYER) { @@ -3523,6 +3537,10 @@ void DrawPreviewPlayers(void) if (game_status != GAME_MODE_MAIN) return; + // do not draw preview players if level preview redefined, but players aren't + if (preview.redefined && !menu.main.preview_players.redefined) + return; + boolean player_found[MAX_PLAYERS]; int num_players = 0; int i, x, y; @@ -3628,6 +3646,10 @@ static void DrawNetworkPlayersExt(boolean force) if (!network.connected && !force) return; + // do not draw network players if level preview redefined, but players aren't + if (preview.redefined && !menu.main.network_players.redefined) + return; + int num_players = 0; int i; @@ -4323,12 +4345,15 @@ static int RequestHandleEvents(unsigned int req_state) switch (request_gadget_id) { case TOOL_CTRL_ID_YES: + case TOOL_CTRL_ID_TOUCH_YES: result = TRUE; break; case TOOL_CTRL_ID_NO: + case TOOL_CTRL_ID_TOUCH_NO: result = FALSE; break; case TOOL_CTRL_ID_CONFIRM: + case TOOL_CTRL_ID_TOUCH_CONFIRM: result = TRUE | FALSE; break; @@ -4346,6 +4371,8 @@ static int RequestHandleEvents(unsigned int req_state) break; default: + // only check clickable animations if no request gadget clicked + HandleGlobalAnimClicks(mx, my, button_status, FALSE); break; } @@ -4658,10 +4685,13 @@ static boolean RequestDoor(char *text, unsigned int req_state) { MapGadget(tool_gadget[TOOL_CTRL_ID_YES]); MapGadget(tool_gadget[TOOL_CTRL_ID_NO]); + MapGadget(tool_gadget[TOOL_CTRL_ID_TOUCH_YES]); + MapGadget(tool_gadget[TOOL_CTRL_ID_TOUCH_NO]); } else if (req_state & REQ_CONFIRM) { MapGadget(tool_gadget[TOOL_CTRL_ID_CONFIRM]); + MapGadget(tool_gadget[TOOL_CTRL_ID_TOUCH_CONFIRM]); } else if (req_state & REQ_PLAYER) { @@ -5533,36 +5563,49 @@ static struct int graphic; struct TextPosInfo *pos; int gadget_id; + boolean is_touch_button; char *infotext; } toolbutton_info[NUM_TOOL_BUTTONS] = { { IMG_GFX_REQUEST_BUTTON_YES, &request.button.yes, - TOOL_CTRL_ID_YES, "yes" + TOOL_CTRL_ID_YES, FALSE, "yes" }, { IMG_GFX_REQUEST_BUTTON_NO, &request.button.no, - TOOL_CTRL_ID_NO, "no" + TOOL_CTRL_ID_NO, FALSE, "no" }, { IMG_GFX_REQUEST_BUTTON_CONFIRM, &request.button.confirm, - TOOL_CTRL_ID_CONFIRM, "confirm" + TOOL_CTRL_ID_CONFIRM, FALSE, "confirm" }, { IMG_GFX_REQUEST_BUTTON_PLAYER_1, &request.button.player_1, - TOOL_CTRL_ID_PLAYER_1, "player 1" + TOOL_CTRL_ID_PLAYER_1, FALSE, "player 1" }, { IMG_GFX_REQUEST_BUTTON_PLAYER_2, &request.button.player_2, - TOOL_CTRL_ID_PLAYER_2, "player 2" + TOOL_CTRL_ID_PLAYER_2, FALSE, "player 2" }, { IMG_GFX_REQUEST_BUTTON_PLAYER_3, &request.button.player_3, - TOOL_CTRL_ID_PLAYER_3, "player 3" + TOOL_CTRL_ID_PLAYER_3, FALSE, "player 3" }, { IMG_GFX_REQUEST_BUTTON_PLAYER_4, &request.button.player_4, - TOOL_CTRL_ID_PLAYER_4, "player 4" + TOOL_CTRL_ID_PLAYER_4, FALSE, "player 4" + }, + { + IMG_GFX_REQUEST_BUTTON_TOUCH_YES, &request.button.touch_yes, + TOOL_CTRL_ID_TOUCH_YES, TRUE, "yes" + }, + { + IMG_GFX_REQUEST_BUTTON_TOUCH_NO, &request.button.touch_no, + TOOL_CTRL_ID_TOUCH_NO, TRUE, "no" + }, + { + IMG_GFX_REQUEST_BUTTON_TOUCH_CONFIRM, &request.button.touch_confirm, + TOOL_CTRL_ID_TOUCH_CONFIRM, TRUE, "confirm" } }; @@ -5579,8 +5622,9 @@ void CreateToolButtons(void) 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; + boolean is_touch_button = toolbutton_info[i].is_touch_button; + int base_x = (is_touch_button ? 0 : DX); + int base_y = (is_touch_button ? 0 : DY); int gd_x = gfx->src_x; int gd_y = gfx->src_y; int gd_xp = gfx->src_x + gfx->pressed_xoffset; @@ -5589,9 +5633,9 @@ void CreateToolButtons(void) int y = pos->y; int id = i; - if (global.use_envelope_request) + if (global.use_envelope_request && !is_touch_button) { - setRequestPosition(&dx, &dy, TRUE); + setRequestPosition(&base_x, &base_y, TRUE); // check if request buttons are outside of envelope and fix, if needed if (x < 0 || x + gfx->width > request.width || @@ -5638,8 +5682,8 @@ void CreateToolButtons(void) gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_IMAGE_ID, graphic, GDI_INFO_TEXT, toolbutton_info[i].infotext, - GDI_X, dx + x, - GDI_Y, dy + y, + GDI_X, base_x + x, + GDI_Y, base_y + y, GDI_WIDTH, gfx->width, GDI_HEIGHT, gfx->height, GDI_TYPE, GD_TYPE_NORMAL_BUTTON, @@ -5651,6 +5695,7 @@ void CreateToolButtons(void) GDI_DECORATION_SIZE, pos->size, pos->size, GDI_DECORATION_SHIFTING, 1, 1, GDI_DIRECT_DRAW, FALSE, + GDI_OVERLAY_TOUCH_BUTTON, is_touch_button, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleToolButtons, GDI_END);