Author: cazfi
Date: Tue Nov  8 07:29:10 2016
New Revision: 34438

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

See bug #24642

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

Modified: trunk/client/gui-gtk-3.0/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/citydlg.c?rev=34438&r1=34437&r2=34438&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/citydlg.c  (original)
+++ trunk/client/gui-gtk-3.0/citydlg.c  Tue Nov  8 07:29:10 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);
+  }
 }
 
 /****************************************************************
@@ -2212,7 +2214,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: trunk/client/gui-gtk-3.0/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/gui_main.c?rev=34438&r1=34437&r2=34438&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/gui_main.c (original)
+++ trunk/client/gui-gtk-3.0/gui_main.c Tue Nov  8 07:29:10 2016
@@ -1915,7 +1915,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: trunk/client/gui-gtk-3.0/mapview.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/mapview.c?rev=34438&r1=34437&r2=34438&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/mapview.c  (original)
+++ trunk/client/gui-gtk-3.0/mapview.c  Tue Nov  8 07:29:10 2016
@@ -464,16 +464,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);
-  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);
+    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: trunk/client/gui-gtk-3.0/mapview.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/mapview.h?rev=34438&r1=34437&r2=34438&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/mapview.h  (original)
+++ trunk/client/gui-gtk-3.0/mapview.h  Tue Nov  8 07:29:10 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);

Modified: trunk/client/gui-gtk-3.22/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.22/citydlg.c?rev=34438&r1=34437&r2=34438&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.22/citydlg.c (original)
+++ trunk/client/gui-gtk-3.22/citydlg.c Tue Nov  8 07:29:10 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);
+  }
 }
 
 /****************************************************************
@@ -2243,7 +2245,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: trunk/client/gui-gtk-3.22/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.22/gui_main.c?rev=34438&r1=34437&r2=34438&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.22/gui_main.c        (original)
+++ trunk/client/gui-gtk-3.22/gui_main.c        Tue Nov  8 07:29:10 2016
@@ -1915,7 +1915,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: trunk/client/gui-gtk-3.22/mapview.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.22/mapview.c?rev=34438&r1=34437&r2=34438&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.22/mapview.c (original)
+++ trunk/client/gui-gtk-3.22/mapview.c Tue Nov  8 07:29:10 2016
@@ -478,13 +478,27 @@
 /**************************************************************************
   Fill image with unit gfx
 **************************************************************************/
-void put_unit_image(struct unit *punit, GtkImage *p)
-{
-  struct sprite *spr;
-
-  spr = get_unittype_sprite(tileset, unit_type_get(punit), punit->facing);
-
-  gtk_image_set_from_surface(p, spr->surface);
+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);
+    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: trunk/client/gui-gtk-3.22/mapview.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.22/mapview.h?rev=34438&r1=34437&r2=34438&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.22/mapview.h (original)
+++ trunk/client/gui-gtk-3.22/mapview.h Tue Nov  8 07:29:10 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