/************************************************************************** ... **************************************************************************/ void update_info_label(void) { int d = 0; xaw_set_label(info_command, get_info_label_text(TRUE)); set_indicator_icons(client_research_sprite(), client_warming_sprite(), client_cooling_sprite(), client_government_sprite()); if (NULL == client.conn.playing) { return; } for (; d < (client.conn.playing->economic.luxury) / 10; d++) { xaw_set_bitmap(econ_label[d], get_tax_sprite(tileset, O_LUXURY)->pixmap); } for (; d < (client.conn.playing->economic.science + client.conn.playing->economic.luxury) / 10; d++) { xaw_set_bitmap(econ_label[d], get_tax_sprite(tileset, O_SCIENCE)->pixmap); } for(; d < 10; d++) { xaw_set_bitmap(econ_label[d], get_tax_sprite(tileset, O_GOLD)->pixmap); } update_timeout_label(); }
/************************************************************************** Called to fill econ_label pixmaps (showing tax/lux/sci rates). It may be called again if the tileset changes. **************************************************************************/ void fill_econ_label_pixmaps(void) { int i; int econ_label_count = 10; for(i = 0; i < econ_label_count; i++) { struct sprite *s = i < 5 ? get_tax_sprite(tileset, O_SCIENCE) : get_tax_sprite(tileset, O_GOLD); XtVaSetValues(econ_label[i], XtNbitmap, s->pixmap, NULL); XtAddCallback(econ_label[i], XtNcallback, taxrates_callback, INT_TO_XTPOINTER(i)); } }
/************************************************************************** ... **************************************************************************/ void update_info_label( void ) { GtkWidget *label; const struct player *pplayer = client.conn.playing; label = gtk_frame_get_label_widget(GTK_FRAME(main_frame_civ_name)); if (pplayer != NULL) { char nation[MAX_LEN_NAME]; /* Capitalize the first character of the translated nation * plural name so that the frame label looks good. I assume * that in the case that capitalization does not make sense * (e.g. multi-byte characters or no "upper case" form in * the translation language) my_toupper() will just return * the same value as was passed into it. */ sz_strlcpy(nation, nation_plural_for_player(pplayer)); nation[0] = my_toupper(nation[0]); gtk_label_set_text(GTK_LABEL(label), nation); } else { gtk_label_set_text(GTK_LABEL(label), "-"); } gtk_label_set_text(GTK_LABEL(main_label_info), get_info_label_text()); set_indicator_icons(client_research_sprite(), client_warming_sprite(), client_cooling_sprite(), client_government_sprite()); if (NULL != client.conn.playing) { int d = 0; for (; d < client.conn.playing->economic.luxury /10; d++) { struct sprite *sprite = get_tax_sprite(tileset, O_LUXURY); gtk_image_set_from_pixbuf(GTK_IMAGE(econ_label[d]), sprite_get_pixbuf(sprite)); } for (; d < (client.conn.playing->economic.science + client.conn.playing->economic.luxury) / 10; d++) { struct sprite *sprite = get_tax_sprite(tileset, O_SCIENCE); gtk_image_set_from_pixbuf(GTK_IMAGE(econ_label[d]), sprite_get_pixbuf(sprite)); } for (; d < 10; d++) { struct sprite *sprite = get_tax_sprite(tileset, O_GOLD); gtk_image_set_from_pixbuf(GTK_IMAGE(econ_label[d]), sprite_get_pixbuf(sprite)); } } update_timeout_label(); /* update tooltips. */ gtk_tooltips_set_tip(main_tips, econ_ebox, _("Shows your current luxury/science/tax rates;" "click to toggle them."), ""); gtk_tooltips_set_tip(main_tips, bulb_ebox, get_bulb_tooltip(), ""); gtk_tooltips_set_tip(main_tips, sun_ebox, get_global_warming_tooltip(), ""); gtk_tooltips_set_tip(main_tips, flake_ebox, get_nuclear_winter_tooltip(), ""); gtk_tooltips_set_tip(main_tips, government_ebox, get_government_tooltip(), ""); }
/************************************************************************** Refresh info label **************************************************************************/ void update_info_label(void) { GtkWidget *label; const struct player *pplayer = client.conn.playing; label = gtk_frame_get_label_widget(GTK_FRAME(main_frame_civ_name)); if (pplayer != NULL) { const gchar *name; gunichar c; /* Capitalize the first character of the translated nation * plural name so that the frame label looks good. */ name = nation_plural_for_player(pplayer); c = g_utf8_get_char_validated(name, -1); if ((gunichar) -1 != c && (gunichar) -2 != c) { gchar nation[MAX_LEN_NAME]; gchar *next; gint len; len = g_unichar_to_utf8(g_unichar_toupper(c), nation); nation[len] = '\0'; next = g_utf8_find_next_char(name, NULL); if (NULL != next) { sz_strlcat(nation, next); } gtk_label_set_text(GTK_LABEL(label), nation); } else { gtk_label_set_text(GTK_LABEL(label), name); } } else { gtk_label_set_text(GTK_LABEL(label), "-"); } gtk_label_set_text(GTK_LABEL(main_label_info), get_info_label_text(!gui_gtk3_small_display_layout)); set_indicator_icons(client_research_sprite(), client_warming_sprite(), client_cooling_sprite(), client_government_sprite()); if (NULL != client.conn.playing) { int d = 0; for (; d < client.conn.playing->economic.luxury /10; d++) { struct sprite *sprite = get_tax_sprite(tileset, O_LUXURY); gtk_pixcomm_set_from_sprite(GTK_PIXCOMM(econ_label[d]), sprite); } for (; d < (client.conn.playing->economic.science + client.conn.playing->economic.luxury) / 10; d++) { struct sprite *sprite = get_tax_sprite(tileset, O_SCIENCE); gtk_pixcomm_set_from_sprite(GTK_PIXCOMM(econ_label[d]), sprite); } for (; d < 10; d++) { struct sprite *sprite = get_tax_sprite(tileset, O_GOLD); gtk_pixcomm_set_from_sprite(GTK_PIXCOMM(econ_label[d]), sprite); } } update_timeout_label(); /* update tooltips. */ gtk_widget_set_tooltip_text(econ_ebox, _("Shows your current luxury/science/tax rates; " "click to toggle them.")); gtk_widget_set_tooltip_text(bulb_ebox, get_bulb_tooltip()); gtk_widget_set_tooltip_text(sun_ebox, get_global_warming_tooltip()); gtk_widget_set_tooltip_text(flake_ebox, get_nuclear_winter_tooltip()); gtk_widget_set_tooltip_text(government_ebox, get_government_tooltip()); }