When a menu is disabled, it now uses Benjamin's gray fonts!
[supertux.git] / src / setup.cpp
index 3a2774f..da650e2 100644 (file)
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-#include <assert.h>
-#include <stdio.h>
+#include <cassert>
+#include <cstdio>
 #include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <cerrno>
 #include <unistd.h>
-#include <SDL.h>
-#include <SDL_image.h>
+
+#include "SDL.h"
+#include "SDL_image.h"
 #ifndef NOOPENGL
-#include <SDL_opengl.h>
+#include "SDL_opengl.h"
 #endif
 
 #include <sys/stat.h>
 #ifndef WIN32
 #include <libgen.h>
 #endif
-#include <ctype.h>
+
+#include <cctype>
 
 #include "defines.h"
 #include "globals.h"
 #include "setup.h"
 #include "screen/screen.h"
-#include "screen/texture.h"
+#include "screen/surface.h"
 #include "menu.h"
 #include "gameloop.h"
 #include "configfile.h"
@@ -395,7 +397,7 @@ void st_menu(void)
   options_menu->additem(MN_LABEL,_("Options"),0,0);
   options_menu->additem(MN_HL,"",0,0);
 #ifndef NOOPENGL
-  options_menu->additem(MN_TOGGLE,"OpenGL",use_gl,0, MNID_OPENGL);
+  options_menu->additem(MN_TOGGLE,_("OpenGL    "),use_gl,0, MNID_OPENGL);
 #else
   options_menu->additem(MN_DEACTIVE,_("OpenGL (not supported)"),use_gl, 0, MNID_OPENGL);
 #endif
@@ -411,15 +413,15 @@ void st_menu(void)
       options_menu->additem(MN_DEACTIVE,_("Music     "), false,0, MNID_MUSIC);
     }
   options_menu->additem(MN_TOGGLE,_("Show FPS  "),show_fps,0, MNID_SHOWFPS);
-  options_menu->additem(MN_GOTO,_("Keyboard Setup"),0,options_keys_menu);
+  options_menu->additem(MN_GOTO,_("Setup Keys"),0,options_keys_menu);
 
   if(use_joystick)
-    options_menu->additem(MN_GOTO,_("Joystick Setup"),0,options_joystick_menu);
+    options_menu->additem(MN_GOTO,_("Setup Joystick"),0,options_joystick_menu);
 
   options_menu->additem(MN_HL,"",0,0);
   options_menu->additem(MN_BACK,_("Back"),0,0);
   
-  options_keys_menu->additem(MN_LABEL,_("Key Setup"),0,0);
+  options_keys_menu->additem(MN_LABEL,_("Keyboard Setup"),0,0);
   options_keys_menu->additem(MN_HL,"",0,0);
   options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Left move"), 0,0, 0,&keymap.left);
   options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Right move"), 0,0, 0,&keymap.right);
@@ -588,6 +590,8 @@ void st_general_setup(void)
   blue_text = new Font(datadir + "/images/fonts/blue.png", Font::TEXT, 16,18,3);
   white_text  = new Font(datadir + "/images/fonts/white.png",
       Font::TEXT, 16,18);
+  gray_text  = new Font(datadir + "/images/fonts/gray.png",
+      Font::TEXT, 16,18);
   white_small_text = new Font(datadir + "/images/fonts/white-small.png",
           Font::TEXT, 8,9, 1);
   white_big_text   = new Font(datadir + "/images/fonts/white-big.png",
@@ -633,7 +637,12 @@ void st_general_free(void)
   delete main_menu;
   delete game_menu;
   delete options_menu;
+  delete options_keys_menu;
+  delete options_joystick_menu;
   delete highscore_menu;
+  delete contrib_menu;
+  delete contrib_subset_menu;
+  delete worldmap_menu;
   delete save_game_menu;
   delete load_game_menu;
 }
@@ -671,7 +680,7 @@ void st_video_setup_sdl(void)
         {
           fprintf(stderr,
                   "\nWarning: I could not set up fullscreen video for "
-                  "640x480 mode.\n"
+                  "800x600 mode.\n"
                   "The Simple DirectMedia error that occured was:\n"
                   "%s\n\n", SDL_GetError());
           use_fullscreen = false;
@@ -684,7 +693,7 @@ void st_video_setup_sdl(void)
       if (screen == NULL)
         {
           fprintf(stderr,
-                  "\nError: I could not set up video for 640x480 mode.\n"
+                  "\nError: I could not set up video for 800x600 mode.\n"
                   "The Simple DirectMedia error that occured was:\n"
                   "%s\n\n", SDL_GetError());
           exit(1);
@@ -768,7 +777,7 @@ void st_joystick_setup(void)
       /* Open joystick: */
       if (SDL_NumJoysticks() <= 0)
         {
-          fprintf(stderr, "Warning: No joysticks are available.\n");
+          fprintf(stderr, "Info: No joysticks were found.\n");
 
           use_joystick = false;
         }
@@ -939,10 +948,13 @@ void parseargs(int argc, char * argv[])
       if (strcmp(argv[i], "--fullscreen") == 0 ||
           strcmp(argv[i], "-f") == 0)
         {
-          /* Use full screen: */
-
           use_fullscreen = true;
         }
+      else if (strcmp(argv[i], "--window") == 0 ||
+               strcmp(argv[i], "-w") == 0)
+        {
+          use_fullscreen = false;
+        }
       else if (strcmp(argv[i], "--joystick") == 0 || strcmp(argv[i], "-j") == 0)
         {
           assert(i+1 < argc);
@@ -1033,14 +1045,15 @@ void parseargs(int argc, char * argv[])
         }
       else if (strcmp(argv[i], "--help") == 0)
         {     /* Show help: */
-          puts("Super Tux " VERSION "\n"
-               "  Please see the file \"README.txt\" for more details.\n");
-          printf("Usage: %s [OPTIONS] FILENAME\n\n", argv[0]);
-          puts("Display Options:\n"
-               "  --fullscreen        Run in fullscreen mode.\n"
-               "  --opengl            If opengl support was compiled in, this will enable\n"
-               "                      the EXPERIMENTAL OpenGL mode.\n"
-               "  --sdl               Use non-opengl renderer\n"
+          puts(_("  SuperTux  " VERSION "\n"
+               "  Please see the file \"README.txt\" for more details.\n"));
+          printf(_("Usage: %s [OPTIONS] FILENAME\n\n"), argv[0]);
+          puts(_("Display Options:\n"
+               "  -f, --fullscreen    Run in fullscreen mode.\n"
+               "  -w, --window        Run in window mode.\n"
+               "  --opengl            If OpenGL support was compiled in, this will tell\n"
+               "                      SuperTux to make use of it.\n"
+               "  --sdl               Use the SDL software graphical renderer\n"
                "\n"
                "Sound Options:\n"
                "  --disable-sound     If sound support was compiled in,  this will\n"
@@ -1058,7 +1071,7 @@ void parseargs(int argc, char * argv[])
                "                      options, license and game controls.\n"
                "  --usage             Display a brief message summarizing command-line options.\n"
                "  --version           Display the version of SuperTux you're running.\n\n"
-               );
+               ));
           exit(0);
         }
       else if (argv[i][0] != '-')
@@ -1092,7 +1105,7 @@ void usage(char * prog, int ret)
 
   /* Display the usage message: */
 
-  fprintf(fi, "Usage: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--debug-mode] | [--usage | --help | --version] [--leveleditor] FILENAME\n",
+  fprintf(fi, _("Usage: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--debug-mode] | [--usage | --help | --version] [--leveleditor] FILENAME\n"),
           prog);
 
 
@@ -1101,3 +1114,24 @@ void usage(char * prog, int ret)
   exit(ret);
 }
 
+std::vector<std::string> read_directory(const std::string& pathname)
+{
+  std::vector<std::string> dirnames;
+  
+  DIR* dir = opendir(pathname.c_str());
+  if (dir)
+    {
+      struct dirent *direntp;
+      
+      while((direntp = readdir(dir)))
+        {
+          dirnames.push_back(direntp->d_name);
+        }
+      
+      closedir(dir);
+    }
+
+  return dirnames;
+}
+
+/* EOF */