[Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients:; |
Subject: |
[Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type |
From: |
"Jason Short via RT" <rt@xxxxxxxxxxxxxx> |
Date: |
Sun, 8 Dec 2002 21:01:18 -0800 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
On Sun, 2002-12-08 at 22:45, Jason Short via RT wrote:
> On Sun, 2002-12-08 at 10:12, Mike Kaufman via RT wrote:
> > On Sun, Dec 08, 2002 at 02:16:39AM -0800, Raimar Falke via RT wrote:
> > > >
> > > > Good point. Can we ever see enemy citizens? If so, a player parameter
> > > > is needed, which will be passed city_owner(pdialog->pcity) in most
> > > > cases.
> > >
> > > Yes. Diplomat investigating an enemy city.
> >
> > what, are we going to make them look mean? If this is the only time and
> > only reason, it's silly. Don't bother.
>
> Rafal's patch (PR#2495) provides different citizen sprites based on the
> city style. For this to work, get_citizen_sprite must know the player
> or the city that the citizen belongs to. More generally, this should
> work with most/all conceivable differentiations of citizens (including
> making "enemy" citizens look mean).
New patch attached. This adds pcity as a parameter to
get_citizen_sprite (reserved for future use...), as well as making the
other changes pointed out by Raimar.
jason
? client/gui-sdl/drawing.fig
Index: client//citydlg_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/citydlg_common.h,v
retrieving revision 1.5
diff -u -r1.5 citydlg_common.h
--- client//citydlg_common.h 2002/04/12 13:50:55 1.5
+++ client//citydlg_common.h 2002/12/09 04:40:12
@@ -20,6 +20,17 @@
struct city;
+enum citizen_type {
+ CITIZEN_ELVIS,
+ CITIZEN_SCIENTIST,
+ CITIZEN_TAXMAN,
+ CITIZEN_CONTENT,
+ CITIZEN_HAPPY,
+ CITIZEN_UNHAPPY,
+ CITIZEN_ANGRY,
+ T_LAST_CITIZEN
+};
+
void city_pos_to_canvas_pos(int city_x, int city_y, int *canvas_x, int
*canvas_y);
void canvas_pos_to_city_pos(int canvas_x, int canvas_y, int *map_x, int
*map_y);
Index: client//tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.92
diff -u -r1.92 tilespec.c
--- client//tilespec.c 2002/12/07 09:59:18 1.92
+++ client//tilespec.c 2002/12/09 04:40:12
@@ -554,6 +554,35 @@
}
/**********************************************************************
+ Returns a text name for the citizen, as used in the tileset.
+***********************************************************************/
+static const char *get_citizen_name(enum citizen_type citizen)
+{
+ /* These strings are used in reading the tileset. Do not
+ * translate. */
+ switch (citizen) {
+ case CITIZEN_ELVIS:
+ return "entertainer";
+ case CITIZEN_SCIENTIST:
+ return "scientist";
+ case CITIZEN_TAXMAN:
+ return "tax_collector";
+ case CITIZEN_HAPPY:
+ return "happy";
+ case CITIZEN_CONTENT:
+ return "content";
+ case CITIZEN_UNHAPPY:
+ return "unhappy";
+ case CITIZEN_ANGRY:
+ return "angry";
+ case T_LAST_CITIZEN:
+ break;
+ }
+ assert(0);
+ return "";
+}
+
+/**********************************************************************
Return string n0s0e0w0 such that INDEX_NSEW(n,s,e,w) = idx
The returned string is pointer to static memory.
***********************************************************************/
@@ -612,18 +641,28 @@
SET_SPRITE(coast_color, "t.coast_color");
}
- /* This uses internal code for citizens array/index: */
- SET_SPRITE(citizen[0], "citizen.entertainer");
- SET_SPRITE(citizen[1], "citizen.scientist");
- SET_SPRITE(citizen[2], "citizen.tax_collector");
- SET_SPRITE(citizen[3], "citizen.content_0");
- SET_SPRITE(citizen[4], "citizen.content_1");
- SET_SPRITE(citizen[5], "citizen.happy_0");
- SET_SPRITE(citizen[6], "citizen.happy_1");
- SET_SPRITE(citizen[7], "citizen.unhappy_0");
- SET_SPRITE(citizen[8], "citizen.unhappy_1");
- SET_SPRITE(citizen[9], "citizen.angry_0");
- SET_SPRITE(citizen[10], "citizen.angry_1");
+ /* Load the citizen sprite graphics. */
+ for (i = 0; i < NUM_TILES_CITIZEN; i++) {
+ my_snprintf(buffer, sizeof(buffer), "citizen.%s", get_citizen_name(i));
+ sprites.citizen[i].sprite[0] = hash_lookup_data(sprite_hash, buffer);
+ if (sprites.citizen[i].sprite[0]) {
+ /* If this form exists, use it as the only sprite. This allows
+ * backwards compatability with tilesets that use e.g.,
+ * citizen.entertainer. */
+ sprites.citizen[i].count = 1;
+ continue;
+ }
+ for (j = 0; j < NUM_TILES_CITIZEN; j++) {
+ my_snprintf(buffer, sizeof(buffer), "citizen.%s_%d",
+ get_citizen_name(i), j);
+ sprites.citizen[i].sprite[j] = hash_lookup_data(sprite_hash, buffer);
+ if (!sprites.citizen[i].sprite[j]) {
+ break;
+ }
+ }
+ sprites.citizen[i].count = j;
+ assert(j > 0);
+ }
SET_SPRITE(spaceship.solar_panels, "spaceship.solar_panels");
SET_SPRITE(spaceship.life_support, "spaceship.life_support");
@@ -2044,10 +2083,16 @@
}
/**************************************************************************
- Return a sprite for the given citizen.
+ Return a sprite for the given citizen. The citizen's type is given,
+ as well as their number (in the range [0..pcity->size)). The citizen's
+ city can be used to determine which sprite to use (a NULL value
+ indicates there is no city; i.e., the sprite is just being used as a
+ picture).
**************************************************************************/
-struct Sprite *get_citizen_sprite(int citizen)
+struct Sprite *get_citizen_sprite(enum citizen_type citizen,
+ int cnum, struct city *pcity)
{
- citizen = CLIP(0, citizen, NUM_TILES_CITIZEN - 1);
- return sprites.citizen[citizen];
+ assert(citizen >= 0 && citizen < NUM_TILES_CITIZEN);
+ cnum %= sprites.citizen[citizen].count;
+ return sprites.citizen[citizen].sprite[cnum];
}
Index: client//tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.33
diff -u -r1.33 tilespec.h
--- client//tilespec.h 2002/12/07 09:59:18 1.33
+++ client//tilespec.h 2002/12/09 04:40:12
@@ -21,6 +21,8 @@
#include "map.h" /* NUM_DIRECTION_NSEW */
#include "colors_g.h"
+
+#include "citydlg_common.h" /* enum citizen_type */
#include "options.h"
struct Sprite; /* opaque; gui-dep */
@@ -75,9 +77,10 @@
((w) ? BIT_WEST : 0))
#define NUM_TILES_PROGRESS 8
-#define NUM_TILES_CITIZEN 11
+#define NUM_TILES_CITIZEN T_LAST_CITIZEN
#define NUM_TILES_HP_BAR 11
#define NUM_TILES_DIGITS 10
+#define MAX_NUM_CITIZEN_SPRITES 6
/* This could be moved to common/map.h if there's more use for it. */
enum direction4 {
@@ -89,13 +92,19 @@
*bulb[NUM_TILES_PROGRESS],
*warming[NUM_TILES_PROGRESS],
*cooling[NUM_TILES_PROGRESS],
- *citizen[NUM_TILES_CITIZEN], /* internal code... */
*treaty_thumb[2], /* 0=disagree, 1=agree */
*right_arrow,
*black_tile, /* only used for isometric view */
*dither_tile, /* only used for isometric view */
*coast_color; /* only used for isometric view */
+
+ struct {
+ /* Each citizen type has up to MAX_NUM_CITIZEN_SPRITES different
+ * sprites, as defined by the tileset. */
+ int count;
+ struct Sprite *sprite[MAX_NUM_CITIZEN_SPRITES];
+ } citizen[NUM_TILES_CITIZEN];
struct {
struct Sprite
*solar_panels,
@@ -192,7 +201,8 @@
extern struct named_sprites sprites;
-struct Sprite *get_citizen_sprite(int citizen);
+struct Sprite *get_citizen_sprite(enum citizen_type citizen,
+ int cnum, struct city *pcity);
extern char current_tile_set_name[512];
Index: client//gui-gtk/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/citydlg.c,v
retrieving revision 1.147
diff -u -r1.147 citydlg.c
--- client//gui-gtk/citydlg.c 2002/12/05 22:22:34 1.147
+++ client//gui-gtk/citydlg.c 2002/12/09 04:40:13
@@ -1671,40 +1671,47 @@
i = 0; /* tracks the # of the citizen we are currently placing. */
for (n = 0; n < pcity->ppl_happy[4]; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(5 + i % 2), i * width, 0, TRUE);
+ get_citizen_sprite(CITIZEN_HAPPY, i, pcity),
+ i * width, 0, TRUE);
}
for (n = 0; n < pcity->ppl_content[4]; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(3 + i % 2), i * width, 0, TRUE);
+ get_citizen_sprite(CITIZEN_CONTENT, i, pcity),
+ i * width, 0, TRUE);
}
for (n = 0; n < pcity->ppl_unhappy[4]; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(7 + i % 2), i * width, 0, TRUE);
+ get_citizen_sprite(CITIZEN_UNHAPPY, i, pcity),
+ i * width, 0, TRUE);
}
for (n = 0; n < pcity->ppl_angry[4]; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(9 + i % 2), i * width, 0, TRUE);
+ get_citizen_sprite(CITIZEN_ANGRY, i, pcity),
+ i * width, 0, TRUE);
}
pdialog->first_elvis = i;
for (n = 0; n < pcity->ppl_elvis; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(0), i * width, 0, TRUE);
+ get_citizen_sprite(CITIZEN_ELVIS, i, pcity),
+ i * width, 0, TRUE);
}
pdialog->first_scientist = i;
for (n = 0; n < pcity->ppl_scientist; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(1), i * width, 0, TRUE);
+ get_citizen_sprite(CITIZEN_SCIENTIST, i, pcity),
+ i * width, 0, TRUE);
}
pdialog->first_taxman = i;
for (n = 0; n < pcity->ppl_taxman; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(2), i * width, 0, TRUE);
+ get_citizen_sprite(CITIZEN_TAXMAN, i, pcity),
+ i * width, 0, TRUE);
}
/* gtk_widget_set_sensitive(pdialog->citizen_pixmap,*/
/* !cma_is_city_under_agent(pcity, NULL));*/
Index: client//gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.121
diff -u -r1.121 gui_main.c
--- client//gui-gtk/gui_main.c 2002/11/30 20:04:19 1.121
+++ client//gui-gtk/gui_main.c 2002/12/09 04:40:13
@@ -641,6 +641,7 @@
/* citizens for taxrates */
for (i = 0; i < 10; i++) {
+ enum citizen_type c = i < 5 ? CITIZEN_SCIENTIST : CITIZEN_TAXMAN;
ebox = gtk_event_box_new();
gtk_widget_set_events(ebox, GDK_BUTTON_PRESS_MASK);
@@ -649,7 +650,7 @@
gtk_signal_connect(GTK_OBJECT(ebox), "button_press_event",
GTK_SIGNAL_FUNC(taxrates_callback), GINT_TO_POINTER(i));
- econ_label[i] = gtk_pixmap_new(get_citizen_pixmap(i < 5 ? 1 : 2), NULL);
+ econ_label[i] = gtk_pixmap_new(get_citizen_pixmap(c, i, NULL), NULL);
gtk_pixmap_set_build_insensitive(GTK_PIXMAP(econ_label[i]), FALSE);
gtk_container_add(GTK_CONTAINER(ebox), econ_label[i]);
}
@@ -664,7 +665,8 @@
flake_label = gtk_pixmap_new(sprites.cooling[0]->pixmap, NULL);
gtk_pixmap_set_build_insensitive(GTK_PIXMAP(flake_label), FALSE);
- government_label= gtk_pixmap_new(sprites.citizen[7]->pixmap, NULL);
+ government_label
+ = gtk_pixmap_new(get_citizen_pixmap(CITIZEN_UNHAPPY, 0, NULL), NULL);
gtk_pixmap_set_build_insensitive(GTK_PIXMAP(government_label), FALSE);
timeout_label = gtk_label_new("");
Index: client//gui-gtk/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/happiness.c,v
retrieving revision 1.9
diff -u -r1.9 happiness.c
--- client//gui-gtk/happiness.c 2002/11/15 21:24:28 1.9
+++ client//gui-gtk/happiness.c 2002/12/09 04:40:13
@@ -28,6 +28,7 @@
#include "gui_main.h"
#include "gui_stuff.h"
#include "happiness.h"
+#include "mapview.h"
#include "tilespec.h"
/* semi-arbitrary number that controls the width of the happiness widget */
@@ -158,7 +159,7 @@
static GdkPixmap *create_happiness_pixmap(struct city *pcity, int index)
{
int i;
- int citizen_type;
+ enum citizen_type citizen_type;
int n1 = pcity->ppl_happy[index];
int n2 = n1 + pcity->ppl_content[index];
int n3 = n2 + pcity->ppl_unhappy[index];
@@ -175,22 +176,22 @@
for (i = 0; i < num_citizens; i++) {
if (i < n1)
- citizen_type = 5 + i % 2;
+ citizen_type = CITIZEN_HAPPY;
else if (i < n2)
- citizen_type = 3 + i % 2;
+ citizen_type = CITIZEN_CONTENT;
else if (i < n3)
- citizen_type = 7 + i % 2;
+ citizen_type = CITIZEN_UNHAPPY;
else if (i < n4)
- citizen_type = 9 + i % 2;
+ citizen_type = CITIZEN_ANGRY;
else if (i < n5)
- citizen_type = 0;
+ citizen_type = CITIZEN_ELVIS;
else if (i < n6)
- citizen_type = 1;
+ citizen_type = CITIZEN_SCIENTIST;
else
- citizen_type = 2;
+ citizen_type = CITIZEN_TAXMAN;
gdk_draw_pixmap(happiness_pixmap, civ_gc,
- sprites.citizen[citizen_type]->pixmap,
+ get_citizen_pixmap(citizen_type, i, pcity),
0, 0, i * offset, 0, SMALL_TILE_WIDTH,
SMALL_TILE_HEIGHT);
}
Index: client//gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.142
diff -u -r1.142 mapview.c
--- client//gui-gtk/mapview.c 2002/12/07 09:59:18 1.142
+++ client//gui-gtk/mapview.c 2002/12/09 04:40:14
@@ -357,15 +357,15 @@
d=0;
for(;d<(game.player_ptr->economic.luxury)/10;d++)
gtk_pixmap_set(GTK_PIXMAP(econ_label[d]),
- get_citizen_pixmap(0), NULL ); /* elvis tile */
+ get_citizen_pixmap(CITIZEN_ELVIS, d, NULL), NULL);
for(;d<(game.player_ptr->economic.science+game.player_ptr->economic.luxury)/10;d++)
gtk_pixmap_set(GTK_PIXMAP(econ_label[d]),
- get_citizen_pixmap(1), NULL ); /* scientist tile */
+ get_citizen_pixmap(CITIZEN_SCIENTIST, d, NULL), NULL);
for(;d<10;d++)
gtk_pixmap_set(GTK_PIXMAP(econ_label[d]),
- get_citizen_pixmap(2), NULL ); /* taxman tile */
+ get_citizen_pixmap(CITIZEN_TAXMAN, d, NULL), NULL);
update_timeout_label();
}
@@ -445,10 +445,10 @@
/**************************************************************************
...
**************************************************************************/
-GdkPixmap *get_citizen_pixmap(int frame)
+GdkPixmap *get_citizen_pixmap(enum citizen_type type, int cnum,
+ struct city *pcity)
{
- frame = CLIP(0, frame, NUM_TILES_CITIZEN-1);
- return sprites.citizen[frame]->pixmap;
+ return get_citizen_sprite(type, cnum, pcity)->pixmap;
}
/**************************************************************************
@@ -468,7 +468,7 @@
if (game.government_count==0) {
/* not sure what to do here */
- gov_sprite = sprites.citizen[7];
+ gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
} else {
gov_sprite = get_government(gov)->sprite;
}
Index: client//gui-gtk/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.h,v
retrieving revision 1.14
diff -u -r1.14 mapview.h
--- client//gui-gtk/mapview.h 2002/12/07 09:59:18 1.14
+++ client//gui-gtk/mapview.h 2002/12/09 04:40:14
@@ -17,6 +17,7 @@
#include "gtkpixcomm.h"
+#include "citydlg_common.h"
#include "mapview_g.h"
#include "mapview_common.h"
@@ -26,7 +27,8 @@
struct city;
GdkPixmap *get_thumb_pixmap(int onoff);
-GdkPixmap *get_citizen_pixmap(int frame);
+GdkPixmap *get_citizen_pixmap(enum citizen_type type, int cnum,
+ struct city *pcity);
gint overview_canvas_expose(GtkWidget *w, GdkEventExpose *ev);
gint map_canvas_expose(GtkWidget *w, GdkEventExpose *ev);
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.16
diff -u -r1.16 citydlg.c
--- client//gui-gtk-2.0/citydlg.c 2002/12/05 22:22:34 1.16
+++ client//gui-gtk-2.0/citydlg.c 2002/12/09 04:40:14
@@ -1657,40 +1657,47 @@
i = 0; /* tracks the # of the citizen we are currently placing. */
for (n = 0; n < pcity->ppl_happy[4]; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(5 + i % 2), i * width, 0);
+ get_citizen_sprite(CITIZEN_HAPPY, i, pcity),
+ i * width, 0);
}
for (n = 0; n < pcity->ppl_content[4]; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(3 + i % 2), i * width, 0);
+ get_citizen_sprite(CITIZEN_CONTENT, i, pcity),
+ i * width, 0);
}
for (n = 0; n < pcity->ppl_unhappy[4]; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(7 + i % 2), i * width, 0);
+ get_citizen_sprite(CITIZEN_UNHAPPY, i, pcity),
+ i * width, 0);
}
for (n = 0; n < pcity->ppl_angry[4]; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(9 + i % 2), i * width, 0);
+ get_citizen_sprite(CITIZEN_ANGRY, i, pcity),
+ i * width, 0);
}
pdialog->first_elvis = i;
for (n = 0; n < pcity->ppl_elvis; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(0), i * width, 0);
+ get_citizen_sprite(CITIZEN_ELVIS, i, pcity),
+ i * width, 0);
}
pdialog->first_scientist = i;
for (n = 0; n < pcity->ppl_scientist; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(1), i * width, 0);
+ get_citizen_sprite(CITIZEN_SCIENTIST, i, pcity),
+ i * width, 0);
}
pdialog->first_taxman = i;
for (n = 0; n < pcity->ppl_taxman; n++, i++) {
gtk_pixcomm_copyto(GTK_PIXCOMM(pdialog->citizen_pixmap),
- get_citizen_sprite(2), i * width, 0);
+ get_citizen_sprite(CITIZEN_TAXMAN, i, pcity),
+ i * width, 0);
}
gtk_pixcomm_thaw(GTK_PIXCOMM(pdialog->citizen_pixmap));
Index: client//gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.33
diff -u -r1.33 gui_main.c
--- client//gui-gtk-2.0/gui_main.c 2002/11/30 20:06:49 1.33
+++ client//gui-gtk-2.0/gui_main.c 2002/12/09 04:40:16
@@ -727,6 +727,7 @@
/* citizens for taxrates */
for (i = 0; i < 10; i++) {
+ enum citizen_type c = i < 5 ? CITIZEN_SCIENTIST : CITIZEN_TAXMAN;
ebox = gtk_event_box_new();
gtk_widget_add_events(ebox, GDK_BUTTON_PRESS_MASK);
@@ -735,7 +736,7 @@
g_signal_connect(ebox, "button_press_event",
G_CALLBACK(taxrates_callback), GINT_TO_POINTER(i));
- econ_label[i] = gtk_image_new_from_pixmap(get_citizen_pixmap(i < 5 ? 1 :
2),
+ econ_label[i] = gtk_image_new_from_pixmap(get_citizen_pixmap(c, i, NULL),
NULL);
gtk_container_add(GTK_CONTAINER(ebox), econ_label[i]);
}
@@ -744,8 +745,9 @@
bulb_label = gtk_image_new_from_pixmap(sprites.bulb[0]->pixmap, NULL);
sun_label = gtk_image_new_from_pixmap(sprites.warming[0]->pixmap, NULL);
flake_label = gtk_image_new_from_pixmap(sprites.cooling[0]->pixmap, NULL);
- government_label = gtk_image_new_from_pixmap(sprites.citizen[7]->pixmap,
- NULL);
+ government_label
+ = gtk_image_new_from_pixmap(get_citizen_pixmap(CITIZEN_UNHAPPY, 0, NULL),
+ NULL);
for (i = 0; i < 4; i++) {
GtkWidget *w;
Index: client//gui-gtk-2.0/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/happiness.c,v
retrieving revision 1.4
diff -u -r1.4 happiness.c
--- client//gui-gtk-2.0/happiness.c 2002/11/14 09:14:55 1.4
+++ client//gui-gtk-2.0/happiness.c 2002/12/09 04:40:16
@@ -28,6 +28,7 @@
#include "gui_main.h"
#include "gui_stuff.h"
#include "happiness.h"
+#include "mapview.h"
#include "tilespec.h"
/* semi-arbitrary number that controls the width of the happiness widget */
@@ -145,7 +146,7 @@
static GdkPixmap *create_happiness_pixmap(struct city *pcity, int index)
{
int i;
- int citizen_type;
+ enum citizen_type citizen_type;
int n1 = pcity->ppl_happy[index];
int n2 = n1 + pcity->ppl_content[index];
int n3 = n2 + pcity->ppl_unhappy[index];
@@ -162,22 +163,22 @@
for (i = 0; i < num_citizens; i++) {
if (i < n1)
- citizen_type = 5 + i % 2;
+ citizen_type = CITIZEN_HAPPY;
else if (i < n2)
- citizen_type = 3 + i % 2;
+ citizen_type = CITIZEN_CONTENT;
else if (i < n3)
- citizen_type = 7 + i % 2;
+ citizen_type = CITIZEN_UNHAPPY;
else if (i < n4)
- citizen_type = 9 + i % 2;
+ citizen_type = CITIZEN_ANGRY;
else if (i < n5)
- citizen_type = 0;
+ citizen_type = CITIZEN_ELVIS;
else if (i < n6)
- citizen_type = 1;
+ citizen_type = CITIZEN_SCIENTIST;
else
- citizen_type = 2;
+ citizen_type = CITIZEN_TAXMAN;
gdk_draw_pixmap(happiness_pixmap, civ_gc,
- sprites.citizen[citizen_type]->pixmap,
+ get_citizen_pixmap(citizen_type, i, pcity),
0, 0, i * offset, 0, SMALL_TILE_WIDTH,
SMALL_TILE_HEIGHT);
}
Index: client//gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.30
diff -u -r1.30 mapview.c
--- client//gui-gtk-2.0/mapview.c 2002/12/07 09:59:18 1.30
+++ client//gui-gtk-2.0/mapview.c 2002/12/09 04:40:16
@@ -356,15 +356,18 @@
d=0;
for(;d<(game.player_ptr->economic.luxury)/10;d++)
gtk_image_set_from_pixmap(GTK_IMAGE(econ_label[d]),
- get_citizen_pixmap(0), NULL); /* elvis tile */
+ get_citizen_pixmap(CITIZEN_ELVIS, d, NULL),
+ NULL);
for(;d<(game.player_ptr->economic.science+game.player_ptr->economic.luxury)/10;d++)
gtk_image_set_from_pixmap(GTK_IMAGE(econ_label[d]),
- get_citizen_pixmap(1), NULL); /* scientist tile */
+ get_citizen_pixmap(CITIZEN_SCIENTIST, d, NULL),
+ NULL);
for(;d<10;d++)
gtk_image_set_from_pixmap(GTK_IMAGE(econ_label[d]),
- get_citizen_pixmap(2), NULL); /* taxman tile */
+ get_citizen_pixmap(CITIZEN_TAXMAN, d, NULL),
+ NULL);
update_timeout_label();
}
@@ -444,10 +447,10 @@
/**************************************************************************
...
**************************************************************************/
-GdkPixmap *get_citizen_pixmap(int frame)
+GdkPixmap *get_citizen_pixmap(enum citizen_type type, int cnum,
+ struct city *pcity)
{
- frame = CLIP(0, frame, NUM_TILES_CITIZEN-1);
- return sprites.citizen[frame]->pixmap;
+ return get_citizen_sprite(type, cnum, pcity)->pixmap;
}
/**************************************************************************
@@ -470,7 +473,7 @@
if (game.government_count==0) {
/* not sure what to do here */
- gov_sprite = sprites.citizen[7];
+ gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
} else {
gov_sprite = get_government(gov)->sprite;
}
Index: client//gui-gtk-2.0/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.h,v
retrieving revision 1.5
diff -u -r1.5 mapview.h
--- client//gui-gtk-2.0/mapview.h 2002/12/07 09:59:18 1.5
+++ client//gui-gtk-2.0/mapview.h 2002/12/09 04:40:16
@@ -17,6 +17,7 @@
#include "gtkpixcomm.h"
+#include "citydlg_common.h"
#include "mapview_g.h"
#include "mapview_common.h"
@@ -26,7 +27,8 @@
struct city;
GdkPixmap *get_thumb_pixmap(int onoff);
-GdkPixmap *get_citizen_pixmap(int frame);
+GdkPixmap *get_citizen_pixmap(enum citizen_type type, int cnum,
+ struct city *pcity);
gboolean overview_canvas_expose(GtkWidget *w, GdkEventExpose *ev, gpointer
data);
gboolean map_canvas_expose(GtkWidget *w, GdkEventExpose *ev, gpointer data);
Index: client//gui-mui/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/citydlg.c,v
retrieving revision 1.58
diff -u -r1.58 citydlg.c
--- client//gui-mui/citydlg.c 2002/11/14 09:14:56 1.58
+++ client//gui-mui/citydlg.c 2002/12/09 04:40:16
@@ -1950,14 +1950,14 @@
for (n = 0; n < pcity->ppl_happy[4]; n++)
{
- Object *o = MakeSprite(get_citizen_sprite(5 + n % 2));
+ Object *o = MakeSprite(get_citizen_sprite(CITIZEN_HAPPY, n, pcity));
if (o)
DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
}
for (n = 0; n < pcity->ppl_content[4]; n++)
{
- Object *o = MakeSprite(get_citizen_sprite(3 + n % 2));
+ Object *o = MakeSprite(get_citizen_sprite(CITIZEN_CONTENT, n, pcity));
if (o)
DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
}
@@ -1965,20 +1965,20 @@
for (n = 0; n < pcity->ppl_unhappy[4]; n++)
{
- Object *o = MakeSprite(get_citizen_sprite(7 + n % 2));
+ Object *o = MakeSprite(get_citizen_sprite(CITIZEN_UNHAPPY, n, pcity));
if (o)
DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
}
for (n = 0; n < pcity->ppl_angry[4]; n++) {
- Object *o = MakeSprite(get_citizen_sprite(9 + n % 2));
+ Object *o = MakeSprite(get_citizen_sprite(CITIZEN_ANGRY, n, pcity));
if (o)
DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
}
for (n = 0; n < pcity->ppl_elvis; n++)
{
- Object *o = MakeSprite(get_citizen_sprite(0));
+ Object *o = MakeSprite(get_citizen_sprite(CITIZEN_ELVIS, n, pcity));
if (o)
{
DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
@@ -1988,7 +1988,7 @@
for (n = 0; n < pcity->ppl_scientist; n++)
{
- Object *o = MakeSprite(get_citizen_sprite(1));
+ Object *o = MakeSprite(get_citizen_sprite(CITIZEN_SCIENTIST, n, pcity));
if (o)
{
DoMethod(pdialog->citizen2_group, OM_ADDMEMBER, o);
@@ -1998,7 +1998,7 @@
for (n = 0; n < pcity->ppl_taxman; n++)
{
- Object *o = MakeSprite(get_citizen_sprite(2));
+ Object *o = MakeSprite(get_citizen_sprite(CITIZEN_TAXMAN, n, pcity));
if (o)
{
@@ -2493,8 +2493,9 @@
int n1 = pcity->ppl_happy[i];
int n2 = n1 + pcity->ppl_content[i];
int n3 = n2 + pcity->ppl_unhappy[i];
- int n4 = n3 + pcity->ppl_elvis;
- int n5 = n4 + pcity->ppl_scientist;
+ int n4 = n3 + pcity->ppl_angry[i];
+ int n5 = n4 + pcity->ppl_elvis;
+ int n6 = n5 + pcity->ppl_scientist;
int num_citizens = pcity->size;
DoMethod(pdialog->happiness_citizen_group[i],MUIM_Group_InitChange);
@@ -2504,19 +2505,22 @@
int citizen_type;
Object *obj;
if (j < n1)
- citizen_type = 5 + j % 2;
+ citizen_type = CITIZEN_HAPPY;
else if (j < n2)
- citizen_type = 3 + j % 2;
+ citizen_type = CITIZEN_CONTENT;
else if (j < n3)
- citizen_type = 7 + j % 2;
- else if (j < n4)
- citizen_type = 0;
- else if (j < n5)
- citizen_type = 1;
- else
- citizen_type = 2;
+ citizen_type = CITIZEN_UNHAPPY;
+ else if (j < n4) {
+ citizen_type = CITIZEN_ANGRY;
+ } else if (j < n5) {
+ citizen_type = CITIZEN_ELVIS;
+ } else if (j < n6) {
+ citizen_type = CITIZEN_SCIENTIST;
+ } else {
+ citizen_type = CITIZEN_TAXMAN;
+ }
- if ((obj = MakeSprite(get_citizen_sprite(citizen_type))))
+ if ((obj = MakeSprite(get_citizen_sprite(citizen_type, j, pcity))))
{
DoMethod(pdialog->happiness_citizen_group[i], OM_ADDMEMBER, obj);
}
Index: client//gui-mui/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/gui_main.c,v
retrieving revision 1.67
diff -u -r1.67 gui_main.c
--- client//gui-mui/gui_main.c 2002/11/14 09:22:09 1.67
+++ client//gui-mui/gui_main.c 2002/12/09 04:40:16
@@ -1380,7 +1380,8 @@
main_bulb_sprite = MakeBorderSprite(sprites.bulb[0]);
main_sun_sprite = MakeBorderSprite(sprites.warming[0]);
main_flake_sprite = MakeBorderSprite(sprites.cooling[0]);
- main_government_sprite = MakeBorderSprite(sprites.citizen[7]);
+ main_government_sprite
+ = MakeBorderSprite(get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL));
main_timeout_text = TextObject, End;
econ_group = HGroup, GroupSpacing(0), End;
Index: client//gui-mui/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/mapview.c,v
retrieving revision 1.51
diff -u -r1.51 mapview.c
--- client//gui-mui/mapview.c 2002/11/29 10:01:58 1.51
+++ client//gui-mui/mapview.c 2002/12/09 04:40:16
@@ -223,13 +223,16 @@
d = 0;
for (; d < (game.player_ptr->economic.luxury) / 10; d++)
- set(main_econ_sprite[d], MUIA_Sprite_Sprite, get_citizen_sprite(0));
+ set(main_econ_sprite[d], MUIA_Sprite_Sprite,
+ get_citizen_sprite(CITIZEN_ELVIS, d, NULL));
for (; d < (game.player_ptr->economic.science +
game.player_ptr->economic.luxury) / 10; d++)
- set(main_econ_sprite[d], MUIA_Sprite_Sprite, get_citizen_sprite(1));
+ set(main_econ_sprite[d], MUIA_Sprite_Sprite,
+ get_citizen_sprite(CITIZEN_SCIENTIST, d, NULL));
for (; d < 10; d++)
- set(main_econ_sprite[d], MUIA_Sprite_Sprite, get_citizen_sprite(2));
+ set(main_econ_sprite[d], MUIA_Sprite_Sprite,
+ get_citizen_sprite(CITIZEN_TAXMAN, d, NULL));
update_timeout_label();
}
@@ -353,7 +356,7 @@
if (game.government_count == 0)
{
/* not sure what to do here */
- gov_sprite = sprites.citizen[7];
+ gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
}
else
{
Index: client//gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.1
diff -u -r1.1 mapview.c
--- client//gui-sdl/mapview.c 2002/12/02 08:47:03 1.1
+++ client//gui-sdl/mapview.c 2002/12/09 04:40:16
@@ -762,7 +762,7 @@
struct Sprite *sprite = NULL;
if (game.government_count == 0) {
/* not sure what to do here */
- sprite = sprites.citizen[7];
+ sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
} else {
sprite = get_government(gov)->sprite;
}
Index: client//gui-win32/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/citydlg.c,v
retrieving revision 1.39
diff -u -r1.39 citydlg.c
--- client//gui-win32/citydlg.c 2002/11/14 09:14:59 1.39
+++ client//gui-win32/citydlg.c 2002/12/09 04:40:17
@@ -94,7 +94,7 @@
int present_y;
Impr_Type_id sell_id;
- int citizen_type[NUM_CITIZENS_SHOWN];
+ enum citizen_type citizen_type[NUM_CITIZENS_SHOWN];
int support_unit_ids[NUM_UNITS_SHOWN];
int present_unit_ids[NUM_UNITS_SHOWN];
int change_list_ids[B_LAST+1+U_LAST+1];
@@ -614,46 +614,46 @@
for(i=0, n=0; n<pcity->ppl_happy[4] && i<NUM_CITIZENS_SHOWN; n++, i++)
- if(pdialog->citizen_type[i]!=5 && pdialog->citizen_type[i]!=6) {
- pdialog->citizen_type[i]=5+i%2;
- draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+ if (pdialog->citizen_type[i] != CITIZEN_HAPPY) {
+ pdialog->citizen_type[i] = CITIZEN_HAPPY;
+ draw_sprite(get_citizen_sprite(CITIZEN_HAPPY, i, pcity), citydlgdc,
SMALL_TILE_WIDTH*i,0);
}
for(n=0; n<pcity->ppl_content[4] && i<NUM_CITIZENS_SHOWN; n++, i++)
- if(pdialog->citizen_type[i]!=3 && pdialog->citizen_type[i]!=4) {
- pdialog->citizen_type[i]=3+i%2;
- draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+ if (pdialog->citizen_type[i] != CITIZEN_CONTENT) {
+ pdialog->citizen_type[i] = CITIZEN_CONTENT;
+ draw_sprite(get_citizen_sprite(CITIZEN_CONTENT, i, pcity), citydlgdc,
SMALL_TILE_WIDTH*i,0);
}
for(n=0; n<pcity->ppl_unhappy[4] && i<NUM_CITIZENS_SHOWN; n++, i++)
- if(pdialog->citizen_type[i]!=7 && pdialog->citizen_type[i]!=8) {
- pdialog->citizen_type[i]=7+i%2;
- draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+ if (pdialog->citizen_type[i] != CITIZEN_UNHAPPY) {
+ pdialog->citizen_type[i] = CITIZEN_UNHAPPY;
+ draw_sprite(get_citizen_sprite(CITIZEN_UNHAPPY, i, pcity), citydlgdc,
SMALL_TILE_WIDTH*i,0);
}
for (n = 0; n < pcity->ppl_angry[4] && i < NUM_CITIZENS_SHOWN; n++, i++)
- if (pdialog->citizen_type[i] != 9 && pdialog->citizen_type[i] != 10) {
- pdialog->citizen_type[i] = 9 + i % 2;
- draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]), citydlgdc,
+ if (pdialog->citizen_type[i] != CITIZEN_ANGRY) {
+ pdialog->citizen_type[i] = CITIZEN_ANGRY;
+ draw_sprite(get_citizen_sprite(CITIZEN_ANGRY, i, pcity), citydlgdc,
SMALL_TILE_WIDTH * i, 0);
}
for(n=0; n<pcity->ppl_elvis && i<NUM_CITIZENS_SHOWN; n++, i++)
- if(pdialog->citizen_type[i]!=0) {
- pdialog->citizen_type[i]=0;
- draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+ if (pdialog->citizen_type[i] != CITIZEN_ELVIS) {
+ pdialog->citizen_type[i] = CITIZEN_ELVIS;
+ draw_sprite(get_citizen_sprite(CITIZEN_ELVIS, i, pcity), citydlgdc,
SMALL_TILE_WIDTH*i,0);
}
for(n=0; n<pcity->ppl_scientist && i<NUM_CITIZENS_SHOWN; n++, i++)
- if(pdialog->citizen_type[i]!=1) {
- pdialog->citizen_type[i]=1;
- draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+ if (pdialog->citizen_type[i] != CITIZEN_SCIENTIST) {
+ pdialog->citizen_type[i] = CITIZEN_SCIENTIST;
+ draw_sprite(get_citizen_sprite(CITIZEN_SCIENTIST, i, pcity), citydlgdc,
SMALL_TILE_WIDTH*i,0);
}
for(n=0; n<pcity->ppl_taxman && i<NUM_CITIZENS_SHOWN; n++, i++)
- if(pdialog->citizen_type[i]!=2) {
- pdialog->citizen_type[i]=2;
- draw_sprite(get_citizen_sprite(pdialog->citizen_type[i]),citydlgdc,
+ if (pdialog->citizen_type[i] != CITIZEN_TAXMAN) {
+ pdialog->citizen_type[i] = CITIZEN_TAXMAN;
+ draw_sprite(get_citizen_sprite(CITIZEN_TAXMAN, i, pcity), citydlgdc,
SMALL_TILE_WIDTH*i,0);
}
Index: client//gui-win32/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/happiness.c,v
retrieving revision 1.3
diff -u -r1.3 happiness.c
--- client//gui-win32/happiness.c 2002/11/14 09:14:59 1.3
+++ client//gui-win32/happiness.c 2002/12/09 04:40:17
@@ -392,7 +392,7 @@
HBITMAP old;
RECT rc;
int i;
- int citizen_type;
+ enum citizen_type citizen_type;
int n1 = pcity->ppl_happy[index];
int n2 = n1 + pcity->ppl_content[index];
int n3 = n2 + pcity->ppl_unhappy[index];
@@ -412,21 +412,21 @@
FillRect(hdc,&rc,(HBRUSH)GetClassLong(root_window,GCL_HBRBACKGROUND));
for (i = 0; i < num_citizens; i++) {
if (i < n1)
- citizen_type = 5 + i % 2;
+ citizen_type = CITIZEN_HAPPY;
else if (i < n2)
- citizen_type = 3 + i % 2;
+ citizen_type = CITIZEN_CONTENT;
else if (i < n3)
- citizen_type = 7 + i % 2;
+ citizen_type = CITIZEN_UNHAPPY;
else if (i < n4)
- citizen_type = 9 + i % 2;
+ citizen_type = CITIZEN_ANGRY;
else if (i < n5)
- citizen_type = 0;
+ citizen_type = CITIZEN_ELVIS;
else if (i < n6)
- citizen_type = 1;
+ citizen_type = CITIZEN_SCIENTIST;
else
- citizen_type = 2;
- draw_sprite(sprites.citizen[citizen_type],hdc,
- i*offset,0);
+ citizen_type = CITIZEN_TAXMAN;
+ draw_sprite(get_citizen_sprite(citizen_type, i, pcity),
+ hdc, i * offset, 0);
}
SelectObject(hdc,old);
DeleteDC(hdc);
Index: client//gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.43
diff -u -r1.43 mapview.c
--- client//gui-win32/mapview.c 2002/12/07 09:59:18 1.43
+++ client//gui-win32/mapview.c 2002/12/09 04:40:18
@@ -430,13 +430,13 @@
int d;
d=0;
for(;d<(game.player_ptr->economic.luxury)/10;d++)
- draw_sprite(get_citizen_sprite(0), hdc,
+ draw_sprite(get_citizen_sprite(CITIZEN_ELVIS, d, NULL), hdc,
SMALL_TILE_WIDTH*d,taxinfoline_y);/* elvis tile */
for(;d<(game.player_ptr->economic.science+game.player_ptr->economic.luxury)/10;d++)
- draw_sprite(get_citizen_sprite(1), hdc,
+ draw_sprite(get_citizen_sprite(CITIZEN_SCIENTIST, d, NULL), hdc,
SMALL_TILE_WIDTH*d,taxinfoline_y); /* scientist tile */
for(;d<10;d++)
- draw_sprite(get_citizen_sprite(2), hdc,
+ draw_sprite(get_citizen_sprite(CITIZEN_TAXMAN, d, NULL), hdc,
SMALL_TILE_WIDTH*d,taxinfoline_y); /* taxman tile */
}
@@ -556,7 +556,7 @@
indicator_sprite[2]=sprites.cooling[flake];
if (game.government_count==0) {
/* not sure what to do here */
- indicator_sprite[3] = sprites.citizen[7];
+ indicator_sprite[3] = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
} else {
indicator_sprite[3] = get_government(gov)->sprite;
}
Index: client//gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.83
diff -u -r1.83 citydlg.c
--- client//gui-xaw/citydlg.c 2002/11/15 21:24:29 1.83
+++ client//gui-xaw/citydlg.c 2002/12/09 04:40:18
@@ -114,7 +114,7 @@
Impr_Type_id sell_id;
- int *citizen_type;
+ enum citizen_type *citizen_type;
int support_unit_base;
int present_unit_base;
char improvlist_names[B_LAST+1][64];
@@ -544,7 +544,8 @@
pdialog->main_form,
XtNfromVert,
pdialog->cityname_label,
- XtNbitmap, get_citizen_pixmap(2),
+ XtNbitmap,
+ get_citizen_pixmap(CITIZEN_TAXMAN, 0, pcity),
NULL);
@@ -931,7 +932,7 @@
pdialog->citizen_labels=
fc_malloc(pdialog->num_citizens_shown * sizeof(Widget));
pdialog->citizen_type=
- fc_malloc(pdialog->num_citizens_shown * sizeof(int));
+ fc_malloc(pdialog->num_citizens_shown * sizeof(*pdialog->citizen_type));
pdialog->support_unit_pixcomms=
fc_malloc(pdialog->num_units_shown * sizeof(Widget));
@@ -948,7 +949,8 @@
XtNfromVert, pdialog->cityname_label,
XtNfromHoriz,
(XtArgVal)pdialog->citizen_labels[i-1],
- XtNbitmap, get_citizen_pixmap(2),
+ XtNbitmap,
+ get_citizen_pixmap(CITIZEN_TAXMAN, 0, pcity),
NULL);
@@ -1048,9 +1050,10 @@
for(i=0; i<B_LAST+1; i++)
pdialog->improvlist_names_ptrs[i]=0;
- for(i=0; i<pdialog->num_citizens_shown; i++)
- pdialog->citizen_type[i]=-1;
-
+ for (i = 0; i < pdialog->num_citizens_shown; i++) {
+ /* Initialize to an invalid value to trigger an assert if it's used */
+ pdialog->citizen_type[i] = T_LAST_CITIZEN;
+ }
XtRealizeWidget(pdialog->shell);
@@ -1581,30 +1584,30 @@
i=0;
for(n=0; n<pcity->ppl_happy[4] && i<pdialog->num_citizens_shown; n++, i++)
- if(pdialog->citizen_type[i]!=5 && pdialog->citizen_type[i]!=6) {
- pdialog->citizen_type[i]=5+i%2;
+ if (pdialog->citizen_type[i] != CITIZEN_HAPPY) {
+ pdialog->citizen_type[i] = CITIZEN_HAPPY;
xaw_set_bitmap(pdialog->citizen_labels[i],
- get_citizen_pixmap(pdialog->citizen_type[i]));
+ get_citizen_pixmap(CITIZEN_HAPPY, i, pcity));
XtSetSensitive(pdialog->citizen_labels[i], FALSE);
XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
}
if(n<pcity->ppl_happy[4]) goto city_dialog_update_citizens_overflow;
for(n=0; n<pcity->ppl_content[4] && i<pdialog->num_citizens_shown; n++, i++)
- if(pdialog->citizen_type[i]!=3 && pdialog->citizen_type[i]!=4) {
- pdialog->citizen_type[i]=3+i%2;
+ if (pdialog->citizen_type[i] != CITIZEN_CONTENT) {
+ pdialog->citizen_type[i] = CITIZEN_CONTENT;
xaw_set_bitmap(pdialog->citizen_labels[i],
- get_citizen_pixmap(pdialog->citizen_type[i]));
+ get_citizen_pixmap(CITIZEN_CONTENT, i, pcity));
XtSetSensitive(pdialog->citizen_labels[i], FALSE);
XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
}
if(n<pcity->ppl_content[4]) goto city_dialog_update_citizens_overflow;
for(n=0; n<pcity->ppl_unhappy[4] && i<pdialog->num_citizens_shown; n++, i++)
- if(pdialog->citizen_type[i]!=7 && pdialog->citizen_type[i]!=8) {
- pdialog->citizen_type[i]=7+i%2;
+ if (pdialog->citizen_type[i] != CITIZEN_UNHAPPY) {
+ pdialog->citizen_type[i] = CITIZEN_UNHAPPY;
xaw_set_bitmap(pdialog->citizen_labels[i],
- get_citizen_pixmap(pdialog->citizen_type[i]));
+ get_citizen_pixmap(CITIZEN_UNHAPPY, i, pcity));
XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
XtSetSensitive(pdialog->citizen_labels[i], FALSE);
}
@@ -1612,10 +1615,10 @@
for (n = 0; n < pcity->ppl_angry[4] && i < pdialog->num_citizens_shown;
n++, i++)
- if (pdialog->citizen_type[i] != 9 && pdialog->citizen_type[i] != 10) {
- pdialog->citizen_type[i] = 9 + i % 2;
+ if (pdialog->citizen_type[i] != CITIZEN_ANGRY) {
+ pdialog->citizen_type[i] = CITIZEN_ANGRY;
xaw_set_bitmap(pdialog->citizen_labels[i],
- get_citizen_pixmap(pdialog->citizen_type[i]));
+ get_citizen_pixmap(CITIZEN_ANGRY, i, pcity));
XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
XtSetSensitive(pdialog->citizen_labels[i], FALSE);
}
@@ -1623,9 +1626,10 @@
goto city_dialog_update_citizens_overflow;
for(n=0; n<pcity->ppl_elvis && i<pdialog->num_citizens_shown; n++, i++)
- if(pdialog->citizen_type[i]!=0) {
- xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(0));
- pdialog->citizen_type[i]=0;
+ if (pdialog->citizen_type[i] != CITIZEN_ELVIS) {
+ xaw_set_bitmap(pdialog->citizen_labels[i],
+ get_citizen_pixmap(CITIZEN_ELVIS, i, pcity));
+ pdialog->citizen_type[i] = CITIZEN_ELVIS;
XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
XtAddCallback(pdialog->citizen_labels[i], XtNcallback, elvis_callback,
(XtPointer)pdialog);
@@ -1634,9 +1638,10 @@
if(n<pcity->ppl_elvis) goto city_dialog_update_citizens_overflow;
for(n=0; n<pcity->ppl_scientist && i<pdialog->num_citizens_shown; n++, i++)
- if(pdialog->citizen_type[i]!=1) {
- xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(1));
- pdialog->citizen_type[i]=1;
+ if (pdialog->citizen_type[i] != CITIZEN_SCIENTIST) {
+ xaw_set_bitmap(pdialog->citizen_labels[i],
+ get_citizen_pixmap(CITIZEN_SCIENTIST, i, pcity));
+ pdialog->citizen_type[i] = CITIZEN_SCIENTIST;
XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
XtAddCallback(pdialog->citizen_labels[i], XtNcallback,
scientist_callback,
(XtPointer)pdialog);
@@ -1645,9 +1650,10 @@
if(n<pcity->ppl_scientist) goto city_dialog_update_citizens_overflow;
for(n=0; n<pcity->ppl_taxman && i<pdialog->num_citizens_shown; n++, i++)
- if(pdialog->citizen_type[i]!=2) {
- xaw_set_bitmap(pdialog->citizen_labels[i], get_citizen_pixmap(2));
- pdialog->citizen_type[i]=2;
+ if (pdialog->citizen_type[i] != CITIZEN_TAXMAN) {
+ xaw_set_bitmap(pdialog->citizen_labels[i],
+ get_citizen_pixmap(CITIZEN_TAXMAN, i, pcity));
+ pdialog->citizen_type[i] = CITIZEN_TAXMAN;
XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
XtAddCallback(pdialog->citizen_labels[i], XtNcallback, taxman_callback,
(XtPointer)pdialog);
Index: client//gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.73
diff -u -r1.73 gui_main.c
--- client//gui-xaw/gui_main.c 2002/11/14 09:15:00 1.73
+++ client//gui-xaw/gui_main.c 2002/12/09 04:40:18
@@ -411,8 +411,9 @@
/* Do this outside setup_widgets() so after tiles are loaded */
for(i=0;i<10;i++) {
+ enum citizen_type c = i < 5 ? CITIZEN_SCIENTIST : CITIZEN_TAXMAN;
XtVaSetValues(econ_label[i], XtNbitmap,
- get_citizen_pixmap(i<5?1:2), NULL);
+ get_citizen_pixmap(c, i, NULL), NULL);
XtAddCallback(econ_label[i], XtNcallback, taxrates_callback,
INT_TO_XTPOINTER(i));
}
Index: client//gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.112
diff -u -r1.112 mapview.c
--- client//gui-xaw/mapview.c 2002/12/06 22:25:12 1.112
+++ client//gui-xaw/mapview.c 2002/12/09 04:40:18
@@ -234,13 +234,16 @@
d=0;
for(;d<(game.player_ptr->economic.luxury)/10;d++)
- xaw_set_bitmap(econ_label[d], get_citizen_pixmap(0) ); /* elvis tile */
+ xaw_set_bitmap(econ_label[d],
+ get_citizen_pixmap(CITIZEN_ELVIS, d, NULL));
for(;d<(game.player_ptr->economic.science+game.player_ptr->economic.luxury)/10;d++)
- xaw_set_bitmap(econ_label[d], get_citizen_pixmap(1) ); /* scientist tile */
+ xaw_set_bitmap(econ_label[d],
+ get_citizen_pixmap(CITIZEN_SCIENTIST, d, NULL));
for(;d<10;d++)
- xaw_set_bitmap(econ_label[d], get_citizen_pixmap(2) ); /* taxman tile */
+ xaw_set_bitmap(econ_label[d],
+ get_citizen_pixmap(CITIZEN_TAXMAN, d, NULL));
update_timeout_label();
}
@@ -311,10 +314,10 @@
/**************************************************************************
...
**************************************************************************/
-Pixmap get_citizen_pixmap(int frame)
+Pixmap get_citizen_pixmap(enum citizen_type type, int cnum,
+ struct city *pcity)
{
- frame = CLIP(0, frame, NUM_TILES_CITIZEN-1);
- return sprites.citizen[frame]->pixmap;
+ return get_citizen_sprite(type, cnum, pcity)->pixmap;
}
@@ -335,7 +338,7 @@
if (game.government_count==0) {
/* not sure what to do here */
- gov_sprite = sprites.citizen[7];
+ gov_sprite = get_citizen_sprite(CITIZEN_UNHAPPY, 0, NULL);
} else {
gov_sprite = get_government(gov)->sprite;
}
Index: client//gui-xaw/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.h,v
retrieving revision 1.11
diff -u -r1.11 mapview.h
--- client//gui-xaw/mapview.h 2002/11/15 09:24:52 1.11
+++ client//gui-xaw/mapview.h 2002/12/09 04:40:18
@@ -17,13 +17,16 @@
#include "mapview_g.h"
+#include "citydlg_common.h"
+
#include "graphics.h"
struct unit;
struct city;
Pixmap get_thumb_pixmap(int onoff);
-Pixmap get_citizen_pixmap(int frame);
+Pixmap get_citizen_pixmap(enum citizen_type type, int cnum,
+ struct city *pcity);
void put_unit_pixmap(struct unit *punit, Pixmap pm,
int canvas_x, int canvas_y);
- [Freeciv-Dev] (PR#2516) introducing an enum citizen_type, Jason Short via RT, 2002/12/07
- Message not available
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type, Raimar Falke via RT, 2002/12/08
- Message not available
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type, Jason Short via RT, 2002/12/08
- Message not available
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type, Raimar Falke via RT, 2002/12/08
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type, Mike Kaufman via RT, 2002/12/08
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type, Jason Short via RT, 2002/12/08
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type,
Jason Short via RT <=
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type, Rafał Bursig via RT, 2002/12/09
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type, Jason Short via RT, 2002/12/09
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type, Rafał Bursig via RT, 2002/12/09
- [Freeciv-Dev] Re: (PR#2516) introducing an enum citizen_type, Jason Short via RT, 2002/12/09
|
|