X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftools.c;h=24fecfb31d478829d2f89bf2e59fa93a93a8e812;hp=96ce7f5028d3d55dbe8a03a79e6c9706cbffcf28;hb=70fe541d68f18a22eb3bd134f128c0d56b885701;hpb=fad8edb03b7e296b5f2df0cfb3a46cb014cf0c27 diff --git a/src/tools.c b/src/tools.c index 96ce7f50..24fecfb3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1265,6 +1265,8 @@ static int dx_last = -1, dy_last = -1; static int dxsize_last = -1, dysize_last = -1; static int vx_last = -1, vy_last = -1; static int vxsize_last = -1, vysize_last = -1; +static int ex_last = -1, ey_last = -1; +static int exsize_last = -1, eysize_last = -1; boolean CheckIfGlobalBorderHasChanged() { @@ -1307,6 +1309,11 @@ boolean CheckIfGlobalBorderRedrawIsNeeded() vxsize_last != VXSIZE || vysize_last != VYSIZE) return TRUE; + // redraw if position or size of editor area has changed + if (ex_last != EX || ey_last != EY || + exsize_last != EXSIZE || eysize_last != EYSIZE) + return TRUE; + return FALSE; } @@ -1347,6 +1354,9 @@ static void RedrawGlobalBorderIfNeeded() // redraw global screen border (or clear, if defined to be empty) RedrawGlobalBorderFromBitmap(global_border_bitmap); + if (game_status == GAME_MODE_EDITOR) + DrawSpecialEditorDoor(); + // copy previous playfield and door areas, if they are defined on both // previous and current screen and if they still have the same size @@ -1363,11 +1373,22 @@ static void RedrawGlobalBorderIfNeeded() BlitBitmap(bitmap_db_store_1, backbuffer, dx_last, dy_last, DXSIZE, DYSIZE, DX, DY); - if (vx_last != -1 && vy_last != -1 && - VX != -1 && VY != -1 && - vxsize_last == VXSIZE && vysize_last == VYSIZE) - BlitBitmap(bitmap_db_store_1, backbuffer, - vx_last, vy_last, VXSIZE, VYSIZE, VX, VY); + if (game_status != GAME_MODE_EDITOR) + { + if (vx_last != -1 && vy_last != -1 && + VX != -1 && VY != -1 && + vxsize_last == VXSIZE && vysize_last == VYSIZE) + BlitBitmap(bitmap_db_store_1, backbuffer, + vx_last, vy_last, VXSIZE, VYSIZE, VX, VY); + } + else + { + if (ex_last != -1 && ey_last != -1 && + EX != -1 && EY != -1 && + exsize_last == EXSIZE && eysize_last == EYSIZE) + BlitBitmap(bitmap_db_store_1, backbuffer, + ex_last, ey_last, EXSIZE, EYSIZE, EX, EY); + } redraw_mask = REDRAW_ALL; } @@ -1388,6 +1409,10 @@ static void RedrawGlobalBorderIfNeeded() vy_last = VY; vxsize_last = VXSIZE; vysize_last = VYSIZE; + ex_last = EX; + ey_last = EY; + exsize_last = EXSIZE; + eysize_last = EYSIZE; } void ClearField() @@ -1549,6 +1574,10 @@ void getSizedGraphicSourceExt(int graphic, int frame, int tilesize, { struct GraphicInfo *g = &graphic_info[graphic]; + // if no graphics defined at all, use fallback graphics + if (g->bitmaps == NULL) + *g = graphic_info[IMG_CHAR_EXCLAM]; + // if no in-game graphics defined, always use standard graphic size if (g->bitmaps[IMG_BITMAP_GAME] == NULL) tilesize = TILESIZE; @@ -4156,7 +4185,9 @@ static int RequestHandleEvents(unsigned int req_state) break; case KSYM_Return: + case KSYM_y: #if defined(TARGET_SDL2) + case KSYM_Y: case KSYM_Select: case KSYM_Menu: #if defined(KSYM_Rewind) @@ -4167,7 +4198,9 @@ static int RequestHandleEvents(unsigned int req_state) break; case KSYM_Escape: + case KSYM_n: #if defined(TARGET_SDL2) + case KSYM_N: case KSYM_Back: #if defined(KSYM_FastForward) case KSYM_FastForward: /* for Amazon Fire TV remote */ @@ -5121,11 +5154,14 @@ unsigned int MoveDoor(unsigned int door_state) { /* wait for specified door action post delay */ if (door_state & DOOR_ACTION_1 && door_state & DOOR_ACTION_2) - Delay(MAX(door_1.post_delay, door_2.post_delay)); + door_delay_value = MAX(door_1.post_delay, door_2.post_delay); else if (door_state & DOOR_ACTION_1) - Delay(door_1.post_delay); + door_delay_value = door_1.post_delay; else if (door_state & DOOR_ACTION_2) - Delay(door_2.post_delay); + door_delay_value = door_2.post_delay; + + while (!DelayReached(&door_delay, door_delay_value)) + BackToFront(); } } @@ -5268,7 +5304,8 @@ void CreateToolButtons() for (i = 0; i < NUM_TOOL_BUTTONS; i++) { - struct GraphicInfo *gfx = &graphic_info[toolbutton_info[i].graphic]; + int graphic = toolbutton_info[i].graphic; + struct GraphicInfo *gfx = &graphic_info[graphic]; struct TextPosInfo *pos = toolbutton_info[i].pos; struct GadgetInfo *gi; Bitmap *deco_bitmap = None; @@ -5280,11 +5317,49 @@ void CreateToolButtons() 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 x = pos->x; + int y = pos->y; int id = i; if (global.use_envelope_request) + { setRequestPosition(&dx, &dy, TRUE); + // check if request buttons are outside of envelope and fix, if needed + if (x < 0 || x + gfx->width > request.width || + y < 0 || y + gfx->height > request.height) + { + // use left padding of "yes" button as default border padding + int padding = toolbutton_info[TOOL_CTRL_ID_YES].pos->x; + + if (id == TOOL_CTRL_ID_YES) + { + x = padding; + y = request.height - 2 * request.border_size - gfx->height - padding; + } + else if (id == TOOL_CTRL_ID_NO) + { + x = request.width - 2 * request.border_size - gfx->width - padding; + y = request.height - 2 * request.border_size - gfx->height - padding; + } + else if (id == TOOL_CTRL_ID_CONFIRM) + { + x = (request.width - 2 * request.border_size - gfx->width) / 2; + y = request.height - 2 * request.border_size - gfx->height - padding; + } + else if (id >= TOOL_CTRL_ID_PLAYER_1 && id <= TOOL_CTRL_ID_PLAYER_4) + { + int player_nr = id - TOOL_CTRL_ID_PLAYER_1; + + x = (request.width - 2 * request.border_size - gfx->width) / 2; + y = request.height - 2 * request.border_size - gfx->height - padding; + + x += (player_nr % 2 ? +1 : -1) * gfx->width / 2; + y += (player_nr / 2 ? 0 : -1) * gfx->height; + } + } + } + if (id >= TOOL_CTRL_ID_PLAYER_1 && id <= TOOL_CTRL_ID_PLAYER_4) { int player_nr = id - TOOL_CTRL_ID_PLAYER_1; @@ -5296,9 +5371,10 @@ void CreateToolButtons() } gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_IMAGE_ID, graphic, GDI_INFO_TEXT, toolbutton_info[i].infotext, - GDI_X, dx + GDI_ACTIVE_POS(pos->x), - GDI_Y, dy + GDI_ACTIVE_POS(pos->y), + GDI_X, dx + x, + GDI_Y, dy + y, GDI_WIDTH, gfx->width, GDI_HEIGHT, gfx->height, GDI_TYPE, GD_TYPE_NORMAL_BUTTON,