[Tux4kids-commits] r73 - in tuxmath/trunk: data/missions/lessons src

dbruce at alioth.debian.org dbruce at alioth.debian.org
Thu Mar 8 21:30:15 CET 2007


Author: dbruce
Date: 2007-01-25 17:35:20 +0000 (Thu, 25 Jan 2007)
New Revision: 73

Modified:
   tuxmath/trunk/data/missions/lessons/lesson09
   tuxmath/trunk/src/fileops.c
   tuxmath/trunk/src/options.c
   tuxmath/trunk/src/options.h
   tuxmath/trunk/src/titlescreen.c
   tuxmath/trunk/src/tuxmath.h
Log:
beginning of igloo support


Modified: tuxmath/trunk/data/missions/lessons/lesson09
===================================================================
--- tuxmath/trunk/data/missions/lessons/lesson09	2007-01-25 10:20:35 UTC (rev 72)
+++ tuxmath/trunk/data/missions/lessons/lesson09	2007-01-25 17:35:20 UTC (rev 73)
@@ -1,8 +1,8 @@
-# Subtraction: 0 to 20
+# Addition and Subtraction Review
 play_through_list = 1
 allow_speedup = 1
 use_feedback = 1
-addition_allowed = 0
+addition_allowed = 1
 subtraction_allowed = 1
 multiplication_allowed = 0
 division_allowed = 0
@@ -30,7 +30,7 @@
 question_copies = 1
 repeat_wrongs = 1
 copies_repeated_wrongs = 2
-format_add_answer_last = 0
+format_add_answer_last = 1
 format_add_answer_first = 0
 format_add_answer_middle = 0
 format_sub_answer_last = 1

Modified: tuxmath/trunk/src/fileops.c
===================================================================
--- tuxmath/trunk/src/fileops.c	2007-01-25 10:20:35 UTC (rev 72)
+++ tuxmath/trunk/src/fileops.c	2007-01-25 17:35:20 UTC (rev 73)
@@ -660,6 +660,13 @@
         Opts_SetUseKeypad(v);
     }
 
+    else if(0 == strcasecmp(parameter, "use_igloos"))
+    {
+      int v = str_to_bool(value);
+      if (v != -1)
+        Opts_SetUseIgloos(v);
+    }
+
     else if(0 == strcasecmp(parameter, "save_summary"))
     {
       int v = str_to_bool(value);
@@ -1356,6 +1363,8 @@
                  "# Default: 0                                               #\n"
                  "# Parameter: use_keypad (boolean)                          #\n"
                  "# Default: 0                                               #\n"
+                 "# Parameter: use_igloos (boolean)                          #\n"
+                 "# Default: 1                                               #\n"
                  "# Parameter: save_game_summary (boolean)                   #\n"
                  "# Default: 1                                               #\n"
                  "#                                                          #\n"
@@ -1401,6 +1410,14 @@
 
   if (verbose)
   {
+    fprintf (fp, "\n# Use newer graphics where Tux defends igloo-\n"
+               "# dwelling penguins (for those who find the older\n"
+               "# images of exploding cities to be distasteful)\n");
+  }
+  fprintf(fp, "use_igloos = %d\n", Opts_UseIgloos());
+
+  if (verbose)
+  {
     fprintf (fp, "\n# By default, Tuxmath saves summaries of the last\n"
                "# ten games in the user's .tuxmath directory. Set\n"
                "# this parameter to '0' to turn off.\n");

Modified: tuxmath/trunk/src/options.c
===================================================================
--- tuxmath/trunk/src/options.c	2007-01-25 10:20:35 UTC (rev 72)
+++ tuxmath/trunk/src/options.c	2007-01-25 17:35:20 UTC (rev 73)
@@ -342,6 +342,7 @@
   game_options->demo_mode = DEFAULT_DEMO_MODE;
   game_options->oper_override = DEFAULT_OPER_OVERRIDE;
   game_options->use_keypad = DEFAULT_USE_KEYPAD;
+  game_options->use_igloos = DEFAULT_USE_IGLOOS;
   game_options->speed = DEFAULT_SPEED;
   game_options->allow_speedup = DEFAULT_ALLOW_SPEEDUP;
   game_options->speedup_factor = DEFAULT_SPEEDUP_FACTOR;
@@ -436,6 +437,12 @@
 }
 
 
+void Opts_SetUseIgloos(int val)
+{
+  game_options->use_igloos = int_to_bool(val);
+}
+
+
 void Opts_SetSpeed(float val)
 {
   if (val < MINIMUM_SPEED)
@@ -766,6 +773,17 @@
 }
 
 
+int Opts_UseIgloos(void)
+{
+  if (!game_options)
+  {
+    fprintf(stderr, "\nOpts_UseIgloos(): game_options not valid!\n");
+    return GAME_OPTS_INVALID;
+  }
+  return game_options->use_igloos;
+}
+
+
 float Opts_Speed(void)
 {
   if (!game_options)

Modified: tuxmath/trunk/src/options.h
===================================================================
--- tuxmath/trunk/src/options.h	2007-01-25 10:20:35 UTC (rev 72)
+++ tuxmath/trunk/src/options.h	2007-01-25 17:35:20 UTC (rev 73)
@@ -34,6 +34,7 @@
   int demo_mode;
   int oper_override;
   int use_keypad;
+  int use_igloos;
   float speed;
   int allow_speedup;
   float speedup_factor;
@@ -93,6 +94,7 @@
 void Opts_SetDemoMode(int val);
 void Opts_SetOperOverride(int val);
 void Opts_SetUseKeypad(int val);
+void Opts_SetUseIgloos(int val);
 void Opts_SetSpeed(float val);
 void Opts_SetAllowSpeedup(int val);
 void Opts_SetSpeedupFactor(float val);
@@ -123,6 +125,7 @@
 int Opts_DemoMode(void);
 int Opts_OperOverride(void);
 int Opts_UseKeypad(void);
+int Opts_UseIgloos(void);
 float Opts_Speed(void);
 int Opts_AllowSpeedup(void);
 float Opts_SpeedupFactor(void);

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2007-01-25 10:20:35 UTC (rev 72)
+++ tuxmath/trunk/src/titlescreen.c	2007-01-25 17:35:20 UTC (rev 73)
@@ -1646,109 +1646,97 @@
               break;
             }
           }
-        }
+        } /* End of case SDL_MOUSEDOWN */
 
 
         case SDL_KEYDOWN:
         {
-          // TODO could make these a switch/case statement
-          if (event.key.keysym.sym == SDLK_ESCAPE)
-          { 
-            stop = 2;
-            break;
-          }
-
-          /* Selecting lesson game! */
-          if ((event.key.keysym.sym == SDLK_RETURN)
-           || (event.key.keysym.sym == SDLK_SPACE)
-           || (event.key.keysym.sym == SDLK_KP_ENTER))
+          /* Proceed according to particular key pressed: */
+          switch (event.key.keysym.sym)
           {
-            if (Opts_MenuSound())
-            {
-              tuxtype_playsound(snd_select);
+            case SDLK_ESCAPE:
+            { 
+              stop = 2;
+              break;
             }
 
-            if (read_named_config_file(lesson_list[loc]))
+            case SDLK_RETURN:
+            case SDLK_SPACE:
+            case SDLK_KP_ENTER:
             {
-              if (Opts_MenuMusic())  //Turn menu music off for game
+              if (Opts_MenuSound())
+                {tuxtype_playsound(snd_select);}
+
+              if (read_named_config_file(lesson_list[loc]))
               {
-                audioMusicUnload();
-              }
+                if (Opts_MenuMusic())  //Turn menu music off for game
+                  {audioMusicUnload();}
 
-              game();
+                game();
 
-              if (Opts_MenuMusic()) //Turn menu music back on
-              {
-                audioMusicLoad( "tuxi.ogg", -1 );
+                if (Opts_MenuMusic()) //Turn menu music back on
+                  {audioMusicLoad( "tuxi.ogg", -1 );}
               }
+              else  // Something went wrong - could not read config file:
+                {fprintf(stderr, "\nCould not find file: %s\n", lesson_list[loc]);}
+
+              stop = 1;
+              break;
             }
-            else  // Something went wrong - could not read config file:
-            {
-              fprintf(stderr, "\nCould not find file: %s\n", lesson_list[loc]);
-            }
 
-            stop = 1;
-            break;
-          }
 
-
-          /* Go to previous page, if present: */
-          if ((event.key.keysym.sym == SDLK_LEFT) || (event.key.keysym.sym == SDLK_PAGEUP))
-          {
-            if (Opts_MenuSound())
+            /* Go to previous page, if present: */
+            case SDLK_LEFT:
+            case SDLK_PAGEUP:
             {
-              tuxtype_playsound(snd_move);
+              if (Opts_MenuSound())
+                {tuxtype_playsound(snd_move);}
+              if (loc - (loc % 8) - 8 >= 0)
+                {loc = loc - (loc % 8) - 8;}
+              break;
             }
 
-            if (loc - (loc % 8) - 8 >= 0)
-            {
-              loc = loc - (loc % 8) - 8;
-            }
-          }
 
-          /* Go to next page, if present: */
-          if ((event.key.keysym.sym == SDLK_RIGHT) || (event.key.keysym.sym == SDLK_PAGEDOWN))
-          {
-            if (Opts_MenuSound())
+            /* Go to next page, if present: */
+            case SDLK_RIGHT:
+            case SDLK_PAGEDOWN:
             {
-              tuxtype_playsound(snd_move);
+              if (Opts_MenuSound())
+                {tuxtype_playsound(snd_move);}
+              if (loc - (loc % 8) + 8 < lessons)
+                {loc = (loc - (loc % 8) + 8);}
+              break; 
             }
 
-            if (loc - (loc % 8) + 8 < lessons)
+            /* Go up one entry, if present: */
+            case SDLK_UP:
             {
-              loc = (loc - (loc % 8) + 8);
+              if (Opts_MenuSound())
+                {tuxtype_playsound(snd_move);}
+              if (loc > 0)
+                {loc--;}
+              break;
             }
-          }
 
-          /* Go up one entry, if present: */
-          if (event.key.keysym.sym == SDLK_UP)
-          {
-            if (Opts_MenuSound())
-            {
-              tuxtype_playsound(snd_move);
-            }
 
-            if (loc > 0)
+            /* Go down one entry, if present: */
+            case SDLK_DOWN:
             {
-              loc--;
+              if (Opts_MenuSound())
+                {tuxtype_playsound(snd_move);}
+              if (loc + 1 < lessons)
+                {loc++;}
             }
-          }
 
-          /* Go down one entry, if present: */
-          if (event.key.keysym.sym == SDLK_DOWN)
-          {
-            if (Opts_MenuSound())
+            default:
             {
-              tuxtype_playsound(snd_move);
+              /* Some other key - do nothing. */
             }
 
-            if (loc + 1 < lessons)
-            {
-              loc++;
-            }
-          }
-        }  // End of key handling
-      }  // End switch statement
+            break;  /* To get out of _outer_ switch/case statement */
+          }  /* End of key switch statement */
+        }  // End of case SDL_KEYDOWN in outer switch statement
+      }  // End event switch statement
     }  // End SDL_PollEvent while loop
 
     /* Redraw screen: */

Modified: tuxmath/trunk/src/tuxmath.h
===================================================================
--- tuxmath/trunk/src/tuxmath.h	2007-01-25 10:20:35 UTC (rev 72)
+++ tuxmath/trunk/src/tuxmath.h	2007-01-25 17:35:20 UTC (rev 73)
@@ -61,6 +61,7 @@
 #define DEFAULT_MAX_COMETS 10
 #define DEFAULT_SAVE_SUMMARY 1	
 #define DEFAULT_SOUND_HW_AVAILABLE 1
+#define DEFAULT_USE_IGLOOS 1
 #define DEFAULT_USE_FEEDBACK 0
 #define DEFAULT_DANGER_LEVEL 0.35
 #define DEFAULT_DANGER_LEVEL_SPEEDUP 1.1
@@ -81,11 +82,13 @@
 #define MAX_MAX_COMETS 100
 
 
+/* Going away soon: */
 typedef struct range_type {
   int min;
   int max;
 } range_type;
 
+/* Going away soon: */
 enum {
   OPER_ADD,
   OPER_SUB,
@@ -94,6 +97,7 @@
   NUM_OPERS
 };
 
+/* Going away soon: */
 enum {
   Q_RANGE_1_5,
   Q_RANGE_6_12,




More information about the Tux4kids-commits mailing list