Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] (PR#1328) [patch] "turns-to-grow" on the map overview
Home

[Freeciv-Dev] (PR#1328) [patch] "turns-to-grow" on the map overview

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#1328) [patch] "turns-to-grow" on the map overview
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Mon, 18 Nov 2002 13:40:23 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[vasc@xxxxxxxxxxxxxx - Sun Nov 17 22:43:18 2002]:

> The GTK+ font code at least has issues. You should use the string extents
> function instead of checking the font data directly. Not all languages are
> the same. What works for the Latin alphabet may not work elsewhere and
> this is why the string extents functions exist in the first place.

My mistake.  I don't know why I dropped that originally!

This patch corrects that (for gui-gtk; others should be fine).  I've
also fixed some whitespace style issues.  And I've added GTK2 support,
including color support.

There is one other thing that is bad.  The mapview_common code inserts
an extra space on the end of the city name if the turns-to-grow is also
to be shown.  Originally this was a hack done on a per-GUI basis to get
the spacing to come out right.  But it's really not correct.  For one
thing, gui-gtk-2.0 (on my machine!) uses a different ("better") font in
which one space is simply not wide enough.  And doing this in
mapview_common will conflict with a GUI that tries to use a civ3-like
layout for the display of this information (although in that case the
productions texts will have to be updated as well...).  I have "fixed"
this by moving the hack into the GUI code: introducing a fixed-width
separation between the city name and growth strings.  It is still a
hack, but at least now it's local (and labeled).  Vasco, how should this
actually be done?  It would be possible to at least make the separation
font-dependent by using the width of an actual string instead of
hard-coding it, but this may be locale-dependent.

jason

? client/gui-gtk/diff
? client/gui-stub/stub-update.diff
? client/gui-xaw/diff
Index: client//control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.86
diff -u -r1.86 control.c
--- client//control.c   2002/11/14 09:14:50     1.86
+++ client//control.c   2002/11/18 21:38:04
@@ -946,7 +946,20 @@
   draw_city_names ^= 1;
   update_map_canvas_visible();
 }
+ 
+ /**************************************************************************
+ Toggle display of city growth (turns-to-grow)
+**************************************************************************/
+void request_toggle_city_growth(void)
+{
+  if (get_client_state() != CLIENT_GAME_RUNNING_STATE) {
+    return;
+  }
 
+  draw_city_growth = !draw_city_growth;
+  update_map_canvas_visible();
+}
+
 /**************************************************************************
  Toggle display of city productions
 **************************************************************************/
@@ -1744,6 +1757,15 @@
 void key_city_names_toggle(void)
 {
   request_toggle_city_names();
+}
+
+/**************************************************************************
+  Toggles the "show city growth turns" option by passing off the
+  request to another function...
+**************************************************************************/
+void key_city_growth_toggle(void)
+{
+  request_toggle_city_growth();
 }
 
 /**************************************************************************
Index: client//control.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.h,v
retrieving revision 1.29
diff -u -r1.29 control.h
--- client//control.h   2002/11/01 17:51:12     1.29
+++ client//control.h   2002/11/18 21:38:04
@@ -66,6 +66,7 @@
 void request_unit_wakeup(struct unit *punit);
 void request_toggle_map_grid(void);
 void request_toggle_city_names(void);
+void request_toggle_city_growth(void);
 void request_toggle_city_productions(void);
 void request_toggle_terrain(void);
 void request_toggle_coastline(void);
@@ -99,6 +100,7 @@
 
 void key_cancel_action(void);
 void key_city_names_toggle(void);
+void key_city_growth_toggle(void);
 void key_city_productions_toggle(void);
 void key_terrain_toggle(void);
 void key_coastline_toggle(void);
Index: client//mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.13
diff -u -r1.13 mapview_common.c
--- client//mapview_common.c    2002/11/15 09:24:51     1.13
+++ client//mapview_common.c    2002/11/18 21:38:04
@@ -418,3 +418,44 @@
     need_mapview_update = FALSE;
   }
 }
+
+void get_city_mapview_name_and_growth(struct city *pcity,
+                                     char *name_buffer,
+                                     size_t name_buffer_len,
+                                     char *growth_buffer,
+                                     size_t growth_buffer_len,
+                                     enum color_std *growth_color)
+{
+  if (!draw_city_names) {
+    name_buffer[0] = '\0';
+    growth_buffer[0] = '\0';
+    *growth_color = COLOR_STD_WHITE;
+    return;
+  }
+
+  my_snprintf(name_buffer, name_buffer_len, pcity->name);
+
+  if (draw_city_growth && pcity->owner == game.player_idx) {
+    int turns = city_turns_to_grow(pcity);
+
+    if (turns == 0) {
+      my_snprintf(growth_buffer, growth_buffer_len, "X");
+    } else if (turns == FC_INFINITY) {
+      my_snprintf(growth_buffer, growth_buffer_len, "-");
+    } else {
+      /* Negative turns means we're shrinking, but that's handled
+         down below. */
+      my_snprintf(growth_buffer, growth_buffer_len, "%d", abs(turns));
+    }
+
+    if (turns <= 0) {
+      /* A blocked or shrinking city has its growth status shown in red. */
+      *growth_color = COLOR_STD_RED;
+    } else {
+      *growth_color = COLOR_STD_WHITE;
+    }
+  } else {
+    growth_buffer[0] = '\0';
+    *growth_color = COLOR_STD_WHITE;
+  }
+}
Index: client//mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.8
diff -u -r1.8 mapview_common.h
--- client//mapview_common.h    2002/11/15 09:24:51     1.8
+++ client//mapview_common.h    2002/11/18 21:38:04
@@ -57,6 +57,12 @@
 
 void get_city_mapview_production(struct city *pcity,
                                  char *buf, size_t buf_len);
+void get_city_mapview_name_and_growth(struct city *pcity,
+                                     char *name_buffer,
+                                     size_t name_buffer_len,
+                                     char *growth_buffer,
+                                     size_t growth_buffer_len,
+                                     enum color_std *grwoth_color);
 
 void queue_mapview_update(void);
 void unqueue_mapview_update(void);
Index: client//options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.71
diff -u -r1.71 options.c
--- client//options.c   2002/11/17 02:21:11     1.71
+++ client//options.c   2002/11/18 21:38:04
@@ -127,6 +127,7 @@
 
 bool draw_map_grid = FALSE;
 bool draw_city_names = TRUE;
+bool draw_city_growth = TRUE;
 bool draw_city_productions = FALSE;
 bool draw_terrain = TRUE;
 bool draw_coastline = FALSE;
@@ -147,6 +148,7 @@
 view_option view_options[] = {
   VIEW_OPTION(draw_map_grid),
   VIEW_OPTION(draw_city_names),
+  VIEW_OPTION(draw_city_growth),
   VIEW_OPTION(draw_city_productions),
   VIEW_OPTION(draw_terrain),
   VIEW_OPTION(draw_coastline),
Index: client//options.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.h,v
retrieving revision 1.24
diff -u -r1.24 options.h
--- client//options.h   2002/11/14 09:22:09     1.24
+++ client//options.h   2002/11/18 21:38:04
@@ -75,6 +75,7 @@
 
 extern bool draw_map_grid;
 extern bool draw_city_names;
+extern bool draw_city_growth;
 extern bool draw_city_productions;
 extern bool draw_terrain;
 extern bool draw_coastline;
Index: client//packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.261
diff -u -r1.261 packhand.c
--- client//packhand.c  2002/11/14 09:14:51     1.261
+++ client//packhand.c  2002/11/18 21:38:06
@@ -338,6 +338,12 @@
                pcity->shield_surplus != packet->shield_surplus ||
                pcity->shield_stock != packet->shield_stock)) {
       update_descriptions = TRUE;
+    } else if (draw_city_names && draw_city_growth &&
+              (pcity->food_stock != packet->food_stock ||
+               pcity->food_surplus != packet->food_surplus)) {
+      /* If either the food stock or surplus have changed, the time-to-grow
+        is likely to have changed as well. */
+      update_descriptions = TRUE;
     }
 
     /* update the descriptions if necessary */
Index: client//gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.131
diff -u -r1.131 mapview.c
--- client//gui-gtk/mapview.c   2002/11/17 02:21:12     1.131
+++ client//gui-gtk/mapview.c   2002/11/18 21:38:07
@@ -1307,23 +1307,40 @@
 **************************************************************************/
 static void show_desc_at_tile(int x, int y)
 {
-  static char buffer[512];
-  struct city *pcity;
-  if ((pcity = map_get_city(x, y))) {
+  static char buffer[512], buffer2[32];
+  struct city *pcity = map_get_city(x, y);
+
+  if (pcity) {
     int canvas_x, canvas_y;
-    int w, ascent;
+    int w, w2, ascent;
+    enum color_std color;
 
     get_canvas_xy(x, y, &canvas_x, &canvas_y);
-    if (draw_city_names) {
-      my_snprintf(buffer, sizeof(buffer), "%s", pcity->name);
-      gdk_string_extents(main_fontset, buffer, NULL, NULL, &w, &ascent, NULL);
-      gtk_draw_shadowed_string(map_canvas->window, main_fontset,
-                              toplevel->style->black_gc,
-                              toplevel->style->white_gc,
-                              canvas_x + NORMAL_TILE_WIDTH / 2 - w / 2,
-                              canvas_y + NORMAL_TILE_HEIGHT +
-                              ascent, buffer);
+
+    get_city_mapview_name_and_growth(pcity, buffer, sizeof(buffer),
+                                    buffer2, sizeof(buffer2), &color);
+
+    gdk_string_extents(main_fontset, buffer, NULL, NULL, &w, &ascent, NULL);
+    if (buffer2[0] != '\0') {
+      /* HACK: put some extra space between the two strings. */
+      w += 10;
     }
+    w2 = gdk_string_width(prod_fontset, buffer2);
+
+    gtk_draw_shadowed_string(map_canvas->window, main_fontset,
+                            toplevel->style->black_gc,
+                            toplevel->style->white_gc,
+                            canvas_x + NORMAL_TILE_WIDTH / 2 - (w + w2) / 2,
+                            canvas_y + NORMAL_TILE_HEIGHT + ascent,
+                            buffer);
+    gdk_gc_set_foreground(civ_gc, colors_standard[color]);
+    gtk_draw_shadowed_string(map_canvas->window, prod_fontset,
+                            toplevel->style->black_gc,
+                            civ_gc,
+                            canvas_x + NORMAL_TILE_WIDTH / 2
+                            - (w + w2) / 2 + w,
+                            canvas_y + NORMAL_TILE_HEIGHT + ascent,
+                            buffer2);
 
     if (draw_city_productions && (pcity->owner==game.player_idx)) {
       int y_offset;
Index: client//gui-gtk/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/menu.c,v
retrieving revision 1.70
diff -u -r1.70 menu.c
--- client//gui-gtk/menu.c      2002/11/14 09:14:54     1.70
+++ client//gui-gtk/menu.c      2002/11/18 21:38:07
@@ -80,6 +80,7 @@
 
   MENU_VIEW_SHOW_MAP_GRID,
   MENU_VIEW_SHOW_CITY_NAMES,
+  MENU_VIEW_SHOW_CITY_GROWTH_TURNS,
   MENU_VIEW_SHOW_CITY_PRODUCTIONS,
   MENU_VIEW_SHOW_TERRAIN,
   MENU_VIEW_SHOW_COASTLINE,
@@ -227,8 +228,14 @@
       key_map_grid_toggle();
     break;
   case MENU_VIEW_SHOW_CITY_NAMES:
-    if (draw_city_names ^ GTK_CHECK_MENU_ITEM(widget)->active)
+    if (draw_city_names ^ GTK_CHECK_MENU_ITEM(widget)->active) {
       key_city_names_toggle();
+      menus_set_sensitive("<main>/_View/City G_rowth", draw_city_names);
+    }
+    break;
+  case MENU_VIEW_SHOW_CITY_GROWTH_TURNS:
+    if (draw_city_growth ^ GTK_CHECK_MENU_ITEM(widget)->active)
+      key_city_growth_toggle();
     break;
   case MENU_VIEW_SHOW_CITY_PRODUCTIONS:
     if (draw_city_productions ^ GTK_CHECK_MENU_ITEM(widget)->active)
@@ -599,6 +606,9 @@
        view_menu_callback,     MENU_VIEW_SHOW_MAP_GRID,                
"<CheckItem>"   },
   { "/" N_("View") "/" N_("City _Names"),              "<control>n",
        view_menu_callback,     MENU_VIEW_SHOW_CITY_NAMES,              
"<CheckItem>"   },
+  { "/" N_("View") "/" N_("City G_rowth"),             "<control>r",
+       view_menu_callback,     MENU_VIEW_SHOW_CITY_GROWTH_TURNS,
+       "<CheckItem>"   },
   { "/" N_("View") "/" N_("City _Productions"),                "<control>p",
        view_menu_callback,     MENU_VIEW_SHOW_CITY_PRODUCTIONS,        
"<CheckItem>"   },
   { "/" N_("View") "/sep1",                            NULL,
@@ -982,6 +992,8 @@
 
     menus_set_active("<main>/_View/Map _Grid", draw_map_grid);
     menus_set_active("<main>/_View/City _Names", draw_city_names);
+    menus_set_sensitive("<main>/_View/City G_rowth", draw_city_names);
+    menus_set_active("<main>/_View/City G_rowth", draw_city_growth);
     menus_set_active("<main>/_View/City _Productions", draw_city_productions);
     menus_set_active("<main>/_View/Terrain", draw_terrain);
     menus_set_active("<main>/_View/Coastline", draw_coastline);
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.19
diff -u -r1.19 mapview.c
--- client//gui-gtk-2.0/mapview.c       2002/11/17 02:21:12     1.19
+++ client//gui-gtk-2.0/mapview.c       2002/11/18 21:38:08
@@ -1331,26 +1331,64 @@
 **************************************************************************/
 static void show_desc_at_tile(PangoLayout *layout, int x, int y)
 {
-  static char buffer[512];
+  static char buffer[512], buffer2[32];
   struct city *pcity;
   if ((pcity = map_get_city(x, y))) {
     int canvas_x, canvas_y;
-    PangoRectangle rect;
+    PangoRectangle rect, rect2;
+    enum color_std color;
 
     get_canvas_xy(x, y, &canvas_x, &canvas_y);
     if (draw_city_names) {
-      my_snprintf(buffer, sizeof(buffer), "%s", pcity->name);
-      
+      get_city_mapview_name_and_growth(pcity, buffer, sizeof(buffer),
+                                      buffer2, sizeof(buffer2), &color);
+
       pango_layout_set_font_description(layout, main_font);
       pango_layout_set_text(layout, buffer, -1);
-
       pango_layout_get_pixel_extents(layout, &rect, NULL);
+      if (buffer2[0] != '\0') {
+       /* HACK: put some extra space between the two strings. */
+       rect.width += 1;
+      }
+
+
+      if (draw_city_growth && pcity->owner == game.player_idx) {
+       /* We need to know the size of the growth text before
+          drawing anything. */
+       pango_layout_set_font_description(layout, city_productions_font);
+       pango_layout_set_text(layout, buffer2, -1);
+       pango_layout_get_pixel_extents(layout, &rect2, NULL);
+
+       /* Now return the layout to its previous state. */
+       pango_layout_set_font_description(layout, main_font);
+       pango_layout_set_text(layout, buffer, -1);
+      } else {
+       rect2.width = 0;
+      }
+
       gtk_draw_shadowed_string(map_canvas->window,
                           toplevel->style->black_gc,
                           toplevel->style->white_gc,
-                          canvas_x + NORMAL_TILE_WIDTH / 2 - rect.width / 2,
+                          canvas_x + NORMAL_TILE_WIDTH / 2
+                              - (rect.width + rect2.width) / 2,
                           canvas_y + NORMAL_TILE_HEIGHT +
                           PANGO_ASCENT(rect), layout);
+
+      if (draw_city_growth && pcity->owner == game.player_idx) {
+       pango_layout_set_font_description(layout, city_productions_font);
+       pango_layout_set_text(layout, buffer2, -1);
+       gdk_gc_set_foreground(civ_gc, colors_standard[color]);
+       gtk_draw_shadowed_string(map_canvas->window,
+                       toplevel->style->black_gc,
+                       civ_gc,
+                       canvas_x + NORMAL_TILE_WIDTH / 2
+                                - (rect.width + rect2.width) / 2
+                                + rect.width,
+                       canvas_y + NORMAL_TILE_HEIGHT +
+                       PANGO_ASCENT(rect) + rect.height / 2
+                                - rect2.height / 2, layout);
+
+      }
     }
 
     if (draw_city_productions && (pcity->owner==game.player_idx)) {
Index: client//gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.8
diff -u -r1.8 menu.c
--- client//gui-gtk-2.0/menu.c  2002/11/14 09:14:55     1.8
+++ client//gui-gtk-2.0/menu.c  2002/11/18 21:38:09
@@ -81,6 +81,7 @@
 
   MENU_VIEW_SHOW_MAP_GRID,
   MENU_VIEW_SHOW_CITY_NAMES,
+  MENU_VIEW_SHOW_CITY_GROWTH_TURNS,
   MENU_VIEW_SHOW_CITY_PRODUCTIONS,
   MENU_VIEW_SHOW_TERRAIN,
   MENU_VIEW_SHOW_COASTLINE,
@@ -228,8 +229,14 @@
       key_map_grid_toggle();
     break;
   case MENU_VIEW_SHOW_CITY_NAMES:
-    if (draw_city_names ^ GTK_CHECK_MENU_ITEM(widget)->active)
+    if (draw_city_names ^ GTK_CHECK_MENU_ITEM(widget)->active) {
       key_city_names_toggle();
+      menus_set_sensitive("<main>/_View/City G_rowth", draw_city_names);
+    }
+    break;
+  case MENU_VIEW_SHOW_CITY_GROWTH_TURNS:
+    if (draw_city_growth ^ GTK_CHECK_MENU_ITEM(widget)->active)
+      key_city_growth_toggle();
     break;
   case MENU_VIEW_SHOW_CITY_PRODUCTIONS:
     if (draw_city_productions ^ GTK_CHECK_MENU_ITEM(widget)->active)
@@ -600,6 +607,9 @@
        view_menu_callback,     MENU_VIEW_SHOW_MAP_GRID,                
"<CheckItem>"   },
   { "/" N_("View") "/" N_("City _Names"),              "<control>n",
        view_menu_callback,     MENU_VIEW_SHOW_CITY_NAMES,              
"<CheckItem>"   },
+  { "/" N_("View") "/" N_("City G_rowth"),             "<control>r",
+       view_menu_callback,     MENU_VIEW_SHOW_CITY_GROWTH_TURNS,
+       "<CheckItem>"   },
   { "/" N_("View") "/" N_("City _Productions"),                "<control>p",
        view_menu_callback,     MENU_VIEW_SHOW_CITY_PRODUCTIONS,        
"<CheckItem>"   },
   { "/" N_("View") "/sep1",                            NULL,
@@ -977,6 +987,8 @@
 
     menus_set_active("<main>/_View/Map _Grid", draw_map_grid);
     menus_set_active("<main>/_View/City _Names", draw_city_names);
+    menus_set_sensitive("<main>/_View/City G_rowth", draw_city_names);
+    menus_set_active("<main>/_View/City G_rowth", draw_city_growth);
     menus_set_active("<main>/_View/City _Productions", draw_city_productions);
     menus_set_active("<main>/_View/Terrain", draw_terrain);
     menus_set_active("<main>/_View/Coastline", draw_coastline);
Index: client//gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.104
diff -u -r1.104 mapview.c
--- client//gui-xaw/mapview.c   2002/11/17 22:06:21     1.104
+++ client//gui-xaw/mapview.c   2002/11/18 21:38:10
@@ -735,22 +735,23 @@
 }
 
 /**************************************************************************
-Draw at x = center of string, y = top of string.
+Draw at x = left of string, y = top of string.
 **************************************************************************/
 static void draw_shadowed_string(XFontStruct * font, GC font_gc,
-                                         int x, int y, const char *string)
+                                enum color_std foreground,
+                                enum color_std shadow,
+                                int x, int y, const char *string)
 {
-  Window wndw=XtWindow(map_canvas);
-  int len=strlen(string);
-  int wth=XTextWidth(font, string, len);
-  int xs=x-wth/2;
-  int ys=y+font->ascent;
+  Window wndw = XtWindow(map_canvas);
+  size_t len = strlen(string);
 
-  XSetForeground(display, font_gc, colors_standard[COLOR_STD_BLACK]);
-  XDrawString(display, wndw, font_gc, xs+1, ys+1, string, len);
+  y += font->ascent;
 
-  XSetForeground(display, font_gc, colors_standard[COLOR_STD_WHITE]);
-  XDrawString(display, wndw, font_gc, xs, ys, string, len);
+  XSetForeground(display, font_gc, colors_standard[shadow]);
+  XDrawString(display, wndw, font_gc, x + 1, y + 1, string, len);
+
+  XSetForeground(display, font_gc, colors_standard[foreground]);
+  XDrawString(display, wndw, font_gc, x, y, string, len);
 }
 
 /**************************************************************************
@@ -771,31 +772,48 @@
 
       if (!normalize_map_pos(&rx, &ry))
         continue;
-
-      if((pcity=map_get_city(rx, ry))) {
 
-       if (draw_city_names) {
-         draw_shadowed_string(main_font_struct, font_gc,
-                              x*NORMAL_TILE_WIDTH+NORMAL_TILE_WIDTH/2,
-                              (y+1)*NORMAL_TILE_HEIGHT,
-                              pcity->name);
+      if ((pcity = map_get_city(rx, ry))) {
+       char buffer[512], buffer2[512];
+       enum color_std color;
+       int w, w2;
+
+       get_city_mapview_name_and_growth(pcity, buffer, sizeof(buffer),
+                                        buffer2, sizeof(buffer2), &color);
+
+       w = XTextWidth(main_font_struct, buffer, strlen(buffer));
+       if (buffer2[0] != '\0') {
+         /* HACK: put some extra space between the two strings. */
+         w += 10;
        }
+       w2 = XTextWidth(main_font_struct, buffer2, strlen(buffer2));
 
-       if (draw_city_productions && (pcity->owner==game.player_idx)) {
-         char buffer[512];
-       
+       draw_shadowed_string(main_font_struct, font_gc,
+                            COLOR_STD_WHITE, COLOR_STD_BLACK,
+                            x * NORMAL_TILE_WIDTH +
+                            NORMAL_TILE_WIDTH / 2 - (w + w2) / 2,
+                            (y + 1) * NORMAL_TILE_HEIGHT, buffer);
+
+       draw_shadowed_string(prod_font_struct, prod_font_gc, color,
+                            COLOR_STD_BLACK,
+                            x * NORMAL_TILE_WIDTH + NORMAL_TILE_WIDTH / 2 -
+                            (w + w2) / 2 + w, (y + 1) * NORMAL_TILE_HEIGHT,
+                            buffer2);
+
+       if (draw_city_productions && (pcity->owner == game.player_idx)) {
+         int yoffset = (draw_city_names ? main_font_struct->ascent +
+                        main_font_struct->descent : 0);
+
           get_city_mapview_production(pcity, buffer, sizeof(buffer));
+         w = XTextWidth(prod_font_struct, buffer, strlen(buffer));
 
          draw_shadowed_string(prod_font_struct, prod_font_gc,
-                              x*NORMAL_TILE_WIDTH+NORMAL_TILE_WIDTH/2,
-                              (y+1)*NORMAL_TILE_HEIGHT +
-                                (draw_city_names ?
-                                  main_font_struct->ascent +
-                                    main_font_struct->descent :
-                                  0),
-                              buffer);
+                              COLOR_STD_WHITE, COLOR_STD_BLACK,
+                              x * NORMAL_TILE_WIDTH +
+                              NORMAL_TILE_WIDTH / 2 - w / 2,
+                              (y + 1) * NORMAL_TILE_HEIGHT +
+                              yoffset, buffer);
        }
-
       }
     }
   }
Index: client//gui-xaw/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/menu.c,v
retrieving revision 1.50
diff -u -r1.50 menu.c
--- client//gui-xaw/menu.c      2002/11/14 09:15:01     1.50
+++ client//gui-xaw/menu.c      2002/11/18 21:38:10
@@ -129,6 +129,8 @@
 static struct MenuEntry view_menu_entries[]={
     { { N_("Map Grid"), 0             }, "ctl-g", MENU_VIEW_SHOW_MAP_GRID, 0 },
     { { N_("City Names"), 0           }, "ctl-n", MENU_VIEW_SHOW_CITY_NAMES, 0 
},
+    { { N_("City Growth"), 0          }, "ctl-r",
+      MENU_VIEW_SHOW_CITY_GROWTH, 0 },
     { { N_("City Productions"), 0     }, "ctl-p", 
MENU_VIEW_SHOW_CITY_PRODUCTIONS, 0 },
     { { 0                             },      "", MENU_SEPARATOR_LINE, 0 },
     { { N_("Terrain"), 0              },      "", MENU_VIEW_SHOW_TERRAIN, 0 },
@@ -277,6 +279,8 @@
     XtSetSensitive(menus[MENU_VIEW]->button, True);
     XtSetSensitive(menus[MENU_KINGDOM]->button, True);
 
+    menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_CITY_GROWTH,
+                        draw_city_names);
     menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_TERRAIN, 1);
     menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_COASTLINE, !draw_terrain);
     menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_ROADS_RAILS, 1);
@@ -503,6 +507,11 @@
     break;
   case MENU_VIEW_SHOW_CITY_NAMES:
     key_city_names_toggle();
+    menu_entry_sensitive(MENU_VIEW, MENU_VIEW_SHOW_CITY_GROWTH,
+                        draw_city_names);
+    break;
+  case MENU_VIEW_SHOW_CITY_GROWTH:
+    key_city_growth_toggle();
     break;
   case MENU_VIEW_SHOW_CITY_PRODUCTIONS:
     key_city_productions_toggle();
Index: client//gui-xaw/menu.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/menu.h,v
retrieving revision 1.13
diff -u -r1.13 menu.h
--- client//gui-xaw/menu.h      2001/04/20 22:16:01     1.13
+++ client//gui-xaw/menu.h      2002/11/18 21:38:10
@@ -50,6 +50,7 @@
 
   MENU_VIEW_SHOW_MAP_GRID,
   MENU_VIEW_SHOW_CITY_NAMES,
+  MENU_VIEW_SHOW_CITY_GROWTH,
   MENU_VIEW_SHOW_CITY_PRODUCTIONS,
   MENU_VIEW_SHOW_TERRAIN,
   MENU_VIEW_SHOW_COASTLINE,

[Prev in Thread] Current Thread [Next in Thread]