Complete.Org: Mailing Lists: Archives: freeciv-dev: June 1999:
[freeciv-dev] Patch adds trade info to GTK city display.
Home

[freeciv-dev] Patch adds trade info to GTK city display.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: - freeciv-dev <freeciv-dev@xxxxxxxxxxx>
Subject: [freeciv-dev] Patch adds trade info to GTK city display.
From: "Bobby D. Bryant" <bdbryant@xxxxxxxxxxxxxxx>
Date: Sun, 13 Jun 1999 08:18:02 -0500

This is a patch to client/gui-gtk/citydlg.c.  It splits up the "Trade:"
info in the panel at the left of the city display, separating out the
amounts recieved from the city's various sources.

This helps with a frustrating problem that I mentioned a month or two
back, namely that when you call up the production "Change" window from
the city display you can't see your trade route info, so if there's no
obvious production choice you often have to back out of the "Change"
window, click "Trade" to see whether you should consider buying a
Caravan, exit "Trade", call up "Change" again, and then make your choice
based on the new information.  I find myself doing this many times over
the course of a game; I was playing just for fun last night, and got so
tired of doing this that I stopped and fixed it.  You can now see how
many trade routes the city has and how productive they are, all by a
glance at the main city display, whether the "Change" window is open or
not.

The "Trade" button on the city display may or may not be considered
obsolete by this patch; I didn't want to remove it until somebody
expressed an opinion.  (It's almost completely redundant, except that it
calculates the total for the trade routes and does not abbreviate long
city names.  Mine totals the trade routes + rest-of-city rather than the
routes alone, and abbreviates names with length > 9, in order to keep
the numeric columns aligned.)

Also, if people like this patch I'm considering trying to crowd in more
information on the panel showing how much gold you're losing to
corruption and maintenance costs.  (I didn't really understand all the
numbers in the display until I read the code while working on this
patch!  [See my next message.])

The patch applies to the GTK display only.  It is derived from the CVS
snapshot dated 11-Jun-1999. (Sorry; I get an error when I try to
download either of the two more recent ones.)

Bobby Bryant
Austin, Texas

--- client/gui-gtk/citydlg.c-orig       Sun Jun 13 04:03:21 1999
+++ client/gui-gtk/citydlg.c    Sun Jun 13 07:05:02 1999
@@ -885,7 +885,7 @@
   GtkStyle *s;
   int col;
 
-  sprintf(buf, "Pollution:   %3d", pcity->pollution);
+  sprintf(buf, "Pollution:      %3d", pcity->pollution);
 
   gtk_set_label(pdialog->pollution_label, buf);
 
@@ -910,7 +910,7 @@
   char buf[512];
   struct city *pcity=pdialog->pcity;
   
-  sprintf(buf, "Granary: %3d/%-3d", pcity->food_stock,
+  sprintf(buf, "Granary:    %3d/%-3d", pcity->food_stock,
          game.foodbox*pcity->size);
 
   gtk_set_label(pdialog->storage_label, buf);
@@ -955,10 +955,53 @@
 {
   char buf[512];
   struct city *pcity=pdialog->pcity;
+
+  /* The following is mostly duplicode from trade_callback, but the
+     Trade button can probably be removed if this patch is accepted. */
+
+  int i;
+  int x=0,routetotal=0;
+  char routebuf[512],*routebptr=routebuf;
   
-  sprintf(buf, "Food:    %2d (%+2d)\nProd:    %2d (%+2d)\nTrade:   %2d (%+2d)",
+  for(i=0; i<4; i++)
+     if(pcity->trade[i]) {
+      struct city *proutecity;
+      x=1;
+      routetotal+=pcity->trade_value[i];
+      if((proutecity=find_city_by_id(pcity->trade[i]))) {
+       if(strlen(proutecity->name)<=9) {
+       sprintf(routebptr, "  %-9s %2d\n",
+               proutecity->name, pcity->trade_value[i]);
+       }
+       else {
+       sprintf(routebptr, "  %-8.8s. %2d\n", /* 2nd period is abbreviation */
+               proutecity->name, pcity->trade_value[i]);
+       }
+       routebptr += strlen(routebptr);
+      }
+      else {
+       sprintf(routebptr, "  (unknown) %2d\n",
+              pcity->trade_value[i]);
+       routebptr += strlen(routebptr);
+      }
+     }
+  if(!x)
+     sprintf(routebptr, "  (none)\n");
+
+  /* End duplicode. */
+
+  sprintf(buf,
+         "Food:       %2d (%+2d)\n"
+         "Prod:       %2d (%+2d)\n"
+         "Income -\n"
+         " From City: %2d\n"
+         " From Trade,\n"
+         "%s" /* Pre-formatted trade route list, per above. */
+         " Total:     %2d (%+2d)",
          pcity->food_prod, pcity->food_surplus,
          pcity->shield_prod, pcity->shield_surplus,
+         pcity->trade_prod+pcity->corruption-routetotal,
+         routebuf,
          pcity->trade_prod+pcity->corruption, pcity->trade_prod);
 
   gtk_set_label(pdialog->production_label, buf);
@@ -971,7 +1014,7 @@
   char buf[512];
   struct city *pcity=pdialog->pcity;
   
-  sprintf(buf, "Gold:    %2d (%+2d)\nLuxury:  %2d\nScience: %2d",
+  sprintf(buf, "Gold:       %2d (%+2d)\nLuxury:     %2d\nScience:    %2d",
          pcity->tax_total, city_gold_surplus(pcity),
          pcity->luxury_total,
          pcity->science_total);

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-dev] Patch adds trade info to GTK city display., Bobby D. Bryant <=