2 // Copyright (C) 2013 Ingo Ruhnke <grumbel@gmail.com>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "supertux/game_manager.hpp"
21 #include "gui/menu_manager.hpp"
22 #include "supertux/game_session.hpp"
23 #include "supertux/gameconfig.hpp"
24 #include "supertux/globals.hpp"
25 #include "supertux/screen.hpp"
26 #include "supertux/screen_fade.hpp"
27 #include "supertux/screen_manager.hpp"
28 #include "supertux/world.hpp"
29 #include "util/file_system.hpp"
30 #include "util/log.hpp"
32 GameManager::GameManager() :
37 GameManager::~GameManager()
42 GameManager::start_level(std::unique_ptr<World> world, int index)
44 m_world = std::move(world);
46 std::unique_ptr<Screen> screen(new GameSession(m_world->get_level_filename(index),
47 m_world->get_player_status()));
48 g_screen_manager->push_screen(std::move(screen));
52 GameManager::start_game(std::unique_ptr<World> world)
54 m_world = std::move(world);
56 MenuManager::instance().clear_menu_stack();
62 catch(std::exception& e)
64 log_fatal << "Couldn't start world: " << e.what() << std::endl;