Author: mir3x
Date: Thu Feb  2 20:47:36 2017
New Revision: 34934

URL: http://svn.gna.org/viewcvs/freeciv?rev=34934&view=rev
Log:
Gtk2 client - added scaling tileset

See patch #8094


Modified:
    branches/S2_6/client/gui-gtk-2.0/citydlg.c
    branches/S2_6/client/gui-gtk-2.0/gui_main.c
    branches/S2_6/client/gui-gtk-2.0/happiness.c
    branches/S2_6/client/gui-gtk-2.0/sprite.c

Modified: branches/S2_6/client/gui-gtk-2.0/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/citydlg.c?rev=34934&r1=34933&r2=34934&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/citydlg.c  (original)
+++ branches/S2_6/client/gui-gtk-2.0/citydlg.c  Thu Feb  2 20:47:36 2017
@@ -1344,8 +1344,9 @@
   gtk_box_pack_start(GTK_BOX(cbox), ebox, FALSE, FALSE, 0);
   pdialog->citizen_pixmap =
       gtk_pixcomm_new(tileset_small_sprite_width(tileset)
-                      * NUM_CITIZENS_SHOWN,
-                      tileset_small_sprite_height(tileset));
+                      * NUM_CITIZENS_SHOWN / tileset_scale(tileset),
+                      tileset_small_sprite_height(tileset)
+                      / tileset_scale(tileset));
   gtk_misc_set_padding(GTK_MISC(pdialog->citizen_pixmap), 2, 2);
   gtk_misc_set_alignment(GTK_MISC(pdialog->citizen_pixmap), 0.0f, 0.5f);
   gtk_container_add(GTK_CONTAINER(ebox), pdialog->citizen_pixmap);
@@ -1501,11 +1502,11 @@
   /* tileset_small_sprite_width(tileset) pixels.                           */
 
   if (num_citizens > 1) {
-    width = MIN(tileset_small_sprite_width(tileset),
-               ((NUM_CITIZENS_SHOWN - 1) * 
tileset_small_sprite_width(tileset)) /
-               (num_citizens - 1));
+    width = MIN(tileset_small_sprite_width(tileset)  / tileset_scale(tileset),
+        ((NUM_CITIZENS_SHOWN - 1) * (tileset_small_sprite_width(tileset))
+        / tileset_scale(tileset)) / (num_citizens - 1));
   } else {
-    width = tileset_small_sprite_width(tileset);
+    width = tileset_small_sprite_width(tileset) / tileset_scale(tileset);
   }
   pdialog->cwidth = width;
 
@@ -2553,7 +2554,7 @@
     return FALSE;
   }
 
-  tlen = tileset_small_sprite_width(tileset);
+  tlen = tileset_small_sprite_width(tileset) / tileset_scale(tileset);
   len = (city_size_get(pcity) - 1) * pdialog->cwidth + tlen;
   if (ev->x > len) {
     return FALSE;              /* no citizen that far to the right */

Modified: branches/S2_6/client/gui-gtk-2.0/gui_main.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/gui_main.c?rev=34934&r1=34933&r2=34934&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/gui_main.c (original)
+++ branches/S2_6/client/gui-gtk-2.0/gui_main.c Thu Feb  2 20:47:36 2017
@@ -561,7 +561,14 @@
   case GDK_Escape:
     key_cancel_action();
     return TRUE;
-
+  case GDK_KEY_plus:
+    tilespec_reread(tileset_basename(tileset), true, tileset_scale(tileset)
+                    * 1.2f);
+    return TRUE;
+  case GDK_KEY_minus:
+    tilespec_reread(tileset_basename(tileset), true, tileset_scale(tileset)
+                    / 1.2f);
+    return TRUE;
   case GDK_b:
     if (tiles_hilited_cities) {
       buy_production_in_selected_cities();

Modified: branches/S2_6/client/gui-gtk-2.0/happiness.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/happiness.c?rev=34934&r1=34933&r2=34934&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/happiness.c        (original)
+++ branches/S2_6/client/gui-gtk-2.0/happiness.c        Thu Feb  2 20:47:36 2017
@@ -42,8 +42,10 @@
 /* semi-arbitrary number that controls the width of the happiness widget */
 #define HAPPINESS_PIX_WIDTH 30
 
-#define        PIXCOMM_WIDTH   (HAPPINESS_PIX_WIDTH * 
tileset_small_sprite_width(tileset))
-#define        PIXCOMM_HEIGHT  (tileset_small_sprite_height(tileset))
+#define        PIXCOMM_WIDTH   (HAPPINESS_PIX_WIDTH * 
tileset_small_sprite_width(tileset) \
+                         / tileset_scale(tileset))
+#define        PIXCOMM_HEIGHT  (tileset_small_sprite_height(tileset) \
+                        / tileset_scale(tileset))
 
 #define NUM_HAPPINESS_MODIFIERS 6
 
@@ -276,7 +278,8 @@
   enum citizen_category categories[MAX_CITY_SIZE];
   int i;
   int num_citizens = get_city_citizen_types(pcity, index, categories);
-  int offset = MIN(tileset_small_sprite_width(tileset), PIXCOMM_WIDTH / 
num_citizens);
+  int offset = MIN(tileset_small_sprite_width(tileset)
+                   / tileset_scale(tileset), PIXCOMM_WIDTH / num_citizens);
 
   gtk_pixcomm_freeze(dst);
   gtk_pixcomm_clear(dst);

Modified: branches/S2_6/client/gui-gtk-2.0/sprite.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/sprite.c?rev=34934&r1=34933&r2=34934&view=diff
==============================================================================
--- branches/S2_6/client/gui-gtk-2.0/sprite.c   (original)
+++ branches/S2_6/client/gui-gtk-2.0/sprite.c   Thu Feb  2 20:47:36 2017
@@ -18,6 +18,7 @@
 /* utility */
 #include "log.h"
 #include "mem.h"
+#include "math.h"
 #include "shared.h"
 
 /* client/gtk-2.0 */
@@ -65,7 +66,13 @@
   height = CLIP(0, height, source->height - y);
   sub = gdk_pixbuf_new_subpixbuf(sprite_get_pixbuf(source), x, y,
                                 width, height);
-  mypixbuf = gdk_pixbuf_copy(sub);
+  if (scale == 1.0f) {
+    mypixbuf = gdk_pixbuf_copy(sub);
+  } else {
+    mypixbuf = gdk_pixbuf_scale_simple(sub, ceil(width *scale),
+                                       ceil(height * scale),
+                                       GDK_INTERP_NEAREST);
+  }
   g_object_unref(sub);
 
   /* Now mask.  This reduces the alpha of the final image proportional to the
@@ -95,8 +102,8 @@
       g_object_unref(p2);
     }
 
-    for (x1 = 0; x1 < width; x1++) {
-      for (y1 = 0; y1 < height; y1++) {
+    for (x1 = 0; x1 < ceil(width * scale); x1++) {
+      for (y1 = 0; y1 < ceil(height * scale); y1++) {
        int mask_x = x1 - mask_offset_x, mask_y = y1 - mask_offset_y;
        guchar *alpha = gdk_pixbuf_get_pixels(mypixbuf)
          + y1 * gdk_pixbuf_get_rowstride(mypixbuf)


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

Reply via email to