#include "supertux/gameconfig.hpp"
#include "supertux/globals.hpp"
#include "supertux/levelintro.hpp"
-#include "supertux/menu/game_menu.hpp"
#include "supertux/menu/menu_storage.hpp"
#include "supertux/menu/options_menu.hpp"
#include "supertux/player_status.hpp"
GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_status, Statistics* statistics) :
level(),
- statistics_backdrop(),
+ statistics_backdrop(Surface::create("images/engine/menu/score-backdrop.png")),
scripts(),
- currentsector(0),
+ currentsector(nullptr),
levelnb(),
pause_menu_frame(),
end_sequence(0),
- game_pause(),
- speed_before_pause(),
+ game_pause(false),
+ speed_before_pause(g_screen_manager->get_speed()),
levelfile(levelfile_),
reset_sector(),
reset_pos(),
capture_file(),
playback_demo_stream(0),
demo_controller(0),
- game_menu(),
play_time(0),
edit_mode(false),
- levelintro_shown(false)
+ levelintro_shown(false),
+ coins_at_start(),
+ bonus_at_start(),
+ max_fire_bullets_at_start(),
+ max_ice_bullets_at_start()
{
- currentsector = NULL;
-
- game_pause = false;
- speed_before_pause = g_screen_manager->get_speed();
-
- statistics_backdrop = Surface::create("images/engine/menu/score-backdrop.png");
-
if (restart_level() != 0)
throw std::runtime_error ("Initializing the level failed.");
-
- game_menu.reset(new GameMenu(*level));
}
int
if(!game_pause) {
speed_before_pause = g_screen_manager->get_speed();
g_screen_manager->set_speed(0);
- MenuManager::instance().set_current(game_menu.get());
- game_menu->set_active_item(MNID_CONTINUE);
+ MenuManager::instance().set_menu(MenuStorage::GAME_MENU);
game_pause = true;
}
void
GameSession::abort_level()
{
- MenuManager::instance().set_current(0);
+ MenuManager::instance().clear_menu_stack();
g_screen_manager->exit_screen();
currentsector->player->set_bonus(bonus_at_start);
PlayerStatus *currentStatus = get_player_status();
void
GameSession::process_events()
{
- // end of pause mode?
- // XXX this looks like a fail-safe to unpause the game if there's no menu
- // XXX having it enabled causes some unexpected problems
- // XXX hopefully disabling it won't...
- /*
- if(!Menu::current() && game_pause) {
- game_pause = false;
- }
- */
-
// playback a demo?
if(playback_demo_stream != 0) {
demo_controller->update();
on_escape_press();
process_events();
- Menu* menu = MenuManager::instance().current();
- if (menu && menu == game_menu.get())
- {
- menu->check_menu();
- }
+ MenuManager::instance().check_menu();
// Unpause the game if the menu has been closed
if (game_pause && !MenuManager::instance().is_active()) {