From 823974dd43d0e8ef1224a70e7bd9f85944a78887 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 27 Jun 2022 19:53:25 +0300 Subject: [PATCH 64/64] sdl2: Scale units down to icons by more accurate amount Citydlg icons were often scaled down far too much. See osdn #44891 Signed-off-by: Marko Lindqvist --- client/gui-sdl2/citydlg.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/client/gui-sdl2/citydlg.c b/client/gui-sdl2/citydlg.c index 69ca33ae5d..8182d5944b 100644 --- a/client/gui-sdl2/citydlg.c +++ b/client/gui-sdl2/citydlg.c @@ -616,16 +616,21 @@ static SDL_Surface *create_unit_surface(struct unit *punit, bool support, put_unit(punit, destcanvas, 1.0, 0, 0); - /* Get unit sprite width, but do not limit height by it */ + /* Get unit sprite width, and crop top. Bottom might get restored in 'support' + * case below. */ src_rect = get_smaller_surface_rect(destcanvas->surf); - src_rect.y = 0; - src_rect.h = destcanvas->surf->h; if (support) { int i, step; int free_unhappy; int happy_cost; SDL_Rect dest; + int offset = tileset_unit_layout_small_offset_y(tileset); + + /* Support also layouts placing support icons higher than unit. */ + src_rect.y = MIN(src_rect.y, offset); + /* Restore bottom space when needed for support icons. */ + src_rect.h = destcanvas->surf->h - src_rect.y; free_unhappy = get_city_bonus(pcity_dlg->pcity, EFT_MAKE_CONTENT_MIL); happy_cost = city_unit_unhappiness(punit, &free_unhappy); -- 2.35.1