From ecff2fbeb5c183b25d7be9f9c14d1aa2c2d69d64 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C5=82awomir=20Lach?= <slawek@lach.art.pl>
Date: Thu, 30 Mar 2023 18:45:00 +0200
Subject: [PATCH] =?UTF-8?q?!OSDN:=20#47804:=20S=C5=82awomir=20Lach=20<slaw?=
 =?UTF-8?q?ek@lach.art.pl>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Code to generate help for counter in place

diff --git a/client/gui-qt/helpdlg.cpp b/client/gui-qt/helpdlg.cpp
index 191013bf03..ed9ada882b 100644
--- a/client/gui-qt/helpdlg.cpp
+++ b/client/gui-qt/helpdlg.cpp
@@ -807,6 +807,7 @@ void help_widget::set_topic(const help_item *topic)
 
   switch (topic->type) {
     case HELP_ANY:
+    case HELP_COUNTER:
     case HELP_MULTIPLIER:
     case HELP_RULESET:
     case HELP_TILESET:
diff --git a/client/helpdata.c b/client/helpdata.c
index 0e9988575a..97890609bd 100644
--- a/client/helpdata.c
+++ b/client/helpdata.c
@@ -35,6 +35,7 @@
 #include "support.h"
 
 /* common */
+#include "counters.h"
 #include "effects.h"
 #include "game.h"
 #include "government.h"
@@ -70,7 +71,7 @@
 static const char * const help_type_names[] = {
   "(Any)", "(Text)", "Units", "Improvements", "Wonders",
   "Techs", "Terrain", "Extras", "Goods", "Specialists", "Governments",
-  "Ruleset", "Tileset", "Musicset", "Nations", "Multipliers", NULL
+  "Ruleset", "Tileset", "Musicset", "Nations", "Multipliers", "Counters", NULL
 };
 
 #define SPECLIST_TAG help
@@ -1130,6 +1131,28 @@ void boot_help_texts(void)
               help_list_append(help_nodes, pitem);
             } multipliers_iterate_end;
             break;
+          case HELP_COUNTER:
+            {
+              int j;
+              for (j = 0; j < game.control.num_counters; j++) {
+                struct counter *pcount = counter_by_id(j);
+
+                help_text_buffer[0] = '\0';
+                pitem = new_help_item(current_type);
+                fc_snprintf(name, sizeof(name), "%*s%s", level, "",
+                            counter_name_translation(pcount));
+                pitem->topic = fc_strdup(name);
+                if (pcount->helptext) {
+                  strvec_iterate(pcount->helptext, text) {
+                    cat_snprintf(help_text_buffer, sizeof(help_text_buffer),
+                               "%s%s", "\n\n", text);
+                  } strvec_iterate_end;
+                }
+                pitem->text = fc_strdup(help_text_buffer);
+                help_list_append(help_nodes, pitem);
+              }
+            }
+            break;
           default:
             log_error("Bad current_type: %d.", current_type);
             break;
diff --git a/client/include/helpdlg_g.h b/client/include/helpdlg_g.h
index 1c0db32227..b90f847e61 100644
--- a/client/include/helpdlg_g.h
+++ b/client/include/helpdlg_g.h
@@ -21,7 +21,8 @@ enum help_page_type { HELP_ANY, HELP_TEXT, HELP_UNIT, HELP_IMPROVEMENT,
                       HELP_WONDER, HELP_TECH, HELP_TERRAIN, HELP_EXTRA,
                       HELP_GOODS, HELP_SPECIALIST, HELP_GOVERNMENT,
                       HELP_RULESET, HELP_TILESET, HELP_MUSICSET,
-                      HELP_NATIONS, HELP_MULTIPLIER, HELP_LAST };
+                      HELP_NATIONS, HELP_MULTIPLIER,  HELP_COUNTER,
+                      HELP_LAST };
 
 GUI_FUNC_PROTO(void, popup_help_dialog_string, const char *item)
 GUI_FUNC_PROTO(void, popup_help_dialog_typed, const char *item,
@@ -57,5 +58,6 @@ GUI_FUNC_PROTO(void, popdown_help_dialog, void)
 #define HELP_COPYING_ITEM N_("Copying")
 #define HELP_ABOUT_ITEM N_("About Freeciv")
 #define HELP_MULTIPLIER_ITEM N_("Policies")
+#define HELP_COUNTER_ITEM N_("Counters")
 
 #endif /* FC__HELPDLG_G_H */
diff --git a/data/helpdata.txt b/data/helpdata.txt
index 8f8bdc990d..e219d6dc83 100644
--- a/data/helpdata.txt
+++ b/data/helpdata.txt
@@ -1344,6 +1344,16 @@ expect to lose about 60% of its hit points during the fight, and should \
 expect to have no movement points left.\
 ")
 
+[help_counters]
+name = "Counters"
+text = _("Counter are currently hard-coded entity, which value could been \
+tested to fire various possibilities, like allowing to build unit, or to \
+enabling effect (reduce/increase production), etc. Currently only city \
+counters are supported.")
+
+[help_gen_counters]
+generate = " Counters"
+
 [help_zones_of_control]
 name = _("Zones of Control")
 text = _("\
-- 
2.42.0

