[Tux4kids-commits] r70 - in tuxmath/trunk: . data data/images/backgrounds data/images/title data/missions data/missions/arcade data/missions/lessons nsis src

dbruce at alioth.debian.org dbruce at alioth.debian.org
Thu Mar 8 21:28:44 CET 2007


Author: dbruce
Date: 2007-01-12 11:52:34 +0000 (Fri, 12 Jan 2007)
New Revision: 70

Added:
   tuxmath/trunk/data/fonts/
   tuxmath/trunk/data/images/backgrounds/10.jpg
   tuxmath/trunk/data/images/backgrounds/11.jpg
   tuxmath/trunk/data/images/backgrounds/12.jpg
   tuxmath/trunk/data/images/backgrounds/5.jpg
   tuxmath/trunk/data/images/backgrounds/6.jpg
   tuxmath/trunk/data/images/backgrounds/7.jpg
   tuxmath/trunk/data/images/backgrounds/8.jpg
   tuxmath/trunk/data/images/backgrounds/9.jpg
   tuxmath/trunk/data/images/title/left.png
   tuxmath/trunk/data/images/title/right.png
   tuxmath/trunk/data/missions/arcade/
   tuxmath/trunk/data/missions/arcade/ace
   tuxmath/trunk/data/missions/arcade/ranger
   tuxmath/trunk/data/missions/arcade/scout
   tuxmath/trunk/data/missions/arcade/space_cadet
   tuxmath/trunk/data/missions/lessons/
   tuxmath/trunk/data/missions/lessons/lesson01
   tuxmath/trunk/data/missions/lessons/lesson02
   tuxmath/trunk/data/missions/lessons/lesson03
Modified:
   tuxmath/trunk/Makefile.am
   tuxmath/trunk/data/images/title/main_bkg.png
   tuxmath/trunk/data/images/title/title1.png
   tuxmath/trunk/nsis/tuxmath.nsi
   tuxmath/trunk/nsis/tuxmath.nsi.in
   tuxmath/trunk/src/alphabet.c
   tuxmath/trunk/src/audio.c
   tuxmath/trunk/src/fileops.c
   tuxmath/trunk/src/game.h
   tuxmath/trunk/src/gettext.c
   tuxmath/trunk/src/loaders.c
   tuxmath/trunk/src/mathcards.c
   tuxmath/trunk/src/mathcards.h
   tuxmath/trunk/src/options.c
   tuxmath/trunk/src/pause.c
   tuxmath/trunk/src/setup.c
   tuxmath/trunk/src/theme.c
   tuxmath/trunk/src/titlescreen.c
   tuxmath/trunk/src/titlescreen.h
   tuxmath/trunk/src/tuxmath.h
Log:
More menu work


Modified: tuxmath/trunk/Makefile.am
===================================================================
--- tuxmath/trunk/Makefile.am	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/Makefile.am	2007-01-12 11:52:34 UTC (rev 70)
@@ -19,7 +19,9 @@
 	(cd $(top_srcdir)/$(PACKAGE_DATA_DIR) ; tar cf -  --exclude "Makefile.in" --exclude "*.in" --exclude "*~" --exclude \ "Makefile" --exclude "Makefile.am" --exclude CVS --exclude .xvpics --exclude "1[1-9].ogg"  --exclude "2?.ogg" --exclude "*.svn*" * ) \
          | ( cd $(top_srcdir)/$(NSI_INSTALL_DIR)/$(PACKAGE_DATA_DIR) ; tar xf -) ; \
 	cp $(NSI_DLL_DIR)/*.dll $(top_srcdir)/$(NSI_INSTALL_DIR) ; \
-        cp $(SUBDIRS)/*.exe $(top_srcdir)/$(NSI_INSTALL_DIR) ;
+	cp $(NSI_DLL_DIR)/*.ttf $(top_srcdir)/$(NSI_INSTALL_DIR)/data/fonts ; \
+	cp $(SUBDIRS)/*.exe $(top_srcdir)/$(NSI_INSTALL_DIR) ;
+
 if NSI_USE_TUXMATH_CONF
 	$(INSTALL) -d $(top_srcdir)/$(NSI_INSTALL_DIR)/TuxMathConfig ;
 	cp $(NSI_TUXMATH_CONF_DIR)/*.*  $(top_srcdir)/$(NSI_INSTALL_DIR)/TuxMathConfig ;

Added: tuxmath/trunk/data/images/backgrounds/10.jpg
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/backgrounds/10.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/backgrounds/11.jpg
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/backgrounds/11.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/backgrounds/12.jpg
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/backgrounds/12.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/backgrounds/5.jpg
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/backgrounds/5.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/backgrounds/6.jpg
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/backgrounds/6.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/backgrounds/7.jpg
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/backgrounds/7.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/backgrounds/8.jpg
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/backgrounds/8.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/backgrounds/9.jpg
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/backgrounds/9.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/title/left.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/title/left.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: tuxmath/trunk/data/images/title/main_bkg.png
===================================================================
(Binary files differ)

Added: tuxmath/trunk/data/images/title/right.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/title/right.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: tuxmath/trunk/data/images/title/title1.png
===================================================================
(Binary files differ)

Added: tuxmath/trunk/data/missions/arcade/ace
===================================================================
--- tuxmath/trunk/data/missions/arcade/ace	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/data/missions/arcade/ace	2007-01-12 11:52:34 UTC (rev 70)
@@ -0,0 +1,58 @@
+# arcade_ranger lesson file
+
+play_through_list = 0
+allow_speedup = 1
+use_feedback = 0
+addition_allowed = 1
+subtraction_allowed = 1
+multiplication_allowed = 1
+division_allowed = 1
+allow_negatives = 1
+min_augend = -20
+max_augend = 20
+min_addend = -20
+max_addend = 20
+min_minuend = -20
+max_minuend = 20
+min_subtrahend = -20
+max_subtrahend = 20
+min_multiplier = -20
+max_multiplier = 20
+min_multiplicand = -20
+max_multiplicand = 20
+min_divisor = -20
+max_divisor = 20
+min_quotient = -20
+max_quotient = 20
+use_sound = 1
+fullscreen = 1
+use_bkgd = 1
+demo_mode = 0
+save_summary = 1
+question_copies = 1
+repeat_wrongs = 1
+copies_repeated_wrongs = 1
+format_add_answer_last = 1
+format_add_answer_first = 1
+format_add_answer_middle = 1
+format_sub_answer_last = 1
+format_sub_answer_first = 1
+format_sub_answer_middle = 1
+format_mult_answer_last = 1
+format_mult_answer_first = 1
+format_mult_answer_middle = 1
+format_div_answer_last = 1
+format_div_answer_first = 1
+format_div_answer_middle = 1
+randomize = 1
+max_answer = 400
+starting_comets = 2
+extra_comets_per_wave = 2
+max_comets = 10
+speed = 1.00
+max_speed = 10.00
+speedup_factor = 1.25
+slow_after_wrong = 0
+max_questions = 25000
+
+

Added: tuxmath/trunk/data/missions/arcade/ranger
===================================================================
--- tuxmath/trunk/data/missions/arcade/ranger	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/data/missions/arcade/ranger	2007-01-12 11:52:34 UTC (rev 70)
@@ -0,0 +1,55 @@
+# arcade_ranger lesson file
+
+play_through_list = 0
+allow_speedup = 1
+use_feedback = 0
+addition_allowed = 1
+subtraction_allowed = 1
+multiplication_allowed = 1
+division_allowed = 1
+allow_negatives = 0
+min_augend = 0
+max_augend = 20
+min_addend = 0
+max_addend = 20
+min_minuend = 0
+max_minuend = 20
+min_subtrahend = 0
+max_subtrahend = 20
+min_multiplier = 0
+max_multiplier = 10
+min_multiplicand = 0
+max_multiplicand = 10
+min_divisor = 0
+max_divisor = 10
+min_quotient = 0
+max_quotient = 10
+use_sound = 1
+fullscreen = 1
+use_bkgd = 1
+demo_mode = 0
+save_summary = 1
+question_copies = 1
+repeat_wrongs = 1
+copies_repeated_wrongs = 1
+format_add_answer_last = 1
+format_add_answer_first = 0
+format_add_answer_middle = 0
+format_sub_answer_last = 1
+format_sub_answer_first = 0
+format_sub_answer_middle = 0
+format_mult_answer_last = 1
+format_mult_answer_first = 0
+format_mult_answer_middle = 0
+format_div_answer_last = 1
+format_div_answer_first = 0
+format_div_answer_middle = 0
+max_answer = 100
+starting_comets = 2
+extra_comets_per_wave = 2
+max_comets = 10
+speed = 1.00
+max_speed = 10.00
+speedup_factor = 1.2
+slow_after_wrong = 0
+max_questions = 25000

Added: tuxmath/trunk/data/missions/arcade/scout
===================================================================
--- tuxmath/trunk/data/missions/arcade/scout	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/data/missions/arcade/scout	2007-01-12 11:52:34 UTC (rev 70)
@@ -0,0 +1,42 @@
+# arcade_scout lesson file
+
+play_through_list = 0
+allow_speedup = 1
+use_feedback = 0
+addition_allowed = 1
+subtraction_allowed = 1
+multiplication_allowed = 0
+division_allowed = 0
+allow_negatives = 0
+min_augend = 0
+max_augend = 10
+min_addend = 0
+max_addend = 10
+min_minuend = 0
+max_minuend = 10
+min_subtrahend = 0
+max_subtrahend = 10
+use_sound = 1
+fullscreen = 1
+use_bkgd = 1
+demo_mode = 0
+save_summary = 1
+question_copies = 1
+repeat_wrongs = 1
+copies_repeated_wrongs = 1
+format_add_answer_last = 1
+format_add_answer_first = 0
+format_add_answer_middle = 0
+format_sub_answer_last = 1
+format_sub_answer_first = 0
+format_sub_answer_middle = 0
+max_answer = 20
+starting_comets = 2
+extra_comets_per_wave = 2
+max_comets = 10
+speed = 1.00
+max_speed = 10.00
+speedup_factor = 1.15
+slow_after_wrong = 0
+max_questions = 5000
+

Added: tuxmath/trunk/data/missions/arcade/space_cadet
===================================================================
--- tuxmath/trunk/data/missions/arcade/space_cadet	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/data/missions/arcade/space_cadet	2007-01-12 11:52:34 UTC (rev 70)
@@ -0,0 +1,34 @@
+# arcade_space_ cadet lesson file
+
+play_through_list = 0
+allow_speedup = 1
+use_feedback = 0
+addition_allowed = 1
+subtraction_allowed = 0
+multiplication_allowed = 0
+division_allowed = 0
+allow_negatives = 0
+min_augend = 0
+max_augend = 10
+min_addend = 0
+max_addend = 10
+use_sound = 1
+fullscreen = 1
+use_bkgd = 1
+demo_mode = 0
+save_summary = 1
+question_copies = 1
+repeat_wrongs = 1
+copies_repeated_wrongs = 1
+format_add_answer_last = 1
+format_add_answer_first = 0
+format_add_answer_middle = 0
+max_answer = 10
+starting_comets = 2
+extra_comets_per_wave = 2
+max_comets = 10
+speed = 1.00
+max_speed = 10.00
+speedup_factor = 1.1
+slow_after_wrong = 0
+max_questions = 5000

Added: tuxmath/trunk/data/missions/lessons/lesson01
===================================================================
--- tuxmath/trunk/data/missions/lessons/lesson01	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/data/missions/lessons/lesson01	2007-01-12 11:52:34 UTC (rev 70)
@@ -0,0 +1,54 @@
+# Addition 1 to 3
+play_through_list = 1
+allow_speedup = 1
+use_feedback = 1
+addition_allowed = 1
+subtraction_allowed = 0
+multiplication_allowed = 0
+division_allowed = 0
+allow_negatives = 0
+min_augend = 1
+max_augend = 3
+min_addend = 1
+max_addend = 3
+min_minuend = 0
+max_minuend = 10
+min_subtrahend = 0
+max_subtrahend = 10
+min_multiplier = 0
+max_multiplier = 10
+min_multiplicand = 0
+max_multiplicand = 10
+min_divisor = 0
+max_divisor = 10
+min_quotient = 0
+max_quotient = 10
+save_summary = 1
+question_copies = 2
+repeat_wrongs = 1
+copies_repeated_wrongs = 2
+format_add_answer_last = 1
+format_add_answer_first = 0
+format_add_answer_middle = 0
+format_sub_answer_last = 0
+format_sub_answer_first = 0
+format_sub_answer_middle = 0
+format_mult_answer_last = 0
+format_mult_answer_first = 0
+format_mult_answer_middle = 0
+format_div_answer_last = 0
+format_div_answer_first = 0
+format_div_answer_middle = 0
+max_answer = 400
+max_questions = 5000
+randomize = 1
+starting_comets = 2
+extra_comets_per_wave = 2
+max_comets = 10
+speed = 1.00
+max_speed = 10.00
+danger_level = 0.35
+danger_level_speedup = 1
+danger_level_max = 0.90
+city_explode_handicap = 0.00
+

Added: tuxmath/trunk/data/missions/lessons/lesson02
===================================================================
--- tuxmath/trunk/data/missions/lessons/lesson02	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/data/missions/lessons/lesson02	2007-01-12 11:52:34 UTC (rev 70)
@@ -0,0 +1,54 @@
+# Addition 0 to 5
+play_through_list = 1
+allow_speedup = 1
+use_feedback = 1
+addition_allowed = 1
+subtraction_allowed = 0
+multiplication_allowed = 0
+division_allowed = 0
+allow_negatives = 0
+min_augend = 0
+max_augend = 5
+min_addend = 0
+max_addend = 5
+min_minuend = 0
+max_minuend = 10
+min_subtrahend = 0
+max_subtrahend = 10
+min_multiplier = 0
+max_multiplier = 10
+min_multiplicand = 0
+max_multiplicand = 10
+min_divisor = 0
+max_divisor = 10
+min_quotient = 0
+max_quotient = 10
+save_summary = 1
+question_copies = 2
+repeat_wrongs = 1
+copies_repeated_wrongs = 2
+format_add_answer_last = 1
+format_add_answer_first = 0
+format_add_answer_middle = 0
+format_sub_answer_last = 0
+format_sub_answer_first = 0
+format_sub_answer_middle = 0
+format_mult_answer_last = 0
+format_mult_answer_first = 0
+format_mult_answer_middle = 0
+format_div_answer_last = 0
+format_div_answer_first = 0
+format_div_answer_middle = 0
+max_answer = 400
+max_questions = 5000
+randomize = 1
+starting_comets = 2
+extra_comets_per_wave = 2
+max_comets = 10
+speed = 1.00
+max_speed = 10.00
+danger_level = 0.35
+danger_level_speedup = 1
+danger_level_max = 0.90
+city_explode_handicap = 0.00
+

Added: tuxmath/trunk/data/missions/lessons/lesson03
===================================================================
--- tuxmath/trunk/data/missions/lessons/lesson03	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/data/missions/lessons/lesson03	2007-01-12 11:52:34 UTC (rev 70)
@@ -0,0 +1,54 @@
+# Addition - Sums To 10
+play_through_list = 1
+allow_speedup = 1
+use_feedback = 1
+addition_allowed = 1
+subtraction_allowed = 0
+multiplication_allowed = 0
+division_allowed = 0
+allow_negatives = 0
+min_augend = 0
+max_augend = 10
+min_addend = 0
+max_addend = 10
+min_minuend = 0
+max_minuend = 10
+min_subtrahend = 0
+max_subtrahend = 10
+min_multiplier = 0
+max_multiplier = 10
+min_multiplicand = 0
+max_multiplicand = 10
+min_divisor = 0
+max_divisor = 10
+min_quotient = 0
+max_quotient = 10
+save_summary = 1
+question_copies = 2
+repeat_wrongs = 1
+copies_repeated_wrongs = 2
+format_add_answer_last = 1
+format_add_answer_first = 0
+format_add_answer_middle = 0
+format_sub_answer_last = 0
+format_sub_answer_first = 0
+format_sub_answer_middle = 0
+format_mult_answer_last = 0
+format_mult_answer_first = 0
+format_mult_answer_middle = 0
+format_div_answer_last = 0
+format_div_answer_first = 0
+format_div_answer_middle = 0
+max_answer = 10
+max_questions = 5000
+randomize = 1
+starting_comets = 2
+extra_comets_per_wave = 2
+max_comets = 10
+speed = 1.00
+max_speed = 10.00
+danger_level = 0.35
+danger_level_speedup = 1
+danger_level_max = 0.90
+city_explode_handicap = 0.00
+

Modified: tuxmath/trunk/nsis/tuxmath.nsi
===================================================================
--- tuxmath/trunk/nsis/tuxmath.nsi	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/nsis/tuxmath.nsi	2007-01-12 11:52:34 UTC (rev 70)
@@ -48,7 +48,7 @@
   File "mingw32\${APP_EXE}"
   File "mingw32\*.dll"
   SetOutPath $INSTDIR\data
-  File /r "data\*.*"
+  File /r "mingw32\data\*.*"
   SetOutPath $INSTDIR\docs
   File "docs\COPYING.txt"
 

Modified: tuxmath/trunk/nsis/tuxmath.nsi.in
===================================================================
--- tuxmath/trunk/nsis/tuxmath.nsi.in	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/nsis/tuxmath.nsi.in	2007-01-12 11:52:34 UTC (rev 70)
@@ -48,7 +48,7 @@
   File "mingw32\${APP_EXE}"
   File "mingw32\*.dll"
   SetOutPath $INSTDIR\data
-  File /r "data\*.*"
+  File /r "mingw32\data\*.*"
   SetOutPath $INSTDIR\docs
   File "docs\COPYING.txt"
 

Modified: tuxmath/trunk/src/alphabet.c
===================================================================
--- tuxmath/trunk/src/alphabet.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/alphabet.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -5,7 +5,11 @@
     begin                : Jan 6 2003
     copyright            : (C) 2003 by Jesse Andrews
     email                : jdandr2 at tux4kids.net
- ***************************************************************************/
+ 
+    Modified for use in tuxmath by David Bruce - 2006.
+    email                : <dbruce at tampabay.rr.com>
+                           <tuxmath-devel at lists.sourceforge.net> 
+***************************************************************************/
 
 /***************************************************************************
  *                                                                         *
@@ -113,6 +117,8 @@
 	fprintf( stderr, "Error finding file for keyboard setup!\n" );
 }
 
+
+/* FIXME this function segfaults if passed "" as the char arg */
 SDL_Surface* black_outline(unsigned char *t, TTF_Font *font, SDL_Color *c) {
 	SDL_Surface *out, *tmp, *tmp2;
 	SDL_Rect dstrect;

Modified: tuxmath/trunk/src/audio.c
===================================================================
--- tuxmath/trunk/src/audio.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/audio.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -5,6 +5,10 @@
     begin                : Jan 22, 2003
     copyright            : Sam Hart, Jesse Andrews (C) 2003
     email                : tuxtype-dev at tux4kids.net
+
+    Modified for use in tuxmath by David Bruce - 2006.
+    email                : <dbruce at tampabay.rr.com>
+                           <tuxmath-devel at lists.sourceforge.net>
 ***************************************************************************/
 
 /***************************************************************************

Modified: tuxmath/trunk/src/fileops.c
===================================================================
--- tuxmath/trunk/src/fileops.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/fileops.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -228,8 +228,11 @@
 /* Looks for matching file in various locations:        */
 /*   1. Current working directory                       */
 /*   2. As an absolute path filename                    */
-/*   3. In tuxmath's missions (i.e. lessons) directory. */
-/*   4. In user's own .tuxmath directory                */
+/*   3. In tuxmath's missions directory.                */
+/*   4. In missions/lessons directory.                  */
+/*   5. In missions/arcade directory.                   */
+/*   6. In user's own .tuxmath directory                */
+/* FIXME redudant code - figure out way to iterate through above */
 int read_named_config_file(char* filename)
 {
   FILE* fp;
@@ -313,9 +316,9 @@
   }
 
 
-  /* Next look in missions folder (for prepared "lessons curriculum"):      */
+  /* Next look in missions folder:      */
   strcpy(opt_path, DATA_PREFIX);
-  strcat(opt_path, "missions/");
+  strcat(opt_path, "/missions/");
   strcat(opt_path, filename);
 
   #ifdef TUXMATH_DEBUG
@@ -342,7 +345,64 @@
     }
   }  
 
+  /* Next look in missions/lessons folder (for prepared "lessons curriculum"):      */
+  strcpy(opt_path, DATA_PREFIX);
+  strcat(opt_path, "/missions/lessons/");
+  strcat(opt_path, filename);
 
+  #ifdef TUXMATH_DEBUG
+  printf("\nIn read_named_config_file() checking for %s (missions/lessons)\n", opt_path);
+  #endif
+
+  fp = fopen(opt_path, "r");
+  if (fp) /* file exists */
+  {
+    #ifdef TUXMATH_DEBUG
+    printf("\nFound %s\n", opt_path);
+    #endif
+
+    if (read_config_file(fp, USER_CONFIG_FILE))
+    {
+      fclose(fp);
+      fp = NULL;
+      return 1;
+    }
+    else /* keep trying to match filename elsewhere */
+    {
+      fclose(fp);
+      fp = NULL;
+    }
+  }  
+
+  /* Next look in missions/arcade folder (for high score competition):      */
+  strcpy(opt_path, DATA_PREFIX);
+  strcat(opt_path, "/missions/arcade/");
+  strcat(opt_path, filename);
+
+  #ifdef TUXMATH_DEBUG
+  printf("\nIn read_named_config_file() checking for %s (missions/arcade)\n", opt_path);
+  #endif
+
+  fp = fopen(opt_path, "r");
+  if (fp) /* file exists */
+  {
+    #ifdef TUXMATH_DEBUG
+    printf("\nFound %s\n", opt_path);
+    #endif
+
+    if (read_config_file(fp, USER_CONFIG_FILE))
+    {
+      fclose(fp);
+      fp = NULL;
+      return 1;
+    }
+    else /* keep trying to match filename elsewhere */
+    {
+      fclose(fp);
+      fp = NULL;
+    }
+  }  
+
   /* Look in user's hidden .tuxmath directory  */
   /* find $HOME and tack on file name: */
   strcpy(opt_path, get_user_data_dir());
@@ -708,9 +768,7 @@
 
     else if(0 == strcasecmp(parameter, "question_copies"))
     {
-      int v = str_to_bool(value);
-      if (v != -1)
-        MC_SetQuestionCopies(v);
+        MC_SetQuestionCopies(atoi(value));
     }
 
     else if(0 == strcasecmp(parameter, "randomize"))

Modified: tuxmath/trunk/src/game.h
===================================================================
--- tuxmath/trunk/src/game.h	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/game.h	2007-01-12 11:52:34 UTC (rev 70)
@@ -22,7 +22,7 @@
 #define MAX_COMETS 10
 #define NUM_CITIES 4   /* MUST BE AN EVEN NUMBER! */
 
-#define NUM_BKGDS 5
+#define NUM_BKGDS 12
 
 #define MAX_CITY_COLORS 4
 

Modified: tuxmath/trunk/src/gettext.c
===================================================================
--- tuxmath/trunk/src/gettext.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/gettext.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -5,6 +5,10 @@
 begin                : Sunday Feb 23, 2003
 copyright            : (C) 2003 by Jesse Andrews
 email                : jdandr2 at uky.edu
+
+    Modified for use in tuxmath by David Bruce - 2006.
+    email                : <dbruce at tampabay.rr.com>
+                           <tuxmath-devel at lists.sourceforge.net>
 ***************************************************************************/
 
 /***************************************************************************

Modified: tuxmath/trunk/src/loaders.c
===================================================================
--- tuxmath/trunk/src/loaders.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/loaders.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -6,6 +6,10 @@
     copyright            : (C) 2000 by Sam Hart
                          : (C) 2003 by Jesse Andrews
     email                : tuxtype-dev at tux4kids.net
+
+    Modified for use in tuxmath by David Bruce - 2006.
+    email                : <dbruce at tampabay.rr.com>
+                           <tuxmath-devel at lists.sourceforge.net>
  ***************************************************************************/
 
 /***************************************************************************
@@ -21,6 +25,7 @@
 //#include "funcs.h"
 
 #include "titlescreen.h"
+#include "setup.h"  // for cleanup_on_error()
 
 /* check to see if file exists, if so return true */
 int checkFile( const char *file ) {
@@ -274,7 +279,8 @@
     /* If image was required, exit from program: */
     /* FIXME may need to do some cleanup before exiting - free heap, restore screen res, etc */
     fprintf(stderr, "ERROR could not load required graphics file %s\n", datafile);
-    exit(1);
+    cleanup_on_error();
+//    exit(1);
   }
 
 
@@ -364,7 +370,7 @@
 		fprintf( stderr, "loading sprite %s - contains %d frames\n",
 		        name, new_sprite->num_frames );
 	}
-
+	
 	return new_sprite;
 }
 

Modified: tuxmath/trunk/src/mathcards.c
===================================================================
--- tuxmath/trunk/src/mathcards.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/mathcards.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -57,6 +57,7 @@
 static int int_to_bool(int i);
 static int sane_value(int i);
 static int abs_value(int i);
+static int randomly_keep(void);
 
 static void print_list(FILE* fp,MC_MathQuestion* list);
 static void print_node(FILE* fp, MC_MathQuestion* ptr);
@@ -119,6 +120,7 @@
   math_opts->max_questions = DEFAULT_MAX_QUESTIONS;
   math_opts->question_copies = DEFAULT_QUESTION_COPIES;
   math_opts->randomize = DEFAULT_RANDOMIZE;
+  math_opts->fraction_to_keep = DEFAULT_FRACTION_TO_KEEP;
   /* set question formats:  */
   math_opts->format_add_answer_last = DEFAULT_FORMAT_ADD_ANSWER_LAST; 
   math_opts->format_add_answer_first = DEFAULT_FORMAT_ADD_ANSWER_FIRST;
@@ -878,7 +880,17 @@
   math_opts->randomize = int_to_bool(opt);
 } 
 
+void MC_SetFractionToKeep(float fract)
+{
+  if (!math_opts)
+  {
+    fprintf(stderr, "\nMC_SetRandomize(): math_opts not valid!\n");
+    return;
+  }
+  math_opts->fraction_to_keep = fract;
+}
 
+
 /* Set math operations to be used in game: */
 void MC_SetAddAllowed(int opt)
 {
@@ -1957,8 +1969,10 @@
             /* questions like num1 + num2 = ? */
             if (math_opts->format_add_answer_last)
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
               {
                 tmp_ptr = create_node(i, j, MC_OPER_ADD, i + j, MC_FORMAT_ANS_LAST);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -1970,8 +1984,10 @@
             /* questions like num1 + ? = num3 */
             if (math_opts->format_add_answer_middle)
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
               {
                 tmp_ptr = create_node(i, j, MC_OPER_ADD, i + j, MC_FORMAT_ANS_MIDDLE);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -1983,8 +1999,11 @@
             /* questions like ? + num2 = num3 */
             if (math_opts->format_add_answer_first)
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
+
               {
                 tmp_ptr = create_node(i, j, MC_OPER_ADD, i + j, MC_FORMAT_ANS_FIRST);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2016,8 +2035,11 @@
             /* questions like num1 - num2 = ? */
             if (math_opts->format_sub_answer_last)
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
+
               {
                 tmp_ptr = create_node(i, j, MC_OPER_SUB, i - j, MC_FORMAT_ANS_LAST);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2029,8 +2051,11 @@
             /* questions like num1 - ? = num3 */
             if (math_opts->format_sub_answer_middle)
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
+
               {
                 tmp_ptr = create_node(i, j, MC_OPER_SUB, i - j, MC_FORMAT_ANS_MIDDLE);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2042,8 +2067,10 @@
             /* questions like ? - num2 = num3 */
             if (math_opts->format_sub_answer_first)
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
               {
                 tmp_ptr = create_node(i, j, MC_OPER_SUB, i - j, MC_FORMAT_ANS_FIRST);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2075,8 +2102,10 @@
             /* questions like num1 x num2 = ? */
             if (math_opts->format_mult_answer_last)
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
               {
                 tmp_ptr = create_node(i, j, MC_OPER_MULT, i * j, MC_FORMAT_ANS_LAST);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2090,8 +2119,10 @@
             if ((math_opts->format_mult_answer_middle)
              && (i != 0)) 
             {
-                 /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
               {
                 tmp_ptr = create_node(i, j, MC_OPER_MULT, i * j, MC_FORMAT_ANS_MIDDLE);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2105,8 +2136,10 @@
             if ((math_opts->format_mult_answer_first)
              && (j != 0))
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
               {
                 tmp_ptr = create_node(i, j, MC_OPER_MULT, i * j, MC_FORMAT_ANS_FIRST);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2140,8 +2173,10 @@
             /* questions like num1 / num2 = ? */
             if (math_opts->format_div_answer_last)
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
               {
                 tmp_ptr = create_node(i * j, j, MC_OPER_DIV, i, MC_FORMAT_ANS_LAST);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2154,8 +2189,10 @@
             if ((math_opts->format_div_answer_middle)
                && (i))      /* This avoids creating indeterminate questions: 0/? = 0 */
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
               {
                 tmp_ptr = create_node(i * j, j, MC_OPER_DIV, i, MC_FORMAT_ANS_MIDDLE);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2167,8 +2204,10 @@
             /* questions like ? / num2  = num3 */
             if (math_opts->format_div_answer_first)
             {
-              /* make sure max_questions not exceeded */
-              if (length < math_opts->max_questions)
+              /* make sure max_questions not exceeded, */
+              /* also check if question being randomly kept or discarded: */
+              if ((length < math_opts->max_questions)
+                 && randomly_keep())
               {
                 tmp_ptr = create_node(i * j, j, MC_OPER_DIV, i, MC_FORMAT_ANS_FIRST);
                 top_of_list = insert_node(top_of_list, end_of_list, tmp_ptr);
@@ -2699,3 +2738,25 @@
   else
     return -i;
 }
+
+
+/* Returns true at probability set by math_opts->fraction_to_keep */
+int randomly_keep(void)
+{
+  double random;
+
+  if (!math_opts)
+    return 0;
+
+  /* Skip random number generation if keeping all (default) */
+  if (1 == math_opts->fraction_to_keep)
+    return 1;
+
+  /* Hopefully this function is sufficiently portable: */
+  random = drand48();
+
+  if (random < math_opts->fraction_to_keep)
+    return 1;
+  else
+    return 0;
+}

Modified: tuxmath/trunk/src/mathcards.h
===================================================================
--- tuxmath/trunk/src/mathcards.h	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/mathcards.h	2007-01-12 11:52:34 UTC (rev 70)
@@ -49,6 +49,8 @@
   int max_questions;
   int question_copies;         /* how many times each question is put in list */
   int randomize;               /* whether to shuffle cards */
+  float fraction_to_keep;      /* Can use to have list contain a random subset */
+                               /* of the questions meeting selection criteria. */
 
   /*  math question formats:   NOTE - list can contain more than one format*/
   /* operation-specific question formats:  */
@@ -105,6 +107,7 @@
 #define DEFAULT_MAX_QUESTIONS 5000
 #define DEFAULT_QUESTION_COPIES 1         /* how many times each question is put in list */
 #define DEFAULT_RANDOMIZE 1               /* whether to shuffle cards */
+#define DEFAULT_FRACTION_TO_KEEP 1
 
 #define DEFAULT_FORMAT_ANSWER_LAST 1      /* question format is: a + b = ? */
 #define DEFAULT_FORMAT_ANSWER_FIRST 0     /* question format is: ? + b = c */
@@ -266,6 +269,7 @@
 void MC_SetMaxQuestions(int max); 
 void MC_SetAllowNegatives(int opt);
 void MC_SetRandomize(int opt);           
+void MC_SetFractionToKeep(float fract);
 
 /* Set question formats for all operations:     */
 /* NOTE - list can contain more than one format */
@@ -337,8 +341,8 @@
 int MC_AllowNegatives(void);
 int MC_QuestionCopies(void);         /* how many times each question is put in list */
 int MC_Randomize(void);         
+float MC_FractionToKeep(void);
 
-
 int MC_FormatAddAnswerLast(void);      /* a + b = ?   */ 
 int MC_FormatAddAnswerFirst(void);     /* ? + b = c   */
 int MC_FormatAddAnswerMiddle(void);    /* a + ? = c   */

Modified: tuxmath/trunk/src/options.c
===================================================================
--- tuxmath/trunk/src/options.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/options.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -390,7 +390,7 @@
   game_options->use_sound = int_to_bool(val);
 }
 
-
+/* FIXME need to actually change screen resolution when this is called */
 void Opts_SetFullscreen(int val)
 {
   game_options->fullscreen = int_to_bool(val);

Modified: tuxmath/trunk/src/pause.c
===================================================================
--- tuxmath/trunk/src/pause.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/pause.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -5,6 +5,10 @@
 begin                : Jan 22, 2003
 copyright            : (C) 2003 by Jesse Andrews
 email                : jdandr2 at uky.edu
+
+    Modified for use in tuxmath by David Bruce - 2006.
+    email                : <dbruce at tampabay.rr.com>
+                           <tuxmath-devel at lists.sourceforge.net>
 ***************************************************************************/
 
 /***************************************************************************

Modified: tuxmath/trunk/src/setup.c
===================================================================
--- tuxmath/trunk/src/setup.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/setup.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -65,7 +65,7 @@
 void initialize_SDL(void);
 void load_data_files(void);
 
-int initialize_game_options(void);
+//int initialize_game_options(void);
 void seticon(void);
 void usage(int err, char * cmd);
 
@@ -525,11 +525,13 @@
 void cleanup_on_error(void)
 {
   cleanup_memory();
+  exit(1);
 }
 
 
 
 /* free any heap memory used during game DSB */
+/* and also quit SDL properly:               */
 void cleanup_memory(void)
 {
   TTF_Quit();

Modified: tuxmath/trunk/src/theme.c
===================================================================
--- tuxmath/trunk/src/theme.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/theme.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -5,6 +5,10 @@
     begin                : Jan 6 2003
     copyright            : (C) 2003 by Jesse Andrews et al
     email                : jdandr2 at tux4kids.net
+ 
+    Modified for use in tuxmath by David Bruce - 2006.
+    email                : <dbruce at tampabay.rr.com>
+                           <tuxmath-devel at lists.sourceforge.net>
  ***************************************************************************/
 
 /***************************************************************************

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/titlescreen.c	2007-01-12 11:52:34 UTC (rev 70)
@@ -6,6 +6,10 @@
     copyright            : (C) 2000 by Sam Hart
                          : (C) 2003 by Jesse Andrews
     email                : tuxtype-dev at tux4kids.net
+
+    Modified for use in tuxmath by David Bruce - 2006.
+    email                : <dbruce at tampabay.rr.com>
+                           <tuxmath-devel at lists.sourceforge.net>
 ***************************************************************************/
 
 /***************************************************************************
@@ -23,8 +27,11 @@
 
 // tuxmath includes:
 #include "options.h"
+#include "fileops.h"
+#include "game.h"
+#include "mathcards.h"
+#include "setup.h"     //for cleanup()
 
-
 /* --- Data Structure for Dirty Blitting --- */
 SDL_Rect srcupdate[MAX_UPDATES];
 SDL_Rect dstupdate[MAX_UPDATES];
@@ -55,29 +62,29 @@
 
 /* --- define menu structure --- */
 /* (these values are all in the Game_Type enum in globals.h) */
-const int menu_item[][6]= {{0, 0,         0,         0,       0           },
-			   {0, CASCADE,   LEVEL1,    LEVEL1,  NOT_CODED   },
-			   {0, LASER,     LEVEL2,    LEVEL2,  FREETYPE    },
-			   {0, LESSONS,   LEVEL3,    LEVEL3,  PROJECT_INFO},
-			   {0, OPTIONS,   INSTRUCT,  LEVEL4,  SET_LANGUAGE},
-			   {0, QUIT_GAME, MAIN,      MAIN,    MAIN        }};
+const int menu_item[][6]= {{0, 0,         0,         0,        0           },
+			   {0, LESSONS,      LEVEL1,    LEVEL1,   NOT_CODED   },
+			   {0, ARCADE,       LEVEL2,    LEVEL2,   FREETYPE    },
+			   {0, OPTIONS,      LEVEL3,    LEVEL3,   PROJECT_INFO},
+			   {0, MORE_OPTIONS, LEVEL4,    LEVEL4,   SET_LANGUAGE},
+			   {0, QUIT_GAME,    MAIN,      MAIN,     MAIN        }};
 
 /* --- menu text --- */
 const unsigned char *menu_text[][6]= 
-/*    Main Menu                Options Menu                    Math Options                        Game Options                   */
-{{"", "",                      "",                             "",                                 ""                              },
- {"", gettext_noop("Play"),    gettext_noop("Math Options"),   gettext_noop("Addition"),           gettext_noop("Speed")           },
- {"", gettext_noop("Options"), gettext_noop("Game Options"),   gettext_noop("Subtraction"),        gettext_noop("Sound")           },
- {"", gettext_noop("Help"),    gettext_noop("Lessons"),        gettext_noop("Multiplication"),     gettext_noop("Graphics")        },
- {"", gettext_noop("Credits"), gettext_noop("Setup Language"), gettext_noop("Division"),           gettext_noop("Advanced Options")},
- {"", gettext_noop("Quit"),    gettext_noop("Main Menu"),      gettext_noop("Main Menu"),          gettext_noop("Main Menu")      }};
+/*    Main Menu                                       'Arcade' Games                    Math Options                     Game Options            */
+{{"", "",                                             "",                             "",                              ""                       },
+ {"", gettext_noop("Math Command Training Academy"),  gettext_noop("Space Cadet"), gettext_noop("Addition"),       gettext_noop("Speed")    },
+ {"", gettext_noop("Play Arcade Game"),               gettext_noop("Scout"),       gettext_noop("Subtraction"),    gettext_noop("Sound")    },
+ {"", gettext_noop("Play Custom Game"),               gettext_noop("Ranger"),      gettext_noop("Multiplication"), gettext_noop("Graphics") },
+ {"", gettext_noop("More Options"),                   gettext_noop("Ace"),         gettext_noop("Division"),       gettext_noop("Advanced Options")},
+ {"", gettext_noop("Quit"),                           gettext_noop("Main Menu"),   gettext_noop("Main Menu"),      gettext_noop("Main Menu") }};
 
 
 /* These are the filenames of the images used in the animated menu icons: */
 /* --- menu icons --- */
 const unsigned char *menu_icon[][6]= 
 {{"", "",        "",       "",        ""        },
- {"", "cascade", "easy",   "grade1_", "list"    },
+ {"", "lesson", "easy",   "grade1_", "list"    },
  {"", "comet",   "medium", "grade2_", "practice"},
  {"", "lesson",  "hard",   "grade3_", "keyboard"},
  {"", "option",  "tutor",  "grade4_", "lang"    },
@@ -121,7 +128,7 @@
 
 
 /* Local function prototypes: */
-int chooseWordlist(void);
+//int chooseWordlist(void);
 void draw_button(int id, sprite* s);
 void TitleScreen_load_menu(void);
 void TitleScreen_unload_menu(void);
@@ -415,7 +422,7 @@
 
 
             /* Toggle screen mode: */
-            case SDLK_F10: /* NOTE Cool! - should add this to TuxMath*/
+            case SDLK_F10: 
             {
               switch_screen_mode();
               redraw = 1;
@@ -473,12 +480,17 @@
               break;
             }
 
-
+	    case SDLK_KP_ENTER:
+            case SDLK_SPACE:
             case SDLK_RETURN:
             {
               if (key_menu)
               {
+                DOUT(key_menu);
+		DOUT(menu_depth);
                 menu_opt = menu_item[key_menu][menu_depth];
+                DOUT(menu_opt);
+
                 if (menu_sound)
                   tuxtype_playsound(snd_select);
               }
@@ -516,195 +528,267 @@
 
     /* --- do menu processing --- */
 
-
-    if (menu_opt == QUIT_GAME)
+    if (menu_opt == LESSONS)
     {
-      done = 1;
-    }
+//      NotImplemented();
+//      redraw = 1;
 
 
-    if (menu_opt == LASER)
-    {
-      menu_depth = LASER_SUBMENU;
-      sub_menu = LASER;
-      update_locs = 1;
+
+      if (choose_config_file()) 
+      {
+        TitleScreen_unload_media();
+
+        /* play game with chosen file */
+
+//         switch (sub_menu)
+//         {
+//           case CASCADE: PlayCascade( EASY ); break;
+//           case LASER:   laser_game(  EASY ); break;
+//         }
+
+        TitleScreen_load_media();
+
+        if (menu_music)
+          audioMusicLoad( "tuxi.ogg", -1 );
+      }
+
       redraw = 1;
+
+
+//       SDL_BlitSurface(bkg, NULL, screen, NULL);
+//       SDL_Flip( screen );
+//       TitleScreen_unload_media();
+// 
+//       if (menu_music)
+//       {
+//         audioMusicUnload( );
+//       }
+// //      testLesson();
+// 
+//       TitleScreen_load_media();
+//       redraw = 1;
+// 
+//       if (menu_music)
+//       {
+//         audioMusicLoad( "tuxi.ogg", -1 );
+//       }
     }
 
 
-    if (menu_opt == CASCADE)
+    if (menu_opt == ARCADE)
     {
-      menu_depth = CASCADE_SUBMENU;
-      sub_menu = CASCADE;
-      update_locs = 1;
-      redraw=1;
+//      NotImplemented();
+//      redraw = 1;
+       menu_depth = ARCADE_SUBMENU; /* i.e. 2 */
+       sub_menu = ARCADE;           /* i.e. 1 */
+       update_locs = 1;
+       redraw=1;
     }
 
 
-    if (menu_opt == OPTIONS)
+    if (menu_opt == HELP)
     {
-      menu_depth = OPTIONS_SUBMENU;
-      sub_menu = OPTIONS;
-      update_locs = 1;
+      NotImplemented();
       redraw = 1;
+//       menu_depth = CASCADE_SUBMENU;
+//       sub_menu = ARCADE;
+//       update_locs = 1;
+//       redraw=1;
     }
 
 
-    if (menu_opt == MAIN)
+    if (menu_opt == OPTIONS)
     {
-      menu_depth = ROOTMENU;
+      NotImplemented();
+      redraw = 1;
+
+/*      menu_depth = OPTIONS_SUBMENU;
+      sub_menu = OPTIONS;
       update_locs = 1;
-      redraw = 1;
+      redraw = 1;*/
     }
 
-
-    if (menu_opt == NOT_CODED)
+    if (menu_opt == MORE_OPTIONS)
     {
       NotImplemented();
       redraw = 1;
+//       menu_depth = OPTIONS_SUBMENU;
+//       sub_menu = OPTIONS;
+//       update_locs = 1;
+//       redraw = 1;
     }
 
-
-    if (menu_opt == PROJECT_INFO)
+    if (menu_opt == QUIT_GAME)
     {
-//      projectInfo();
-      redraw = 1;
+      done = 1;
     }
 
 
-    if (menu_opt == LESSONS)
+
+    if (menu_opt == LEVEL1)
     {
-      SDL_BlitSurface(bkg, NULL, screen, NULL);
-      SDL_Flip( screen );
-      TitleScreen_unload_media();
-
-      if (menu_music)
+      LOG("menu_opt == LEVEL1");
+      if (read_named_config_file("arcade/space_cadet"))
       {
-        audioMusicUnload( );
+        if (menu_music)
+        {
+          audioMusicUnload();
+        }
+        game();
       }
-//      testLesson();
+      else
+      {
+        fprintf(stderr, "\nCould not find arcade space_cadet config file\n");
+      }
 
       TitleScreen_load_media();
-      redraw = 1;
 
       if (menu_music)
       {
         audioMusicLoad( "tuxi.ogg", -1 );
       }
+      redraw = 1;
     }
 
 
-    if (menu_opt == SET_LANGUAGE)
+    if (menu_opt == LEVEL2)
     {
-      TitleScreen_unload_media();
-      chooseTheme();
-      LoadLang();
-      LoadKeyboard();
+      LOG("menu_opt == LEVEL2");
+      if (read_named_config_file("arcade/scout"))
+      {
+        if (menu_music)
+        {
+          audioMusicUnload();
+        }
+        game();
+      }
+      else
+      {
+        fprintf(stderr, "\nCould not find arcade scout config file\n");
+      }
+
       TitleScreen_load_media();
-      redraw = 1;
 
       if (menu_music)
       {
         audioMusicLoad( "tuxi.ogg", -1 );
       }
+      redraw = 1;
     }
 
 
-    if (menu_opt == LEVEL1)
+
+    if (menu_opt == LEVEL3)
     {
-      if (chooseWordlist()) 
+      LOG("menu_opt == LEVEL3");
+      if (read_named_config_file("arcade/ranger"))
       {
-        TitleScreen_unload_media();
-
-        switch (sub_menu)
+        if (menu_music)
         {
-//          case CASCADE: PlayCascade( EASY ); break;
-//          case LASER:   laser_game(  EASY ); break;
+          audioMusicUnload();
         }
+        game();
+      }
+      else
+      {
+        fprintf(stderr, "\nCould not find arcade ranger config file\n");
+      }
 
-        TitleScreen_load_media();
+      TitleScreen_load_media();
 
-        if (menu_music)
-        {
-          audioMusicLoad( "tuxi.ogg", -1 );
-        }
+      if (menu_music)
+      {
+        audioMusicLoad( "tuxi.ogg", -1 );
       }
-
       redraw = 1;
     }
 
 
-    if (menu_opt == LEVEL2)
+
+    if (menu_opt == LEVEL4)
     {
-      if (chooseWordlist())
+      LOG("menu_opt == LEVEL4");
+      if (read_named_config_file("arcade/ace"))
       {
-        TitleScreen_unload_media();
-
-        switch (sub_menu)
+        if (menu_music)
         {
-//          case CASCADE: PlayCascade( MEDIUM ); break;
-//          case LASER:   laser_game(  MEDIUM ); break;
+          audioMusicUnload();
         }
 
-        TitleScreen_load_media();
+	/* The 'Ace' list is _very_ long, so only use a random 10%  */
+        /* of questions meeting the criteria (and reset afterward): */
+        MC_SetFractionToKeep(0.1);
+        game();
+        MC_SetFractionToKeep(1);
+      }
+      else
+      {
+        fprintf(stderr, "\nCould not find arcade ace config file\n");
+      }
 
-        if (menu_music)
-        {
-          audioMusicLoad( "tuxi.ogg", -1 );
-        }
+      TitleScreen_load_media();
+
+      if (menu_music)
+      {
+        audioMusicLoad( "tuxi.ogg", -1 );
       }
-
       redraw = 1;
     }
 
 
 
-    if (menu_opt == LEVEL3)
+    if (menu_opt == LASER)
     {
-      if (chooseWordlist())
-      {
-        TitleScreen_unload_media();
+      menu_depth = LASER_SUBMENU;
+      sub_menu = LASER;
+      update_locs = 1;
+      redraw = 1;
+    }
 
-        switch (sub_menu)
-        {
-//          case CASCADE: PlayCascade( HARD ); break;
-//          case LASER:   laser_game(  HARD ); break;
-        }
 
-        TitleScreen_load_media();
 
-        if (menu_music)
-        {
-          audioMusicLoad( "tuxi.ogg", -1 );
-        }
-      }
 
+
+
+
+    if (menu_opt == MAIN)
+    {
+      menu_depth = ROOTMENU;
+      update_locs = 1;
       redraw = 1;
     }
 
 
+    if (menu_opt == NOT_CODED)
+    {
+      NotImplemented();
+      redraw = 1;
+    }
 
-    if (menu_opt == LEVEL4)
+
+    if (menu_opt == PROJECT_INFO)
     {
-      if (chooseWordlist())
-      {
-        TitleScreen_unload_media();
+//      projectInfo();
+      redraw = 1;
+    }
 
-        switch (sub_menu)
-        {
-//          case CASCADE: PlayCascade( INSANE ); break;
-//          case LASER:   laser_game(  INSANE ); break;
-        }
 
-        TitleScreen_load_media();
 
-        if (menu_music)
-        {
-          audioMusicLoad( "tuxi.ogg", -1 );
-        }
-      }
 
+    if (menu_opt == SET_LANGUAGE)
+    {
+      TitleScreen_unload_media();
+      chooseTheme();
+      LoadLang();
+      LoadKeyboard();
+      TitleScreen_load_media();
       redraw = 1;
+
+      if (menu_music)
+      {
+        audioMusicLoad( "tuxi.ogg", -1 );
+      }
     }
 
 
@@ -998,7 +1082,7 @@
 
   speaker = LoadImage( "title/sound.png", IMG_ALPHA );
   speakeroff = LoadImage( "title/nosound.png", IMG_ALPHA );
-  bkg = LoadImage( "title/main_bkg.png", IMG_REGULAR );
+  bkg = LoadImage( "title/main_bkg.jpg", IMG_REGULAR );
 
   sel = LoadSprite("menu/sel", IMG_ALPHA);
   reg = LoadSprite("menu/reg", IMG_ALPHA);
@@ -1164,18 +1248,18 @@
 
 	s1 = black_outline( _("Work In Progress!"), font, &white);
 	s2 = black_outline( _("This feature is not ready yet"), font, &white);
-	s3 = black_outline( _("Discuss the future of TuxTyping at"), font, &white);
+	s3 = black_outline( _("Discuss the future of TuxMath at"), font, &white);
 
 	/* we always want the URL in english */
 	if (!useEnglish) {
 		TTF_Font *english_font;
 		useEnglish = 1;
 		english_font = LoadFont( menu_font, menu_font_size );
-		s4 = black_outline( "http://tuxtype.sf.net/forums", english_font, &white);
+		s4 = black_outline( "tuxmath-devel at lists.sourceforge.net", english_font, &white);
 		TTF_CloseFont(english_font);
 		useEnglish = 0;
 	} else 
-		s4 = black_outline( "http://tuxtype.sf.net/forums", font, &white);
+		s4 = black_outline( "tuxmath-devel at lists.sourceforge.net", font, &white);
 
         LOG( "NotImplemented() - drawing screen\n" );
 
@@ -1189,14 +1273,16 @@
 	loc.x = 320-(s4->w/2); loc.y = 440;
 	SDL_BlitSurface( s4, NULL, screen, &loc);
 
-	tux = LoadSprite("tux/tux-egypt", IMG_ALPHA);
-
-	loc.x = 320-(tux->frame[0]->w/2);
-	loc.y = 200;
-	loc.w = tux->frame[0]->w;
-	loc.h = tux->frame[0]->h;
-	SDL_BlitSurface( tux->frame[tux->cur], NULL, screen, &loc);
-
+//	tux = LoadSprite("tux/tux-egypt", IMG_ALPHA);
+	tux = LoadSprite("tux/bigtux", IMG_ALPHA);
+	if (tux && tux->num_frames) /* make sure sprite has at least one frame */
+	{
+	  loc.x = 320-(tux->frame[0]->w/2);
+	  loc.y = 200;
+	  loc.w = tux->frame[0]->w;
+	  loc.h = tux->frame[0]->h;
+	  SDL_BlitSurface( tux->frame[tux->cur], NULL, screen, &loc);
+	}
 	SDL_UpdateRect(screen, 0, 0, 0, 0);
 
 	i=0;
@@ -1210,7 +1296,10 @@
 					finished=1;
 			}
 		i++;
-		if (i%5==0) {
+		if ((i%5==0)
+		 && tux
+		 && tux->num_frames) /* make sure sprite has at least one frame */
+		{
 			next_frame(tux);
 			SDL_BlitSurface( bkg, &loc, screen, &loc);
 			SDL_BlitSurface( tux->frame[tux->cur], NULL, screen, &loc);
@@ -1229,227 +1318,374 @@
 }
 
 
-#define MAX_WORD_LISTS 100
 
+
+/* choose_config_file() - adapted from chooseWordlist() from tuxtype. */
+/* Display a list of tuxmath config files in the missions directory   */
+/* and allow the player to pick one.                                  */
+/* FIXME the directory search and list generation belongs in fileops.c */
+
 /* returns 0 if user pressed escape (or if dir not found)
- *         1 if word list was set correctly
+ *         1 if config was set correctly
  */
-int chooseWordlist( void ) {
-	SDL_Surface *titles[MAX_WORD_LISTS];
-	SDL_Surface *select[MAX_WORD_LISTS];
-	SDL_Surface *left, *right;
-	SDL_Rect leftRect, rightRect;
-	SDL_Rect titleRects[8];
-	int stop = 0;
-	int loc = 0;
-	int old_loc = 1;
-	int lists = 1;
-	int i;
-	unsigned char wordPath[FNLEN];
-	unsigned char wordlistFile[MAX_WORD_LISTS][200];
-	unsigned char wordlistName[MAX_WORD_LISTS][200];
+int choose_config_file(void)
+{
+  SDL_Surface *titles[MAX_LESSONS];
+  SDL_Surface *select[MAX_LESSONS];
+  SDL_Surface *left, *right;
+  SDL_Rect leftRect, rightRect;
+  SDL_Rect titleRects[8];               //8 lessons displayed per page 
 
-	DIR *wordsDir;
-	struct dirent *wordsFile;
-	struct stat fileStats;
-	FILE *tempFile;
+  int stop = 0;
+  int loc = 0;                                  //The currently selected lesson file
+  int old_loc = 1;
+  int lessons = 0;                              //Number of lesson files found in dir
+  int i;
+  int length;
 
-	LOG("Entering chooseWordlist():\n");
+  unsigned char lesson_path[FNLEN];             //Path to lesson directory
+  unsigned char lesson_list[MAX_LESSONS][200];  //List of lesson file names
+  unsigned char lesson_names[MAX_LESSONS][200]; //List of lesson names for display
+  unsigned char name_buf[200];
 
-	/* find the directory to load wordlists from */
+  DIR* lesson_dir;
+  struct dirent* lesson_file;
+  struct stat fileStats;
+  FILE* tempFile;
 
-	for (i=useEnglish; i<2; i++) {
-		fileStats.st_mode = 0; // clear last use!
-		sprintf( wordPath, "%s/words", realPath[i] );
-		stat( wordPath, &fileStats );
-		if ( fileStats.st_mode & S_IFDIR )
-			break;
-	}
+  LOG("Entering choose_config_file():\n");
 
-	if (i==2) {
-		fprintf(stderr, "ERROR: Unable to find wordlist directory\n");
-		return 0;
+  /* find the directory containing the lesson files:  */
+
+  for (i = useEnglish; i < 2; i++)
+  {
+    fileStats.st_mode = 0; // clear last use!
+    sprintf( lesson_path, "%s/missions/lessons", realPath[i] );
+
+#ifdef TUXMATH_DEBUG
+    fprintf(stderr, "Checking path: %s\n", lesson_path);
+#endif
+
+    stat(lesson_path, &fileStats);
+
+    if (fileStats.st_mode & S_IFDIR)
+    {
+#ifdef TUXMATH_DEBUG
+      fprintf(stderr, "Path found\n");
+#endif
+      break;
+    }
+    else
+    {
+#ifdef TUXMATH_DEBUG
+      fprintf(stderr, "Path NOT found\n");
+#endif
+    }
+  }
+
+  if (i==2)
+  {
+    fprintf(stderr, "ERROR: Unable to find lesson directory\n");
+    return 0;
 //		exit(1);  // FIXME if exiting, need to restore screen resolution, cleanup heap, etc.
-	}
+  }
 
-	DEBUGCODE { fprintf(stderr, "wordPath is: %s\n", wordPath); }
+#ifdef TUXMATH_DEBUG
+  fprintf(stderr, "lesson_path is: %s\n", lesson_path);
+#endif
 
-	/* create a list of all the .txt files */
+  /* create a list of all the lesson files */
+  lesson_dir = opendir(lesson_path);	
 
-	wordsDir = opendir( wordPath );	
+  do
+  {
+    /* readdir() returns ptr to next file in dir AND resets ptr to following file: */
+    lesson_file = readdir(lesson_dir);
+    /* Get out when no more files: */
+    if (!lesson_file)
+    {
+      break;
+    }
 
-	do {
-		wordsFile = readdir(wordsDir);
-		if (!wordsFile)
-			break;
+    /* file names must begin with 'lesson' (case-insensitive) */
+    if (0 != strncasecmp(&lesson_file->d_name, "lesson", 6))
+    { 
+      continue;
+    }
 
-		/* must have at least .txt at the end */
-		if (strlen(wordsFile->d_name) < 5)
-			continue;
+    /* FIXME Should somehow test each file to see if it is a tuxmath config file */
+    /* Put file name into array of names found in lesson directory */
+    sprintf(lesson_list[lessons], "%s/%s", lesson_path, lesson_file->d_name);
 
-		if (strcmp(&wordsFile->d_name[strlen(wordsFile->d_name)-4],".txt"))
-			continue;
+#ifdef TUXMATH_DEBUG
+    fprintf(stderr, "Found lesson file %d:\t%s\n", lessons, lesson_list[lessons]);
+#endif
 
-		sprintf( wordlistFile[lists], "%s/%s", wordPath, wordsFile->d_name );
+    /* load the name for the lesson from the file ... (1st line) */
+    tempFile = fopen(lesson_list[lessons], "r");
 
-		/* load the name for the wordlist from the file ... (1st line) */
-		tempFile = fopen( wordlistFile[lists], "r" );
-		if (tempFile==NULL) continue;
-		fscanf( tempFile, "%[^\n]\n", wordlistName[lists] );
+    if (tempFile==NULL)
+    {
+      /* By leaving the loop without incrementing 'lessons', */
+      /* the bad file name will get clobbered next time through: */
+      continue;
+    }
 
-		/* check to see if it has a \r at the end of it (dos format!) */
-		if (wordlistName[lists][ strlen(wordlistName[lists])-1 ] == '\r')
-			wordlistName[lists][ strlen(wordlistName[lists])-1 ] = '\0';
-		lists++;
+    /* FIXME I think the following could overflow: */
+    fscanf(tempFile, "%[^\n]\n", name_buf);
 
-		fclose(tempFile);
-		
-	} while (1);
+    /* check to see if it has a \r at the end of it (dos format!) */
+    length = strlen(name_buf);
+    if (name_buf[length - 1] == '\r')
+    {
+      name_buf[length - 1] = '\0';
+    }
 
-	closedir( wordsDir );	
+    /* Go past leading '#', ';', or whitespace: */
+    /* NOTE the value of i on exit is the main goal of the loop */
+    for (  i = 0;
+           ((name_buf[i] == '#') ||
+           (name_buf[i] == ';') ||
+           isspace(name_buf[i])) &&
+           (i < 200);
+           i++  )
+    {
+      length--;
+    }
+    /* Now copy the rest of the first line into the list: */
+    memmove(&lesson_names[lessons], &name_buf[i], length); 
+    lessons++;
+    fclose(tempFile);
+  } while (1);        // Loop will end when 'break' encountered
 
-	/* let the user pick the list */
+  closedir(lesson_dir);	
 
-	titles[0] = black_outline( _("Alphabet"), font, &white );
-	select[0] = black_outline( _("Alphabet"), font, &yellow);
-	for (i = 1; i<lists; i++) {
-		titles[i] = black_outline( wordlistName[i], font, &white );
-		select[i] = black_outline( wordlistName[i], font, &yellow);
-	}
 
-	SDL_FreeSurface(bkg);
-        bkg = LoadImage("main_bkg.png", IMG_REGULAR);
+  /* Display the list of lessons for the player to select: */
 
-        left = LoadImage("left.png", IMG_ALPHA);       
-        leftRect.w = left->w; leftRect.h = left->h;
-        leftRect.x = 320 - 80 - (leftRect.w/2); leftRect.y = 430;
+  /* FIXME black_outline() segfaults if passed "" as arg */
+  for (i = 0; i < lessons; i++)
+  {
+    titles[i] = black_outline( lesson_names[i], font, &white );
+    select[i] = black_outline( lesson_names[i], font, &yellow);
+  }
 
-        right = LoadImage("right.png", IMG_ALPHA);
-        rightRect.w = right->w; rightRect.h = right->h;
-        rightRect.x = 320 + 80 - (rightRect.w/2); rightRect.y = 430;
+  SDL_FreeSurface(bkg);
+  bkg = LoadImage("title/main_bkg.png", IMG_REGULAR);
 
-        /* set initial rect sizes */
-        titleRects[0].y = 30;
-        titleRects[0].w = titleRects[0].h = titleRects[0].x = 0;
-        for (i = 1; i<8; i++) { 
-                titleRects[i].y = titleRects[i-1].y + 50;
-                titleRects[i].w = titleRects[i].h = titleRects[i].x = 0;
+  left = LoadImage("title/left.png", IMG_ALPHA);       
+  leftRect.w = left->w; leftRect.h = left->h;
+  leftRect.x = 320 - 80 - (leftRect.w/2); leftRect.y = 430;
+
+  right = LoadImage("title/right.png", IMG_ALPHA);
+  rightRect.w = right->w; rightRect.h = right->h;
+  rightRect.x = 320 + 80 - (rightRect.w/2); rightRect.y = 430;
+
+  /* set initial rect sizes */
+  titleRects[0].y = 30;
+  titleRects[0].w = titleRects[0].h = titleRects[0].x = 0;
+
+  for (i = 1; i < 8; i++)
+  { 
+    titleRects[i].y = titleRects[i - 1].y + 50;
+    titleRects[i].w = titleRects[i].h = titleRects[i].x = 0;
+  }
+
+
+  while (!stop)
+  {
+    while (SDL_PollEvent(&event))
+    {
+      switch (event.type)
+      {
+        case SDL_QUIT:
+        {
+          cleanup();
+          //exit(0);
+          break;
         }
+ 
+        case SDL_MOUSEMOTION:
+        {
+          for (i = 0; (i < 8) && (loc -(loc % 8) + i < lessons); i++)
+          {
+            if (inRect(titleRects[i], event.motion.x, event.motion.y))
+            {
+              loc = loc - (loc % 8) + i;
+              break;
+            }
+          }
+          break;
+        }
 
-        while (!stop) {
-                while (SDL_PollEvent(&event))
-                        switch (event.type) {
-                                case SDL_QUIT:
-                                        exit(0);
-                                        break;
-                                case SDL_MOUSEMOTION:
-                                        for (i=0; (i<8) && (loc-(loc%8)+i<lists); i++)
-                                                if (inRect( titleRects[i], event.motion.x, event.motion.y )) {
-                                                        loc = loc-(loc%8)+i;
-                                                        break;
-                                                }
+        case SDL_MOUSEBUTTONDOWN:
+        {
+#ifdef TUXMATH_DEBUG
+              fprintf(stderr, "MouseDown at x = %d, y = %d\n", event.button.x, event.button.y);
+#endif
 
-                                        break;
-                                case SDL_MOUSEBUTTONDOWN:
-                                        if (inRect( leftRect, event.button.x, event.button.y ))
-                                                if (loc-(loc%8)-8 >= 0) {
-                                                        loc=loc-(loc%8)-8;
-                                                        break;
-                                                }
-                                        if (inRect( rightRect, event.button.x, event.button.y ))
-                                                if (loc-(loc%8)+8 < lists) {
-                                                        loc=loc-(loc%8)+8;
-                                                        break;
-                                                }
-                                        for (i=0; (i<8) && (loc-(loc%8)+i<lists); i++)
-                                                if (inRect(titleRects[i], event.button.x, event.button.y)) {
-                                                        loc = loc-(loc%8)+i;
-							WORDS_init(); /* clear old selection */
-							if (loc==0)
-								WORDS_use_alphabet(); 
-							else
-								WORDS_use( wordlistFile[loc] ); 
-                                                        stop = 1;
-                                                        break;
-                                                }
-                                        break;
-                                case SDL_KEYDOWN:
-                                        if (event.key.keysym.sym == SDLK_ESCAPE) { stop = 2; break; }
-                                        if (event.key.keysym.sym == SDLK_RETURN) {
-						WORDS_init(); /* clear old selection */
-						if (loc==0)
-							WORDS_use_alphabet(); 
-						else
-							WORDS_use( wordlistFile[loc] ); 
-                                                stop = 1;
-                                                break;
-                                        }
+          /* Lesson buttons - play game with corresponding lesson file: */
+          for (i = 0; (i < 8) && (loc - (loc % 8) + i < lessons); i++)
+          {
+            if (inRect(titleRects[i], event.button.x, event.button.y))
+            {
+              loc = loc - (loc % 8) + i;
 
-                                        if ((event.key.keysym.sym == SDLK_LEFT) || (event.key.keysym.sym == SDLK_PAGEUP)) {
-                                                if (loc-(loc%8)-8 >= 0)
-                                                        loc=loc-(loc%8)-8;
-                                        }
+#ifdef TUXMATH_DEBUG
+              fprintf(stderr, "Player selecting lesson, loc = %d\n", loc);
+              fprintf(stderr, "Name of lesson file: %s", lesson_list[loc]);
+#endif
+              read_named_config_file(lesson_list[loc]);
+              game();
+              //FIXME only recognizing first entry in list
 
-                                        if ((event.key.keysym.sym == SDLK_RIGHT) || (event.key.keysym.sym == SDLK_PAGEDOWN)) {
-                                                if (loc-(loc%8)+8 < lists)
-                                                        loc=(loc-(loc%8)+8);
-                                        }
+              stop = 1;
+              break;
+            }
+          }
+        
+          /* "Left" button - go to previous page: */
+          if (inRect(leftRect, event.button.x, event.button.y))
+          {
+            if (loc - (loc % 8) - 8 >= 0)
+            {
+              loc = loc - (loc % 8) - 8;
+              break;
+            }
+          }
 
-                                        if (event.key.keysym.sym == SDLK_UP) {
-                                                if (loc > 0)
-                                                        loc--;
-                                        }
+          /* "Right" button - go to next page: */
+          if (inRect( rightRect, event.button.x, event.button.y ))
+          {
+            if (loc - (loc % 8) + 8 < lessons)
+            {
+              loc = loc - (loc % 8) + 8;
+              break;
+            }
+          }
+        }
 
-                                        if (event.key.keysym.sym == SDLK_DOWN) {
-                                                if (loc+1<lists)
-                                                        loc++;
-                                        }
-                        }
 
-                if (old_loc != loc) {
-                        int start;
+        case SDL_KEYDOWN:
+        {
+          // TODO could make these a switch/case statement
+          if (event.key.keysym.sym == SDLK_ESCAPE)
+          { 
+            stop = 2;
+            break;
+          }
 
-                        SDL_BlitSurface( bkg, NULL, screen, NULL );
+          if ((event.key.keysym.sym == SDLK_RETURN)
+           || (event.key.keysym.sym == SDLK_SPACE)
+           || (event.key.keysym.sym == SDLK_KP_ENTER))
+          {
+#ifdef TUXMATH_DEBUG
+            fprintf(stderr, "Player selecting lesson, loc = %d\n", loc);
+            fprintf(stderr, "Name of lesson file: %s", lesson_list[loc]);
+#endif
+            read_named_config_file(lesson_list[loc]);
+            game();
+            stop = 1;
+            break;
+          }
 
-                        start = loc - (loc % 8);
-                        for (i = start; i<MIN(start+8,lists); i++) {
-                                titleRects[i%8].x = 320 - (titles[i]->w/2);
-                                if (i == loc)
-                                        SDL_BlitSurface(select[loc], NULL, screen, &titleRects[i%8]);
-                                else
-                                        SDL_BlitSurface(titles[i], NULL, screen, &titleRects[i%8]);
-                        }
+          /* Go to previous page, if present: */
+          if ((event.key.keysym.sym == SDLK_LEFT) || (event.key.keysym.sym == SDLK_PAGEUP))
+          {
+            if (loc - (loc % 8) - 8 >= 0)
+            {
+              loc = loc - (loc % 8) - 8;
+            }
+          }
 
-                        /* --- draw buttons --- */
+          /* Go to next page, if present: */
+          if ((event.key.keysym.sym == SDLK_RIGHT) || (event.key.keysym.sym == SDLK_PAGEDOWN))
+          {
+            if (loc-(loc%8)+8 < lessons)
+            {
+              loc = (loc - (loc % 8) + 8);
+            }
+          }
 
-                        if (start>0)
-                                SDL_BlitSurface( left, NULL, screen, &leftRect );
+          /* Go up one entry, if present: */
+          if (event.key.keysym.sym == SDLK_UP)
+          {
+            if (loc > 0)
+            {
+              loc--;
+            }
+          }
 
-                        if (start+8<lists)
-                                SDL_BlitSurface( right, NULL, screen, &rightRect );
+          /* Go down one entry, if present: */
+          if (event.key.keysym.sym == SDLK_DOWN)
+          {
+            if (loc + 1 < lessons)
+            {
+              loc++;
+            }
+          }
+        }  // End of key handling
+      }  // End switch statement
+    }  // End SDL_PollEvent while loop
 
-                        SDL_UpdateRect(screen, 0, 0, 0 ,0);
-                }
-                SDL_Delay(40);
-                old_loc = loc;
+    /* Redraw screen: */
+    if (old_loc != loc) 
+    {
+      int start;
+      start = loc - (loc % 8);
+
+      SDL_BlitSurface( bkg, NULL, screen, NULL );
+
+      /* FIXME get rid of evil macro ;)       */
+      for (i = start; i < MIN(start+8,lessons); i++)
+      {
+        titleRects[i % 8].x = 320 - (titles[i]->w/2); //Center in screen
+        titleRects[i % 8].w = titles[i]->w;
+        titleRects[i % 8].h = titles[i]->h;
+
+        if (i == loc)  //Draw text in yellow
+        {
+          SDL_BlitSurface(select[loc], NULL, screen, &titleRects[i % 8]);
         }
+        else           //Draw text in white
+        {
+          SDL_BlitSurface(titles[i], NULL, screen, &titleRects[i % 8]);
+        }
+      }
 
-	/* --- clear graphics before leaving function --- */ 
+      /* --- draw buttons --- */
+      if (start > 0)        // i.e. not on first page
+      {
+        SDL_BlitSurface( left, NULL, screen, &leftRect );
+      }
+      if (start + 8 < lessons)  // not on last page
+      {
+        SDL_BlitSurface( right, NULL, screen, &rightRect );
+      }
 
-	for (i = 0; i<lists; i++) {
-		SDL_FreeSurface(titles[i]);
-		SDL_FreeSurface(select[i]);
-	}
+      /* Now redraw whole screen: */
+      SDL_UpdateRect(screen, 0, 0, 0 ,0);
+    }
+    SDL_Delay(40);
+    old_loc = loc;
+  }  // End !stop while loop
 
-	SDL_FreeSurface(left);
-	SDL_FreeSurface(right);
+  /* --- clear graphics before leaving function --- */ 
+  for (i = 0; i < lessons; i++)
+  {
+    SDL_FreeSurface(titles[i]);
+    SDL_FreeSurface(select[i]);
+  }
 
-        DEBUGCODE { fprintf( stderr, "Leaving chooseWordlist();\n" ); }
+  SDL_FreeSurface(left);
+  SDL_FreeSurface(right);
 
-	if (stop == 2)
-		return 0;
+  DEBUGCODE { fprintf( stderr, "Leaving choose_config_file();\n" ); }
 
-	return 1;
+  if (stop == 2)
+    return 0;
+
+  return 1;
 }
 
 

Modified: tuxmath/trunk/src/titlescreen.h
===================================================================
--- tuxmath/trunk/src/titlescreen.h	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/titlescreen.h	2007-01-12 11:52:34 UTC (rev 70)
@@ -1,3 +1,22 @@
+/***************************************************************************
+ -  file: titlescreen.h
+ -  description: header for the tuxtype-derived files in tuxmath
+                            ------------------
+
+    David Bruce - 2006.
+    email                : <dbruce at tampabay.rr.com>
+                           <tuxmath-devel at lists.sourceforge.net>
+***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
 #ifdef WIN32 
 #undef DATA_PREFIX
 #define DATA_PREFIX ".//"
@@ -101,6 +120,7 @@
 #define ttf_font	"GenAI102.ttf" /* or "DejaVuSans-Bold.ttf" or "FreeSansBold.ttf" */  	/* was letters.ttf */
 #define ttf_font_size	20
 
+#define MAX_LESSONS 100
 #define MAX_NUM_WORDS   500
 #define MAX_WORD_SIZE   8
 
@@ -114,7 +134,7 @@
 
 /* Menu Prototypes */
 enum Game_Type { 
-	QUIT_GAME, CASCADE, OPTIONS, LESSONS,
+	QUIT_GAME, ARCADE, OPTIONS, LESSONS, MORE_OPTIONS, HELP,
 	INSTRUCT_CASCADE, CASCADE1, CASCADE2, CASCADE3, CASCADE4,
 	INSTRUCT_LASER,    LASER1,    LASER2,    LASER3,    LASER4,
 	FREETYPE, ASDF, ALL, MAIN, SET_LANGUAGE, PROJECT_INFO, EDIT_WORDLIST,
@@ -207,7 +227,7 @@
 
 #define OPTIONS_SUBMENU                 4
 #define LASER_SUBMENU	        	3
-#define CASCADE_SUBMENU	        	2
+#define ARCADE_SUBMENU	        	2
 #define ROOTMENU		        1
 
 
@@ -230,6 +250,7 @@
 
 extern void TitleScreen( void );
 extern void switch_screen_mode( void );
+extern int choose_config_file(void);  //FIXME really should be in fileops.c
 extern int Phrases(char *practice_phrase); // NOTE this is not implemented
 
 /* in theme.c (from tuxtype): */

Modified: tuxmath/trunk/src/tuxmath.h
===================================================================
--- tuxmath/trunk/src/tuxmath.h	2007-01-12 11:51:53 UTC (rev 69)
+++ tuxmath/trunk/src/tuxmath.h	2007-01-12 11:52:34 UTC (rev 70)
@@ -29,7 +29,7 @@
 #endif
 
 //#define NOSOUND
-//#define TUXMATH_DEBUG   /* for conditional compilation of debugging output */
+#define TUXMATH_DEBUG   /* for conditional compilation of debugging output */
 //#define FEEDBACK_DEBUG  /* for Tim's feedback speed control code           */
 
 //#define TUXMATH_VERSION 0.98 This is now done by autoheader and configure.in
@@ -68,7 +68,7 @@
 /* These values are hard-coded and used 'as is' by the program */
 /* (i.e. these behaviors require recompilation to change)   */ 
 #define DEFAULT_NUM_CITIES 4   /* MUST BE AN EVEN NUMBER! */
-#define DEFAULT_NUM_BKGDS 5
+#define DEFAULT_NUM_BKGDS 6
 #define DEFAULT_MAX_CITY_COLORS 4
 
 #define MINIMUM_SPEED 0.1




More information about the Tux4kids-commits mailing list