Author: cazfi Date: Thu Dec 10 23:53:07 2015 New Revision: 30939 URL: http://svn.gna.org/viewcvs/freeciv?rev=30939&view=rev Log: Fixed scaling up upkeep sprites in sdl-clients' unit icon creation.
See bug #24148 Modified: trunk/client/gui-sdl2/citydlg.c Modified: trunk/client/gui-sdl2/citydlg.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/citydlg.c?rev=30939&r1=30938&r2=30939&view=diff ============================================================================== --- trunk/client/gui-sdl2/citydlg.c (original) +++ trunk/client/gui-sdl2/citydlg.c Thu Dec 10 23:53:07 2015 @@ -600,15 +600,14 @@ struct canvas *destcanvas; destcanvas = canvas_create(tileset_full_tile_width(tileset), - tileset_full_tile_height(tileset)); + tileset_unit_with_upkeep_height(tileset)); put_unit(punit, destcanvas, 1.0, 0, 0); + + /* Get unit sprite width, but do not limit height by it */ src_rect = get_smaller_surface_rect(destcanvas->surf); - src_rect.h = tileset_unit_with_upkeep_height(tileset); - psurf = create_surf(src_rect.w, src_rect.h, SDL_SWSURFACE); - alphablit(destcanvas->surf, &src_rect, psurf, NULL, 255); - - canvas_free(destcanvas); + src_rect.y = 0; + src_rect.h = destcanvas->surf->h; if (support) { int i, step; @@ -622,36 +621,41 @@ i = punit->upkeep[O_SHIELD] + punit->upkeep[O_FOOD] + punit->upkeep[O_GOLD] + happy_cost; - if (i * pIcons->pFood->w > psurf->w / 2) { - step = (psurf->w / 2 - pIcons->pFood->w) / (i - 1); + if (i * pIcons->pFood->w > src_rect.w / 2) { + step = (src_rect.w / 2 - pIcons->pFood->w) / (i - 1); } else { step = pIcons->pFood->w; } dest.y = tileset_unit_layout_offset_y(tileset); - dest.x = psurf->w / 8; + dest.x = src_rect.x + src_rect.w / 8; for (i = 0; i < punit->upkeep[O_SHIELD]; i++) { - alphablit(pIcons->pShield, NULL, psurf, &dest, 255); + alphablit(pIcons->pShield, NULL, destcanvas->surf, &dest, 255); dest.x += step; } for (i = 0; i < punit->upkeep[O_FOOD]; i++) { - alphablit(pIcons->pFood, NULL, psurf, &dest, 255); + alphablit(pIcons->pFood, NULL, destcanvas->surf, &dest, 255); dest.x += step; } for (i = 0; i < punit->upkeep[O_GOLD]; i++) { - alphablit(pIcons->pCoin, NULL, psurf, &dest, 255); + alphablit(pIcons->pCoin, NULL, destcanvas->surf, &dest, 255); dest.x += step; } for (i = 0; i < happy_cost; i++) { - alphablit(pIcons->pFace, NULL, psurf, &dest, 255); + alphablit(pIcons->pFace, NULL, destcanvas->surf, &dest, 255); dest.x += step; } } + + psurf = create_surf(src_rect.w, src_rect.h, SDL_SWSURFACE); + alphablit(destcanvas->surf, &src_rect, psurf, NULL, 255); + + canvas_free(destcanvas); if (w != src_rect.w || h != src_rect.h) { SDL_Surface *pzoomed; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits