<URL: http://bugs.freeciv.org/Ticket/Display.html?id=35961 >

On Mon, 12 Mar 2007 01:14:42 -0800 Egor Vyscrebentsov wrote:
>
> Attached is a pre-version of patch. Legends are used as a help text.
> Only gui-xaw supported.
>
> Ah, and main "Nations" section requires a better text ;)
>
> Hope to make gui-gtk2 part at evenight.
>
> PS. Do we want to have "helptext" field in data/nation/*.ruleset ?

Second pre-version, with gtk2 support.

-- 
Thanks, evyscr

Index: data/helpdata.txt
===================================================================
--- data/helpdata.txt	(revision 12823)
+++ data/helpdata.txt	(working copy)
@@ -12,7 +12,7 @@
 ; 'generate' = means replace this node with generated list of game
 ;	       elements; current categories are: 
 ;	          "Units", "Improvements", "Wonders", "Techs", 
-;		  "Terrain", "Governments"
+;		  "Terrain", "Governments", "Nations"
 ;
 ; Within the text, the help engine recognizes a few "generated table"s.  
 ; These are generated by the help engine, and inserted at the point of 
@@ -1497,3 +1497,12 @@
 that will arrive earlier.  The only other option is to capture \
 their capital.\
 ")
+
+[help_nations]
+name = _("Nations")
+text = _("\
+Daniel, please, write something here ;)\
+")
+
+[help_gen_nations]
+generate = "Nations"
Index: client/gui-gtk-2.0/menu.c
===================================================================
--- client/gui-gtk-2.0/menu.c	(revision 12823)
+++ client/gui-gtk-2.0/menu.c	(working copy)
@@ -177,6 +177,7 @@
   MENU_HELP_GOVERNMENT,
   MENU_HELP_HAPPINESS,
   MENU_HELP_SPACE_RACE,
+  MENU_HELP_NATIONS,
   MENU_HELP_COPYING,
   MENU_HELP_ABOUT
 };
@@ -643,6 +644,9 @@
   case MENU_HELP_SPACE_RACE:
     popup_help_dialog_string(HELP_SPACE_RACE_ITEM);
     break;
+  case MENU_HELP_NATIONS:
+    popup_help_dialog_string(HELP_NATIONS_ITEM);
+    break;
   case MENU_HELP_COPYING:
     popup_help_dialog_string(HELP_COPYING_ITEM);
     break;
@@ -952,6 +956,8 @@
 	help_menu_callback,	MENU_HELP_HAPPINESS					},
   { "/" N_("Help") "/" N_("Space _Race"),		NULL,
 	help_menu_callback,	MENU_HELP_SPACE_RACE					},
+  { "/" N_("Help") "/" N_("Nations"),		NULL,
+	help_menu_callback,	MENU_HELP_NATIONS					},
   { "/" N_("Help") "/sep2",				NULL,
 	NULL,			0,					"<Separator>"	},
   { "/" N_("Help") "/" N_("_Copying"),			NULL,
Index: client/gui-gtk-2.0/helpdlg.c
===================================================================
--- client/gui-gtk-2.0/helpdlg.c	(revision 12823)
+++ client/gui-gtk-2.0/helpdlg.c	(working copy)
@@ -1136,6 +1136,24 @@
 }
 
 /**************************************************************************
+  This is currently just a text page, with special text
+**************************************************************************/
+static void help_update_nation(const struct help_item *pitem, char *title,
+			       struct nation_type *pnation)
+{
+  char buf[4096];
+
+  if (!pnation) {
+    strcat(buf, pitem->text);
+  } else {
+    helptext_nation(buf, sizeof(buf), pnation, pitem->text);
+  }
+  create_help_page(HELP_TEXT);
+  gtk_text_buffer_set_text(help_text, buf, -1);
+  gtk_widget_show(help_text_sw);
+}
+
+/**************************************************************************
 ...
 **************************************************************************/
 static void help_update_dialog(const struct help_item *pitem)
@@ -1179,6 +1197,9 @@
   case HELP_GOVERNMENT:
     help_update_government(pitem, top, find_government_by_name(top));
     break;
+  case HELP_NATION:
+    help_update_nation(pitem, top, find_nation_by_name(top));
+    break;
   case HELP_TEXT:
   default:
     /* it was a pure text item */ 
Index: client/gui-xaw/menu.c
===================================================================
--- client/gui-xaw/menu.c	(revision 12823)
+++ client/gui-xaw/menu.c	(working copy)
@@ -246,6 +246,7 @@
     { { N_("Government"), 0           },      "", MENU_HELP_GOVERNMENT, 0 },
     { { N_("Happiness"), 0            },      "", MENU_HELP_HAPPINESS, 0 },
     { { N_("Space Race"), 0           },      "", MENU_HELP_SPACE_RACE, 0 },
+    { { N_("Nations"), 0              },      "", MENU_HELP_NATIONS, 0 },
     { { 0                             },      "", MENU_SEPARATOR_LINE, 0 },
     { { N_("Copying"), 0              },      "", MENU_HELP_COPYING, 0 },
     { { N_("About"), 0                },      "", MENU_HELP_ABOUT, 0 },
@@ -882,6 +883,9 @@
   case MENU_HELP_SPACE_RACE:
     popup_help_dialog_string(HELP_SPACE_RACE_ITEM);
     break;
+  case MENU_HELP_NATIONS:
+    popup_help_dialog_string(HELP_NATIONS_ITEM);
+    break;
   case MENU_HELP_COPYING:
     popup_help_dialog_string(HELP_COPYING_ITEM);
     break;
Index: client/gui-xaw/menu.h
===================================================================
--- client/gui-xaw/menu.h	(revision 12823)
+++ client/gui-xaw/menu.h	(working copy)
@@ -129,6 +129,7 @@
   MENU_HELP_GOVERNMENT,
   MENU_HELP_HAPPINESS,
   MENU_HELP_SPACE_RACE,
+  MENU_HELP_NATIONS,
   MENU_HELP_COPYING,
   MENU_HELP_ABOUT,
 
Index: client/gui-xaw/helpdlg.c
===================================================================
--- client/gui-xaw/helpdlg.c	(revision 12823)
+++ client/gui-xaw/helpdlg.c	(working copy)
@@ -1059,6 +1059,24 @@
   XtVaSetValues(help_text, XtNstring, buf, NULL);
 }
 
+/****************************************************************************
+  This is currently just a text page, with special text
+****************************************************************************/
+static void help_update_nation(const struct help_item *pitem, char *title,
+			       struct nation_type *pnation)
+{
+  char buf[4096];
+
+  if (!pnation) {
+    strcat(buf, pitem->text);
+  } else {
+    helptext_nation(buf, sizeof(buf), pnation, pitem->text);
+  }
+  create_help_page(HELP_TEXT);
+  set_title_topic(pitem);
+  XtVaSetValues(help_text, XtNstring, buf, NULL);
+}
+
 /**************************************************************************
 ...
 **************************************************************************/
@@ -1096,6 +1114,9 @@
   case HELP_GOVERNMENT:
     help_update_government(pitem, top, find_government_by_name(top));
     break;
+  case HELP_NATION:
+    help_update_nation(pitem, top, find_nation_by_name(top));
+    break;
   case HELP_TEXT:
   default:
     /* it was a pure text item */ 
Index: client/include/helpdlg_g.h
===================================================================
--- client/include/helpdlg_g.h	(revision 12823)
+++ client/include/helpdlg_g.h	(working copy)
@@ -15,7 +15,7 @@
 
 enum help_page_type { HELP_ANY, HELP_TEXT, HELP_UNIT, HELP_IMPROVEMENT,
 		      HELP_WONDER, HELP_TECH, HELP_TERRAIN,
-                      HELP_GOVERNMENT, HELP_LAST };
+                      HELP_GOVERNMENT, HELP_NATION, HELP_LAST };
 
 void popup_help_dialog_string(const char *item);
 void popup_help_dialog_typed(const char *item, enum help_page_type);
@@ -38,6 +38,7 @@
 #define HELP_GOVERNMENT_ITEM "Government"
 #define HELP_HAPPINESS_ITEM "Happiness"
 #define HELP_SPACE_RACE_ITEM "Space Race"
+#define HELP_NATIONS_ITEM "Nations"
 #define HELP_COPYING_ITEM "Copying"
 #define HELP_ABOUT_ITEM "About"
 
Index: client/helpdata.c
===================================================================
--- client/helpdata.c	(revision 12823)
+++ client/helpdata.c	(working copy)
@@ -45,7 +45,7 @@
 
 static const char * const help_type_names[] = {
   "(Any)", "(Text)", "Units", "Improvements", "Wonders",
-  "Techs", "Terrain", "Governments", NULL
+  "Techs", "Terrain", "Governments", "Nations", NULL
 };
 
 #define MAX_LAST (MAX(MAX(MAX(A_LAST,B_LAST),U_LAST),T_COUNT))
@@ -441,6 +441,14 @@
 	      help_list_append(category_nodes, pitem);
 	    }
 	  } impr_type_iterate_end;
+	} else if (current_type == HELP_NATION) {
+	  nations_iterate(pnation) {
+	    pitem = new_help_item(current_type);
+	    my_snprintf(name, sizeof(name), " %s", pnation->name);
+	    pitem->topic = mystrdup(name);
+	    pitem->text = mystrdup("");
+	    help_list_append(category_nodes, pitem);
+	  } nations_iterate_end;
 	} else {
 	  die("Bad current_type %d", current_type);
 	}
@@ -1505,3 +1513,16 @@
   }
   return buf;
 }
+
+/****************************************************************************
+  Returns nation legend
+****************************************************************************/
+void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation,
+		     const char *user_text)
+{
+  buf[0] = '\0';
+
+  if (pnation->legend[0] != '\0') {
+    sprintf(buf, "%s\n\n", _(pnation->legend));
+  }
+}
Index: client/helpdata.h
===================================================================
--- client/helpdata.h	(revision 12823)
+++ client/helpdata.h	(working copy)
@@ -48,6 +48,9 @@
 void helptext_government(char *buf, size_t bufsz, struct government *gov,
 			 const char *user_text);
 
+void helptext_nation(char *buf, size_t bufsz, struct nation_type *pnation,
+		     const char *user_text);
+
 char *helptext_unit_upkeep_str(struct unit_type *punittype);
 
 #define help_items_iterate(pitem) {       \
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to