X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsdl.c;h=47ad26237b32ab1186c6a059152f038c69655b96;hb=8996c42ebfda1439fbf40a6a4c13129f760ecf2d;hp=46d9abac9ea7aef6cb5d048c3f3f94ce86a1812f;hpb=d93d679ebb98f8466d0d0a8231356da1e6d2d62b;p=rocksndiamonds.git diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 46d9abac..47ad2623 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -3012,6 +3012,13 @@ static void DrawTouchInputOverlay_ShowGrid(int alpha) SDL_SetRenderDrawColor(sdl_renderer, 0, 0, 0, 255); } +static void RenderFillRectangle(int x, int y, int width, int height) +{ + SDL_Rect rect = { x, y, width, height }; + + SDL_RenderFillRect(sdl_renderer, &rect); +} + static void DrawTouchInputOverlay_ShowGridButtons(int alpha) { static int alpha_direction = 0; @@ -3053,7 +3060,12 @@ static void DrawTouchInputOverlay_ShowGridButtons(int alpha) for (y = 0; y < grid_ysize; y++) { int grid_button = overlay.grid_button[x][y]; + int grid_button_action = GET_ACTION_FROM_GRID_BUTTON(grid_button); int alpha_draw = alpha; + int outline_border = MV_NONE; + int border_size = 2; + boolean draw_outlined = setup.touch.draw_outlined; + boolean draw_pressed = setup.touch.draw_pressed; if (grid_button == CHAR_GRID_BUTTON_NONE) continue; @@ -3061,6 +3073,14 @@ static void DrawTouchInputOverlay_ShowGridButtons(int alpha) if (grid_button == overlay.grid_button_highlight) alpha_draw = alpha_highlight; + if (draw_pressed && overlay.grid_button_action & grid_button_action) + { + if (draw_outlined) + draw_outlined = FALSE; + else + alpha_draw = MIN((float)alpha_draw * 1.5, SDL_ALPHA_OPAQUE); + } + SDL_SetRenderDrawColor(sdl_renderer, 255, 255, 255, alpha_draw); rect.x = (x + 0) * video.screen_width / grid_xsize; @@ -3070,27 +3090,60 @@ static void DrawTouchInputOverlay_ShowGridButtons(int alpha) if (x == 0 || overlay.grid_button[x - 1][y] != grid_button) { - rect.x += 2; - rect.w -= 2; + rect.x += border_size; + rect.w -= border_size; + + outline_border |= MV_LEFT; } if (x == grid_xsize - 1 || overlay.grid_button[x + 1][y] != grid_button) { - rect.w -= 2; + rect.w -= border_size; + + outline_border |= MV_RIGHT; } if (y == 0 || overlay.grid_button[x][y - 1] != grid_button) { - rect.y += 2; - rect.h -= 2; + rect.y += border_size; + rect.h -= border_size; + + outline_border |= MV_UP; } if (y == grid_ysize - 1 || overlay.grid_button[x][y + 1] != grid_button) { - rect.h -= 2; + rect.h -= border_size; + + outline_border |= MV_DOWN; } - SDL_RenderFillRect(sdl_renderer, &rect); + if (draw_outlined) + { + int rect_x = rect.x + + (outline_border & MV_LEFT ? border_size : 0); + int rect_w = rect.w - + (outline_border & MV_LEFT ? border_size : 0) - + (outline_border & MV_RIGHT ? border_size : 0); + + if (outline_border & MV_LEFT) + RenderFillRectangle(rect.x, rect.y, border_size, rect.h); + + if (outline_border & MV_RIGHT) + RenderFillRectangle(rect.x + rect.w - border_size, rect.y, + border_size, rect.h); + + if (outline_border & MV_UP) + RenderFillRectangle(rect_x, rect.y, rect_w, border_size); + + if (outline_border & MV_DOWN) + RenderFillRectangle(rect_x, rect.y + rect.h - border_size, + rect_w, border_size); + } + else + { + SDL_RenderFillRect(sdl_renderer, &rect); + } } }