2 // Copyright (C) 2014 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/levelset_screen.hpp"
19 #include "supertux/game_session.hpp"
20 #include "supertux/globals.hpp"
21 #include "supertux/savegame.hpp"
22 #include "supertux/screen_fade.hpp"
23 #include "supertux/screen_manager.hpp"
24 #include "util/file_system.hpp"
26 LevelsetScreen::LevelsetScreen(const std::string& basedir, const std::string& level_filename,
29 m_level_filename(level_filename),
31 m_level_started(false),
34 LevelsetState state = m_savegame.get_levelset_state(basedir);
35 LevelState level_state = state.get_level_state(level_filename);
36 m_solved = level_state.solved;
39 LevelsetScreen::~LevelsetScreen()
44 LevelsetScreen::draw(DrawingContext&)
49 LevelsetScreen::update(float elapsed_time)
54 LevelsetScreen::finished_level(bool win)
56 m_solved = m_solved || win;
60 LevelsetScreen::setup()
64 log_info << "Saving Levelset state" << std::endl;
65 // this gets called when the GameSession is done and we return back to the
66 m_savegame.set_levelset_state(m_basedir, m_level_filename, m_solved);
68 g_screen_manager->pop_screen();
72 m_level_started = true;
74 std::unique_ptr<Screen> screen(new GameSession(FileSystem::join(m_basedir, m_level_filename),
76 g_screen_manager->push_screen(std::move(screen));
81 LevelsetScreen::leave()