- fixed bug in live counting
[supertux.git] / src / setup.cpp
index 3cf9980..24397e8 100644 (file)
@@ -11,6 +11,7 @@
 */
 
 #include <assert.h>
+#include <stdio.h>
 #include <iostream>
 #include <stdio.h>
 #include <stdlib.h>
@@ -40,6 +41,7 @@
 #include "gameloop.h"
 #include "configfile.h"
 #include "scene.h"
+#include "worldmap.h"
 
 #ifdef WIN32
 #define mkdir(dir, mode)    mkdir(dir)
@@ -373,7 +375,11 @@ 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);
+#else
+  options_menu->additem(MN_DEACTIVE,"OpenGL (not supported)",use_gl,0);
+#endif
   options_menu->additem(MN_TOGGLE,"Fullscreen",use_fullscreen,0);
   if(audio_device)
     {
@@ -416,18 +422,17 @@ void st_menu(void)
   save_game_menu->additem(MN_HL,"",0,0);
   save_game_menu->additem(MN_BACK,"Back",0,0);
 
-  game_menu->additem(MN_LABEL,"InGame Menu",0,0);
+  game_menu->additem(MN_LABEL,"Pause",0,0);
   game_menu->additem(MN_HL,"",0,0);
-  game_menu->additem(MN_ACTION,"Return To Game",0,0);
-  game_menu->additem(MN_GOTO,"Save Game",0,save_game_menu);
-  game_menu->additem(MN_GOTO,"Load Game",0,load_game_menu);
+  game_menu->additem(MN_ACTION,"Continue",0,0);
   game_menu->additem(MN_GOTO,"Options",0,options_menu);
   game_menu->additem(MN_HL,"",0,0);
-  game_menu->additem(MN_ACTION,"Quit Game",0,0);
+  game_menu->additem(MN_ACTION,"Abort Level",0,0);
 
-  worldmap_menu->additem(MN_LABEL,"Worldmap Menu",0,0);
+  worldmap_menu->additem(MN_LABEL,"Pause",0,0);
   worldmap_menu->additem(MN_HL,"",0,0);
-  worldmap_menu->additem(MN_ACTION,"Return To Game",0,0);
+  worldmap_menu->additem(MN_ACTION,"Continue",0,0);
+  worldmap_menu->additem(MN_ACTION,"Save",0,0);
   worldmap_menu->additem(MN_GOTO,"Options",0,options_menu);
   worldmap_menu->additem(MN_HL,"",0,0);
   worldmap_menu->additem(MN_ACTION,"Quit Game",0,0);
@@ -435,66 +440,37 @@ void st_menu(void)
   highscore_menu->additem(MN_TEXTFIELD,"Enter your name:",0,0);
 }
 
-void update_load_save_game_menu(Menu* pmenu, int load)
+void update_load_save_game_menu(Menu* pmenu)
 {
   for(int i = 2; i < 7; ++i)
     {
       // FIXME: Insert a real savegame struct/class here instead of
       // doing string vodoo
-      std::string tmp = slotinfo(i-1);
-
-      if(load && tmp.length() == strlen("Slot X - Free"))
-        pmenu->item[i].kind = MN_ACTION;
-      else
-        pmenu->item[i].kind = MN_ACTION;
+      std::string tmp = slotinfo(i - 1);
+      pmenu->item[i].kind = MN_ACTION;
       pmenu->item[i].change_text(tmp.c_str());
     }
 }
 
-void process_save_game_menu()
-{
-  int slot = save_game_menu->check();
-  if (slot != -1)
-    GameSession::current()->savegame(slot - 1);
-}
-
 bool process_load_game_menu()
 {
   int slot = load_game_menu->check();
 
   if(slot != -1)
     {
-      // FIXME: Insert a real savegame struct/class here instead of
-      // doing string vodoo
-      std::string tmp = slotinfo(slot-1);
+      WorldMapNS::WorldMap worldmap;
 
-      if (tmp.length() == strlen("Slot X - Free"))
-        { // Slot is free, so start a new game
-          GameSession session("default", 1, ST_GL_PLAY);
-          session.run();
+      char slotfile[1024];
+      snprintf(slotfile, 1024, "%s/slot%d.stsg", st_save_dir, slot-1);
+     
+      // Load the game or at least set the savegame_file variable
+      worldmap.loadgame(slotfile);
 
-          show_menu = true;
-          Menu::set_current(main_menu);
-        }
-      else
-        { 
-          puts("Warning: Loading games isn't supported at the moment");
-#if 0
-          // Slot contains a level, so load it
-          if (game_started)
-            {
-              GameSession session("default",slot - 1,ST_GL_LOAD_GAME);
-              session.run();
+      worldmap.display();
+      
+      show_menu = true;
+      Menu::set_current(main_menu);
 
-              show_menu = true;
-              Menu::set_current(main_menu);
-            }
-          else
-            {
-              //loadgame(slot - 1);
-            }
-#endif
-        }
       st_pause_ticks_stop();
       return true;
     }
@@ -510,13 +486,13 @@ void process_options_menu(void)
   switch (options_menu->check())
     {
     case 2:
+#ifndef NOOPENGL
       if(use_gl != options_menu->item[2].toggled)
         {
-#ifndef NOOPENGL
           use_gl = !use_gl;
           st_video_setup();
-#endif
         }
+#endif
       break;
     case 3:
       if(use_fullscreen != options_menu->item[3].toggled)