<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39385 >

Ulrik Sverdrup wrote:
> I did this with the field width wrong as well, but I think we should
> reserve a width up to 5 for build costs. I can imagine wonders costing
> more than 10000 if you buy them from scratch in the derfault ruleset.
> With mods or altered rulesets, it might be even more possible, so we
> should allow up to 5 digits.
> 
OK.  Done.


> + { TRUE, 4, 1, NULL, N_("?gold:Buy"), N_("Gold to purchase building"),
> + NULL, FUNC_TAG(buy_cost) },
> 
> In this change, shouldn't it be FALSE in the first field (for
> numerical values), And a better long text would be "Cost to rush
> production" (I think that is consistent with other wording around in
> freeciv, and "building" might associate to improvement which is wrong.
> 
The first field is whether to show by default.  We want it to show --
it is the same Buy formerly shown in "Currently Building".

After playing around a bit, I've combined the Turns and Buy into a
single column.  Two columns just takes too much screen real estate.
The sort always seems to have the buy cost roughly correspond to the
remaining turns.  How about:

?action:Building
Turns/Buy

Turns or gold to complete production

===

While playing around, I've implemented my wish list of changes.

It's always bugged me that the specialists occur at the far right, after
the buildings.  That turned out to be an artifact of the initialization.

And that the name of the city scrolls off to the left as I'm looking at
buildings.  So, I moved the city name into the middle.

All the happiness and growth (and units) are now to the left.

All the science, production, and trade are now to the right.

Comments?

Index: client/cityrepdata.c
===================================================================
--- client/cityrepdata.c        (revision 12977)
+++ client/cityrepdata.c        (working copy)
@@ -60,8 +60,8 @@
                                           const void *data)
 {
   static char buf[4];
-  my_snprintf(buf, sizeof(buf), "%s", (city_celebrating(pcity) ? "*" :
-                                      (city_unhappy(pcity) ? "X" : " ")));
+  my_snprintf(buf, sizeof(buf), "%s", (city_celebrating(pcity) ? "+" :
+                                      (city_unhappy(pcity) ? "-" : " ")));
   return buf;
 }
 
@@ -272,9 +272,8 @@
   static char buf[32];
   int goldie = pcity->surplus[O_GOLD];
 
-  my_snprintf(buf, sizeof(buf), "%s%d/%d/%d",
-             (goldie < 0) ? "-" : (goldie > 0) ? "+" : "",
-             (goldie < 0) ? (-goldie) : goldie,
+  my_snprintf(buf, sizeof(buf), "%3d/%d/%d",
+             goldie,
              pcity->prod[O_LUXURY],
              pcity->prod[O_SCIENCE]);
   return buf;
@@ -311,28 +310,24 @@
   return buf;
 }
 
-static const char *cr_entry_food(const struct city *pcity,
-                                const void *data)
-{
-  static char buf[32];
-  my_snprintf(buf, sizeof(buf), "%d/%d",
-             pcity->food_stock,
-             city_granary_size(pcity->size) );
-  return buf;
-}
-
 static const char *cr_entry_growturns(const struct city *pcity,
                                      const void *data)
 {
-  static char buf[8];
   int turns = city_turns_to_grow(pcity);
+  char buffer[8];
+  static char buf[32];
+
   if (turns == FC_INFINITY) {
     /* 'never' wouldn't be easily translatable here. */
-    my_snprintf(buf, sizeof(buf), "-");
+    my_snprintf(buffer, sizeof(buffer), "---");
   } else {
     /* Shrinking cities get a negative value. */
-    my_snprintf(buf, sizeof(buf), "%4d", turns);
+    my_snprintf(buffer, sizeof(buffer), "%4d", turns);
   }
+  my_snprintf(buf, sizeof(buf), "%s (%d/%d)",
+             buffer,
+             pcity->food_stock,
+             city_granary_size(pcity->size) );
   return buf;
 }
 
@@ -362,21 +357,13 @@
        
   if (!pcity->production.is_unit
       && impr_flag(pcity->production.value, IF_GOLD)) {
-    my_snprintf(buf, sizeof(buf), "%s (%d/X/X/X)%s",
+    my_snprintf(buf, sizeof(buf), "%s (%d/X)%s",
                get_impr_name_ex(pcity, pcity->production.value),
                MAX(0, pcity->surplus[O_SHIELD]), from_worklist);
   } else {
-    int turns = city_turns_to_build(pcity, pcity->production, TRUE);
-    char time[32];
     const char *name;
     int cost;
 
-    if (turns < 999) {
-      my_snprintf(time, sizeof(time), "%d", turns);
-    } else {
-      my_snprintf(time, sizeof(time), "-");
-    }
-
     if(pcity->production.is_unit) {
       name = get_unit_type(pcity->production.value)->name;
       cost = unit_build_shield_cost(get_unit_type(pcity->production.value));
@@ -385,19 +372,42 @@
       cost = impr_build_shield_cost(pcity->production.value);
     }
 
-    my_snprintf(buf, sizeof(buf), "%s (%d/%d/%s/%d)%s", name,
-               pcity->shield_stock, cost, time, city_buy_cost(pcity),
+    my_snprintf(buf, sizeof(buf), "%s (%d/%d)%s", name,
+               pcity->shield_stock, cost,
                from_worklist);
   }
 
   return buf;
 }
 
+static const char *cr_entry_build_cost(const struct city *pcity,
+                                 const void *data)
+{
+  int price = city_buy_cost(pcity);
+  int turns = city_turns_to_build(pcity, pcity->production, TRUE);
+  char bufone[8];
+  char buftwo[8];
+  static char buf[32];
+
+  if (price > 99999) {
+    my_snprintf(bufone, sizeof(bufone), "---");
+  } else {
+    my_snprintf(bufone, sizeof(bufone), "%d", price);
+  }
+  if (turns > 999) {
+    my_snprintf(buftwo, sizeof(buftwo), "--");
+  } else {
+    my_snprintf(buftwo, sizeof(buftwo), "%3d", turns);
+  }
+  my_snprintf(buf, sizeof(buf), "%s/%s", buftwo, bufone);
+  return buf;
+}
+
 static const char *cr_entry_corruption(const struct city *pcity,
                                       const void *data)
 {
   static char buf[8];
-  my_snprintf(buf, sizeof(buf), "%3d", pcity->waste[O_TRADE]);
+  my_snprintf(buf, sizeof(buf), "%3d", -(pcity->waste[O_TRADE]));
   return buf;
 }
 
@@ -405,7 +415,7 @@
                                  const void *data)
 {
   static char buf[8];
-  my_snprintf(buf, sizeof(buf), "%3d", pcity->waste[O_SHIELD]);
+  my_snprintf(buf, sizeof(buf), "%3d", -(pcity->waste[O_SHIELD]));
   return buf;
 }
 
@@ -417,27 +427,25 @@
 
 /* City report options (which columns get shown)
  * To add a new entry, you should just have to:
- * - increment NUM_CREPORT_COLS in cityrepdata.h
  * - add a function like those above
- * - add an entry in the city_report_specs[] table
+ * - add an entry in the base_city_report_specs[] table
  */
 
 /* This generates the function name and the tagname: */
 #define FUNC_TAG(var)  cr_entry_##var, #var 
 
 static const struct city_report_spec base_city_report_specs[] = {
-  { TRUE, -15, 0, NULL,  N_("?city:Name"),      N_("City Name"),
-    NULL, FUNC_TAG(cityname) },
-  { TRUE, 2, 1, NULL,  N_("?size:Sz"),        N_("Size"),
-    NULL, FUNC_TAG(size) },
-  { TRUE,  -8, 1, NULL,  N_("State"),     N_("Rapture/Peace/Disorder"),
+  /* Specialists grouped with init_city_report_game_data specialists */ 
+  { FALSE,  7, 1, N_("Special"),
+    N_("?entertainers/scientists/taxmen:E/S/T"),
+    N_("Entertainers, Scientists, Taxmen"),
+    NULL, FUNC_TAG(specialists) },
+
+  { FALSE,  1, 1, NULL,  NULL,          N_("Concise +=Rapture, -=Disorder"),
+    NULL, FUNC_TAG(hstate_concise) },
+  { TRUE,  -8, 1, NULL,  N_("State"),   N_("Rapture/Peace/Disorder"),
     NULL, FUNC_TAG(hstate_verbose) },
-  { FALSE,  1, 1, NULL,  NULL,            N_("Concise *=Rapture, X=Disorder"),
-    NULL, FUNC_TAG(hstate_concise) },
-  { TRUE, 10, 1, N_("Workers"),
-    N_("?happy/content/unhappy/angry:H/C/U/A"),
-    N_("Workers: Happy, Content, Unhappy, Angry"),
-    NULL, FUNC_TAG(workers) },
+
   { FALSE, 2, 1, NULL, N_("?Happy workers:H"), N_("Workers: Happy"),
     NULL, FUNC_TAG(happy) },
   { FALSE, 2, 1, NULL, N_("?Content workers:C"), N_("Workers: Content"),
@@ -446,29 +454,45 @@
     NULL, FUNC_TAG(unhappy) },
   { FALSE, 2, 1, NULL, N_("?Angry workers:A"), N_("Workers: Angry"),
     NULL, FUNC_TAG(angry) },
-  { FALSE, 7, 1, N_("Special"),
-    N_("?entertainers/scientists/taxmen:E/S/T"),
-    N_("Entertainers, Scientists, Taxmen"),
-    NULL, FUNC_TAG(specialists) },
+  { TRUE, 10, 1, N_("Workers"),
+    N_("?happy/content/unhappy/angry:H/C/U/A"),
+    N_("Workers: Happy, Content, Unhappy, Angry"),
+    NULL, FUNC_TAG(workers) },
+
   { FALSE, 8, 1, N_("Best"), N_("attack"),
     N_("Best attacking units"), NULL, FUNC_TAG(attack)},
   { FALSE, 8, 1, N_("Best"), N_("defense"),
     N_("Best defending units"), NULL, FUNC_TAG(defense)},
-  { FALSE, 2, 1, N_("Units"), N_("?Supported (units):Sup"),
+  { FALSE, 2, 1, N_("Units"), N_("?Present (units):Here"),
+    N_("Number of units present"), NULL, FUNC_TAG(present) },
+  { FALSE, 2, 1, N_("Units"), N_("?Supported (units):Owned"),
     N_("Number of units supported"), NULL, FUNC_TAG(supported) },
-  { FALSE, 2, 1, N_("Units"), N_("?Present (units):Prs"),
-    N_("Number of units present"), NULL, FUNC_TAG(present) },
 
-  { TRUE,  10, 1, N_("Surplus"), N_("?food/prod/trade:F/P/T"),
+  { TRUE,  14, 1, N_("?turn:Grow"), N_("(Have/Need)"),
+    N_("Turns until growth/famine"),
+    NULL, FUNC_TAG(growturns) },
+  { TRUE,   2, 1, NULL,  N_("?size:Sz"),        N_("Size"),
+    NULL, FUNC_TAG(size) },
+
+  /* city name closer to center, try to keep within scroll window */
+  { TRUE, -15, 0, NULL,  N_("?city:Name"),      N_("City Name"),
+    NULL, FUNC_TAG(cityname) },
+
+  { TRUE,  10, 1, N_("Surplus"), N_("?food/production/trade:F/P/T"),
                                  N_("Surplus: Food, Production, Trade"),
     NULL, FUNC_TAG(resources) },
-  { FALSE, 3, 1, NULL, N_("?Food surplus:F+"), N_("Surplus: Food"),
+  { FALSE,  3, 1, NULL, N_("?Food surplus:+F"), N_("Surplus: Food"),
     NULL, FUNC_TAG(foodplus) },
-  { FALSE, 3, 1, NULL, N_("?Production surplus:P+"),
+  { FALSE,  3, 1, NULL, N_("?Production surplus:+P"),
     N_("Surplus: Production"), NULL, FUNC_TAG(prodplus) },
-  { FALSE, 3, 1, NULL, N_("?Trade surplus:T+"), N_("Surplus: Trade"),
+  { FALSE,  3, 1, NULL, N_("?Production loss:-P"), N_("Waste"),
+    NULL, FUNC_TAG(waste) },
+  { FALSE,  3, 1, NULL, N_("?Trade surplus:+T"), N_("Surplus: Trade"),
     NULL, FUNC_TAG(tradeplus) },
-  { TRUE,  10, 1, N_("Economy"), N_("?gold/lux/sci:G/L/S"),
+  { FALSE,  3, 1, NULL, N_("?Trade loss:-T"), N_("Corruption"),
+    NULL, FUNC_TAG(corruption) },
+
+  { TRUE,  10, 1, N_("Economy"), N_("?gold/luxury/science:G/L/S"),
                                  N_("Economy: Gold, Luxuries, Science"),
     NULL, FUNC_TAG(output) },
   { FALSE, 3, 1, NULL, N_("?Gold:G"), N_("Economy: Gold"),
@@ -480,19 +504,15 @@
   { FALSE,  1, 1, N_("?trade_routes:n"), N_("?trade_routes:T"),
                                          N_("Number of Trade Routes"),
     NULL, FUNC_TAG(num_trade) },
-  { TRUE,   7, 1, N_("Food"), N_("Stock"), N_("Food Stock"),
-    NULL, FUNC_TAG(food) },
-  { FALSE,  3, 1, NULL, N_("?pollution:Pol"),        N_("Pollution"),
+  { FALSE,  3, 1, NULL, N_("?pollution:Pol"), N_("Pollution"),
     NULL, FUNC_TAG(pollution) },
-  { FALSE,  4, 1, N_("Grow"), N_("Turns"), N_("Turns until growth/famine"),
-    NULL, FUNC_TAG(growturns) },
-  { FALSE,  3, 1, NULL, N_("?corruption:Cor"),        N_("Corruption"),
-    NULL, FUNC_TAG(corruption) },
-  { FALSE,  3, 1, NULL, N_("?waste:Was"), N_("Waste"),
-    NULL, FUNC_TAG(waste) },
-  { TRUE,  15, 1, NULL, N_("?cma:Governor"),         N_("Citizen Governor"),
+  { FALSE, 15, 1, NULL, N_("?cma:Governor"), N_("Citizen Governor"),
     NULL, FUNC_TAG(cma) },
-  { TRUE,   0, 1, N_("Currently Building"), N_("(Stock,Target,Turns,Buy)"),
+
+  { TRUE,   9, 1, N_("?action:Building"), N_("Turns/Buy"),
+    N_("Turns or gold to complete production"),
+    NULL, FUNC_TAG(build_cost) },
+  { TRUE,   0, 1, N_("Currently Building"), N_("(Have/Need)"),
                                             N_("Currently Building"),
     NULL, FUNC_TAG(building) }
 };
@@ -523,31 +543,17 @@
 ******************************************************************/
 void init_city_report_game_data(void)
 {
+  static char explanation[SP_MAX][128];
+  struct city_report_spec *p;
   int i;
 
   num_creport_cols = ARRAY_SIZE(base_city_report_specs) + SP_COUNT;
   city_report_specs
     = fc_realloc(city_report_specs,
                 num_creport_cols * sizeof(*city_report_specs));
-  memcpy(city_report_specs, base_city_report_specs,
-        sizeof(base_city_report_specs));
+  p = &city_report_specs[0];
 
-  for (i = 0; i < ARRAY_SIZE(base_city_report_specs); i++) {
-    struct city_report_spec* p = &city_report_specs[i];
-
-    if (p->title1) {
-      p->title1 = Q_(p->title1);
-    }
-    if (p->title2) {
-      p->title2 = Q_(p->title2);
-    }
-    p->explanation = _(p->explanation);
-  }
-
   specialist_type_iterate(sp) {
-    struct city_report_spec *p = &city_report_specs[i];
-    static char explanation[SP_MAX][128];
-
     p->show = FALSE;
     p->width = 2;
     p->space = 1;
@@ -559,10 +565,23 @@
     p->data = get_specialist(sp);
     p->func = cr_entry_specialist;
     p->tagname = get_specialist(sp)->name;
-
-    i++;
+    p++;
   } specialist_type_iterate_end;
 
+  memcpy(p, base_city_report_specs,
+        sizeof(base_city_report_specs));
+
+  for (i = 0; i < ARRAY_SIZE(base_city_report_specs); i++) {
+    if (p->title1) {
+      p->title1 = Q_(p->title1);
+    }
+    if (p->title2) {
+      p->title2 = Q_(p->title2);
+    }
+    p->explanation = _(p->explanation);
+    p++;
+  }
+
   assert(NUM_CREPORT_COLS == ARRAY_SIZE(base_city_report_specs) + SP_COUNT);
 }
 
Index: client/gui-gtk-2.0/cityrep.c
===================================================================
--- client/gui-gtk-2.0/cityrep.c        (revision 12977)
+++ client/gui-gtk-2.0/cityrep.c        (working copy)
@@ -653,7 +653,7 @@
   int i;
 
   menu = gtk_menu_new();
-  for(i=1, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) {
+  for(i=0, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) {
     item = gtk_check_menu_item_new_with_label(spec->explanation);
     gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
     gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), spec->show);
Index: client/gui-xaw/cityrep.c
===================================================================
--- client/gui-xaw/cityrep.c    (revision 12977)
+++ client/gui-xaw/cityrep.c    (working copy)
@@ -696,7 +696,7 @@
 
   config_toggle = fc_realloc(config_toggle,
                             NUM_CREPORT_COLS * sizeof(*config_toggle));
-  for(i=1, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) {
+  for(i=0, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) {
     my_snprintf(buf, sizeof(buf), "%-32s", spec->explanation);
     above = (i==1)?config_label:config_optlabel;
 
@@ -744,7 +744,7 @@
   
   XtDestroyWidget(config_shell);
 
-  for(i=1, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) {
+  for(i=0, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) {
     Boolean b;
 
     XtVaGetValues(config_toggle[i], XtNstate, &b, NULL);
Index: client/gui-win32/cityrep.c
===================================================================
--- client/gui-win32/cityrep.c  (revision 12977)
+++ client/gui-win32/cityrep.c  (working copy)
@@ -125,7 +125,7 @@
   struct city_report_spec *spec;   
   box=fcwin_vbox_new(hWnd,FALSE);
   fcwin_box_add_static_default(box,_("Set columns shown"),-1,SS_CENTER);
-  for(i=1, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) {     
+  for(i=0, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) {     
     fcwin_box_add_checkbox(box, spec->explanation,
                           ID_CITYREP_CONFIG_BASE+i,0,FALSE,FALSE,5);
   }
@@ -157,7 +157,7 @@
        {
          struct city_report_spec *spec;   
          int i;
-         for(i=1, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) 
+         for(i=0, spec=city_report_specs+i; i<NUM_CREPORT_COLS; i++, spec++) 
            {   
              spec->show=IsDlgButtonChecked(hWnd,ID_CITYREP_CONFIG_BASE+i);  
            }
Index: client/options.c
===================================================================
--- client/options.c    (revision 12977)
+++ client/options.c    (working copy)
@@ -555,7 +555,7 @@
   }
 
   /* Load city report columns (which include some ruleset data). */
-  for (i = 1; i < num_city_report_spec(); i++) {
+  for (i = 0; i < num_city_report_spec(); i++) {
     bool *ip = city_report_spec_show_ptr(i);
 
     *ip = secfile_lookup_bool_default(&sf, *ip, "client.city_report_%s",
@@ -610,7 +610,7 @@
 
   message_options_save(&sf, "client");
 
-  for (i = 1; i < num_city_report_spec(); i++) {
+  for (i = 0; i < num_city_report_spec(); i++) {
     secfile_insert_bool(&sf, *(city_report_spec_show_ptr(i)),
                       "client.city_report_%s",
                       city_report_spec_tagname(i));
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to