Complete.Org: Mailing Lists: Archives: freeciv-dev: September 1999:
[Freeciv-Dev] patch: generalized xhelp on unit upkeep parameters (PR#132
Home

[Freeciv-Dev] patch: generalized xhelp on unit upkeep parameters (PR#132

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] patch: generalized xhelp on unit upkeep parameters (PR#132)
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sat, 18 Sep 1999 21:27:22 -0700 (PDT)

(Subject line munged in attempt to thwart Listar...)

With the generality for unit upkeep now allowed in the units
ruleset, the ehlp system should really show this generalised
information.

This patch does this for both Xaw and Gtk+, and also makes 
vision range as a widget instead of in text, for the Gtk+ client.

The only problem is that the format is probably confusingly 
concise, eg:
   1s/1h  =>  1 shield, 1 unhappy (eg military units)
   1s/1f  =>  1 shield, 1 food    (eg Settlers/Engineers)
   0      =>  none (eg, Caravan, Diplomat etc)

But making it more verbose means possible space problems
in the fully general case ... 

-- David
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-gtk/helpdlg.c 
freeciv-mod/client/gui-gtk/helpdlg.c
--- freeciv-cvs/client/gui-gtk/helpdlg.c        Sun Sep 19 12:06:52 1999
+++ freeciv-mod/client/gui-gtk/helpdlg.c        Sun Sep 19 13:21:10 1999
@@ -68,7 +68,7 @@
 GtkWidget *            help_tree_scrolled;
 GtkWidget *            help_ilabel     [6];
 GtkWidget *            help_wlabel     [6];
-GtkWidget *            help_ulabel     [4][5];
+GtkWidget *            help_ulabel     [5][5];
 GtkWidget *            help_tlabel     [4][5];
 
 char *help_ilabel_name[6] =
@@ -77,11 +77,12 @@
 char *help_wlabel_name[6] =
 { N_("Cost:"), "", N_("Requirement:"), "", N_("Obsolete by:"), "" };
 
-char *help_ulabel_name[4][5] =
+char *help_ulabel_name[5][5] =
 {
     { N_("Cost:"),             "", "", N_("Attack:"),  "" },
     { N_("Defense:"),  "", "", N_("Move:")     ,       "" },
     { N_("FirePower:"),        "", "", N_("Hitpoints:"),       "" },
+    { N_("Basic Upkeep:"),     "", "", N_("Vision:"),  "" },
     { N_("Requirement:"),      "", "", N_("Obsolete by:"),     "" }
 };
 
@@ -363,12 +364,12 @@
   gtk_box_pack_start(GTK_BOX(help_box), help_utable, FALSE, FALSE, 0);
 
   for (i=0; i<5; i++)
-    for (j=0; j<4; j++)
+    for (j=0; j<5; j++)
     {
       help_ulabel[j][i] = gtk_label_new(_(help_ulabel_name[j][i]));
       gtk_widget_set_style(help_ulabel[j][i], style);
 
-      if (j==3 && (i==1 || i==4))
+      if (j==4 && (i==1 || i==4))
       {
        if (i==1)
           button = help_hyperlink_new(help_ulabel[j][i], HELP_TECH);
@@ -558,25 +559,22 @@
     gtk_set_label(help_ulabel[2][1], buf);
     sprintf(buf, "%d", utype->hp);
     gtk_set_label(help_ulabel[2][4], buf);
+    gtk_set_label(help_ulabel[3][1], helptext_unit_upkeep_str(i));
     sprintf(buf, "%d", utype->vision_range);
-/*    xaw_set_label(help_unit_visrange_data, buf); -- FIXME */
+    gtk_set_label(help_ulabel[3][4], buf);
     if(utype->tech_requirement==A_LAST) {
-      gtk_set_label(help_ulabel[3][1], _("(Never)"));
+      gtk_set_label(help_ulabel[4][1], _("(Never)"));
     } else {
-      gtk_set_label(help_ulabel[3][1], advances[utype->tech_requirement].name);
+      gtk_set_label(help_ulabel[4][1], advances[utype->tech_requirement].name);
     }
 /*    create_tech_tree(help_improvement_tree, 0, utype->tech_requirement, 3);*/
     if(utype->obsoleted_by==-1) {
-      gtk_set_label(help_ulabel[3][4], _("None"));
+      gtk_set_label(help_ulabel[4][4], _("None"));
     } else {
-      gtk_set_label(help_ulabel[3][4], 
get_unit_type(utype->obsoleted_by)->name);
+      gtk_set_label(help_ulabel[4][4], 
get_unit_type(utype->obsoleted_by)->name);
     }
 
-    /* No separate Vision widget for Gtk+ client (yet?) */
-    sprintf(buf, _("* Vision range of %d square%s.\n"),
-       utype->vision_range, (utype->vision_range==1)?"":"s"); /* -- REMOVE ME 
*/
-
-    helptext_unit(buf+strlen(buf), i, pitem->text);
+    helptext_unit(buf, i, pitem->text);
 
     gtk_text_freeze(GTK_TEXT(help_text));
     gtk_text_insert(GTK_TEXT(help_text), NULL, NULL, NULL, buf, -1);
@@ -594,11 +592,12 @@
     gtk_set_label(help_ulabel[1][4], "0");
     gtk_set_label(help_ulabel[2][1], "0");
     gtk_set_label(help_ulabel[2][4], "0");
-/*    xaw_set_label(help_unit_visrange_data, "0 "); -- FIXME */
+    gtk_set_label(help_ulabel[3][1], "0");
+    gtk_set_label(help_ulabel[3][4], "0");
 
-    gtk_set_label(help_ulabel[3][1], _("(Never)"));
+    gtk_set_label(help_ulabel[4][1], _("(Never)"));
 /*    create_tech_tree(help_improvement_tree, 0, A_LAST, 3);*/
-    gtk_set_label(help_ulabel[3][4], _("None"));
+    gtk_set_label(help_ulabel[4][4], _("None"));
 
     gtk_text_freeze(GTK_TEXT(help_text));
     gtk_text_insert(GTK_TEXT(help_text), NULL, NULL, NULL, pitem->text, -1);
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-xaw/Freeciv.h 
freeciv-mod/client/gui-xaw/Freeciv.h
--- freeciv-cvs/client/gui-xaw/Freeciv.h        Sun Sep 19 12:02:16 1999
+++ freeciv-mod/client/gui-xaw/Freeciv.h        Sun Sep 19 13:21:10 1999
@@ -595,7 +595,7 @@
 "Freeciv*helpdialog.*.helpunittile.internalWidth: 0",
 "Freeciv*helpdialog.*.helpunittile.internalHeight: 0",
 "Freeciv*helpdialog.*.helpunittile.fromVert: helptext",
-"Freeciv*helpdialog.*.helpunittile.fromHoriz: helpunitmovedata",
+"Freeciv*helpdialog.*.helpunittile.fromHoriz: helpunitvisrangedata",
 "Freeciv*helpdialog.*.helpunittile.left: chainLeft",
 "Freeciv*helpdialog.*.helpunittile.right: chainLeft",
 "Freeciv*helpdialog.*.helpunittile.top: chainTop",
@@ -632,14 +632,14 @@
 "Freeciv*helpdialog.*.helpunitfpdata.bottom: chainTop",
 "Freeciv*helpdialog.*.helpunitfpdata.background: lightblue",
 "Freeciv*helpdialog.*.helpunitfpdata.borderWidth: 0",
-"Freeciv*helpdialog.*.helpunitvisrange.fromVert: helpunitcost",
-"Freeciv*helpdialog.*.helpunitvisrange.fromHoriz: helpunithpdata",
+"Freeciv*helpdialog.*.helpunitvisrange.fromVert: helptext",
+"Freeciv*helpdialog.*.helpunitvisrange.fromHoriz: helpunitmovedata",
 "Freeciv*helpdialog.*.helpunitvisrange.label: Vision:",
 "Freeciv*helpdialog.*.helpunitvisrange.left: chainLeft",
 "Freeciv*helpdialog.*.helpunitvisrange.right: chainLeft",
 "Freeciv*helpdialog.*.helpunitvisrange.top: chainTop",
 "Freeciv*helpdialog.*.helpunitvisrange.bottom: chainTop",
-"Freeciv*helpdialog.*.helpunitvisrangedata.fromVert: helpunitcost",
+"Freeciv*helpdialog.*.helpunitvisrangedata.fromVert: helptext",
 "Freeciv*helpdialog.*.helpunitvisrangedata.fromHoriz: helpunitvisrange",
 "Freeciv*helpdialog.*.helpunitvisrangedata.label: 1\\ ",
 "Freeciv*helpdialog.*.helpunitvisrangedata.left: chainLeft",
@@ -648,6 +648,23 @@
 "Freeciv*helpdialog.*.helpunitvisrangedata.bottom: chainTop",
 "Freeciv*helpdialog.*.helpunitvisrangedata.background: lightblue",
 "Freeciv*helpdialog.*.helpunitvisrangedata.borderWidth: 0",
+"Freeciv*helpdialog.*.helpunitupkeep.fromVert: helpunitcost",
+"Freeciv*helpdialog.*.helpunitupkeep.fromHoriz: helpunithpdata",
+"Freeciv*helpdialog.*.helpunitupkeep.label: Basic Upkeep:",
+"Freeciv*helpdialog.*.helpunitupkeep.left: chainLeft",
+"Freeciv*helpdialog.*.helpunitupkeep.right: chainLeft",
+"Freeciv*helpdialog.*.helpunitupkeep.top: chainTop",
+"Freeciv*helpdialog.*.helpunitupkeep.bottom: chainTop",
+"Freeciv*helpdialog.*.helpunitupkeepdata.fromVert: helpunitcost",
+"Freeciv*helpdialog.*.helpunitupkeepdata.fromHoriz: helpunitupkeep",
+"Freeciv*helpdialog.*.helpunitupkeepdata.label: 1s/1f/1h/1g",
+"Freeciv*helpdialog.*.helpunitupkeepdata.justify: left",
+"Freeciv*helpdialog.*.helpunitupkeepdata.left: chainLeft",
+"Freeciv*helpdialog.*.helpunitupkeepdata.right: chainLeft",
+"Freeciv*helpdialog.*.helpunitupkeepdata.top: chainTop",
+"Freeciv*helpdialog.*.helpunitupkeepdata.bottom: chainTop",
+"Freeciv*helpdialog.*.helpunitupkeepdata.background: lightblue",
+"Freeciv*helpdialog.*.helpunitupkeepdata.borderWidth: 0",
 "Freeciv*helpdialog.*.helpunitcost.fromVert: helptext",
 "Freeciv*helpdialog.*.helpunitcost.label: Cost:",
 "Freeciv*helpdialog.*.helpunitcost.left: chainLeft",
diff -u -r --exclude-from exclude freeciv-cvs/client/gui-xaw/helpdlg.c 
freeciv-mod/client/gui-xaw/helpdlg.c
--- freeciv-cvs/client/gui-xaw/helpdlg.c        Sun Sep 19 12:06:52 1999
+++ freeciv-mod/client/gui-xaw/helpdlg.c        Sun Sep 19 13:21:11 1999
@@ -79,6 +79,7 @@
 Widget help_unit_fp, help_unit_fp_data;
 Widget help_unit_cost, help_unit_cost_data;
 Widget help_unit_visrange, help_unit_visrange_data;
+Widget help_unit_upkeep, help_unit_upkeep_data;
 Widget help_unit_tile;
 
 Widget help_terrain_movement_defense, help_terrain_movement_defense_data;
@@ -479,6 +480,16 @@
                                               labelWidgetClass, 
                                               help_right_form,
                                               NULL);
+
+    help_unit_visrange=XtVaCreateManagedWidget("helpunitvisrange",
+                                              labelWidgetClass,
+                                              help_right_form,
+                                              NULL);
+    help_unit_visrange_data=XtVaCreateManagedWidget("helpunitvisrangedata",
+                                                   labelWidgetClass,
+                                                   help_right_form,
+                                                   NULL);
+     
     help_unit_tile=XtVaCreateManagedWidget("helpunittile",
                                           labelWidgetClass,
                                           help_right_form,
@@ -505,11 +516,11 @@
                                              help_right_form,
                                              NULL);
    
-    help_unit_visrange=XtVaCreateManagedWidget("helpunitvisrange",
+    help_unit_upkeep=XtVaCreateManagedWidget("helpunitupkeep",
                                               labelWidgetClass,
                                               help_right_form,
                                               NULL);
-    help_unit_visrange_data=XtVaCreateManagedWidget("helpunitvisrangedata",
+    help_unit_upkeep_data=XtVaCreateManagedWidget("helpunitupkeepdata",
                                                    labelWidgetClass,
                                                    help_right_form,
                                                    NULL);
@@ -810,6 +821,7 @@
     xaw_set_label(help_unit_hp_data, buf);
     sprintf(buf, "%d ", utype->vision_range);
     xaw_set_label(help_unit_visrange_data, buf);
+    xaw_set_label(help_unit_upkeep_data, helptext_unit_upkeep_str(i));
     if(utype->tech_requirement==A_LAST) {
       xaw_set_label(help_improvement_req_data, "(Never)");
     } else {
diff -u -r --exclude-from exclude freeciv-cvs/client/helpdata.c 
freeciv-mod/client/helpdata.c
--- freeciv-cvs/client/helpdata.c       Sun Sep 19 12:05:48 1999
+++ freeciv-mod/client/helpdata.c       Sun Sep 19 13:21:11 1999
@@ -829,3 +829,37 @@
   }
 }
 
+/****************************************************************
+  Returns pointer to static string with eg:
+  1s/1h (1 shield/1 unhappy)
+*****************************************************************/
+char *helptext_unit_upkeep_str(int i)
+{
+  static char buf[32];
+  struct unit_type *utype = get_unit_type(i);
+
+  if (utype->shield_cost || utype->food_cost || utype->gold_cost
+     || utype->happy_cost) {
+    int any = 0;
+    buf[0] = '\0';
+    if (utype->shield_cost) {
+      sprintf(buf+strlen(buf), _("%s%ds") /*shields*/,
+             (any++ ? "/" : ""), utype->shield_cost);
+    }
+    if (utype->food_cost) {
+      sprintf(buf+strlen(buf), _("%s%df") /*food*/,
+             (any++ ? "/" : ""), utype->food_cost);
+    }
+    if (utype->happy_cost) {
+      sprintf(buf+strlen(buf), _("%s%dh") /*(un)happy*/,
+             (any++ ? "/" : ""), utype->happy_cost);
+    }
+    if (utype->gold_cost) {
+      sprintf(buf+strlen(buf), _("%s%dg") /*gold*/,
+             (any++ ? "/" : ""), utype->gold_cost);
+    }
+  } else {
+    sprintf(buf, "%d", 0);
+  }
+  return buf;
+}
diff -u -r --exclude-from exclude freeciv-cvs/client/helpdata.h 
freeciv-mod/client/helpdata.h
--- freeciv-cvs/client/helpdata.h       Sat Aug 28 00:04:31 1999
+++ freeciv-mod/client/helpdata.h       Sun Sep 19 13:21:11 1999
@@ -35,6 +35,8 @@
 void helptext_unit(char *buf, int i, const char *user_text);
 void helptext_tech(char *buf, int i, const char *user_text);
 
+char *helptext_unit_upkeep_str(int i);
+
 #define help_items_iterate(pitem) {       \
         const struct help_item *pitem;    \
         help_iter_start();                \
diff -u -r --exclude-from exclude freeciv-cvs/data/Freeciv 
freeciv-mod/data/Freeciv
--- freeciv-cvs/data/Freeciv    Sun Sep 19 12:02:16 1999
+++ freeciv-mod/data/Freeciv    Sun Sep 19 13:21:12 1999
@@ -768,7 +768,7 @@
 Freeciv*helpdialog.*.helpunittile.internalWidth: 0
 Freeciv*helpdialog.*.helpunittile.internalHeight: 0
 Freeciv*helpdialog.*.helpunittile.fromVert: helptext
-Freeciv*helpdialog.*.helpunittile.fromHoriz: helpunitmovedata
+Freeciv*helpdialog.*.helpunittile.fromHoriz: helpunitvisrangedata
 Freeciv*helpdialog.*.helpunittile.left: chainLeft
 Freeciv*helpdialog.*.helpunittile.right: chainLeft
 Freeciv*helpdialog.*.helpunittile.top: chainTop
@@ -810,15 +810,15 @@
 Freeciv*helpdialog.*.helpunitfpdata.background: lightblue
 Freeciv*helpdialog.*.helpunitfpdata.borderWidth: 0
 
-Freeciv*helpdialog.*.helpunitvisrange.fromVert: helpunitcost
-Freeciv*helpdialog.*.helpunitvisrange.fromHoriz: helpunithpdata
+Freeciv*helpdialog.*.helpunitvisrange.fromVert: helptext
+Freeciv*helpdialog.*.helpunitvisrange.fromHoriz: helpunitmovedata
 Freeciv*helpdialog.*.helpunitvisrange.label: Vision:
 Freeciv*helpdialog.*.helpunitvisrange.left: chainLeft
 Freeciv*helpdialog.*.helpunitvisrange.right: chainLeft
 Freeciv*helpdialog.*.helpunitvisrange.top: chainTop
 Freeciv*helpdialog.*.helpunitvisrange.bottom: chainTop
 
-Freeciv*helpdialog.*.helpunitvisrangedata.fromVert: helpunitcost
+Freeciv*helpdialog.*.helpunitvisrangedata.fromVert: helptext
 Freeciv*helpdialog.*.helpunitvisrangedata.fromHoriz: helpunitvisrange
 Freeciv*helpdialog.*.helpunitvisrangedata.label: 1\ 
 Freeciv*helpdialog.*.helpunitvisrangedata.left: chainLeft
@@ -827,6 +827,25 @@
 Freeciv*helpdialog.*.helpunitvisrangedata.bottom: chainTop
 Freeciv*helpdialog.*.helpunitvisrangedata.background: lightblue
 Freeciv*helpdialog.*.helpunitvisrangedata.borderWidth: 0
+
+Freeciv*helpdialog.*.helpunitupkeep.fromVert: helpunitcost
+Freeciv*helpdialog.*.helpunitupkeep.fromHoriz: helpunithpdata
+Freeciv*helpdialog.*.helpunitupkeep.label: Basic Upkeep:
+Freeciv*helpdialog.*.helpunitupkeep.left: chainLeft
+Freeciv*helpdialog.*.helpunitupkeep.right: chainLeft
+Freeciv*helpdialog.*.helpunitupkeep.top: chainTop
+Freeciv*helpdialog.*.helpunitupkeep.bottom: chainTop
+
+Freeciv*helpdialog.*.helpunitupkeepdata.fromVert: helpunitcost
+Freeciv*helpdialog.*.helpunitupkeepdata.fromHoriz: helpunitupkeep
+Freeciv*helpdialog.*.helpunitupkeepdata.label: 1s/1f/1h/1g
+Freeciv*helpdialog.*.helpunitupkeepdata.justify: left
+Freeciv*helpdialog.*.helpunitupkeepdata.left: chainLeft
+Freeciv*helpdialog.*.helpunitupkeepdata.right: chainLeft
+Freeciv*helpdialog.*.helpunitupkeepdata.top: chainTop
+Freeciv*helpdialog.*.helpunitupkeepdata.bottom: chainTop
+Freeciv*helpdialog.*.helpunitupkeepdata.background: lightblue
+Freeciv*helpdialog.*.helpunitupkeepdata.borderWidth: 0
 
 Freeciv*helpdialog.*.helpunitcost.fromVert: helptext
 Freeciv*helpdialog.*.helpunitcost.label: Cost:

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] patch: generalized xhelp on unit upkeep parameters (PR#132), David Pfitzner <=