Author: cazfi
Date: Sun Nov  8 17:07:02 2015
New Revision: 30477

URL: http://svn.gna.org/viewcvs/freeciv?rev=30477&view=rev
Log:
Made all the clients to respect tileset_unit_layout_offset_y()

See patch #6520

Modified:
    trunk/client/gui-qt/citydlg.cpp
    trunk/client/gui-sdl2/citydlg.c

Modified: trunk/client/gui-qt/citydlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/citydlg.cpp?rev=30477&r1=30476&r2=30477&view=diff
==============================================================================
--- trunk/client/gui-qt/citydlg.cpp     (original)
+++ trunk/client/gui-qt/citydlg.cpp     Sun Nov  8 17:07:02 2015
@@ -58,18 +58,6 @@
 static city_dialog *city_dlg;
 
 /****************************************************************************
-  Calculates extra space needed for upkeep sprites for non-isometric tileset
-****************************************************************************/
-static float overhead_upkeep_scale()
-{
-  float ret = 1.0f;
-  if (!tileset_is_isometric(tileset)) {
-    ret = 1.33f;
-  }
-  return ret;
-}
-
-/****************************************************************************
   Draws X on pixmap pointing its useless
 ****************************************************************************/
 static void pixmap_put_x(QPixmap *pix)
@@ -99,13 +87,12 @@
   qunit = punit;
   if (punit) {
     unit_pixmap = qtg_canvas_create(tileset_full_tile_width(tileset),
-                                    overhead_upkeep_scale()
-                                    * tileset_tile_height(tileset) * 3 / 2);
+                                    tileset_unit_with_upkeep_height(tileset));
     unit_pixmap->map_pixmap.fill(Qt::transparent);
     put_unit(punit, unit_pixmap, 1.0, 0, 0);
     if (supported) {
       put_unit_city_overlays(punit, unit_pixmap, 0,
-                             tileset_tile_height(tileset),
+                             tileset_unit_layout_offset_y(tileset),
                              punit->upkeep, happy_cost);
     }
   }
@@ -356,13 +343,12 @@
   }
   if (qunit) {
     unit_pixmap = qtg_canvas_create(tileset_full_tile_width(tileset),
-                                    overhead_upkeep_scale()
-                                    * tileset_tile_height(tileset) * 3 / 2);
+                                    tileset_unit_with_upkeep_height(tileset));
     unit_pixmap->map_pixmap.fill(QColor(200, 200, 200));
     put_unit(qunit, unit_pixmap, 1.0, 0, 0);
     if (supported) {
       put_unit_city_overlays(qunit, unit_pixmap, 0,
-                             tileset_tile_height(tileset),
+                             tileset_unit_layout_offset_y(tileset),
                              qunit->upkeep, happy_cost);
     }
   }
@@ -379,13 +365,12 @@
   }
   if (qunit) {
     unit_pixmap = qtg_canvas_create(tileset_full_tile_width(tileset),
-                                    overhead_upkeep_scale()
-                                    * tileset_tile_height(tileset) * 3 / 2);
+                                    tileset_unit_with_upkeep_height(tileset));
     unit_pixmap->map_pixmap.fill(Qt::transparent);
     put_unit(qunit, unit_pixmap, 1.0, 0, 0);
     if (supported) {
       put_unit_city_overlays(qunit, unit_pixmap, 0,
-                             tileset_tile_height(tileset),
+                             tileset_unit_layout_offset_y(tileset),
                              qunit->upkeep, happy_cost);
     }
   }
@@ -453,8 +438,7 @@
   QSizePolicy size_fixed_policy(QSizePolicy::Fixed, QSizePolicy::Fixed);
   layout->setContentsMargins(3, 6, 3, 6);
   setSizePolicy(size_fixed_policy);
-  setFixedHeight(overhead_upkeep_scale() * tileset_tile_height(tileset)
-                 * 3 / 2 + 6);
+  setFixedHeight(tileset_unit_with_upkeep_height(tileset) + 6);
   setLayout(layout);
 }
 
@@ -700,7 +684,7 @@
   size_expanding_policy.setVerticalStretch(0);
   current_building = 0;
 
-  /** Overview tab initiazlization */
+  /** Overview tab initialization */
   {
     QGroupBox *map_box = new QGroupBox(this);
     QVBoxLayout *v_layout = new QVBoxLayout;
@@ -764,8 +748,7 @@
     supported_units = new unit_info(this, true);
     scroll = new QScrollArea;
     scroll->setWidgetResizable(true);
-    scroll->setMaximumHeight(tileset_tile_height(tileset) * 2
-                             * overhead_upkeep_scale());
+    scroll->setMaximumHeight(tileset_unit_with_upkeep_height(tileset) * 2);
     scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     scroll->setWidget(supported_units);
     current_units = new unit_info(this, false);

Modified: trunk/client/gui-sdl2/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/citydlg.c?rev=30477&r1=30476&r2=30477&view=diff
==============================================================================
--- trunk/client/gui-sdl2/citydlg.c     (original)
+++ trunk/client/gui-sdl2/citydlg.c     Sun Nov  8 17:07:02 2015
@@ -592,25 +592,23 @@
 /**************************************************************************
   create unit icon with support icons.
 **************************************************************************/
-static SDL_Surface *create_unit_surface(struct unit *pUnit, bool support,
+static SDL_Surface *create_unit_surface(struct unit *punit, bool support,
                                         int w, int h)
 {
   SDL_Rect src_rect;
-  SDL_Surface *pSurf, *pZoomed;
-  struct canvas *destcanvas = canvas_create(tileset_full_tile_width(tileset),
-                                            tileset_full_tile_height(tileset));
-
-  put_unit(pUnit, destcanvas, 1.0, 0, 0);
-
+  SDL_Surface *psurf;
+  struct canvas *destcanvas;
+
+  destcanvas = canvas_create(tileset_full_tile_width(tileset),
+                             tileset_full_tile_height(tileset));
+
+  put_unit(punit, destcanvas, 1.0, 0, 0);
   src_rect = get_smaller_surface_rect(destcanvas->surf);
-  pSurf = create_surf(src_rect.w, src_rect.h, SDL_SWSURFACE);
-  alphablit(destcanvas->surf, &src_rect, pSurf, NULL, 255);
+  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);
-
-  pZoomed = ResizeSurfaceBox(pSurf, w, h, 1, TRUE, TRUE);
-  FREESURFACE(pSurf);
-  pSurf = pZoomed;
 
   if (support) {
     int i, step;
@@ -619,43 +617,51 @@
     SDL_Rect dest;
 
     free_unhappy = get_city_bonus(pCityDlg->pCity, EFT_MAKE_CONTENT_MIL);
-    happy_cost = city_unit_unhappiness(pUnit, &free_unhappy);
-
-    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);
+    happy_cost = city_unit_unhappiness(punit, &free_unhappy);
+
+    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);
     } else {
       step = pIcons->pFood->w;
     }
 
-    dest.y = pSurf->h - pIcons->pFood->h - adj_size(2);
-    dest.x = pSurf->w / 8;
-
-    for (i = 0; i < pUnit->upkeep[O_SHIELD]; i++) {
-      alphablit(pIcons->pShield, NULL, pSurf, &dest, 255);
+    dest.y = tileset_unit_layout_offset_y(tileset);
+    dest.x = psurf->w / 8;
+
+    for (i = 0; i < punit->upkeep[O_SHIELD]; i++) {
+      alphablit(pIcons->pShield, NULL, psurf, &dest, 255);
       dest.x += step;
     }
 
-    for (i = 0; i < pUnit->upkeep[O_FOOD]; i++) {
-      alphablit(pIcons->pFood, NULL, pSurf, &dest, 255);
+    for (i = 0; i < punit->upkeep[O_FOOD]; i++) {
+      alphablit(pIcons->pFood, NULL, psurf, &dest, 255);
       dest.x += step;
     }
 
-    for (i = 0; i < pUnit->upkeep[O_GOLD]; i++) {
-      alphablit(pIcons->pCoin, NULL, pSurf, &dest, 255);
+    for (i = 0; i < punit->upkeep[O_GOLD]; i++) {
+      alphablit(pIcons->pCoin, NULL, psurf, &dest, 255);
       dest.x += step;
     }
 
     for (i = 0; i < happy_cost; i++) {
-      alphablit(pIcons->pFace, NULL, pSurf, &dest, 255);
+      alphablit(pIcons->pFace, NULL, psurf, &dest, 255);
       dest.x += step;
     }
 
   }
 
-  return pSurf;
+  if (w != src_rect.w || h != src_rect.h) {
+    SDL_Surface *pzoomed;
+
+    pzoomed = ResizeSurfaceBox(psurf, w, h, 1, TRUE, TRUE);
+    FREESURFACE(psurf);
+    psurf = pzoomed;
+  }
+
+  return psurf;
 }
 
 /**************************************************************************


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to