[Tux4kids-commits] r1266 - tuxmath/trunk/src

Bolesław Kulbabiński bolekk-guest at alioth.debian.org
Fri Jul 24 13:51:02 UTC 2009


Author: bolekk-guest
Date: 2009-07-24 13:51:00 +0000 (Fri, 24 Jul 2009)
New Revision: 1266

Modified:
   tuxmath/trunk/src/titlescreen.c
   tuxmath/trunk/src/titlescreen.h
Log:
removed old menu code from titlescreen.c

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2009-07-24 09:58:00 UTC (rev 1265)
+++ tuxmath/trunk/src/titlescreen.c	2009-07-24 13:51:00 UTC (rev 1266)
@@ -1,45 +1,32 @@
-/***************************************************************************
- -  file: titlescreen.c
- -  description: splash, title and menu screen functionality
-                            ------------------
-    begin                : Thur May 4 2000
-    copyright            : (C) 2000 by Sam Hart
-                         : (C) 2003 by Jesse Andrews
-    email                : tuxtype-dev at tux4kids.net
+/*
+  titlescreen.c
 
-    Modified for use in tuxmath by David Bruce - 2006-2007.
-    email                : <dbruce at tampabay.rr.com>
-                           <tuxmath-devel at lists.sourceforge.net>
-    Also significantly enhanced by Tim Holy - 2007
-***************************************************************************/
+  Splash, background and title screen items.
 
-/***************************************************************************
- *                                                                         *
- *   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.                                   *
- *                                                                         *
- ***************************************************************************/
+  begin                : Thur May 4 2000
+  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-2007.
+  email                : <dbruce at tampabay.rr.com>
+                         <tuxmath-devel at lists.sourceforge.net>
 
-// titlescreen.h has all of the tuxtype-related stuff:
+  Also significantly enhanced by Tim Holy - 2007
+
+  Part of "Tux4Kids" Project
+  http://www.tux4kids.com/
+
+  Copyright: See COPYING file that comes with this distribution.
+*/
+
 #include "titlescreen.h"
 
-// tuxmath includes:
 #include "tuxmath.h"
 #include "options.h"
 #include "fileops.h"
-#include "game.h"
-#include "campaign.h"
-#include "factoroids.h"
-#include "multiplayer.h"
-#include "mathcards.h"
-#include "setup.h"     //for cleanup()
+#include "setup.h"
 #include "loaders.h"
-#include "credits.h"
-#include "highscore.h"
-#include "convert_utf.h" // for wide char to UTF-8 conversion
 #include "SDL_extras.h"
 #include "menu.h"
 
@@ -72,78 +59,16 @@
 /*TODO: move these constants into a config file
   (together with menu.c constants ? ) */
 const float title_pos[4] = {0.0, 0.0, 0.3, 0.25};
-const float tux_pos[4] = {0.0, 0.6, 0.3, 0.4};
-const char* bkg_path = "title/menu_bkg.jpg";
+const float tux_pos[4]   = {0.0, 0.6, 0.3, 0.4};
+const char* bkg_path     = "title/menu_bkg.jpg";
 const char* standby_path = "status/standby.svg";
-const char* title_path = "title/title1.svg";
-const char* egg_path = "title/egg.svg";
-const char* tux_path = "tux/bigtux";
+const char* title_path   = "title/title1.svg";
+const char* egg_path     = "title/egg.svg";
+const char* tux_path     = "tux/bigtux";
 /* beak coordinates relative to tux rect */
-const float beak_pos[4] = {0.36, 0.21, 0.27, 0.14};
+const float beak_pos[4]  = {0.36, 0.21, 0.27, 0.14};
 
 
-/* --- media for menus --- */
-
-enum {
-  SPRITE_TRAINING,
-  SPRITE_ARCADE,
-  SPRITE_HELP,
-  SPRITE_CUSTOM,
-  SPRITE_OPTIONS,
-  SPRITE_CADET,
-  SPRITE_SCOUT,
-  SPRITE_RANGER,
-  SPRITE_ACE,
-  SPRITE_COMMANDO,
-  SPRITE_QUIT,
-  SPRITE_MAIN,
-  SPRITE_GOLDSTAR,
-  SPRITE_NO_GOLDSTAR,
-  SPRITE_TROPHY,
-  SPRITE_CREDITS,
-  SPRITE_ALONE,
-  SPRITE_FRIENDS,
-  SPRITE_FACTOROIDS,
-  SPRITE_FACTORS,
-  SPRITE_FRACTIONS,
-  SPRITE_CAMPAIGN,
-  SPRITE_SSWEEP,
-  SPRITE_ELIMINATION,
-  SPRITE_SERVER,
-  SPRITE_CLIENT,
-  N_SPRITES};
-
-const char* menu_sprite_files[N_SPRITES] =
-{
-  "lesson",
-  "comet",
-  "help",
-  "tux_config",
-  "tux_config_brown",
-  "tux_helmet_yellow",
-  "tux_helmet_green",
-  "tux_helmet_blue",
-  "tux_helmet_red",
-  "tux_helmet_black",
-  "quit",
-  "main",
-  "goldstar",
-  "no_goldstar",
-  "trophy",
-  "credits",
-  "alone", 
-  "friends", 
-  "factoroids",
-  "factors",
-  "fractions",
-  "fleet",
-  "nums",
-  "exclamation"
-};
-
-sprite **sprite_list = NULL;
-
-
 SDL_Event event;
 
 /* screen dimensions to which titlescreen graphics are currently rendered */
@@ -170,7 +95,7 @@
          cursor,
          beak;
 
-SDL_Rect stopRect; /* part of the menu */
+SDL_Rect stopRect;
 
 SDL_Surface* current_bkg()
   /* This syntax makes my brain start to explode! */
@@ -193,8 +118,6 @@
 }
 
 /* Local function prototypes: */
-int TitleScreen_load_menu(void);
-void TitleScreen_unload_menu(void);
 void NotImplemented(void);
 
 void free_titlescreen(void);
@@ -204,24 +127,6 @@
 void update_screen(int* frame);
 void add_rect(SDL_Rect* src, SDL_Rect* dst);
 
-void RecalcMenuPositions(int*, int, menu_options*, void (*)(menu_options*),
-                         SDL_Rect**, SDL_Rect**, SDL_Rect**,
-                         SDL_Rect**, SDL_Rect**, SDL_Rect**,
-                         SDL_Rect*, SDL_Rect*);
-void set_buttons_max_width(SDL_Rect *, SDL_Rect *, int);
-
-int run_login_menu(void);
-int run_main_menu(void);
-int run_game_menu(void);
-int run_multiplay_menu(void);
-int run_lessons_menu(void);
-int run_arcade_menu(void);
-int run_campaign_menu(void);
-int run_custom_menu(void);
-int run_activities_menu(void);
-int run_options_menu(void);
-int run_lan_menu(void);
-int run_server_menu(void);
 int handle_easter_egg(const SDL_Event* evt);
 
 
@@ -280,8 +185,6 @@
     return;
   }
 
-  //TitleScreen_load_menu();
-
   /* load titlescreen images */
   if(RenderTitleScreen() == 0)
   {
@@ -367,19 +270,6 @@
 
   DEBUGMSG(debug_titlescreen, "TitleScreen(): Tux and Title are in place now\n");
 
-
-  /* Red "Stop" circle in upper right corner to go back to main menu: */
-  /* this is going to be part of the menu */
-  /*if (images[IMG_STOP])
-  {
-    stopRect.w = images[IMG_STOP]->w;
-    stopRect.h = images[IMG_STOP]->h;
-    stopRect.x = screen->w - images[IMG_STOP]->w;
-    stopRect.y = 0;
-    SDL_BlitSurface(images[IMG_STOP], NULL, screen, &stopRect);
-  }
-  SDL_UpdateRect(screen, 0, 0, 0, 0);*/
-
   /* Start playing menu music if desired: */
   if (Opts_GetGlobalOpt(MENU_MUSIC))
   {
@@ -387,20 +277,16 @@
   }
 
   /* If necessary, have the user log in */
-  //if (run_login_menu() != -1) {
   if (RunLoginMenu() != -1) {
     /* Finish parsing user options */
     initialize_options_user();
     /* Start the main menu */
-    //run_main_menu();
     RunMainMenu();
   }
 
   /* User has selected quit, clean up */
   DEBUGMSG(debug_titlescreen, "TitleScreen(): Freeing title screen images\n");
-
   free_titlescreen();
-  //TitleScreen_unload_menu();
 
   DEBUGMSG(debug_titlescreen, "leaving TitleScreen()\n");
 }
@@ -486,13 +372,6 @@
     beak.w = beak_pos[2] * tux_rect.w;
     beak.h = beak_pos[3] * tux_rect.h;
 
-
-    /* stop button - going to be part of the menu */
-    stopRect.x = screen->w - stopRect.w;
-    stopRect.y = 0;
-
-
-
     curr_res_x = screen->w;
     curr_res_y = screen->h;
 
@@ -556,42 +435,6 @@
 /***********************************************************/
 
 
-/* this is going to be moved to menu.c */
-int TitleScreen_load_menu(void)
-{
-  char fn[PATH_MAX];
-  int i;
-
-  sprite_list = (sprite**) malloc(N_SPRITES*sizeof(sprite*));
-  if (sprite_list == NULL)
-    return 0;
-
-  for (i = 0; i < N_SPRITES; i++) {
-    /* --- load animated icon for menu item --- */
-    sprintf(fn, "sprites/%s", menu_sprite_files[i]);
-    sprite_list[i] = LoadSprite(fn, IMG_ALPHA);
-  }
-  return 1;
-}
-
-
-void TitleScreen_unload_menu(void)
-{
-  int i;
-
-  for (i = 0; i < N_SPRITES; i++)
-  {
-    DEBUGMSG(debug_menu, "Freeing image %d: ", i);
-    FreeSprite(sprite_list[i]);
-    sprite_list[i] = NULL;
-  }
-  free(sprite_list);
-  DEBUGMSG(debug_menu, "Images freed\n");
-  sprite_list = NULL;
-}
-
-
-
 void free_titlescreen(void)
 {
   DEBUGMSG(debug_titlescreen, "Entering free_titlescreen()\n");
@@ -648,7 +491,6 @@
   SDL_Surface *s1, *s2, *s3, *s4;
   SDL_Rect loc;
   int finished = 0;
-  int tux_frame = 0;
   Uint32 frame = 0;
   Uint32 start = 0;
 
@@ -744,25 +586,8 @@
       }
     }
 
-    /* --- make tux blink --- */
-    switch (frame % TUX6)
-    {
-      case 0:    tux_frame = 1; break;
-      case TUX1: tux_frame = 2; break;
-      case TUX2: tux_frame = 3; break;
-      case TUX3: tux_frame = 4; break;
-      case TUX4: tux_frame = 3; break;
-      case TUX5: tux_frame = 2; break;
-      default: tux_frame = 0;
-    }
+    HandleTitleScreenAnimations();
 
-    if (Tux && tux_frame)
-    {
-      SDL_BlitSurface(Tux->frame[tux_frame - 1], NULL, screen, &tux_rect);
-//      SDL_UpdateRect(screen, tux_rect.x+37, tux_rect.y+40, 70, 45);
-      SDL_UpdateRect(screen, tux_rect.x, tux_rect.y, tux_rect.w, tux_rect.h);
-
-    }
     /* Wait so we keep frame rate constant: */
     while ((SDL_GetTicks() - start) < 33)
     {
@@ -777,1597 +602,6 @@
   SDL_FreeSurface(s4);
 }
 
-
-void main_scmo(menu_options* mo) //set custom menu opts for main
-{
-  mo->ygap = 15;
-}
-
-int run_main_menu(void)
-{
-  const char* menu_text[7] =
-    {N_("Play Alone"),
-     N_("LAN Game"),
-     N_("Play With Friends"),
-     N_("Factoroids!"),
-     N_("Help"),
-     N_("More Options"),
-     N_("Quit")};
-  sprite* sprites[7] =
-    {NULL, NULL, NULL, NULL, NULL, NULL,NULL};
-  menu_options menu_opts;
-  int choice,ret;
-
-  // Set up the sprites
-  sprites[0] = sprite_list[SPRITE_ALONE];
-  sprites[2] = sprite_list[SPRITE_FRIENDS];
-  sprites[3] = sprite_list[SPRITE_FACTOROIDS];
-  sprites[4] = sprite_list[SPRITE_HELP];
-  sprites[5] = sprite_list[SPRITE_OPTIONS];
-  sprites[6] = sprite_list[SPRITE_QUIT];
-  
-  //set_default_menu_options(&menu_opts);
-  //menu_opts.ytop = 100;
-  //menu_opts.ygap = 15;
-
-  //This function takes care of all the drawing and receives
-  //user input:
-  choice = choose_menu_item(menu_text,sprites,7,NULL,main_scmo);
-
-  while (choice >= 0) {
-    switch (choice) {
-      case 0: {
-        // All single player modes
-        ret = run_game_menu();
-        break;
-      }
-      case 1: {
-        ret = run_lan_menu();
-        break;
-      }
-      case 2: {
-        // Multiplayer games
-        ret = run_multiplay_menu();
-        break;
-      }
-      case 3: {
-        // Factroids et. al.
-        ret = run_activities_menu();
-        break;
-      }
-      case 4: {
-        // Help
-        Opts_SetHelpMode(1);
-        Opts_SetDemoMode(0);
-        if (Opts_GetGlobalOpt(MENU_MUSIC))  //Turn menu music off for game
-          {audioMusicUnload();}
-        game();
-        RenderTitleScreen();
-        if (Opts_GetGlobalOpt(MENU_MUSIC)) //Turn menu music back on
-          {audioMusicLoad( "tuxi.ogg", -1 );}
-        Opts_SetHelpMode(0);
-        break;
-      }
-      case 5: {
-        // More options
-        ret = run_options_menu();
-        break;
-      }
-      case 6: {
-        // Quit
-        DEBUGMSG(debug_titlescreen, "Exiting main menu\n");
-        return 0;
-      }    
-    }
-    menu_opts.starting_entry = choice;
-    choice = choose_menu_item(menu_text,sprites,7,NULL,main_scmo);
-  }
-  return 0;
-}
-                                                     
-#define NUM_GAME_MENU_ITEMS 5
-int run_game_menu(void)
-{
-  const char* menu_text[NUM_GAME_MENU_ITEMS] =
-    {N_("Math Command Training Academy"),
-     N_("Math Command Fleet Missions"),          
-     N_("Play Arcade Game"),
-     N_("Play Custom Game"),
-     N_("Main menu")};
-
-  sprite* sprites[NUM_GAME_MENU_ITEMS] = {NULL, NULL, NULL, NULL, NULL};
-
-  int ret, choice = 0;
-
-  sprites[0] = sprite_list[SPRITE_TRAINING];
-  sprites[1] = sprite_list[SPRITE_CAMPAIGN];
-  sprites[2] = sprite_list[SPRITE_ARCADE];
-  sprites[3] = sprite_list[SPRITE_CUSTOM];
-  sprites[4] = sprite_list[SPRITE_MAIN];
-
-  while (choice >= 0) {
-    choice = choose_menu_item(menu_text,sprites,NUM_GAME_MENU_ITEMS,NULL,NULL);
-    switch (choice) {
-      case 0:
-        ret = run_lessons_menu();
-        break;
-      case 1:
-        ret = start_campaign();
-        break;
-      case 2:
-        ret = run_arcade_menu();
-        break;
-      case 3:
-        ret = run_custom_menu();
-        break;
-      case 4:
-        return 0;
-      default:
-        DEBUGMSG(debug_titlescreen, "choose_menu_item() returned %d--returning\n", choice);
-        return 0;
-    }
-  }
-  return 0;
-}
-
-/*
-Set up and start a turn-based multiplayer game. Some funky heap issues so
-quarantine it behind the return for the time being.
-*/
-int run_multiplay_menu(void)
-{
-  int nplayers = 0;
-  int mode = -1;
-  int difficulty = -1;
-  char npstr[HIGH_SCORE_NAME_LENGTH * 3];
-
-  const char* menu_text[3] =
-    {N_("Score Sweep"),
-     N_("Elimination"),
-     N_("Main menu")};
-
-  //just leech settings from arcade modes
-  const char* diff_menu_text[NUM_MATH_COMMAND_LEVELS + 1] =
-    {N_("Space Cadet"),
-     N_("Scout"),
-     N_("Ranger"),
-     N_("Ace"),
-     N_("Commando"),
-     N_("Main menu")};
-
-
-  sprite* modesprites[3] = {NULL, NULL, NULL};
-  sprite* diffsprites[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
-  // Set up the sprites
-  modesprites[0] = sprite_list[SPRITE_SSWEEP];
-  modesprites[1] = sprite_list[SPRITE_ELIMINATION];
-  modesprites[2] = sprite_list[SPRITE_MAIN];
-  
-  diffsprites[0] = sprite_list[SPRITE_CADET];
-  diffsprites[1] = sprite_list[SPRITE_SCOUT];
-  diffsprites[2] = sprite_list[SPRITE_RANGER];
-  diffsprites[3] = sprite_list[SPRITE_ACE];
-  diffsprites[4] = sprite_list[SPRITE_COMMANDO];
-  diffsprites[5] = sprite_list[SPRITE_MAIN];
-
-  while (1)
-  {
-    //choose difficulty
-    difficulty = choose_menu_item(diff_menu_text, diffsprites, 
-                 NUM_MATH_COMMAND_LEVELS + 1, NULL, NULL);
-
-    if (difficulty == -1 || difficulty >= NUM_MATH_COMMAND_LEVELS)
-      break; //user chose main menu or hit escape
-
-    //choose mode
-    mode = choose_menu_item(menu_text,modesprites,3,NULL,NULL);
-    if (mode == 2 || mode == -1)
-      break;
-
-    //ask how many players
-    while (nplayers <= 0 || nplayers > MAX_PLAYERS)
-    {
-      NameEntry(npstr, _("How many kids are playing?"),
-                       _("(Between 2 and 4 players)"));
-      nplayers = atoi(npstr);
-    }
-
-
-    mp_set_parameter(PLAYERS, nplayers);
-    mp_set_parameter(MODE, mode);
-    mp_set_parameter(DIFFICULTY, difficulty);
-
-    //RUN!
-    mp_run_multiplayer();
-  }
-
-  return 0;
-}
-
-///////////////////////////   LAN game menu()////////////
-
-
-int run_lan_menu(void)
-{
-  int mode = -1;
-  char ipstr[HIGH_SCORE_NAME_LENGTH * 3];
-  
-  const char* menu_text[3] =
-    {N_("Host"),
-     N_("Join"),
-     N_("Main menu")};
-
-  sprite* modesprites[3] = {NULL, NULL, NULL};
-  // Set up the sprites
-  modesprites[0] = sprite_list[SPRITE_SERVER];
-  modesprites[1] = sprite_list[SPRITE_CLIENT];
-  modesprites[2] = sprite_list[SPRITE_MAIN];
-   while (1)
-  {
-    //choose mode
-    mode = choose_menu_item(menu_text,modesprites,3,NULL,NULL);
-    if (mode == 2 || mode == -1)
-      break;
-
-    if(mode == 0)                     //chooses Host
-    run_server_menu();
-    
-    if(mode == 1)
-    NameEntry(ipstr, _("Enter the IP Address"),
-                       _("(of the Host)"));
-      
-
-   }
-
-  return 0;
-
-}
-
-
-int run_server_menu(void)
-{
-
-  int difficulty = -1;
-  
-
-  //just leech settings from arcade modes
-  const char* diff_menu_text[NUM_MATH_COMMAND_LEVELS + 1] =
-    {N_("Space Cadet"),
-     N_("Scout"),
-     N_("Ranger"),
-     N_("Ace"),      
-     N_("Commando"),
-     N_("Main menu")};
- 
-  
-
-   sprite* diffsprites[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
-  
- 
-  diffsprites[0] = sprite_list[SPRITE_CADET];
-  diffsprites[1] = sprite_list[SPRITE_SCOUT];
-  diffsprites[2] = sprite_list[SPRITE_RANGER];
-  diffsprites[3] = sprite_list[SPRITE_ACE];
-  diffsprites[4] = sprite_list[SPRITE_COMMANDO];
-  diffsprites[5] = sprite_list[SPRITE_MAIN];
-
-     while (1)
-  {
-    //choose difficulty
-    difficulty = choose_menu_item(diff_menu_text,diffsprites,6,NULL,NULL);
-    break;
-   }
-   return 0;
-
-
-}
-
-
-
-
-int run_arcade_menu(void)
-{
-  const char* menu_text[7] =
-    {N_("Space Cadet"),
-     N_("Scout"),
-     N_("Ranger"),
-     N_("Ace"),
-     N_("Commando"),
-     N_("Hall Of Fame"),
-     N_("Main menu")};               
-  const char* arcade_config_files[5] =
-    {"arcade/space_cadet",
-     "arcade/scout",
-     "arcade/ranger",
-     "arcade/ace",
-     "arcade/commando"
-    };
-
-  const int arcade_high_score_tables[5] =
-    {CADET_HIGH_SCORE,
-     SCOUT_HIGH_SCORE,
-     RANGER_HIGH_SCORE,
-     ACE_HIGH_SCORE,
-     COMMANDO_HIGH_SCORE
-    };
-  sprite* sprites[7] =
-    {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
-  menu_options menu_opts;
-  int choice,hs_table;
-
-  // Set up the sprites
-  sprites[0] = sprite_list[SPRITE_CADET];
-  sprites[1] = sprite_list[SPRITE_SCOUT];
-  sprites[2] = sprite_list[SPRITE_RANGER];
-  sprites[3] = sprite_list[SPRITE_ACE];
-  sprites[4] = sprite_list[SPRITE_COMMANDO];
-  sprites[5] = sprite_list[SPRITE_TROPHY];
-  sprites[6] = sprite_list[SPRITE_MAIN];
-
-//  set_default_menu_options(&menu_opts);
-//  menu_opts.ytop = 100;
-
-  //This function takes care of all the drawing and receives
-  //user input:
-  choice = choose_menu_item(menu_text,sprites,7,NULL,NULL);
-
-  while (choice >= 0) {
-    if (choice < NUM_MATH_COMMAND_LEVELS) {
-      // Play arcade game
-      if (read_named_config_file(arcade_config_files[choice]))
-      {
-        audioMusicUnload();
-        game();
-        RenderTitleScreen();
-        if (Opts_GetGlobalOpt(MENU_MUSIC)) {
-          audioMusicLoad( "tuxi.ogg", -1 );
-        }
-        /* See if player made high score list!                        */
-        read_high_scores();  /* Update, in case other users have added to it */
-        hs_table = arcade_high_score_tables[choice];
-        if (check_score_place(hs_table, Opts_LastScore()) < HIGH_SCORES_SAVED){
-
-          char player_name[HIGH_SCORE_NAME_LENGTH * 3];
-
-          /* Get name from player: */
-          HighScoreNameEntry(&player_name[0]);
-          insert_score(player_name, hs_table, Opts_LastScore());
-          /* Show the high scores. Note the user will see his/her */
-          /* achievement even if (in the meantime) another player */
-          /* has in fact already bumped this score off the table. */
-          DisplayHighScores(hs_table);
-          /* save to disk: */
-          /* See "On File Locking" in fileops.c */
-          append_high_score(choice,Opts_LastScore(),&player_name[0]);
-
-          DEBUGCODE(debug_titlescreen)
-            print_high_scores(stderr);
-        }
-      } else {
-        fprintf(stderr, "\nCould not find %s config file\n",arcade_config_files[choice]);
-      }
-
-    } else if (choice == NUM_MATH_COMMAND_LEVELS) {
-      // Display the Hall of Fame
-      DisplayHighScores(CADET_HIGH_SCORE);
-    }
-    else {
-      // Return to main menu
-      return 0;
-    }
-    set_default_menu_options(&menu_opts);
-    menu_opts.starting_entry = choice;
-    choice = choose_menu_item(menu_text,sprites,7,NULL, NULL);
-  }
-
-  return 0;
-}
-
-
-int run_custom_menu(void)
-{
-  const char *s1, *s2, *s3, *s4;
-  s1 = _("Edit 'options' file in your home directory");
-  s2 = _("to create customized game!");
-  s3 = _("Press a key or click your mouse to start game.");
-  s4 = _("See README.txt for more information");
-  ShowMessage(s1, s2, s3, s4);
-
-  if (read_user_config_file()) {
-    if (Opts_GetGlobalOpt(MENU_MUSIC))
-      audioMusicUnload();
-
-    game();
-    RenderTitleScreen();
-    write_user_config_file();
-
-    if (Opts_GetGlobalOpt(MENU_MUSIC))
-      audioMusicLoad( "tuxi.ogg", -1 );
-  }
-
-  return 0;
-}
-
-int run_activities_menu(void)
-{ 
-  const char* menu_text[3] =
-    {N_("Factors"),
-     N_("Fractions"),
-     N_("Main menu")};
-  const int factoroids_high_score_tables[2] =
-    {FACTORS_HIGH_SCORE, FRACTIONS_HIGH_SCORE};
-  sprite* sprites[3] =
-    {NULL, NULL, NULL};
-  menu_options menu_opts;
-  int choice, hs_table;
-
-  // Set up the sprites
-  sprites[0] = sprite_list[SPRITE_FACTORS];
-  sprites[1] = sprite_list[SPRITE_FRACTIONS];
-  sprites[2] = sprite_list[SPRITE_MAIN];
-
-  set_default_menu_options(&menu_opts);
-  menu_opts.ytop = 100;
-
-  //This function takes care of all the drawing and receives
-  //user input:
-  choice = choose_menu_item(menu_text, sprites, 3, NULL, NULL);
-
-  while (choice >= 0) {
-    switch(choice){
-      case 0:
-          audioMusicUnload();
-          factors();
-	  
-	  if (Opts_GetGlobalOpt(MENU_MUSIC)) {
-	      audioMusicLoad( "tuxi.ogg", -1 );
-	  }
-	  break;
-      case 1:
-          audioMusicUnload(); 
-          fractions();
-	  
-	  if (Opts_GetGlobalOpt(MENU_MUSIC)) {
-	     audioMusicLoad( "tuxi.ogg", -1 );
-	  }
-	  break;
-     case 2:
-          // Return to main menu
-          return 0;
-    }
-
-	hs_table = factoroids_high_score_tables[choice];
-	if (check_score_place(hs_table, Opts_LastScore()) < HIGH_SCORES_SAVED){
-
-	  char player_name[HIGH_SCORE_NAME_LENGTH * 3];
-
-	  /* Get name from player: */
-	  HighScoreNameEntry(&player_name[0]);
-	  insert_score(player_name, hs_table, Opts_LastScore());
-	  /* Show the high scores. Note the user will see his/her */
-	  /* achievement even if (in the meantime) another player */
-	  /* has in fact already bumped this score off the table. */
-	  DisplayHighScores(hs_table);
-	  /* save to disk: */
-	  /* See "On File Locking" in fileops.c */
-	  append_high_score(hs_table,Opts_LastScore(),&player_name[0]);
-
-    DEBUGCODE(debug_titlescreen)
-	    print_high_scores(stderr);
-	}
-       else {
-	fprintf(stderr, "\nCould not find config file\n");
-      }  
-
-    menu_opts.starting_entry = choice;
-    choice = choose_menu_item(menu_text,sprites,3,NULL,NULL);
-
-
-  }
-
-
-  return 0; 
-}
-
-
-int run_options_menu(void)
-{
-  /*
-    // Use the following version if we get "Settings" implemented
-  const unsigned char* menu_text[5] =
-    {(const unsigned char*)N_("Settings"),
-     (const unsigned char*)N_("Demo"),
-     (const unsigned char*)N_("Credits"),
-     (const unsigned char*)N_("Project Info"),
-     (const unsigned char*)N_("Main Menu")};
-  sprite* sprites[5] =
-    {NULL, NULL, NULL, NULL, NULL};
-  */
-  const char* menu_text[4] =
-    {N_("Demo"),
-     N_("Project Info"),
-     N_("Credits"),
-     N_("Main Menu")};
-
-  sprite* sprites[4] =
-    {NULL, NULL, NULL, NULL};
-  int n_menu_entries = 4;
-  menu_options menu_opts;
-  int choice;
-
-  // Set up the sprites
-  sprites[0] = sprite_list[SPRITE_ARCADE];
-  sprites[1] = sprite_list[SPRITE_HELP];
-  sprites[2] = sprite_list[SPRITE_CREDITS];
-  sprites[3] = sprite_list[SPRITE_MAIN];
-
-  //set_default_menu_options(&menu_opts);
-  //menu_opts.ytop = 100;
-
-  //This function takes care of all the drawing and receives
-  //user input:
-  choice = choose_menu_item(menu_text, sprites, n_menu_entries, NULL, NULL);
-
-  while (choice >= 0) {
-    switch (choice) {
-      /*
-    case 0: {
-      // Settings
-      NotImplemented();
-      break;
-      }*/
-    case 0: {
-      // Demo
-      if (read_named_config_file("demo"))
-      {
-        audioMusicUnload();
-        game();
-        RenderTitleScreen();
-        if (Opts_GetGlobalOpt(MENU_MUSIC)) {
-          audioMusicLoad( "tuxi.ogg", -1 );
-        }
-      } else {
-        fprintf(stderr, "\nCould not find demo config file\n");
-      }
-
-      break;
-    }
-    case 1: {
-      // Project Info
-      //NotImplemented();
-      ShowMessage(_("TuxMath is free and open-source!"),
-                  _("You can help make it better by reporting problems,"),
-                  _("suggesting improvements, or adding code."),
-                  _("Discuss the future at tuxmath-devel at lists.sourceforge.net"));
-      break;
-    }
-    case 2: {
-      // Credits
-      //TitleScreen_unload_media();
-      credits();
-      //TitleScreen_load_media();
-      break;
-    }
-    case 3: {
-      // Main menu
-      return 0;
-    }
-    }
-
-    set_default_menu_options(&menu_opts);
-    menu_opts.starting_entry = choice;
-    choice = choose_menu_item(menu_text,sprites,n_menu_entries,NULL,NULL);
-  }
-
-  return 0;
-}
-
-
-void lessons_scmo(menu_options* mo)
-{
-mo->ytop = 30;
-}
-/* Display a list of tuxmath config files in the missions directory   */
-/* and allow the player to pick one (AKA "Lessons").                  */
-
-/* returns 0 if user pressed escape
- *         1 if config was set correctly
- */
-int run_lessons_menu(void)
-{
-  int chosen_lesson = -1;
-  menu_options menu_opts;
-  sprite** star_sprites = NULL;
-
-  /* Set up sprites (as long as gold star list is valid) */
-  if (lesson_list_goldstars != NULL)
-  {
-    int i;
-    star_sprites = (sprite**)malloc(num_lessons * sizeof(sprite*));
-    for (i = 0; i < num_lessons; i++)
-    {
-      if (lesson_list_goldstars[i])
-        star_sprites[i] = sprite_list[SPRITE_GOLDSTAR];
-      else
-        star_sprites[i] = sprite_list[SPRITE_NO_GOLDSTAR];
-    }
-  }
-//  set_default_menu_options(&menu_opts);
-//  ytop = 30;
-
-  //This function takes care of all the drawing and receives
-  //user input:
-  chosen_lesson = choose_menu_item((const char**)lesson_list_titles, star_sprites, num_lessons, NULL, &lessons_scmo);
-
-  while (chosen_lesson >= 0)
-  {
-    if (Opts_GetGlobalOpt(MENU_SOUND))
-      playsound(SND_POP);
-
-    /* Re-read global settings first in case any settings were */
-    /* clobbered by other lesson or arcade games this session: */
-    read_global_config_file();
-    /* Now read the selected file and play the "mission": */
-    if (read_named_config_file(lesson_list_filenames[chosen_lesson]))
-    {
-      if (Opts_GetGlobalOpt(MENU_MUSIC))  //Turn menu music off for game
-        {audioMusicUnload();}
-
-
-      game();
-      RenderTitleScreen();
-
-      /* If successful, display Gold Star for this lesson! */
-      if (MC_MissionAccomplished())
-      {
-        lesson_list_goldstars[chosen_lesson] = 1;
-        star_sprites[chosen_lesson] = sprite_list[SPRITE_GOLDSTAR];
-       /* and save to disk: */
-        write_goldstars();
-      }
-
-      if (Opts_GetGlobalOpt(MENU_MUSIC)) //Turn menu music back on
-        {audioMusicLoad("tuxi.ogg", -1);}
-    }
-    else  // Something went wrong - could not read lesson config file:
-    {
-      fprintf(stderr, "\nCould not find file: %s\n", lesson_list_filenames[chosen_lesson]);
-      chosen_lesson = -1;
-    }
-    // Let the user choose another lesson; start with the screen and
-    // selection that we ended with
-    set_default_menu_options(&menu_opts);
-    menu_opts.starting_entry = chosen_lesson;
-    chosen_lesson = choose_menu_item((const char**)lesson_list_titles, star_sprites, num_lessons, &menu_opts, &lessons_scmo);
-  }
-  if (star_sprites)
-  {
-    free(star_sprites);
-    star_sprites = NULL;
-  }
-
-  if (chosen_lesson < 0)
-    return 0;
-  else
-    return 1;
-}
-
-
-/* Sets the user home directory in a tree of possible users     */
-/* -1 indicates that the user wants to quit without logging in, */
-/* 0 indicates that a choice has been made.                     */
-int run_login_menu(void)
-{
-  int n_login_questions = 0;
-  char **user_login_questions = NULL;
-  int n_users = 0;
-  char **user_names = NULL;
-  menu_options menu_opts;
-  int chosen_login = -1;
-  int level;
-  int i;
-  char *trailer_quit = "Quit";
-  char *trailer_back = "Back";
-  SDLMod mod;
-
-  // Check for & read user_login_questions file
-  n_login_questions = read_user_login_questions(&user_login_questions);
-
-  // Check for & read user_menu_entries file
-  n_users = read_user_menu_entries(&user_names);
-
-  if (n_users == 0)
-    return 0;   // a quick exit, there's only one user
-
-  // Check for a highscores file
-  if (high_scores_found_in_user_dir())
-    set_high_score_path();
-
-  level = 0;
-  set_default_menu_options(&menu_opts);
-  if (n_login_questions > 0)
-    menu_opts.title = user_login_questions[0];
-  menu_opts.trailer = trailer_quit;
-
-  while (n_users) {
-    // Get the user choice
-    chosen_login = choose_menu_item((const char**)user_names, NULL, n_users, &menu_opts, NULL);
-    // Determine whether there were any modifier (CTRL) keys pressed
-    mod = SDL_GetModState();
-    if (chosen_login == -1 || chosen_login == n_users) {
-      // User pressed escape or selected Quit/Back, handle by quitting
-      // or going up a level
-      if (level == 0) {
-        // We are going to quit without logging in.
-        // Clean up memory (prob. not necessary, but prevents Valgrind errors!)
-        for (i = 0; i < n_login_questions; i++)
-          free(user_login_questions[i]);
-        free(user_login_questions);
-        for (i = 0; i < n_users; i++)
-          free(user_names[i]);
-        free(user_names);
-        return -1;
-      }
-      else {
-        // Go back up one level of the directory tree
-        user_data_dirname_up();
-        level--;
-        menu_opts.starting_entry = -1;
-      }
-    }
-    else {
-      // User chose an entry, set it up
-      user_data_dirname_down(user_names[chosen_login]);
-      level++;
-      menu_opts.starting_entry = 0;
-    }
-    // Check for a highscores file
-    if (high_scores_found_in_user_dir())
-      set_high_score_path();
-    // Free the entries from the previous menu
-    for (i = 0; i < n_users; i++)
-      free(user_names[i]);
-    free(user_names);
-    user_names = NULL;
-    // If the CTRL key was pressed, choose this as the identity, even
-    // if there is a lower level to the hierarchy
-    if (mod & KMOD_CTRL)
-      break;
-    // Set the title appropriately for the next menu
-    if (level < n_login_questions)
-      menu_opts.title = user_login_questions[level];
-    else
-      menu_opts.title = NULL;
-    if (level == 0)
-      menu_opts.trailer = trailer_quit;
-    else
-      menu_opts.trailer = trailer_back;
-    // Check to see if there are more choices to be made
-    n_users = read_user_menu_entries(&user_names);
-  }
-
-  // The user home directory is set, clean up remaining memory
-  for (i = 0; i < n_login_questions; i++)
-    free(user_login_questions[i]);
-  free(user_login_questions);
-
-  // Signal success
-  return 0;
-}
-
-
-/****************************************************************/
-/* choose_menu_item: menu navigation utility function           */
-/* (the function returns the index for the selected menu item)  */
-/* -1 indicates that the user pressed escape                    */
-/****************************************************************/
-int choose_menu_item(const char **menu_text, sprite **menu_sprites, int n_menu_entries, menu_options* custom_mo, void (*set_custom_menu_opts)(menu_options*) )
-{
-  // Pixel renderings of menu text choices
-  SDL_Surface **menu_item_unselected = NULL;
-  SDL_Surface **menu_item_selected = NULL;
-  // Display region for menu choices
-  SDL_Rect *menu_text_rect = NULL;
-  // Translucent mouse "buttons" around menu text
-  SDL_Rect *menu_button_rect = NULL;
-  // Menu sprite locations
-  SDL_Rect *menu_sprite_rect = NULL;
-
-  // The section of the background that the menu rects actually cover
-  SDL_Rect *back_text_rect = NULL,
-           *back_button_rect = NULL,
-           *back_sprite_rect = NULL;
-  SDL_Rect left_arrow_rect, right_arrow_rect;
-  SDL_Rect temp_rect; //temporary copy of a dest rect that may be written to by SDL_BlitSurface
-
-  menu_options menu_opts;
-
-  Uint32 frame_counter = 0;
-  Uint32 frame_start = 0;       //For keeping frame rate constant
-  Uint32 frame_now = 0;
-  int stop = 0;
-  int loc = 0;                  //The currently selected menu item
-  int old_loc = 1;
-  int loc_screen_start = 0;     //The number of the top entry on current screen
-  int old_loc_screen_start = 0;
-  int redraw = 0;
-  int n_entries_per_screen = 0;
-  int buttonheight = 0;
-  int i = 0;
-  int imod = 0;                 // i % n_entries_per_screen
-  int click_flag = 1;
-  int use_sprite = 0;
-  int warp_mouse = 0;
-  int title_offset = 0;
-  int have_trailer = 0;
-
-  DEBUGMSG(debug_menu, "Entering choose_menu_item():\n");
-
-  DEBUGMSG(debug_menu, "%d menu entries:\n", n_menu_entries);
-  DEBUGCODE(debug_menu)
-  {
-    for (i = 0; i < n_menu_entries; i++)
-      DEBUGMSG(debug_menu, "%s\n", menu_text[i]);
-  }
-
-  if (custom_mo == NULL)
-    set_default_menu_options(&menu_opts);
-  else
-    menu_opts = *custom_mo;
-  if (set_custom_menu_opts != NULL)
-    set_custom_menu_opts(&menu_opts);
-
-  DEBUGMSG(debug_menu, "Allocating memory\n");
-  /**** Memory allocation for menu text  ****/
-  title_offset = 0;
-  if (menu_opts.title != NULL)
-    title_offset = 1;
-  if (menu_opts.trailer != NULL)
-    have_trailer = 1;
-  menu_item_unselected = (SDL_Surface**)malloc((n_menu_entries+title_offset+have_trailer) * sizeof(SDL_Surface*));
-  menu_item_selected = (SDL_Surface**)malloc((n_menu_entries+title_offset+have_trailer) * sizeof(SDL_Surface*));
-  if (menu_item_unselected == NULL || menu_item_selected == NULL) {
-    free(menu_item_unselected);
-    free(menu_item_selected);
-    return -2;  // error
-  }
-
-  /**** Render the menu choices                               ****/
-  if (title_offset)
-  {
-    menu_item_unselected[0] = BlackOutline( _(menu_opts.title), DEFAULT_MENU_FONT_SIZE, &red);
-    // It will never be selected, so we don't have to do anything for selected.
-    menu_item_selected[0] = NULL;
-  }
-  for (i = 0; i < n_menu_entries; i++)
-  {
-    menu_item_unselected[i+title_offset] = BlackOutline( _(menu_text[i]), DEFAULT_MENU_FONT_SIZE, &white );
-    menu_item_selected[i+title_offset] = BlackOutline( _(menu_text[i]), DEFAULT_MENU_FONT_SIZE, &yellow);
-  }
-  if (have_trailer) {
-    menu_item_unselected[n_menu_entries+title_offset] = BlackOutline( _(menu_opts.trailer), DEFAULT_MENU_FONT_SIZE, &white );
-    menu_item_selected[n_menu_entries+title_offset] = BlackOutline( _(menu_opts.trailer), DEFAULT_MENU_FONT_SIZE, &yellow);
-  }
-  // We won't need the menu_text again, so now we can keep track of
-  // the total entries including the title & trailer
-  n_menu_entries += title_offset+have_trailer;
-
-//  recalcMenuPositions();
-
-  /**** Calculate the menu item heights and the number of     ****/
-  /**** entries per screen                                    ****/
-  if (menu_opts.buttonheight <= 0) {
-    buttonheight = 0;
-    for (i = 0; i < n_menu_entries; i++)
-      if (buttonheight < menu_item_unselected[i]->h)
-        buttonheight = menu_item_unselected[i]->h;
-    buttonheight += 10;
-  } else
-    buttonheight = menu_opts.buttonheight;
-
-  // First try using the whole screen; if we need more than one
-  // screen, then we have to save space for the arrows by respecting
-  // ybottom
-  n_entries_per_screen = (int) (screen->h - menu_opts.ytop+menu_opts.ygap)/(buttonheight + menu_opts.ygap);
-  if (n_entries_per_screen < n_menu_entries)
-    n_entries_per_screen = (int) (menu_opts.ybottom - menu_opts.ytop+menu_opts.ygap)/(buttonheight + menu_opts.ygap);
-
-  if (n_entries_per_screen > n_menu_entries)
-    n_entries_per_screen = n_menu_entries;
-
-  /**** Memory allocation for current screen rects  ****/
-  menu_text_rect = (SDL_Rect*) malloc(n_entries_per_screen * sizeof(SDL_Rect));
-  menu_button_rect = (SDL_Rect*) malloc(n_entries_per_screen * sizeof(SDL_Rect));
-  back_text_rect = (SDL_Rect*) malloc(n_entries_per_screen * sizeof(SDL_Rect));
-  back_button_rect = (SDL_Rect*) malloc(n_entries_per_screen * sizeof(SDL_Rect));
-  if (menu_text_rect == NULL || menu_button_rect == NULL ||
-      back_text_rect == NULL || back_button_rect == NULL) {
-    free(menu_text_rect);
-    free(menu_button_rect);
-    free(back_text_rect);
-    free(back_button_rect);
-    return -2;
-  }
-  if (menu_sprites != NULL) {
-    menu_sprite_rect = (SDL_Rect*) malloc(n_entries_per_screen * sizeof(SDL_Rect));
-    back_sprite_rect = (SDL_Rect*) malloc(n_entries_per_screen * sizeof(SDL_Rect));
-    if (menu_sprite_rect == NULL || back_sprite_rect == NULL) {
-      free(menu_sprite_rect);
-      free(back_sprite_rect);
-      return -2;
-    }
-  }
-
-  /**** Define the locations of graphical elements on the screen ****/
-  /* Arrow buttons in right lower corner, inset by 20 pixels     */
-  /* with a 10 pixel space between:                              */
-  if (images[IMG_RIGHT])
-  {
-    right_arrow_rect.w = images[IMG_RIGHT]->w;
-    right_arrow_rect.h = images[IMG_RIGHT]->h;
-    right_arrow_rect.x = screen->w - images[IMG_RIGHT]->w - 20;
-    right_arrow_rect.y = screen->h - images[IMG_RIGHT]->h - 20;
-  }
-
-  if (images[IMG_LEFT])
-  {
-    left_arrow_rect.w = images[IMG_LEFT]->w;
-    left_arrow_rect.h = images[IMG_LEFT]->h;
-    left_arrow_rect.x = right_arrow_rect.x - 10 - images[IMG_LEFT]->w;
-    left_arrow_rect.y = screen->h - images[IMG_LEFT]->h - 20;
-  }
-  /* Red "Stop" circle in upper right corner to go back to main menu: */
-  if (images[IMG_STOP])
-  {
-    stopRect.w = images[IMG_STOP]->w;
-    stopRect.h = images[IMG_STOP]->h;
-    stopRect.x = screen->w - images[IMG_STOP]->w;
-    stopRect.y = 0;
-  }
-
-  /* Set initial menu rect sizes. The widths will change depending      */
-  /* on the size of the text displayed in each rect.  Set the widths    */
-  /* for the current screen of menu items.                              */
-  loc = menu_opts.starting_entry + title_offset;  // Initially selected item
-  loc_screen_start = loc - (loc % n_entries_per_screen);
-  if (loc_screen_start < 0 || loc_screen_start*n_entries_per_screen > n_menu_entries)
-    loc_screen_start = 0;  // in case starting_entry was -1 (or wasn't set)
-  imod = loc-loc_screen_start;
-  for (i = 0; i < n_entries_per_screen; i++)
-  {
-    menu_button_rect[i].x = menu_opts.xleft;
-    menu_text_rect[i].x = menu_opts.xleft + 15;  // 15 is left gap
-    if (menu_sprites != NULL)
-      menu_text_rect[i].x += 60;  // 40 is sprite width, 20 is gap
-    if (i > 0)
-      menu_text_rect[i].y = menu_text_rect[i - 1].y + buttonheight + menu_opts.ygap;
-    else
-      menu_text_rect[i].y = menu_opts.ytop;
-    menu_button_rect[i].y = menu_text_rect[i].y-5;
-    menu_text_rect[i].h = buttonheight-10;
-    menu_button_rect[i].h = buttonheight;
-    menu_button_rect[i].w = menu_text_rect[i].w = 0;
-    if (i + loc_screen_start < n_menu_entries) {
-      menu_text_rect[i].w = menu_item_unselected[i+loc_screen_start]->w;
-      menu_button_rect[i].w = menu_text_rect[i].w + 30;
-    }
-    if (menu_sprite_rect != NULL) {
-      menu_sprite_rect[i].x = menu_button_rect[i].x+3;
-      menu_sprite_rect[i].y = menu_button_rect[i].y+3;
-      menu_sprite_rect[i].w = 40;
-      menu_sprite_rect[i].h = 50;
-    }
-  }
-
-  if (menu_opts.button_same_width)
-    set_buttons_max_width(menu_button_rect,back_button_rect,n_entries_per_screen);
-
-  for (i = 0; i < n_entries_per_screen; ++i)
-  {
-    if (menu_button_rect)
-    {
-      back_button_rect[i] = menu_button_rect[i];
-      back_button_rect[i].x -= bkg_rect.x;
-      back_button_rect[i].y -= bkg_rect.y;
-    }
-    if (menu_text_rect)
-    {
-      back_text_rect[i] = menu_text_rect[i];
-      back_text_rect[i].x -= bkg_rect.x;
-      back_text_rect[i].y -= bkg_rect.y;
-    }
-    if (menu_sprite_rect)
-    {
-      back_sprite_rect[i] = menu_sprite_rect[i];
-      back_sprite_rect[i].x -= bkg_rect.x;
-      back_sprite_rect[i].y -= bkg_rect.y;
-    }
-  }
-
-  /**** Draw background, title, and Tux:                            ****/
-  if (current_bkg() )
-    SDL_BlitSurface(current_bkg(), NULL, screen, &bkg_rect);
-  if (images[IMG_MENU_TITLE])
-    SDL_BlitSurface(images[IMG_MENU_TITLE], NULL, screen, &title_rect);
-  if (Tux && Tux->frame[0])
-    SDL_BlitSurface(Tux->frame[0], NULL, screen, &tux_rect);
-  SDL_UpdateRect(screen, 0, 0, 0 ,0);
-
-  /* Move mouse to current button: */
-  cursor.x = menu_button_rect[imod].x + menu_button_rect[imod].w/2;
-  cursor.y = menu_button_rect[imod].y + menu_button_rect[imod].h/2;
-//  SDL_WarpMouse(cursor.x, cursor.y);
-  SDL_WM_GrabInput(SDL_GRAB_OFF);
-
-
-  /******** Main loop:                                *********/
-  redraw = 1;  // force a full redraw on first pass
-  old_loc_screen_start = loc_screen_start;
-  while (SDL_PollEvent(&event));  // clear pending events
-  while (!stop)
-  {
-    frame_start = SDL_GetTicks();         /* For keeping frame rate constant.*/
-
-    while (SDL_PollEvent(&event))
-    {
-      switch (event.type)
-      {
-        case SDL_QUIT:
-        {
-          cleanup();
-          //exit(0);
-          break;
-        }
-
-        case SDL_MOUSEMOTION:
-        {
-          loc = -1;  // By default, don't be in any entry
-          for (i = 0; (i < n_entries_per_screen) && (loc_screen_start + i < n_menu_entries); i++)
-          {
-            if (inRect(menu_button_rect[i], event.motion.x, event.motion.y))
-            {
-              // Play sound if loc is being changed:
-              if (Opts_GetGlobalOpt(MENU_SOUND) && (old_loc != loc_screen_start + i))
-              {
-                playsound(SND_TOCK);
-              }
-              loc = loc_screen_start + i;
-              break;   /* from for loop */
-            }
-          }
-
-          /* "Left" button - make click if button active: */
-          if (inRect(left_arrow_rect, event.motion.x, event.motion.y))
-          {
-            if (loc_screen_start - n_entries_per_screen >= 0)
-            {
-              if (Opts_GetGlobalOpt(MENU_SOUND) && click_flag)
-              {
-                playsound(SND_TOCK);
-                click_flag = 0;
-              }
-            }
-            break;  /* from case switch */
-          }
-
-          /* "Right" button - go to next page: */
-          else if (inRect(right_arrow_rect, event.motion.x, event.motion.y ))
-          {
-            if (loc_screen_start + n_entries_per_screen < n_menu_entries)
-            {
-              if (Opts_GetGlobalOpt(MENU_SOUND) && click_flag)
-              {
-                playsound(SND_TOCK);
-                click_flag = 0;
-              }
-            }
-            break;  /* from case switch */
-          }
-
-          else  // Mouse outside of arrow rects - re-enable click sound:
-          {
-            click_flag = 1;
-            break;  /* from case switch */
-          }
-        }
-
-        case SDL_MOUSEBUTTONDOWN:
-        {
-          /* Choose a menu entry by mouse click */
-          for (i = 0; (i < n_entries_per_screen) && (loc_screen_start + i < n_menu_entries); i++)
-          {
-            if (inRect(menu_button_rect[i], event.button.x, event.button.y))
-            {
-              if (Opts_GetGlobalOpt(MENU_SOUND))
-              {
-                playsound(SND_POP);
-              }
-
-              loc = loc_screen_start + i;
-              stop = 1;
-              break;
-            }
-          }
-
-          /* "Left" button - go to previous page: */
-          if (inRect(left_arrow_rect, event.button.x, event.button.y))
-          {
-            if (loc_screen_start - n_entries_per_screen >= 0)
-            {
-              //loc = loc_screen_start - n_entries_per_screen;
-              loc_screen_start -= n_entries_per_screen;
-              loc = -1;  // nothing selected
-              if (Opts_GetGlobalOpt(MENU_SOUND))
-              {
-                playsound(SND_TOCK);
-              }
-              break;
-            }
-          }
-
-          /* "Right" button - go to next page: */
-          if (inRect( right_arrow_rect, event.button.x, event.button.y ))
-          {
-            if (loc_screen_start + n_entries_per_screen < n_menu_entries)
-            {
-              //loc = loc_screen_start + n_entries_per_screen;
-              loc_screen_start += n_entries_per_screen;
-              loc = -1;  // nothing selected
-              if (Opts_GetGlobalOpt(MENU_SOUND))
-              {
-                playsound(SND_TOCK);
-              }
-              break;
-            }
-          }
-
-          /* "Stop" button - go to main menu: */
-          if (inRect(stopRect, event.button.x, event.button.y ))
-          {
-            stop = 2;
-            playsound(SND_TOCK);
-            break;
-          }
-        } /* End of case SDL_MOUSEDOWN */
-
-
-        case SDL_KEYDOWN:
-        {
-          /* Proceed according to particular key pressed: */
-          switch (event.key.keysym.sym)
-          {
-            case SDLK_ESCAPE:
-            {
-              stop = 2;
-              break;
-            }
-
-            case SDLK_RETURN:
-            case SDLK_SPACE:
-            case SDLK_KP_ENTER:
-            {
-              if (Opts_GetGlobalOpt(MENU_SOUND))
-                playsound(SND_POP);
-              stop = 1;
-              break;
-            }
-
-
-            /* Go to previous page, if present: */
-            case SDLK_LEFT:
-            case SDLK_PAGEUP:
-            {
-              if (Opts_GetGlobalOpt(MENU_SOUND))
-                playsound(SND_TOCK);
-              if (loc_screen_start - n_entries_per_screen >= 0) {
-                loc_screen_start -= n_entries_per_screen;
-                loc = -1;
-              }
-              //  {loc = loc_screen_start - n_entries_per_screen;}
-              break;
-            }
-
-
-            /* Go to next page, if present: */
-            case SDLK_RIGHT:
-            case SDLK_PAGEDOWN:
-            {
-              if (Opts_GetGlobalOpt(MENU_SOUND))
-                playsound(SND_TOCK);
-              if (loc_screen_start + n_entries_per_screen < n_menu_entries) {
-                loc_screen_start += n_entries_per_screen;
-                loc = -1;
-              }
-              //  {loc = (loc_screen_start + n_entries_per_screen);}
-              break;
-            }
-
-            /* Go up one entry, if present: */
-            case SDLK_UP:
-            {
-              if (Opts_GetGlobalOpt(MENU_SOUND))
-                playsound(SND_TOCK);
-              if (loc > title_offset)
-                {loc--;}
-              else if (n_menu_entries <= n_entries_per_screen) {
-                loc = n_menu_entries-1;  // wrap around if only 1 screen
-              }
-              else if (loc == -1 && loc_screen_start > 0) {
-                loc = loc_screen_start-1;
-                loc_screen_start -= n_entries_per_screen;
-              }
-              if (loc != old_loc)
-                warp_mouse = 1;
-              break;
-            }
-
-
-            /* Go down one entry, if present: */
-            case SDLK_DOWN:
-            {
-              if (Opts_GetGlobalOpt(MENU_SOUND))
-                playsound(SND_TOCK);
-              if (loc >= 0 && loc + 1 < n_menu_entries)
-                {loc++;}
-              else if (n_menu_entries <= n_entries_per_screen)
-                loc = title_offset;       // wrap around if only 1 screen
-              else if (loc == -1)
-                loc = loc_screen_start;
-              if (loc != old_loc)
-                warp_mouse = 1;
-              break;
-            }
-
-            /* Change window size (used only to debug) */
-            case SDLK_F5:
-            case SDLK_F6:
-            case SDLK_F7:
-            case SDLK_F8:
-            {
-              /* these keys are available only if in debug mode */
-              DEBUGCODE(debug_titlescreen | debug_menu)
-              {
-                switch(event.key.keysym.sym)
-                {
-                  case SDLK_F5:
-                  {
-                    /* decrease screen width */
-                    ChangeWindowSize(win_res_x - 50, win_res_y);
-                    break;
-                  }
-                  case SDLK_F6:
-                  {
-                    /* increase screen width */
-                    ChangeWindowSize(win_res_x + 50, win_res_y);
-                    break;
-                  }
-                  case SDLK_F7:
-                  {
-                    /* decrease screen height */
-                    ChangeWindowSize(win_res_x, win_res_y - 50);
-                    break;
-                  }
-                  case SDLK_F8:
-                  {
-                    /* increase screen height */
-                    ChangeWindowSize(win_res_x, win_res_y + 50);
-                    break;
-                  }
-                  default:
-                    break;
-                }
-
-                RenderTitleScreen();
-                RecalcMenuPositions(&n_entries_per_screen,
-                                    n_menu_entries,
-                                    &menu_opts,
-                                    set_custom_menu_opts,
-                                    &menu_button_rect,
-                                    &menu_sprite_rect,
-                                    &menu_text_rect,
-                                    &back_button_rect,
-                                    &back_sprite_rect,
-                                    &back_text_rect,
-                                    &left_arrow_rect,
-                                    &right_arrow_rect);
-                //we're unsure how the entries might shuffle, so return to start
-                loc_screen_start = 0;
-                redraw = 1;
-              }
-              break;
-            }
-
-
-            /* Toggle screen mode: */
-            case SDLK_F10:
-            {
-              SwitchScreenMode();
-              RenderTitleScreen();
-              RecalcMenuPositions(&n_entries_per_screen,
-                                  n_menu_entries,
-                                  &menu_opts,
-                                  set_custom_menu_opts,
-                                  &menu_button_rect,
-                                  &menu_sprite_rect,
-                                  &menu_text_rect,
-                                  &back_button_rect,
-                                  &back_sprite_rect,
-                                  &back_text_rect,
-                                  &left_arrow_rect,
-                                  &right_arrow_rect);
-              //we're unsure how the entries might shuffle, so return to start
-              loc_screen_start = 0;
-              redraw = 1;
-              break;
-            }
-
-            /* Toggle menu music: */
-            case SDLK_F11:
-            {
-              if (Opts_GetGlobalOpt(MENU_MUSIC))
-              {
-                audioMusicUnload( );
-                Opts_SetGlobalOpt(MENU_MUSIC, 0);
-              }
-              else
-              {
-                Opts_SetGlobalOpt(MENU_MUSIC, 1);
-                audioMusicLoad("tuxi.ogg", -1);
-              }
-              break;
-            }
-#ifdef TESTING_CAMPAIGN
-            case SDLK_c:
-            {
-              start_campaign();
-              RenderTitleScreen();
-              RecalcMenuPositions(&n_entries_per_screen,
-                                  n_menu_entries,
-                                  &menu_opts,
-                                  set_custom_menu_opts,
-                                  &menu_button_rect,
-                                  &menu_sprite_rect,
-                                  &menu_text_rect,
-                                  &back_button_rect,
-                                  &back_sprite_rect,
-                                  &back_text_rect,
-                                  &left_arrow_rect,
-                                  &right_arrow_rect);
-              redraw = 1;
-            }
-
-#endif
-            default:
-            {
-              /* Some other key - do nothing. */
-            }
-
-            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
-
-      if(HandleTitleScreenEvents(&event))
-        redraw = 1;
-    }  // End SDL_PollEvent while loop
-
-
-
-    // Make sure the menu title is not selected
-    if (loc == 0 && title_offset)
-      loc = title_offset;
-
-    /* Redraw screen: */
-    if (loc >= 0)
-      loc_screen_start = loc - (loc % n_entries_per_screen);
-    if (old_loc_screen_start != loc_screen_start)
-      redraw = 1;
-    if (redraw)
-    {
-      DEBUGMSG(debug_menu, "Updating entire screen\n");
-      /* This is a full-screen redraw */
-      /* Redraw background, title, stop button, and Tux: */
-      if (!current_bkg() || screen->flags & SDL_FULLSCREEN )
-        SDL_FillRect(screen, &screen->clip_rect, 0); //clear to black
-      if (current_bkg())
-        SDL_BlitSurface(current_bkg(), NULL, screen, &bkg_rect);
-      if (images[IMG_MENU_TITLE])
-        SDL_BlitSurface(images[IMG_MENU_TITLE], NULL, screen, &title_rect);
-      if (images[IMG_STOP])
-        SDL_BlitSurface(images[IMG_STOP], NULL, screen, &stopRect);
-      if (Tux->frame[0])
-        SDL_BlitSurface(Tux->frame[0], NULL, screen, &tux_rect);
-      /* Redraw the menu entries */
-      for (imod = 0; imod < n_entries_per_screen; imod++)
-        menu_button_rect[imod].w = 0;  // so undrawn buttons don't affect width
-      for (i = loc_screen_start, imod = 0; i < loc_screen_start+n_entries_per_screen && i < n_menu_entries; i++, imod++) {
-        menu_text_rect[imod].w = menu_item_unselected[i]->w;
-        if (i >= title_offset) {
-          menu_button_rect[imod].w = menu_text_rect[imod].w + 30;
-          if (menu_sprites != NULL)
-            menu_button_rect[imod].w += 60;
-        }
-      }
-
-      if (menu_opts.button_same_width)
-        set_buttons_max_width(menu_button_rect,back_button_rect,n_entries_per_screen);
-      // Make sure the menu title mouse button didn't get turned on
-      if (loc_screen_start == 0 && title_offset)
-        menu_button_rect[0].w = 0;
-      for (i = loc_screen_start, imod = 0; i < loc_screen_start+n_entries_per_screen && i < n_menu_entries; i++, imod++) {
-        if (i == loc) {  //Draw text in yellow
-          DrawButton(&menu_button_rect[imod], 10, SEL_RGBA);
-          SDL_BlitSurface(menu_item_selected[loc], NULL, screen, &menu_text_rect[imod]);
-        }
-        else {          //Draw text in white
-          if (menu_button_rect[imod].w > 0)
-            DrawButton(&menu_button_rect[imod], 10, REG_RGBA);
-          SDL_BlitSurface(menu_item_unselected[i], NULL, screen, &menu_text_rect[imod]);
-        }
-        if (menu_sprites != NULL && (i >= title_offset) && menu_sprites[i-title_offset] != NULL)
-          SDL_BlitSurface(menu_sprites[i-title_offset]->default_img, NULL, screen, &menu_sprite_rect[imod]);
-      }
-
-      /* --- draw 'left' and 'right' buttons --- */
-      if (n_menu_entries > n_entries_per_screen) {
-        if (loc_screen_start > 0)        // i.e. not on first page
-        {
-            SDL_BlitSurface(images[IMG_LEFT], NULL, screen, &left_arrow_rect);
-        }
-        else  /* Draw grayed-out left button: */
-        {
-          SDL_BlitSurface(images[IMG_LEFT_GRAY], NULL, screen, &left_arrow_rect);
-        }
-
-        if (loc_screen_start + n_entries_per_screen < n_menu_entries)  // not on last page
-        {
-          SDL_BlitSurface(images[IMG_RIGHT], NULL, screen, &right_arrow_rect);
-        }
-        else  /* Draw grayed-out right button: */
-        {
-          SDL_BlitSurface(images[IMG_RIGHT_GRAY], NULL, screen, &right_arrow_rect);
-        }
-      }
-
-      SDL_Flip(screen);//SDL_UpdateRect(screen, 0, 0, 0 ,0);
-    } else if (old_loc != loc) {
-      // This is not a full redraw, but the selected entry did change.
-      // By just redrawing the old and new selections, we avoid flickering.
-      if (old_loc >= 0) {
-        imod = old_loc-loc_screen_start;
-        use_sprite = (menu_sprites != NULL && old_loc >= title_offset && menu_sprites[old_loc-title_offset] != NULL);
-        temp_rect = menu_button_rect[imod];
-        SDL_FillRect(screen, &temp_rect, 0);
-        SDL_BlitSurface(current_bkg(), &back_button_rect[imod], screen, &temp_rect);   // redraw background
-        if (use_sprite) {
-          // Some of the sprites extend beyond the menu button, so we
-          // have to make sure we redraw in the sprite rects, too
-          SDL_BlitSurface(current_bkg(), &back_sprite_rect[imod], screen, &temp_rect);
-        }
-        DrawButton(&menu_button_rect[imod], 10, REG_RGBA);  // draw button
-        //temp_rect = menu_text_rect[imod];
-        SDL_BlitSurface(menu_item_unselected[old_loc], NULL, screen, &menu_text_rect[imod]);  // draw text
-        if (use_sprite) {
-          temp_rect = menu_sprite_rect[imod];
-          DEBUGMSG(debug_menu, "Sprite %d at (%d %d)\n",  imod, temp_rect.x, temp_rect.y);
-          SDL_BlitSurface(menu_sprites[old_loc-title_offset]->default_img, NULL, screen, &temp_rect);
-          // Also update the sprite rect (in some cases the sprite
-          // extends beyond the menu button)
-          SDL_UpdateRect(screen, menu_sprite_rect[imod].x, menu_sprite_rect[imod].y, menu_sprite_rect[imod].w, menu_sprite_rect[imod].h);
-        }
-        SDL_UpdateRect(screen, menu_button_rect[imod].x, menu_button_rect[imod].y, menu_button_rect[imod].w, menu_button_rect[imod].h);
-      }
-      if (loc >= 0) {
-        imod = loc-loc_screen_start;
-        use_sprite = (menu_sprites != NULL && loc >= title_offset && menu_sprites[loc] != NULL);
-        temp_rect = menu_button_rect[imod];
-        SDL_BlitSurface(current_bkg(), &(back_button_rect[imod]), screen, &temp_rect);
-        if (use_sprite)
-        {
-          temp_rect = menu_sprite_rect[imod];
-          SDL_BlitSurface(current_bkg(), &(back_sprite_rect[imod]), screen, &temp_rect);
-        }
-        DrawButton(&menu_button_rect[imod], 10, SEL_RGBA);
-        SDL_BlitSurface(menu_item_selected[loc], NULL, screen, &menu_text_rect[imod]);
-        if (use_sprite) {
-          menu_sprites[loc-title_offset]->cur = 0;  // start at beginning of animation sequence
-          SDL_BlitSurface(menu_sprites[loc-title_offset]->frame[menu_sprites[loc-title_offset]->cur], NULL, screen, &menu_sprite_rect[imod]);
-          SDL_UpdateRect(screen, menu_sprite_rect[imod].x, menu_sprite_rect[imod].y, menu_sprite_rect[imod].w, menu_sprite_rect[imod].h);
-          NextFrame(menu_sprites[loc-title_offset]);
-        }
-        SDL_UpdateRect(screen, menu_button_rect[imod].x, menu_button_rect[imod].y, menu_button_rect[imod].w, menu_button_rect[imod].h);
-        DEBUGMSG(debug_menu, "Updating rect: %d %d %d %d\n", menu_button_rect[imod].x, menu_button_rect[imod].y, menu_button_rect[imod].w, menu_button_rect[imod].h);
-      }
-    } else if (frame_counter % 5 == 0 && loc >= 0) {
-      // No user input changed anything, but check to see if we need to
-      // animate the sprite
-      if (menu_sprites != NULL && loc >= title_offset && menu_sprites[loc-title_offset] != NULL) {
-        imod = loc-loc_screen_start;
-        //SDL_BlitSurface(current_bkg, &menu_button_rect[imod], screen, &menu_button_rect[imod]);
-        temp_rect = menu_sprite_rect[imod];
-        SDL_BlitSurface(current_bkg(), &back_sprite_rect[imod], screen, &temp_rect);
-        DrawButton(&menu_button_rect[imod], 10, SEL_RGBA);
-        //SDL_BlitSurface(menu_item_selected[loc], NULL, screen, &menu_text_rect[imod]);
-        // Note: even though the whole button was redrawn, we don't
-        // have to redraw the text & background as long as we don't
-        // update that rect. If something else changes and we go to
-        // full-screen updates, then remove the "commenting-out" on
-        // the two lines above
-        SDL_BlitSurface(menu_sprites[loc-title_offset]->frame[menu_sprites[loc-title_offset]->cur], NULL, screen, &menu_sprite_rect[imod]);
-        SDL_UpdateRect(screen, menu_sprite_rect[imod].x, menu_sprite_rect[imod].y, menu_sprite_rect[imod].w, menu_sprite_rect[imod].h);
-        NextFrame(menu_sprites[loc-title_offset]);
-      }
-    }
-
-    redraw = 0;
-
-    /* Move the mouse pointer if there is only a single screen */
-    if (warp_mouse && n_menu_entries <= n_entries_per_screen) {
-      imod = loc - loc_screen_start;
-      cursor.x = menu_button_rect[imod].x + (menu_button_rect[imod].w / 2);
-      cursor.y = menu_button_rect[imod].y + (3 * menu_button_rect[imod].h / 4);
-//      SDL_WarpMouse(cursor.x, cursor.y);
-      warp_mouse = 0;
-    }
-
-    old_loc = loc;
-    old_loc_screen_start = loc_screen_start;
-
-    HandleTitleScreenAnimations();
-
-    /* Wait so we keep frame rate constant: */
-    frame_now = SDL_GetTicks();
-    if (frame_now < frame_start)
-      frame_start = frame_now;  // in case the timer wraps around
-    if (frame_now - frame_start < 33)
-      SDL_Delay(33-(frame_now-frame_start));
-
-    frame_counter++;
-  }  // End !stop while loop
-
-
-  /***** User made a choice, clean up and return the choice.   ******/
-
-  /* --- clear graphics before leaving function --- */
-  for (i = 0; i < n_menu_entries; i++)
-  {
-    SDL_FreeSurface(menu_item_unselected[i]);
-    SDL_FreeSurface(menu_item_selected[i]);
-  }
-  free(menu_item_unselected);
-  free(menu_item_selected);
-  free(menu_text_rect);
-  free(menu_button_rect);
-  free(back_text_rect);
-  free(back_button_rect);
-  free(menu_sprite_rect);
-  free(back_sprite_rect);
-
-  /* Return the value of the chosen item (-1 indicates escape) */
-  if (stop == 2)
-    return -1;
-  else
-    return loc - title_offset;
-}
-
-
-
-void set_buttons_max_width(SDL_Rect *menu_button_rect,
-                           SDL_Rect *back_button_rect, int n)
-{
-  int i,max;
-
-  max = 0;
-  for (i = 0; i < n; i++)
-    if (max < menu_button_rect[i].w)
-      max = menu_button_rect[i].w;
-
-  for (i = 0; i < n; i++)
-    menu_button_rect[i].w = back_button_rect[i].w = max;
-
-  DEBUGMSG(debug_menu, "All buttons at width %d\n", max);
-}
-
 /* Was in playgame.c in tuxtype: */
 
 /* trans_wipe: Performs various wipes to new bkgs
@@ -2616,151 +850,6 @@
   update->type = 'I';
 }
 
-
-
-
-void set_default_menu_options(menu_options *menu_opts)
-{
-  menu_opts->starting_entry = 0;
-  menu_opts->xleft = screen->w / 2 - screen->w * 3 / 32;
-  menu_opts->ytop = screen->h / 2 - 140;
-  // Leave room for arrows at the bottom:
-  menu_opts->ybottom = screen->h - images[IMG_LEFT]->h - 20;
-  menu_opts->buttonheight = -1;
-  menu_opts->ygap = 10;
-  menu_opts->button_same_width = 1;
-  menu_opts->title = NULL;
-  menu_opts->trailer = NULL;
-}
-
-/* Recalculate on-screen locations for menus when screen dimensions change */
-/* Perhaps consider generalizing this for use in initial menu calculations? */
-void RecalcMenuPositions(int* numentries,
-                         int totalentries,
-                         menu_options* mo,
-                         void (*set_custom_menu_opts)(menu_options*),
-                         SDL_Rect** menu_button_rect,
-                         SDL_Rect** menu_sprite_rect,
-                         SDL_Rect** menu_text_rect,
-                         SDL_Rect** back_button_rect,
-                         SDL_Rect** back_sprite_rect,
-                         SDL_Rect** back_text_rect,
-                         SDL_Rect* left_arrow_rect,
-                         SDL_Rect* right_arrow_rect)
-{
-  int i;
-  SDL_Rect* old_mbr = *menu_button_rect;
-  SDL_Rect* old_msr = *menu_sprite_rect;
-  SDL_Rect* old_mtr = *menu_text_rect;
-  SDL_Rect* old_bbr = *back_button_rect;
-  SDL_Rect* old_bsr = *back_sprite_rect;
-  SDL_Rect* old_btr = *back_text_rect;
-
-  int old_ne = *numentries;
-  int buttonheight = old_mbr->h; //height shouldn't change
-  int textwidth = old_mtr->w; //neither should width =P
-
-  right_arrow_rect->x = screen->w - images[IMG_RIGHT]->w - 20;
-  right_arrow_rect->y = screen->h - images[IMG_RIGHT]->h - 20;
-  left_arrow_rect->x = right_arrow_rect->x - 10 - images[IMG_LEFT]->w;
-  left_arrow_rect->y = screen->h - images[IMG_LEFT]->h - 20;
-
-  set_default_menu_options(mo);
-  if (set_custom_menu_opts != NULL)
-    set_custom_menu_opts(mo);
-
-  *numentries     = (int)(screen->h - mo->ytop+mo->ygap)/(buttonheight + mo->ygap);
-  if (*numentries < totalentries)
-    *numentries = (int)(mo->ybottom - mo->ytop+mo->ygap)/(buttonheight + mo->ygap);
-  if (*numentries > totalentries)
-    *numentries = totalentries;
-
-
-
-
-  /**** Memory allocation for new screen rects  ****/
-  *menu_text_rect = (SDL_Rect*) malloc(*numentries * sizeof(SDL_Rect));
-  *menu_button_rect = (SDL_Rect*) malloc(*numentries * sizeof(SDL_Rect));
-  *menu_sprite_rect = (SDL_Rect*) malloc(*numentries * sizeof(SDL_Rect));
-  *back_text_rect = (SDL_Rect*) malloc(*numentries * sizeof(SDL_Rect));
-  *back_button_rect = (SDL_Rect*) malloc(*numentries * sizeof(SDL_Rect));
-  *back_sprite_rect = (SDL_Rect*) malloc(*numentries * sizeof(SDL_Rect));
-  if (*menu_text_rect == NULL ||
-      *back_text_rect == NULL ||
-      *menu_button_rect == NULL ||
-      *back_button_rect == NULL ||
-      *menu_sprite_rect == NULL ||
-      *back_sprite_rect == NULL) {
-    free(*menu_text_rect);
-    free(*menu_button_rect);
-    free(*menu_sprite_rect);
-    free(*back_text_rect);
-    free(*back_button_rect);
-    free(*back_sprite_rect);
-    *menu_text_rect = old_mtr;
-    *menu_button_rect = old_mbr;
-    *menu_sprite_rect = old_msr;
-    *numentries = old_ne;
-    return;
-  }
-  else {
-    free(old_mtr);
-    free(old_mbr);
-    free(old_msr);
-    free(old_btr);
-    free(old_bbr);
-    free(old_bsr);
-  }
-
-
-  //note: the [0] notation is merely to avoid typing out (*menu_xxx_rect)[i]
-  for (i = 0; i < *numentries; i++)
-  {
-    menu_button_rect[0][i].x = mo->xleft;
-    menu_text_rect[0][i].x = mo->xleft + 15;  // 15 is left gap
-    menu_text_rect[0][i].x += 60;  // for now, assume we have a sprite
-    if (i > 0)
-      menu_text_rect[0][i].y = menu_text_rect[0][i - 1].y + buttonheight + mo->ygap;
-    else
-      menu_text_rect[0][i].y = mo->ytop;
-
-    menu_button_rect[0][i].y = menu_text_rect[0][i].y - 5;
-    menu_text_rect[0][i].h = buttonheight - 10;
-    menu_button_rect[0][i].h = buttonheight;
-
-    menu_text_rect[0][i].w = textwidth;
-    menu_button_rect[0][i].w = menu_text_rect[0][i].w + 30;
-
-    if (menu_sprite_rect != NULL) {
-      menu_sprite_rect[0][i].x = menu_button_rect[0][i].x + 3;
-      menu_sprite_rect[0][i].y = menu_button_rect[0][i].y + 3;
-      menu_sprite_rect[0][i].w = 40;
-      menu_sprite_rect[0][i].h = 50;
-    }
-
-    DEBUGMSG(debug_menu, "***Rects[%d]****\n", i);
-    DEBUGMSG(debug_menu, "%3d %3d %3d %3d\n", menu_button_rect[0][i].x, menu_button_rect[0][i].y, menu_button_rect[0][i].w, menu_button_rect[0][i].h);
-    DEBUGMSG(debug_menu, "%3d %3d %3d %3d\n", menu_text_rect[0][i].x, menu_text_rect[0][i].y, menu_text_rect[0][i].w, menu_text_rect[0][i].h);
-    DEBUGMSG(debug_menu, "%3d %3d %3d %3d\n", menu_sprite_rect[0][i].x, menu_sprite_rect[0][i].y, menu_sprite_rect[0][i].w, menu_sprite_rect[0][i].h);
-    DEBUGMSG(debug_menu, "***************\n");
-  }
-  for (i = 0; i < *numentries; ++i)
-  {
-    back_button_rect[0][i] = menu_button_rect[0][i];
-    back_button_rect[0][i].x -= bkg_rect.x;
-    back_button_rect[0][i].y -= bkg_rect.y;
-
-    back_text_rect[0][i] = menu_text_rect[0][i];
-    back_text_rect[0][i].x -= bkg_rect.x;
-    back_text_rect[0][i].y -= bkg_rect.y;
-
-    back_sprite_rect[0][i] = menu_sprite_rect[0][i];
-    back_sprite_rect[0][i].x -= bkg_rect.x;
-    back_sprite_rect[0][i].y -= bkg_rect.y;
-  }
-
-}
-
 int handle_easter_egg(const SDL_Event* evt)
   {
   static int eggtimer = 0;

Modified: tuxmath/trunk/src/titlescreen.h
===================================================================
--- tuxmath/trunk/src/titlescreen.h	2009-07-24 09:58:00 UTC (rev 1265)
+++ tuxmath/trunk/src/titlescreen.h	2009-07-24 13:51:00 UTC (rev 1266)
@@ -1,25 +1,26 @@
-/***************************************************************************
- -  file: titlescreen.h
- -  description: header for the tuxtype-derived files in tuxmath
-                            ------------------
+/*
+  titlescreen.h
 
-    David Bruce - 2006.
-    email                : <dbruce at tampabay.rr.com>
-                           <tuxmath-devel at lists.sourceforge.net>
-***************************************************************************/
+  Splash, background and title screen items.
+  (interface)
 
-/***************************************************************************
- *                                                                         *
- *   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.                                   *
- *                                                                         *
- ***************************************************************************/
+  begin                : Thur May 4 2000
+  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-2007.
+  email                : <dbruce at tampabay.rr.com>
+                         <tuxmath-devel at lists.sourceforge.net>
 
+  Also significantly enhanced by Tim Holy - 2007
 
+  Part of "Tux4Kids" Project
+  http://www.tux4kids.com/
 
+  Copyright: See COPYING file that comes with this distribution.
+*/
+
 #ifndef TITLESCREEN_H
 #define TITLESCREEN_H
 
@@ -48,41 +49,27 @@
 #include "tuxmath.h"
 #include "loaders.h"
 
+#define MAX_LESSONS                     100
+#define MAX_NUM_WORDS                   500
+#define MAX_WORD_SIZE                   8
 
-// Options that affect how menus are presented
-typedef struct {
-  int starting_entry;
-  int xleft, ytop, ybottom;   // left, top, and bottom borders
-  int buttonheight; // size of menu item button  (-1 if calculated)
-  int ygap;  // vertical gap between entries
-  int button_same_width; // should all buttons have the same width?
-  char *title;
-  char *trailer;
-} menu_options;
-
-
-#define MAX_LESSONS 100
-#define MAX_NUM_WORDS   500
-#define MAX_WORD_SIZE   8
-
 //MAX_UPDATES needed for TransWipe() and friends:
-#define MAX_UPDATES 180
+#define MAX_UPDATES                     180
 
+#define WAIT_MS                         2500
+#define FRAMES_PER_SEC                  50
+#define FULL_CIRCLE                     140
 
-#define WAIT_MS                               2500
-#define FRAMES_PER_SEC                        50
-#define FULL_CIRCLE                           140
 
-
 /* trans_wipe() animation constants */
-#define ANIM_FRAMES                30 /* frames to be displayed */
-#define ANIM_FPS                   25 /* max fps */
+#define ANIM_FRAMES                     30 /* frames to be displayed */
+#define ANIM_FPS                        25 /* max fps */
 
 
 extern SDL_Event  event;
 
 
-#define MUSIC_FADE_OUT_MS        80
+#define MUSIC_FADE_OUT_MS               80
 
 enum {
     WIPE_BLINDS_VERT,
@@ -94,18 +81,6 @@
 };
 // End of code from tuxtype's globals.h
 
-
-/* --- SETUP MENU OPTIONS --- */
-
-#define TITLE_MENU_ITEMS                5
-#define TITLE_MENU_DEPTH                4
-
-#define OPTIONS_SUBMENU                 4
-#define GAME_OPTIONS_SUBMENU                       3
-#define ARCADE_SUBMENU                        2
-#define ROOTMENU                        1
-
-
 /* --- timings for tux blinking --- */
 #define TUX1                            115
 #define TUX2                            118
@@ -114,35 +89,27 @@
 #define TUX5                            127
 #define TUX6                            130
 
-#define EASTER_EGG_MS  5000 //length of time to replace cursor
-#define GOBBLE_ANIM_MS 1000 //duration of the gobbling animation
+#define EASTER_EGG_MS                   5000 //length of time to replace cursor
+#define GOBBLE_ANIM_MS                  1000 //duration of the gobbling animation
 
 /********************************/
 /* "Global" Function Prototypes */
 /********************************/
 
 /*In titlescreen.c */
-void TitleScreen(void);
-int RenderTitleScreen(void);
-void DrawTitleScreen(void);
-int HandleTitleScreenEvents(const SDL_Event* evt);
-void HandleTitleScreenAnimations();
-int ChooseMission(void);  //FIXME really should be in fileops.c
-void ShowMessage(const char* str1, const char* str2, const char* str3, const char* str4);
-int choose_menu_item(const char **menu_text, 
-                     sprite **menu_sprites, 
-                     int n_menu_entries, 
-                     menu_options* custom_mo, 
-                     void (*set_custom_menu_opts)(menu_options*) );
-void set_default_menu_options(menu_options *);
-SDL_Surface* current_bkg(); //appropriate background for current video mode
+void          TitleScreen(void);
+int           RenderTitleScreen(void);
+void          DrawTitleScreen(void);
+int           HandleTitleScreenEvents(const SDL_Event* evt);
+void          HandleTitleScreenAnimations();
+void          ShowMessage(const char* str1, const char* str2, const char* str3, const char* str4);
+SDL_Surface*  current_bkg(); //appropriate background for current video mode
 
 
-
 /* in audio.c  (from tuxtype): */
-void playsound(int snd);
-void audioMusicLoad(char* musicFilename, int repeatQty);
-void audioMusicUnload(void);
-void audioMusicPlay(Mix_Music* musicData, int repeatQty);
+void          playsound(int snd);
+void          audioMusicLoad(char* musicFilename, int repeatQty);
+void          audioMusicUnload(void);
+void          audioMusicPlay(Mix_Music* musicData, int repeatQty);
 
 #endif //TITLESCREEN_H




More information about the Tux4kids-commits mailing list