Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7245) Freeciv Tutorial
Home

[Freeciv-Dev] Re: (PR#7245) Freeciv Tutorial

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: gang65@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7245) Freeciv Tutorial
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 16 Jan 2004 19:19:27 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7245 >

Here's a new tutorial patch.  I moved everything into helpdata.[ch] and 
added some new messages.

jason

Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.123
diff -u -r1.123 control.c
--- client/control.c    2004/01/09 16:59:50     1.123
+++ client/control.c    2004/01/17 03:15:31
@@ -33,6 +33,7 @@
 #include "dialogs_g.h"
 #include "goto.h"
 #include "gui_main_g.h"
+#include "helpdata.h"
 #include "mapctrl_g.h"
 #include "mapview_g.h"
 #include "menu_g.h"
@@ -134,6 +135,18 @@
       punit->ai.control = FALSE;
       refresh_unit_city_dialogs(punit);
       request_new_unit_activity(punit, ACTIVITY_IDLE);
+    }
+
+    if (unit_flag(punit, F_CITIES)) {
+      tutorial_event(TUTORIAL_SETTLERS_ACTIVATED);
+    } else if (unit_flag(punit, F_DIPLOMAT)) {
+      tutorial_event(TUTORIAL_DIPLOMAT_ACTIVATED);
+    } else if (unit_flag(punit, F_HELP_WONDER)) {
+      tutorial_event(TUTORIAL_CARAVAN_ACTIVATED);
+    } else if (is_military_unit(punit)) {
+      tutorial_event(TUTORIAL_MILITARY_ACTIVATED);
+    } else {
+      tutorial_event(TUTORIAL_EXPLORER_ACTIVATED);
     }
   }
   
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.68
diff -u -r1.68 helpdata.c
--- client/helpdata.c   2003/12/01 18:03:40     1.68
+++ client/helpdata.c   2004/01/17 03:15:31
@@ -38,6 +38,8 @@
 #include "support.h"
 #include "unit.h"
 
+#include "dialogs_g.h"
+
 #include "helpdata.h"
 
 static const char * const help_type_names[] = {
@@ -966,4 +968,108 @@
     sprintf(buf, "%d", 0);
   }
   return buf;
+}
+
+
+/*
+ * Tutorial events and functions.
+ */
+
+struct tutorial_data {
+  enum tutorial_event event;
+  const char *name;
+  const char *title;
+  const char *message;
+  bool activated;
+};
+
+struct tutorial_data tutorial[] = {
+  {TUTORIAL_START_TURN, "turn1",
+   N_("The game has started."),
+   N_("Welcome to Freeciv!  Your goal is to build a civilization to take\n"
+      "over the world.  This tutorial mode will help you on your way.\n"
+      "You may disable it in the options window.\n"
+      "\n"
+      "In Freeciv you control units as well as cities.  The first thing\n"
+      "to learn is how to control your units.   You can move the active\n"
+      "unit using the keyboard keypad, or by clicking and dragging the\n"
+      "mouse.  You may also select an order for the unit from the orders\n"
+      "menu, or by pressing the keyboard shortcut for the action you\n"
+      "want.")},
+  {TUTORIAL_START_TURN, "turn3",
+   N_("Learn how to use the mapview."),
+   N_("Knowing how to get around the map view in Freeciv is very\n"
+      "important.  Take a few seconds to learn how.  The mapview is the\n"
+      "main viewing area; it shows terrain, units, and cities.  It is \n"
+      "divided into tiles.\n"
+      "\n"
+      "You can left-click on a tile to select the unit or city on that\n"
+      "tile.  Middle-clicking will give you information about the tile\n"
+      "without changing the active unit.  Right-clicking on a tile will\n"
+      "recenter the mapview around that tile.  You can also scroll using\n"
+      "the keyboard's arrow keys.")},
+  {TUTORIAL_SETTLERS_ACTIVATED, "settlers",
+   N_("This is a settler unit."),
+   N_("This unit can be used to build cities.  Your first task should\n"
+      "be to find a good location for a city and build one.  Move the\n"
+      "settlers onto some clear terrain (preferably near water) and\n"
+      "press 'b' to found the city.")},
+  {TUTORIAL_EXPLORER_ACTIVATED, "explorer",
+   N_("This unit can be used to explore."),
+   N_("You should probably use this unit to explore nearby territory.\n"
+      "You may press 'x' to set it to auto-explore mode, or move it\n"
+      "around manually to investigate areas that interest you.")},
+  {TUTORIAL_MILITARY_ACTIVATED, "military",
+   N_("This is a military unit."),
+   N_("This is your first military unit.  It can be used on attack or\n"
+      "defense.  Move into a tile occupied by an enemy unit to attack\n"
+      "that unit.  Or you can stay inside a city or in a fortified\n"
+      "position to protect it from enemy attack.")}
+};
+
+/****************************************************************************
+  Load the tutorial information from the section file.
+****************************************************************************/
+void load_user_tutorial_options(struct section_file *file)
+{
+  int i;
+
+  for (i = 0; i < ARRAY_SIZE(tutorial); i++) {
+    tutorial[i].activated
+      = secfile_lookup_bool_default(file, FALSE, "tutorial.%s",
+                                   tutorial[i].name);
+    tutorial[i].activated = FALSE;
+  }
+}
+
+/****************************************************************************
+  Save the tutorial information to the section file.
+****************************************************************************/
+void save_user_tutorial_options(struct section_file *file)
+{
+  int i;
+
+  for (i = 0; i < ARRAY_SIZE(tutorial); i++) {
+    secfile_insert_bool(file, tutorial[i].activated, "tutorial.%s",
+                       tutorial[i].name);
+  }
+}
+
+/****************************************************************************
+  Activate the tutorial event (assuming it hasn't already been activated).
+****************************************************************************/
+void tutorial_event(enum tutorial_event event)
+{
+  int i;
+
+  /* This loop is inefficient, but that's okay. */
+  for (i = 0; i < ARRAY_SIZE(tutorial); i++) {
+    if (tutorial[i].event == event && !tutorial[i].activated) {
+      popup_notify_dialog(_("Tutorial"), _(tutorial[i].title),
+                         _(tutorial[i].message));
+      tutorial[i].activated = TRUE;
+
+      return; /* Only one tutorial message per event. */
+    }
+  }
 }
Index: client/helpdata.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.h,v
retrieving revision 1.7
diff -u -r1.7 helpdata.h
--- client/helpdata.h   2002/09/28 01:36:20     1.7
+++ client/helpdata.h   2004/01/17 03:15:31
@@ -13,6 +13,8 @@
 #ifndef FC__HELPDATA_H
 #define FC__HELPDATA_H
 
+#include "registry.h"
+
 #include "helpdlg_g.h"         /* enum help_page_type */
 
 struct help_item {
@@ -47,5 +49,24 @@
 #define help_items_iterate_end }}
 
 extern char long_buffer[64000];
+
+
+/*
+ * Tutorial events and functions.
+ */
+
+enum tutorial_event {
+  TUTORIAL_START_TURN,
+  TUTORIAL_SETTLERS_ACTIVATED,
+  TUTORIAL_EXPLORER_ACTIVATED,
+  TUTORIAL_MILITARY_ACTIVATED,
+  TUTORIAL_DIPLOMAT_ACTIVATED,
+  TUTORIAL_CARAVAN_ACTIVATED,
+  TUTORIAL_LAST
+};
+
+void load_user_tutorial_options(struct section_file *file);
+void save_user_tutorial_options(struct section_file *file);
+void tutorial_event(enum tutorial_event event);
 
 #endif  /* FC__HELPDATA_H */
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.89
diff -u -r1.89 options.c
--- client/options.c    2004/01/11 17:45:03     1.89
+++ client/options.c    2004/01/17 03:15:33
@@ -37,6 +37,7 @@
 #include "civclient.h"
 #include "clinet.h"
 #include "cma_fec.h"
+#include "helpdata.h"
 #include "tilespec.h"
 
 #include "options.h"
@@ -490,6 +491,8 @@
   for (i = num - 1; i >= 0; i--) {
     load_cma_preset(&sf, i);
   }
+
+  load_user_tutorial_options(&sf);
  
   section_file_free(&sf);
 }
@@ -600,6 +603,8 @@
     save_cma_preset(&sf, cmafec_preset_get_descr(i),
                    cmafec_preset_get_parameter(i), i);
   }
+
+  save_user_tutorial_options(&sf);
 
   /* save to disk */
   if (!section_file_save(&sf, name, 0)) {
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.343
diff -u -r1.343 packhand.c
--- client/packhand.c   2004/01/11 17:45:03     1.343
+++ client/packhand.c   2004/01/17 03:15:34
@@ -794,6 +794,8 @@
   if(game.player_ptr->ai.control && !ai_manual_turn_done) {
     user_ended_turn();
   }
+
+  tutorial_event(TUTORIAL_START_TURN);
 }
 
 /**************************************************************************
Index: client/include/dialogs_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/dialogs_g.h,v
retrieving revision 1.13
diff -u -r1.13 dialogs_g.h
--- client/include/dialogs_g.h  2003/11/28 17:37:20     1.13
+++ client/include/dialogs_g.h  2004/01/17 03:15:34
@@ -13,6 +13,7 @@
 #ifndef FC__DIALOGS_G_H
 #define FC__DIALOGS_G_H
 
+#include "nation.h"            /* Nation_Type_id type */
 #include "shared.h"            /* bool type */
 #include "terrain.h"           /* enum tile_special_type */
 

[Prev in Thread] Current Thread [Next in Thread]