[Freeciv-Dev] Patch adds trade info to GTK display. (PR#42)
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Full_Name: Bobby D. Bryant
Version: CVS
OS: Linux
Submission from: (NULL) (129.116.78.130)
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.
The patch is intended as a human engineering improvement, since it makes it
possible to see how many trade routes your city has while you are perusing your
production options in the "Change" menu.
A screenshot of the change is (temporarily) available at
http://www.cs.utexas.edu/users/bdbryant/freeciv/screenshot-city.jpeg.gz. The
screenshot was chosen to show (a) that the patch supports a variable number of
trade routes (in this case the city has 2), and (b) long city names are
abbreviated in order to keep the figures lined up in a column ("Birmingham" -->
"Birmingh.").
Since this is part of the GTK GUI, I request/suggest including it in the 1.8.1
release.
N.B. -- I made the patch a few weeks ago, but have successfully applied it to
several new CVS fetches since then.
Bobby.
---8<-------
--- 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);
- [Freeciv-Dev] Patch adds trade info to GTK display. (PR#42),
bdbryant <=
|
|