X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ftools.c;h=24fecfb31d478829d2f89bf2e59fa93a93a8e812;hp=fd588277fbfe0955579f5629b7b97cc7de3061b3;hb=70fe541d68f18a22eb3bd134f128c0d56b885701;hpb=c710867ec795302b379a5cdf99cb4ad3ed2a9cdd diff --git a/src/tools.c b/src/tools.c index fd588277..24fecfb3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1574,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; @@ -4182,8 +4186,8 @@ static int RequestHandleEvents(unsigned int req_state) case KSYM_Return: case KSYM_y: - case KSYM_Y: #if defined(TARGET_SDL2) + case KSYM_Y: case KSYM_Select: case KSYM_Menu: #if defined(KSYM_Rewind) @@ -4195,8 +4199,8 @@ static int RequestHandleEvents(unsigned int req_state) case KSYM_Escape: case KSYM_n: - 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 */ @@ -5150,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(); } } @@ -5297,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; @@ -5309,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; @@ -5325,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 + pos->x, - GDI_Y, dy + pos->y, + GDI_X, dx + x, + GDI_Y, dy + y, GDI_WIDTH, gfx->width, GDI_HEIGHT, gfx->height, GDI_TYPE, GD_TYPE_NORMAL_BUTTON,