Logo Search packages:      
Sourcecode: teg version File versions  Download package

TEG_STATUS mainstatus_update (  ) 

! updated the contents of the mainstatus

Definition at line 687 of file status.c.

References countries_get_name().

{
      char buffer[256];
      static int offset_right=-1, offset_left=-1;
      static GnomeCanvasItem *gamestatus_item = NULL;
      static GnomeCanvasItem *country_item = NULL;
      static GnomeCanvasItem *cont_item = NULL;


      if( ! mainstatus_canvas )
            return TEG_STATUS_ERROR;

      if( offset_left == -1 && offset_right == -1)
      {
            offset_left = gui_theme.toolbar_offset_left != -1 ? gui_theme.toolbar_offset_left : OFFSET_LEFT;
            offset_right = gui_theme.toolbar_offset_right != -1 ? gui_theme.toolbar_offset_right : OFFSET_RIGHT;
      }

      /* game status */
      if( gamestatus_item  )
            gtk_object_destroy( GTK_OBJECT(gamestatus_item) );

      gamestatus_item = gnome_canvas_item_new(
            gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
            gnome_canvas_text_get_type(),
            "text",_(g_estados[g_game.estado]),
            "x", (double) (MAINSTATUS_X + offset_right),
            "y", (double) (MAINSTATUS_Y/2),
            "x_offset", (double) -1,
            "y_offset", (double) -1,
            "font", HELVETICA_14_FONT,
            "fill_color", gui_theme.toolbar_custom && gui_theme.toolbar_text_color ? gui_theme.toolbar_text_color : "black",
            "anchor",GTK_ANCHOR_EAST,
            NULL);

      /* country */
      if( country_item  )
            gtk_object_destroy( GTK_OBJECT(country_item) );

      if( gui_private.country_i_am < 0 || gui_private.country_i_am >= COUNTRIES_CANT )
            snprintf(buffer,sizeof(buffer)-1," ");
      else
            snprintf(buffer,sizeof(buffer)-1,"%s", countries_get_name(gui_private.country_i_am) );
            
      country_item = gnome_canvas_item_new(
            gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
            gnome_canvas_text_get_type(),
            "text",buffer,
            "x", (double) offset_left,
            "y", (double) (2),
            "x_offset", (double) -1,
            "y_offset", (double) -1,
            "font", HELVETICA_12_FONT,
            "fill_color", gui_theme.toolbar_custom && gui_theme.toolbar_text_color ? gui_theme.toolbar_text_color : "black",
            "anchor",GTK_ANCHOR_NW,
            NULL);

      /* continent */
      if( cont_item  )
            gtk_object_destroy( GTK_OBJECT(cont_item) );

      if( gui_private.country_i_am < 0 || gui_private.country_i_am >= COUNTRIES_CANT )
            snprintf(buffer,sizeof(buffer)-1," ");
      else
            snprintf(buffer,sizeof(buffer)-1,"%s", cont_get_name( g_countries[gui_private.country_i_am].continente )  );
            
      cont_item = gnome_canvas_item_new(
            gnome_canvas_root(GNOME_CANVAS(mainstatus_canvas)),
            gnome_canvas_text_get_type(),
            "text",buffer,
            "x", (double) offset_left,
            "y", (double) (16),
            "x_offset", (double) -1,
            "y_offset", (double) -1,
            "font", HELVETICA_10_FONT,
            "fill_color", gui_theme.toolbar_custom && gui_theme.toolbar_text_color ? gui_theme.toolbar_text_color : "black",
            "anchor",GTK_ANCHOR_NW,
            NULL);

      /* round number */
      {
            char buffer[256];

            gnome_canvas_item_hide( round_number_item );
            if( g_game.round_number >= 0 ) {

                  sprintf(buffer,"%d",g_game.round_number );

                  gnome_canvas_item_set(
                        round_number_item,
                        "text",buffer,
                        NULL);
                  gnome_canvas_item_show( round_number_item );
            }
      }

      mainstatus_update_colors();

      return TEG_STATUS_SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index