On Tue, 28 Aug 2007 11:05:28 -0700 Marko Lindqvist wrote:

> On 28/08/07, Egor Vyscrebentsov <evyscr@> wrote:
> >
> > On Mon, 27 Aug 2007 03:46:50 -0700 Daniel Markstedt wrote:
> >
> > > But as a temporary solution, I could add them manually to
> > > the helptexts. What do you say?
> >
> > No, don't do it. "Temporary" means "forever" too often. Well, my
> > solution is temporary too :( But your decision will cost so much when
> > you decide to change requirements.
> 
>  My opinions about whole help text situation regarding 2.1.0:
> 
>  1) Help texts for official rulesets have to be correct and complete
> before we can release 2.1.0.

Surely.

>  2) When possible without losing clarity, help texts should be
> automatically generated.

Agree. When possible and hot so hard. So I'm going to make patch for
wonders, units (whatever needs reqs helptext.)

>  3) We should not postpone 2.1.0 for implementing automatically
> generated help texts.

See answer to p.2 :)

> > IMHO, we need to rewrite "requirements" part of help dialog(*). While
> > this isn't done, attached patch (alpha-version)(**) add requirements
> > notes to the helptext.
> 
>  This is step towards automatically generated help texts, and as such
> improvement over current situation (at least this solution should go
> in before 2.1.0).

Version 2 of patch. Working, looks not so awful. (I ask to apply
requirements.[ch] part as soon, as it allowed - we need those translations
of requirements types.)

>  Something much better is required for 2.2.

Any thoughts? I have no idea now on what the help page will be in 2.2.
So we need to decide before implementing. Daniel, DB (if you're here),
all others - what's your vision?

-- 
Thanks, evyscr
Index: common/requirements.c
===================================================================
--- common/requirements.c	(revision 13411)
+++ common/requirements.c	(working copy)
@@ -29,19 +29,19 @@
 /* Names of source types.  These must correspond to enum req_source_type in
  * requirements.h.  Do not change these unless you know what you're doing! */
 static const char *req_source_type_names[] = {
-  "None",
-  "Tech",
-  "Gov",
-  "Building",
-  "Special",
-  "Terrain",
-  "Nation",
-  "UnitType",
-  "UnitFlag",
-  "UnitClass",
-  "OutputType",
-  "Specialist",
-  "MinSize"
+  N_("None"),
+  N_("Tech"),
+  N_("Gov"),
+  N_("Building"),
+  N_("Special"),
+  N_("Terrain"),
+  N_("Nation"),
+  N_("UnitType"),
+  N_("UnitFlag"),
+  N_("UnitClass"),
+  N_("OutputType"),
+  N_("Specialist"),
+  N_("MinSize")
 };
 
 /* Names of requirement ranges. These must correspond to enum req_range in
@@ -1058,3 +1058,15 @@
 
   return buf;
 }
+
+/****************************************************************************
+  Make user-friendly text for the source type name. The text is put into
+  a user buffer which is also returned.
+*****************************************************************************/
+char *get_req_source_type_name(const struct req_source *psource,
+			       char *buf, size_t bufsz)
+{
+  buf[0] = '\0'; /* to be safe. */
+  cat_snprintf(buf, bufsz, _(req_source_type_names[psource->type]));
+  return buf;
+}
Index: common/requirements.h
===================================================================
--- common/requirements.h	(revision 13411)
+++ common/requirements.h	(working copy)
@@ -141,5 +141,7 @@
 			   const struct req_source *psource2);
 char *get_req_source_text(const struct req_source *psource,
 			  char *buf, size_t bufsz);
+char *get_req_source_type_name(const struct req_source *psource,
+			       char *buf, size_t bufsz);
 
 #endif  /* FC__REQUIREMENTS_H */
Index: client/helpdata.c
===================================================================
--- client/helpdata.c	(revision 13411)
+++ client/helpdata.c	(working copy)
@@ -645,6 +645,7 @@
     .type = REQ_BUILDING,
     .value = {.building = which}
   };
+  bool has_req = FALSE;
 
   assert(buf);
   buf[0] = '\0';
@@ -656,10 +657,29 @@
 
   imp = improvement_by_number(which);
   
+
   if (imp->helptext && imp->helptext[0] != '\0') {
     cat_snprintf(buf, bufsz, "%s\n\n", _(imp->helptext));
   }
 
+  requirement_vector_iterate(&imp->reqs, preq) {
+    char req_buf[512], reqt_buf[128];
+
+    cat_snprintf(buf, bufsz,
+		 _("Requires (%s): %s\n"),
+		 get_req_source_type_name(&preq->source, reqt_buf,
+					  sizeof(reqt_buf)),
+		 get_req_source_text(&preq->source, req_buf,
+				     sizeof(req_buf)));
+    has_req = TRUE;
+  } requirement_vector_iterate_end;
+
+  if (has_req) {
+    cat_snprintf(buf, bufsz, "\n");
+  } else {
+/*    cat_snprintf(buf, bufsz, _("Requires: Nothing\n\n"));*/
+  }
+
   if (tech_exists(improvement_by_number(which)->obsolete_by)) {
     cat_snprintf(buf, bufsz,
 		 _("* The discovery of %s will make %s obsolete.\n"),
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to