[Freeciv-Dev] (PR#12370) wrappers for some named sprites
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12370 >
This function adds accessor functions used to wrap the access to some of
the named sprites.
In the long run the named_sprites array should be hidden, with all the
hundreds of lines of data structure information moved into tilespec.c.
However this is a rather monolithic task. This patch is just one small
step.
-jason
? client/diff
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.243
diff -u -r1.243 tilespec.c
--- client/tilespec.c 26 Feb 2005 18:40:21 -0000 1.243
+++ client/tilespec.c 26 Feb 2005 22:00:07 -0000
@@ -3490,6 +3490,54 @@
}
/**************************************************************************
+ Return a "sample" sprite for this city style.
+**************************************************************************/
+struct Sprite *get_sample_city_sprite(int city_style)
+{
+ int index = city_styles[city_style].tiles_num - 1;
+
+ return sprites.city.tile[city_style][index];
+}
+
+/**************************************************************************
+ Return a sprite with the "right-arrow" theme graphic.
+**************************************************************************/
+struct Sprite *get_arrow_sprite(void)
+{
+ return sprites.right_arrow;
+}
+
+/**************************************************************************
+ Return a tax sprite for the given output type (usually gold/lux/sci).
+**************************************************************************/
+struct Sprite *get_tax_sprite(Output_type_id otype)
+{
+ switch (otype) {
+ case O_SCIENCE:
+ return sprites.tax_science;
+ case O_GOLD:
+ return sprites.tax_gold;
+ case O_LUXURY:
+ return sprites.tax_luxury;
+ case O_TRADE:
+ case O_FOOD:
+ case O_SHIELD:
+ case O_LAST:
+ break;
+ }
+ return NULL;
+}
+
+/**************************************************************************
+ Return a thumbs-up/thumbs-down sprite to show treaty approval or
+ disapproval.
+**************************************************************************/
+struct Sprite *get_treaty_thumb_sprite(bool on_off)
+{
+ return sprites.treaty_thumb[on_off ? 1 : 0];
+}
+
+/**************************************************************************
Loads the sprite. If the sprite is already loaded a reference
counter is increased. Can return NULL if the sprite couldn't be
loaded.
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.108
diff -u -r1.108 tilespec.h
--- client/tilespec.h 26 Feb 2005 00:54:39 -0000 1.108
+++ client/tilespec.h 26 Feb 2005 22:00:07 -0000
@@ -353,6 +353,10 @@
struct Sprite *get_citizen_sprite(struct citizen_type type,
int citizen_index,
const struct city *pcity);
+struct Sprite *get_sample_city_sprite(int city_style);
+struct Sprite *get_arrow_sprite(void);
+struct Sprite *get_tax_sprite(Output_type_id otype);
+struct Sprite *get_treaty_thumb_sprite(bool on_off);
/* full pathnames: */
extern char *main_intro_filename;
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.162
diff -u -r1.162 gui_main.c
--- client/gui-gtk/gui_main.c 12 Feb 2005 18:47:18 -0000 1.162
+++ client/gui-gtk/gui_main.c 26 Feb 2005 22:00:07 -0000
@@ -645,7 +645,7 @@
/* citizens for taxrates */
for (i = 0; i < 10; i++) {
- struct Sprite *s = i < 5 ? sprites.tax_science : sprites.tax_gold;
+ struct Sprite *s = i < 5 ? get_tax_sprite(O_SCIENCE) :
get_tax_sprite(O_GOLD);
ebox = gtk_event_box_new();
gtk_widget_set_events(ebox, GDK_BUTTON_PRESS_MASK);
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.235
diff -u -r1.235 mapview.c
--- client/gui-gtk/mapview.c 17 Feb 2005 03:12:54 -0000 1.235
+++ client/gui-gtk/mapview.c 26 Feb 2005 22:00:08 -0000
@@ -132,18 +132,18 @@
d=0;
for (; d < game.player_ptr->economic.luxury /10; d++) {
- struct Sprite *sprite = sprite = sprites.tax_luxury;
+ struct Sprite *sprite = sprite = get_tax_sprite(O_LUXURY);
gtk_pixmap_set(GTK_PIXMAP(econ_label[d]), sprite->pixmap, sprite->mask);
}
for (; d < (game.player_ptr->economic.science
+ game.player_ptr->economic.luxury) / 10; d++) {
- struct Sprite *sprite = sprites.tax_science;
+ struct Sprite *sprite = get_tax_sprite(O_SCIENCE);
gtk_pixmap_set(GTK_PIXMAP(econ_label[d]), sprite->pixmap, sprite->mask);
}
for (; d < 10; d++) {
- struct Sprite *sprite = sprites.tax_gold;
+ struct Sprite *sprite = get_tax_sprite(O_GOLD);
gtk_pixmap_set(GTK_PIXMAP(econ_label[d]), sprite->pixmap, sprite->mask);
}
Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.91
diff -u -r1.91 dialogs.c
--- client/gui-gtk-2.0/dialogs.c 16 Feb 2005 23:14:58 -0000 1.91
+++ client/gui-gtk-2.0/dialogs.c 26 Feb 2005 22:00:08 -0000
@@ -1754,7 +1754,6 @@
for (i = 0; i < game.styles_count; i++) {
GdkPixbuf *img;
SPRITE *s;
- int last;
GtkTreeIter it;
if (city_styles[i].techreq != A_NONE) {
@@ -1763,9 +1762,7 @@
gtk_list_store_append(store, &it);
- last = city_styles[i].tiles_num-1;
-
- s = crop_blankspace(sprites.city.tile[i][last]);
+ s = crop_blankspace(get_sample_city_sprite(i));
img = sprite_get_pixbuf(s);
g_object_ref(img);
free_sprite(s);
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.110
diff -u -r1.110 gui_main.c
--- client/gui-gtk-2.0/gui_main.c 12 Feb 2005 18:47:18 -0000 1.110
+++ client/gui-gtk-2.0/gui_main.c 26 Feb 2005 22:00:08 -0000
@@ -625,7 +625,7 @@
}
more_arrow_pixmap
- = gtk_image_new_from_pixbuf(sprite_get_pixbuf(sprites.right_arrow));
+ = gtk_image_new_from_pixbuf(sprite_get_pixbuf(get_arrow_sprite()));
gtk_widget_ref(more_arrow_pixmap);
gtk_table_attach_defaults(GTK_TABLE(table), more_arrow_pixmap, 4, 5, 1, 2);
@@ -828,25 +828,21 @@
g_signal_connect(ebox, "button_press_event",
G_CALLBACK(taxrates_callback), GINT_TO_POINTER(i));
- sprite = i < 5 ? sprites.tax_science : sprites.tax_gold;
+ sprite = i < 5 ? get_tax_sprite(O_SCIENCE) : get_tax_sprite(O_GOLD);
econ_label[i] = gtk_image_new_from_pixbuf(sprite_get_pixbuf(sprite));
gtk_container_add(GTK_CONTAINER(ebox), econ_label[i]);
}
/* science, environmental, govt, timeout */
- bulb_label = gtk_image_new_from_pixbuf(sprite_get_pixbuf(sprites.bulb[0]));
+ bulb_label
+ = gtk_image_new_from_pixbuf(sprite_get_pixbuf(client_research_sprite()));
sun_label
- = gtk_image_new_from_pixbuf(sprite_get_pixbuf(sprites.warming[0]));
+ = gtk_image_new_from_pixbuf(sprite_get_pixbuf(client_warming_sprite()));
flake_label
- = gtk_image_new_from_pixbuf(sprite_get_pixbuf(sprites.cooling[0]));
- {
- /* HACK: the UNHAPPY citizen is used for the government
- * when we don't know any better. */
- struct citizen_type c = {.type = CITIZEN_UNHAPPY};
-
- sprite = get_citizen_sprite(c, 0, NULL);
- }
- government_label = gtk_image_new_from_pixbuf(sprite_get_pixbuf(sprite));
+ = gtk_image_new_from_pixbuf(sprite_get_pixbuf(client_cooling_sprite()));
+ government_label
+ = gtk_image_new_from_pixbuf(sprite_get_pixbuf
+ (client_government_sprite()));
for (i = 0; i < 4; i++) {
GtkWidget *w;
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.159
diff -u -r1.159 mapview.c
--- client/gui-gtk-2.0/mapview.c 17 Feb 2005 03:12:54 -0000 1.159
+++ client/gui-gtk-2.0/mapview.c 26 Feb 2005 22:00:09 -0000
@@ -123,7 +123,7 @@
d=0;
for (; d < game.player_ptr->economic.luxury /10; d++) {
- struct Sprite *sprite = sprites.tax_luxury;
+ struct Sprite *sprite = get_tax_sprite(O_LUXURY);
gtk_image_set_from_pixbuf(GTK_IMAGE(econ_label[d]),
sprite_get_pixbuf(sprite));
@@ -131,14 +131,14 @@
for (; d < (game.player_ptr->economic.science
+ game.player_ptr->economic.luxury) / 10; d++) {
- struct Sprite *sprite = sprites.tax_science;
+ struct Sprite *sprite = get_tax_sprite(O_SCIENCE);
gtk_image_set_from_pixbuf(GTK_IMAGE(econ_label[d]),
sprite_get_pixbuf(sprite));
}
for (; d < 10; d++) {
- struct Sprite *sprite = sprites.tax_gold;
+ struct Sprite *sprite = get_tax_sprite(O_GOLD);
gtk_image_set_from_pixbuf(GTK_IMAGE(econ_label[d]),
sprite_get_pixbuf(sprite));
@@ -215,7 +215,7 @@
**************************************************************************/
GdkPixbuf *get_thumb_pixbuf(int onoff)
{
- return sprite_get_pixbuf(sprites.treaty_thumb[BOOL_VAL(onoff)]);
+ return sprite_get_pixbuf(get_treaty_thumb_sprite(BOOL_VAL(onoff)));
}
/****************************************************************************
Index: client/gui-mui/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/mapview.c,v
retrieving revision 1.69
diff -u -r1.69 mapview.c
--- client/gui-mui/mapview.c 29 Sep 2004 02:24:21 -0000 1.69
+++ client/gui-mui/mapview.c 26 Feb 2005 22:00:09 -0000
@@ -203,13 +203,13 @@
d = 0;
for (; d < (game.player_ptr->economic.luxury) / 10; d++)
- set(main_econ_sprite[d], MUIA_Sprite_Sprite, sprites.tax_luxury);
+ set(main_econ_sprite[d], MUIA_Sprite_Sprite, get_tax_sprite(O_LUXURY));
for (; d < (game.player_ptr->economic.science +
game.player_ptr->economic.luxury) / 10; d++)
- set(main_econ_sprite[d], MUIA_Sprite_Sprite, sprites.tax_science);
+ set(main_econ_sprite[d], MUIA_Sprite_Sprite, get_tax_sprite(O_SCIENCE));
for (; d < 10; d++)
- set(main_econ_sprite[d], MUIA_Sprite_Sprite, sprites.tax_gold);
+ set(main_econ_sprite[d], MUIA_Sprite_Sprite, get_tax_sprite(O_GOLD));
update_timeout_label();
}
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.141
diff -u -r1.141 mapview.c
--- client/gui-win32/mapview.c 17 Feb 2005 03:12:54 -0000 1.141
+++ client/gui-win32/mapview.c 26 Feb 2005 22:00:09 -0000
@@ -243,13 +243,13 @@
int d;
d=0;
for(;d<(game.player_ptr->economic.luxury)/10;d++)
- draw_sprite(sprites.tax_luxury, hdc,
+ draw_sprite(get_tax_sprite(O_LUXURY), 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(sprites.tax_science, hdc,
+ draw_sprite(get_tax_sprite(O_SCIENCE), hdc,
SMALL_TILE_WIDTH*d,taxinfoline_y); /* scientist tile */
for(;d<10;d++)
- draw_sprite(sprites.tax_gold, hdc,
+ draw_sprite(get_tax_sprite(O_GOLD), hdc,
SMALL_TILE_WIDTH*d,taxinfoline_y); /* taxman tile */
}
Index: client/gui-xaw/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/gui_main.c,v
retrieving revision 1.104
diff -u -r1.104 gui_main.c
--- client/gui-xaw/gui_main.c 17 Feb 2005 22:57:58 -0000 1.104
+++ client/gui-xaw/gui_main.c 26 Feb 2005 22:00:09 -0000
@@ -453,7 +453,7 @@
/* Do this outside setup_widgets() so after tiles are loaded */
for(i=0;i<10;i++) {
- struct Sprite *s = i < 5 ? sprites.tax_science : sprites.tax_gold;
+ struct Sprite *s = i < 5 ? get_tax_sprite(O_SCIENCE) :
get_tax_sprite(O_GOLD);
XtVaSetValues(econ_label[i], XtNbitmap,
s->pixmap, NULL);
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.189
diff -u -r1.189 mapview.c
--- client/gui-xaw/mapview.c 17 Feb 2005 03:12:54 -0000 1.189
+++ client/gui-xaw/mapview.c 26 Feb 2005 22:00:09 -0000
@@ -176,13 +176,13 @@
d=0;
for(;d<(game.player_ptr->economic.luxury)/10;d++)
- xaw_set_bitmap(econ_label[d], sprites.tax_luxury->pixmap);
+ xaw_set_bitmap(econ_label[d], get_tax_sprite(O_LUXURY)->pixmap);
for(;d<(game.player_ptr->economic.science+game.player_ptr->economic.luxury)/10;d++)
- xaw_set_bitmap(econ_label[d], sprites.tax_science->pixmap);
+ xaw_set_bitmap(econ_label[d], get_tax_sprite(O_SCIENCE)->pixmap);
for(;d<10;d++)
- xaw_set_bitmap(econ_label[d], sprites.tax_gold->pixmap);
+ xaw_set_bitmap(econ_label[d], get_tax_sprite(O_GOLD)->pixmap);
update_timeout_label();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12370) wrappers for some named sprites,
Jason Short <=
|
|