Esempio n. 1
0
/**************************************************************************
...
**************************************************************************/
void timer_callback(caddr_t client_data, XtIntervalId *id)
{
  static int flip;
  
  x_interval_id=XtAppAddTimeOut(app_context, 500,
				(XtTimerCallbackProc)timer_callback, NULL);  
  
  if(game.player_ptr->is_connected && game.player_ptr->is_alive && 
     !game.player_ptr->turn_done) { 
    int i, is_waiting, is_moving;
    
    for(i=0, is_waiting=0, is_moving=0; i<game.nplayers; i++)
      if(game.players[i].is_alive && game.players[i].is_connected) {
	if(game.players[i].turn_done)
	  is_waiting++;
	else
	  is_moving++;
      }
    
    if(is_moving==1 && is_waiting) 
      update_turn_done_button(0);  /* stress the slow player! */
  }
  
  blink_active_unit();

  if(flip) {
    update_timeout_label();
    if(seconds_to_turndone)
      seconds_to_turndone--;
  }
  
  flip=!flip;
}
Esempio n. 2
0
/**************************************************************************
...
**************************************************************************/
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();
}
Esempio n. 3
0
/**************************************************************************
...
**************************************************************************/
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(),
		       "");
}
Esempio n. 4
0
/**************************************************************************
  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());
}