Author: cazfi
Date: Tue Nov  8 07:29:20 2016
New Revision: 34439

URL: http://svn.gna.org/viewcvs/freeciv?rev=34439&view=rev
Log:
Use proper overlays for units in citydlg present units area.

See bug #24642

Modified:
    branches/S2_6/client/gui-gtk-3.0/citydlg.c
    branches/S2_6/client/gui-gtk-3.22/citydlg.c
    branches/S2_6/client/gui-gtk-3.22/gui_main.c
    branches/S2_6/client/gui-gtk-3.22/mapview.c
    branches/S2_6/client/gui-gtk-3.22/mapview.h

Modified: branches/S2_6/client/gui-gtk-3.0/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/citydlg.c?rev=34439&r1=34438&r2=34439&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.0/citydlg.c  (original)
+++ branches/S2_6/client/gui-gtk-3.0/citydlg.c  Tue Nov  8 07:29:20 2016
@@ -533,11 +533,13 @@
   pcity_sup = game_city_by_number(punit->homecity);
   pcity_pre = tile_city(unit_tile(punit));
 
-  if (pcity_sup && (pdialog = get_city_dialog(pcity_sup)))
+  if (pcity_sup && (pdialog = get_city_dialog(pcity_sup))) {
     city_dialog_update_supported_units(pdialog);
-
-  if (pcity_pre && (pdialog = get_city_dialog(pcity_pre)))
+  }
+
+  if (pcity_pre && (pdialog = get_city_dialog(pcity_pre))) {
     city_dialog_update_present_units(pdialog);
+  }
 }
 
 /****************************************************************

Modified: branches/S2_6/client/gui-gtk-3.22/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/citydlg.c?rev=34439&r1=34438&r2=34439&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/citydlg.c (original)
+++ branches/S2_6/client/gui-gtk-3.22/citydlg.c Tue Nov  8 07:29:20 2016
@@ -535,11 +535,13 @@
   pcity_sup = game_city_by_number(punit->homecity);
   pcity_pre = tile_city(unit_tile(punit));
 
-  if (pcity_sup && (pdialog = get_city_dialog(pcity_sup)))
+  if (pcity_sup && (pdialog = get_city_dialog(pcity_sup))) {
     city_dialog_update_supported_units(pdialog);
-
-  if (pcity_pre && (pdialog = get_city_dialog(pcity_pre)))
+  }
+
+  if (pcity_pre && (pdialog = get_city_dialog(pcity_pre))) {
     city_dialog_update_present_units(pdialog);
+  }
 }
 
 /****************************************************************
@@ -2252,7 +2254,7 @@
       cmd = pnode->cmd;
       pix = pnode->pix;
 
-      put_unit_image(punit, GTK_IMAGE(pix));
+      put_unit_image(punit, GTK_IMAGE(pix), pnode->height);
 
       g_signal_handlers_disconnect_matched(cmd,
          G_SIGNAL_MATCH_FUNC,

Modified: branches/S2_6/client/gui-gtk-3.22/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/gui_main.c?rev=34439&r1=34438&r2=34439&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/gui_main.c        (original)
+++ branches/S2_6/client/gui-gtk-3.22/gui_main.c        Tue Nov  8 07:29:20 2016
@@ -1919,7 +1919,7 @@
   }
 
   if (punit) {
-    put_unit_image(punit, GTK_IMAGE(w));
+    put_unit_image(punit, GTK_IMAGE(w), -1);
   } else {
     gtk_image_clear(GTK_IMAGE(w));
   }

Modified: branches/S2_6/client/gui-gtk-3.22/mapview.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/mapview.c?rev=34439&r1=34438&r2=34439&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/mapview.c (original)
+++ branches/S2_6/client/gui-gtk-3.22/mapview.c Tue Nov  8 07:29:20 2016
@@ -497,16 +497,27 @@
 /**************************************************************************
   Fill image with unit gfx
 **************************************************************************/
-void put_unit_image(struct unit *punit, GtkImage *p)
-{
-  GdkPixbuf *pixbuf;
-  struct sprite *spr;
-
-  spr = get_unittype_sprite(tileset, unit_type_get(punit), punit->facing, 
FALSE);
-  pixbuf = sprite_get_pixbuf(spr);
-
-  gtk_image_set_from_pixbuf(p, pixbuf);
-  g_object_unref(pixbuf);
+void put_unit_image(struct unit *punit, GtkImage *p, int height)
+{
+  struct canvas store = FC_STATIC_CANVAS_INIT;
+  int width;
+
+  if (height <= 0) {
+    struct sprite *spr;
+
+    spr = get_unittype_sprite(tileset, unit_type_get(punit), punit->facing, 
FALSE);
+    get_sprite_dimensions(spr, &width, &height);
+  } else {
+    width = tileset_full_tile_width(tileset);
+  }
+
+  store.surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+                                             width, height);
+
+  put_unit(punit, &store, 1.0, 0, 0);
+
+  gtk_image_set_from_surface(p, store.surface);
+  cairo_surface_destroy(store.surface);
 }
 
 /**************************************************************************

Modified: branches/S2_6/client/gui-gtk-3.22/mapview.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.22/mapview.h?rev=34439&r1=34438&r2=34439&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-3.22/mapview.h (original)
+++ branches/S2_6/client/gui-gtk-3.22/mapview.h Tue Nov  8 07:29:20 2016
@@ -36,7 +36,7 @@
 gboolean map_canvas_configure(GtkWidget *w, GdkEventConfigure *ev,
                               gpointer data);
 
-void put_unit_image(struct unit *punit, GtkImage *p);
+void put_unit_image(struct unit *punit, GtkImage *p, int height);
 
 void put_unit_image_city_overlays(struct unit *punit, GtkImage *p,
                                   int height, int *upkeep_cost, int 
happy_cost);


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

Reply via email to