Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2005:
[Freeciv-Dev] (PR#12698) move building sprites into the tileset
Home

[Freeciv-Dev] (PR#12698) move building sprites into the tileset

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12698) move building sprites into the tileset
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 30 Mar 2005 16:43:25 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12698 >

This simple patch moves building sprites into the tileset.

Only the GTK client is updated.

-jason

Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.283
diff -u -r1.283 tilespec.c
--- client/tilespec.c   30 Mar 2005 23:06:52 -0000      1.283
+++ client/tilespec.c   31 Mar 2005 00:41:45 -0000
@@ -129,6 +129,7 @@
   } mask;
 
   struct sprite *tech[A_LAST];
+  struct sprite *building[B_LAST];
 
   struct citizen_graphic {
     /* Each citizen type has up to MAX_NUM_CITIZEN_SPRITES different
@@ -2235,10 +2236,11 @@
 {
   struct impr_type *pimpr = get_improvement_type(id);
 
-  pimpr->sprite = lookup_sprite_tag_alt(t, pimpr->graphic_str,
-                                       pimpr->graphic_alt,
-                                       FALSE, "impr_type",
-                                       pimpr->name);
+  assert(id >= 0 && id < game.num_impr_types);
+  t->sprites.building[id] = lookup_sprite_tag_alt(t, pimpr->graphic_str,
+                                                 pimpr->graphic_alt,
+                                                 FALSE, "impr_type",
+                                                 pimpr->name);
 
   /* should maybe do something if NULL, eg generic default? */
 }
@@ -4248,6 +4250,18 @@
 }
 
 /**************************************************************************
+  Return the sprite for the building/improvement.
+**************************************************************************/
+struct sprite *get_building_sprite(const struct tileset *t, Impr_Type_id b)
+{
+  if (b <= 0 || b >= game.num_impr_types) {
+    assert(0);
+    return NULL;
+  }
+  return t->sprites.building[b];
+}
+
+/**************************************************************************
   Return a "sample" sprite for this city style.
 **************************************************************************/
 struct sprite *get_sample_city_sprite(const struct tileset *t,
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.142
diff -u -r1.142 tilespec.h
--- client/tilespec.h   30 Mar 2005 23:06:52 -0000      1.142
+++ client/tilespec.h   31 Mar 2005 00:41:45 -0000
@@ -182,6 +182,7 @@
 struct sprite *get_nation_flag_sprite(const struct tileset *t,
                                      const struct nation_type *nation);
 struct sprite *get_tech_sprite(const struct tileset *t, Tech_Type_id tech);
+struct sprite *get_building_sprite(const struct tileset *t, Impr_Type_id b);
 struct sprite *get_sample_city_sprite(const struct tileset *t,
                                      int city_style);
 struct sprite *get_arrow_sprite(const struct tileset *t);
Index: client/gui-gtk-2.0/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/citydlg.c,v
retrieving revision 1.122
diff -u -r1.122 citydlg.c
--- client/gui-gtk-2.0/citydlg.c        28 Mar 2005 16:59:14 -0000      1.122
+++ client/gui-gtk-2.0/citydlg.c        31 Mar 2005 00:41:46 -0000
@@ -1579,10 +1579,8 @@
        name = unit_type->name;
        sprite = unit_type->sprite;
       } else {
-        struct impr_type *impr;
-        impr = get_improvement_type(id);
-       name = impr->name;
-       sprite = impr->sprite;
+       name = get_improvement_name(id);
+       sprite = get_building_sprite(tileset, id);
       }
       gtk_list_store_append(store, &iter);
       gtk_list_store_set(store, &iter, 0, sprite_get_pixbuf(sprite),
@@ -1619,17 +1617,17 @@
   for (item = 0; item < cids_used; item++) {
     GtkTreeIter it;
     int id, upkeep;
-    struct impr_type *impr;
+    struct sprite *sprite;
    
     id = cid_id(items[item].cid);
-    impr = get_improvement_type(id);
     /* This takes effects (like Adam Smith's) into account. */
     upkeep = improvement_upkeep(pdialog->pcity, id);
+    sprite = get_building_sprite(tileset, id);
 
     gtk_list_store_append(store, &it);
     gtk_list_store_set(store, &it,
        0, id,
-       1, sprite_get_pixbuf(impr->sprite),
+                      1, sprite_get_pixbuf(sprite),
        2, items[item].descr,
        3, upkeep,
        -1);
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/repodlgs.c,v
retrieving revision 1.81
diff -u -r1.81 repodlgs.c
--- client/gui-gtk-2.0/repodlgs.c       18 Mar 2005 11:26:24 -0000      1.81
+++ client/gui-gtk-2.0/repodlgs.c       31 Mar 2005 00:41:46 -0000
@@ -835,16 +835,16 @@
 
     for (i = 0; i < entries_used; i++) {
       struct improvement_entry *p = &entries[i];
-      struct impr_type *impr = get_improvement_type(p->type);
+      struct sprite *sprite = get_building_sprite(tileset, p->type);
 
       gtk_list_store_append(economy_store, &it);
       gtk_list_store_set(economy_store, &it,
-       0, sprite_get_pixbuf(impr->sprite),
+                        0, sprite_get_pixbuf(sprite),
        2, p->count,
        3, p->cost,
        4, p->total_cost, -1);
       g_value_init(&value, G_TYPE_STRING);
-      g_value_set_static_string(&value, impr->name);
+      g_value_set_static_string(&value, get_improvement_name(p->type));
       gtk_list_store_set_value(economy_store, &it, 1, &value);
       g_value_unset(&value);
 
Index: client/gui-gtk-2.0/wldlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/wldlg.c,v
retrieving revision 1.43
diff -u -r1.43 wldlg.c
--- client/gui-gtk-2.0/wldlg.c  23 Mar 2005 18:13:21 -0000      1.43
+++ client/gui-gtk-2.0/wldlg.c  31 Mar 2005 00:41:46 -0000
@@ -977,9 +977,9 @@
       g_object_set(rend, "pixbuf", pix, NULL);
       g_object_unref(pix);
     } else {
-      struct impr_type *impr = get_improvement_type(id);
+      struct sprite *sprite = get_building_sprite(tileset, id);
 
-      pix = sprite_get_pixbuf(impr->sprite);
+      pix = sprite_get_pixbuf(sprite);
       g_object_set(rend, "pixbuf", pix, NULL);
     }
   } else {
Index: common/improvement.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/improvement.h,v
retrieving revision 1.40
diff -u -r1.40 improvement.h
--- common/improvement.h        28 Mar 2005 16:59:15 -0000      1.40
+++ common/improvement.h        31 Mar 2005 00:41:46 -0000
@@ -79,7 +79,6 @@
   int build_cost;                      /* Use wrappers to access this. */
   int upkeep;
   int sabotage;                /* Base chance of diplomat sabotage succeeding. 
*/
-  struct sprite *sprite;               /* icon of the improvement */
   char *helptext;
   char soundtag[MAX_LEN_NAME];
   char soundtag_alt[MAX_LEN_NAME];

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12698) move building sprites into the tileset, Jason Short <=