Author: cazfi
Date: Sat Oct  1 06:32:34 2016
New Revision: 33953

URL: http://svn.gna.org/viewcvs/freeciv?rev=33953&view=rev
Log:
Added goods help page.

See patch #7735

Modified:
    trunk/client/gui-gtk-2.0/helpdlg.c
    trunk/client/gui-gtk-3.0/helpdlg.c
    trunk/client/gui-gtk-3.x/helpdlg.c
    trunk/client/helpdata.c
    trunk/client/helpdata.h
    trunk/client/include/helpdlg_g.h
    trunk/common/traderoutes.c
    trunk/common/traderoutes.h
    trunk/data/helpdata.txt

Modified: trunk/client/gui-gtk-2.0/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/helpdlg.c?rev=33953&r1=33952&r2=33953&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/helpdlg.c  (original)
+++ trunk/client/gui-gtk-2.0/helpdlg.c  Sat Oct  1 06:32:34 2016
@@ -1310,8 +1310,30 @@
 /**************************************************************************
   This is currently just a text page, with special text:
 **************************************************************************/
+static void help_update_goods(const struct help_item *pitem,
+                              char *title)
+{
+  char buf[8192];
+  struct goods_type *pgood = goods_by_translated_name(title);
+
+  create_help_page(HELP_GOODS);
+
+  if (!pgood) {
+    strcat(buf, pitem->text);
+  } else {
+    helptext_goods(buf, sizeof(buf), client.conn.playing, pitem->text,
+                   pgood);
+  }
+  create_help_page(HELP_GOODS);
+  gtk_text_buffer_set_text(help_text, buf, -1);
+  gtk_widget_show(help_text_sw);
+}
+
+/**************************************************************************
+  This is currently just a text page, with special text:
+**************************************************************************/
 static void help_update_specialist(const struct help_item *pitem,
-                                  char *title)
+                                   char *title)
 {
   char buf[8192];
   struct specialist *pspec = specialist_by_translated_name(title);
@@ -1399,6 +1421,9 @@
   case HELP_EXTRA:
     help_update_extra(pitem, top);
     break;
+  case HELP_GOODS:
+    help_update_goods(pitem, top);
+    break;
   case HELP_SPECIALIST:
     help_update_specialist(pitem, top);
     break;

Modified: trunk/client/gui-gtk-3.0/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/helpdlg.c?rev=33953&r1=33952&r2=33953&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/helpdlg.c  (original)
+++ trunk/client/gui-gtk-3.0/helpdlg.c  Sat Oct  1 06:32:34 2016
@@ -1334,8 +1334,30 @@
 /**************************************************************************
   This is currently just a text page, with special text:
 **************************************************************************/
+static void help_update_goods(const struct help_item *pitem,
+                              char *title)
+{
+  char buf[8192];
+  struct goods_type *pgood = goods_by_translated_name(title);
+
+  create_help_page(HELP_GOODS);
+
+  if (!pgood) {
+    strcat(buf, pitem->text);
+  } else {
+    helptext_goods(buf, sizeof(buf), client.conn.playing, pitem->text,
+                   pgood);
+  }
+  create_help_page(HELP_GOODS);
+  gtk_text_buffer_set_text(help_text, buf, -1);
+  gtk_widget_show(help_text_sw);
+}
+
+/**************************************************************************
+  This is currently just a text page, with special text:
+**************************************************************************/
 static void help_update_specialist(const struct help_item *pitem,
-                                  char *title)
+                                   char *title)
 {
   char buf[8192];
   struct specialist *pspec = specialist_by_translated_name(title);
@@ -1423,6 +1445,9 @@
   case HELP_EXTRA:
     help_update_extra(pitem, top);
     break;
+  case HELP_GOODS:
+    help_update_goods(pitem, top);
+    break;
   case HELP_SPECIALIST:
     help_update_specialist(pitem, top);
     break;

Modified: trunk/client/gui-gtk-3.x/helpdlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.x/helpdlg.c?rev=33953&r1=33952&r2=33953&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.x/helpdlg.c  (original)
+++ trunk/client/gui-gtk-3.x/helpdlg.c  Sat Oct  1 06:32:34 2016
@@ -1333,8 +1333,30 @@
 /**************************************************************************
   This is currently just a text page, with special text:
 **************************************************************************/
+static void help_update_goods(const struct help_item *pitem,
+                              char *title)
+{
+  char buf[8192];
+  struct goods_type *pgood = goods_by_translated_name(title);
+
+  create_help_page(HELP_GOODS);
+
+  if (!pgood) {
+    strcat(buf, pitem->text);
+  } else {
+    helptext_goods(buf, sizeof(buf), client.conn.playing, pitem->text,
+                   pgood);
+  }
+  create_help_page(HELP_GOODS);
+  gtk_text_buffer_set_text(help_text, buf, -1);
+  gtk_widget_show(help_text_sw);
+}
+
+/**************************************************************************
+  This is currently just a text page, with special text:
+**************************************************************************/
 static void help_update_specialist(const struct help_item *pitem,
-                                  char *title)
+                                   char *title)
 {
   char buf[8192];
   struct specialist *pspec = specialist_by_translated_name(title);
@@ -1422,6 +1444,9 @@
   case HELP_EXTRA:
     help_update_extra(pitem, top);
     break;
+  case HELP_GOODS:
+    help_update_goods(pitem, top);
+    break;
   case HELP_SPECIALIST:
     help_update_specialist(pitem, top);
     break;

Modified: trunk/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.c?rev=33953&r1=33952&r2=33953&view=diff
==============================================================================
--- trunk/client/helpdata.c     (original)
+++ trunk/client/helpdata.c     Sat Oct  1 06:32:34 2016
@@ -61,7 +61,7 @@
 /* This must be in same order as enum in helpdlg_g.h */
 static const char * const help_type_names[] = {
   "(Any)", "(Text)", "Units", "Improvements", "Wonders",
-  "Techs", "Terrain", "Extras", "Specialists", "Governments",
+  "Techs", "Terrain", "Extras", "Goods", "Specialists", "Governments",
   "Ruleset", "Tileset", "Nations", "Multipliers", NULL
 };
 
@@ -682,9 +682,20 @@
               FC_FREE(cats);
             }
             break;
+          case HELP_GOODS:
+            goods_type_iterate(pgood) {
+              pitem = new_help_item(current_type);
+              fc_snprintf(name, sizeof(name), "%*s%s", level, "",
+                          goods_name_translation(pgood));
+              pitem->topic = fc_strdup(name);
+              pitem->text = fc_strdup("");
+              help_list_append(category_nodes, pitem);
+            } goods_type_iterate_end;
+            break;
           case HELP_SPECIALIST:
             specialist_type_iterate(sp) {
               struct specialist *pspec = specialist_by_number(sp);
+
               pitem = new_help_item(current_type);
               fc_snprintf(name, sizeof(name), "%*s%s", level, "",
                           specialist_plural_translation(pspec));
@@ -2795,6 +2806,46 @@
 }
 
 /****************************************************************************
+  Append misc dynamic text for goods.
+  Assumes effects are described in the help text.
+
+  pplayer may be NULL.
+****************************************************************************/
+void helptext_goods(char *buf, size_t bufsz, struct player *pplayer,
+                    const char *user_text, struct goods_type *pgood)
+{
+  bool reqs = FALSE;
+
+  fc_assert_ret(NULL != buf && 0 < bufsz);
+  buf[0] = '\0';
+
+  /* 
+  if (NULL != pgood->helptext) {
+    strvec_iterate(pgood->helptext, text) {
+      cat_snprintf(buf, bufsz, "%s\n\n", _(text));
+    } strvec_iterate_end;
+  }
+  */
+
+  cat_snprintf(buf, bufsz, _("Sending city enjoys %d%% income from the 
route.\n"),
+               pgood->from_pct);
+  cat_snprintf(buf, bufsz, _("Receiving city enjoys %d%% income from the 
route.\n\n"),
+               pgood->to_pct);
+
+  /* Requirements for this good. */
+  requirement_vector_iterate(&pgood->reqs, preq) {
+    if (req_text_insert_nl(buf, bufsz, pplayer, preq, VERB_DEFAULT)) {
+      reqs = TRUE;
+    }
+  } requirement_vector_iterate_end;
+  if (reqs) {
+    fc_strlcat(buf, "\n", bufsz);
+  }
+
+  CATLSTR(buf, bufsz, user_text);
+}
+
+/****************************************************************************
   Append misc dynamic text for specialists.
   Assumes effects are described in the help text.
 

Modified: trunk/client/helpdata.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.h?rev=33953&r1=33952&r2=33953&view=diff
==============================================================================
--- trunk/client/helpdata.h     (original)
+++ trunk/client/helpdata.h     Sat Oct  1 06:32:34 2016
@@ -53,6 +53,8 @@
                       const char *user_text, struct terrain *pterrain);
 void helptext_extra(char *buf, size_t bufsz, struct player *pplayer,
                     const char *user_text, struct extra_type *pextra);
+void helptext_goods(char *buf, size_t bufsz, struct player *pplayer,
+                    const char *user_text, struct goods_type *pgood);
 void helptext_specialist(char *buf, size_t bufsz, struct player *pplayer,
                          const char *user_text, struct specialist *pspec);
 void helptext_government(char *buf, size_t bufsz, struct player *pplayer,

Modified: trunk/client/include/helpdlg_g.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/include/helpdlg_g.h?rev=33953&r1=33952&r2=33953&view=diff
==============================================================================
--- trunk/client/include/helpdlg_g.h    (original)
+++ trunk/client/include/helpdlg_g.h    Sat Oct  1 06:32:34 2016
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/***********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,9 +18,9 @@
 /* This must be in same order as names in helpdata.c */
 enum help_page_type { HELP_ANY, HELP_TEXT, HELP_UNIT, HELP_IMPROVEMENT,
                      HELP_WONDER, HELP_TECH, HELP_TERRAIN, HELP_EXTRA,
-                      HELP_SPECIALIST, HELP_GOVERNMENT, HELP_RULESET,
-                      HELP_TILESET, HELP_NATIONS, HELP_MULTIPLIER,
-                      HELP_LAST };
+                      HELP_GOODS, HELP_SPECIALIST, HELP_GOVERNMENT,
+                      HELP_RULESET, HELP_TILESET, HELP_NATIONS,
+                      HELP_MULTIPLIER, HELP_LAST };
 
 GUI_FUNC_PROTO(void, popup_help_dialog_string, const char *item)
 GUI_FUNC_PROTO(void, popup_help_dialog_typed, const char *item,

Modified: trunk/common/traderoutes.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/traderoutes.c?rev=33953&r1=33952&r2=33953&view=diff
==============================================================================
--- trunk/common/traderoutes.c  (original)
+++ trunk/common/traderoutes.c  Sat Oct  1 06:32:34 2016
@@ -516,6 +516,21 @@
   return NULL;
 }
 
+/**************************************************************************
+  Returns goods type matching the translated name, or NULL if there is no
+  goods type with that name.
+**************************************************************************/
+struct goods_type *goods_by_translated_name(const char *name)
+{
+  goods_type_iterate(pgood) {
+    if (0 == strcmp(goods_name_translation(pgood), name)) {
+      return pgood;
+    }
+  } goods_type_iterate_end;
+
+  return NULL;
+}
+
 /****************************************************************************
   Check if goods has given flag
 ****************************************************************************/

Modified: trunk/common/traderoutes.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/traderoutes.h?rev=33953&r1=33952&r2=33953&view=diff
==============================================================================
--- trunk/common/traderoutes.h  (original)
+++ trunk/common/traderoutes.h  Sat Oct  1 06:32:34 2016
@@ -189,6 +189,7 @@
 const char *goods_name_translation(struct goods_type *pgood);
 const char *goods_rule_name(struct goods_type *pgood);
 struct goods_type *goods_by_rule_name(const char *name);
+struct goods_type *goods_by_translated_name(const char *name);
 
 bool goods_has_flag(const struct goods_type *pgood, enum goods_flag_id flag);
 

Modified: trunk/data/helpdata.txt
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/helpdata.txt?rev=33953&r1=33952&r2=33953&view=diff
==============================================================================
--- trunk/data/helpdata.txt     (original)
+++ trunk/data/helpdata.txt     Sat Oct  1 06:32:34 2016
@@ -12,7 +12,7 @@
 ; 'generate' = means replace this node with generated list of game
 ;             elements; current categories are: 
 ;                "Units", "Improvements", "Wonders", "Techs", 
-;                "Terrain", "Extras", "Specialists",
+;                "Terrain", "Extras", "Goods", "Specialists",
 ;                 "Governments", "Ruleset", "Tileset", "Nations"
 ;              As for 'name', the number of spaces before the category
 ;              name indicates nesting level for display.
@@ -639,6 +639,16 @@
 To view the current trade routes of a city, click and hold over the \
 Trade: line in the Overview tab in the city view.\
 ")
+
+[help_goods]
+; /* TRANS: Preserve the leading space: it controls nesting */
+name = _(" Goods")
+text = _("\
+Goods are carried via trade routes.\
+")
+
+[help_gen_goods]
+generate = "  Goods"
 
 [help_cities]
 name = _("Cities")


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to