Pause music when pressing ESC during a level and resume it when exiting the pause...
[supertux.git] / src / supertux / game_manager.cpp
index baa82e2..1692a84 100644 (file)
 #include "supertux/game_session.hpp"
 #include "supertux/gameconfig.hpp"
 #include "supertux/globals.hpp"
+#include "supertux/levelset_screen.hpp"
+#include "supertux/savegame.hpp"
 #include "supertux/screen.hpp"
 #include "supertux/screen_fade.hpp"
 #include "supertux/screen_manager.hpp"
 #include "supertux/world.hpp"
-#include "supertux/world_state.hpp"
 #include "util/file_system.hpp"
 #include "util/log.hpp"
 #include "worldmap/worldmap.hpp"
 
 GameManager::GameManager() :
   m_world(),
-  m_world_state()
+  m_savegame()
 {
 }
 
@@ -44,32 +45,30 @@ GameManager::~GameManager()
 }
 
 void
-GameManager::start_level(const std::string& level_filename)
+GameManager::start_level(std::unique_ptr<World> world, const std::string& level_filename)
 {
-  /*
   m_world = std::move(world);
-  m_world_state.reset(new WorldState);
-  m_world_state->load(m_world->get_savegame_filename());
+  m_savegame.reset(new Savegame(m_world->get_savegame_filename()));
+  m_savegame->load();
 
-  std::unique_ptr<Screen> screen(new GameSession(level_filename,
-                                                 &m_world_state));
-  g_screen_manager->push_screen(std::move(screen));
-  */
+  std::unique_ptr<Screen> screen(new LevelsetScreen(m_world->get_basedir(),
+                                                    level_filename,
+                                                    *m_savegame));
+  ScreenManager::current()->push_screen(std::move(screen));
 }
 
 void
-GameManager::start_game(std::unique_ptr<World> world)
+GameManager::start_worldmap(std::unique_ptr<World> world)
 {
   try
   {
     m_world = std::move(world);
-    m_world_state.reset(new WorldState);
+    m_savegame.reset(new Savegame(m_world->get_savegame_filename()));
+    m_savegame->load();
 
-    m_world_state->load(m_world->get_savegame_filename());
-
-    g_screen_manager->push_screen(std::unique_ptr<Screen>(
+    ScreenManager::current()->push_screen(std::unique_ptr<Screen>(
                                     new worldmap::WorldMap(m_world->get_worldmap_filename(),
-                                                           *m_world_state)));
+                                                           *m_savegame)));
   }
   catch(std::exception& e)
   {