#include "audio/sound_manager.hpp"
#include "control/joystickkeyboardcontroller.hpp"
#include "gui/menu.hpp"
+#include "gui/menu_manager.hpp"
#include "math/random_generator.hpp"
#include "object/camera.hpp"
#include "object/endsequence_fireworks.hpp"
#include "supertux/gameconfig.hpp"
#include "supertux/levelintro.hpp"
#include "supertux/globals.hpp"
-#include "supertux/mainloop.hpp"
+#include "supertux/screen_manager.hpp"
+#include "supertux/menu/menu_storage.hpp"
+#include "supertux/menu/game_menu.hpp"
#include "supertux/menu/options_menu.hpp"
#include "supertux/sector.hpp"
#include "util/file_system.hpp"
#include "util/gettext.hpp"
#include "worldmap/worldmap.hpp"
-enum GameMenuIDs {
- MNID_CONTINUE,
- MNID_ABORTLEVEL
-};
-
-GameSession::GameSession(const std::string& levelfile_, Statistics* statistics) :
+GameSession::GameSession(const std::string& levelfile_, PlayerStatus* player_status, Statistics* statistics) :
level(0),
statistics_backdrop(),
scripts(),
newsector(),
newspawnpoint(),
best_level_statistics(statistics),
+ player_status(player_status),
capture_demo_stream(0),
capture_file(),
playback_demo_stream(0),
currentsector = NULL;
game_pause = false;
- speed_before_pause = g_main_loop->get_speed();
+ speed_before_pause = g_screen_manager->get_speed();
- statistics_backdrop.reset(new Surface("images/engine/menu/score-backdrop.png"));
+ statistics_backdrop = Surface::create("images/engine/menu/score-backdrop.png");
restart_level();
- game_menu.reset(new Menu());
- game_menu->add_label(level->name);
- game_menu->add_hl();
- game_menu->add_entry(MNID_CONTINUE, _("Continue"));
- game_menu->add_submenu(_("Options"), get_options_menu());
- game_menu->add_hl();
- game_menu->add_entry(MNID_ABORTLEVEL, _("Abort Level"));
+ game_menu.reset(new GameMenu(*level));
}
void
}
} catch(std::exception& e) {
log_fatal << "Couldn't start level: " << e.what() << std::endl;
- g_main_loop->exit_screen();
+ g_screen_manager->exit_screen();
}
sound_manager->stop_music();
delete capture_demo_stream;
delete playback_demo_stream;
delete demo_controller;
- free_options_menu();
}
void
{
// pause
if(!game_pause) {
- speed_before_pause = g_main_loop->get_speed();
- g_main_loop->set_speed(0);
- Menu::set_current(game_menu.get());
+ speed_before_pause = g_screen_manager->get_speed();
+ g_screen_manager->set_speed(0);
+ MenuManager::set_current(game_menu.get());
game_menu->set_active_item(MNID_CONTINUE);
game_pause = true;
}
HSQUIRRELVM
GameSession::run_script(std::istream& in, const std::string& sourcename)
{
- using namespace Scripting;
+ using namespace scripting;
// garbage collect thread list
for(ScriptList::iterator i = scripts.begin();
void
GameSession::process_menu()
{
- Menu* menu = Menu::current();
+ Menu* menu = MenuManager::current();
if(menu) {
if(menu == game_menu.get()) {
switch (game_menu->check()) {
case MNID_CONTINUE:
- Menu::set_current(0);
+ MenuManager::set_current(0);
toggle_pause();
break;
case MNID_ABORTLEVEL:
- Menu::set_current(0);
- g_main_loop->exit_screen();
+ MenuManager::set_current(0);
+ g_screen_manager->exit_screen();
break;
}
}
if (!levelintro_shown) {
levelintro_shown = true;
- g_main_loop->push_screen(new LevelIntro(level.get(), best_level_statistics));
+ g_screen_manager->push_screen(new LevelIntro(level.get(), best_level_statistics));
}
}
process_menu();
// Unpause the game if the menu has been closed
- if (game_pause && !Menu::current()) {
- g_main_loop->set_speed(speed_before_pause);
+ if (game_pause && !MenuManager::current()) {
+ g_screen_manager->set_speed(speed_before_pause);
game_pause = false;
}
void
GameSession::finish(bool win)
{
- using namespace WorldMapNS;
+ using namespace worldmap;
if (edit_mode) {
force_ghost_mode();
WorldMap::current()->finished_level(level.get());
}
- g_main_loop->exit_screen();
+ g_screen_manager->exit_screen();
}
void
}
/* slow down the game for end-sequence */
- g_main_loop->set_speed(0.5f);
+ g_screen_manager->set_speed(0.5f);
currentsector->add_object(end_sequence);
end_sequence->start();
// draw level stats while end_sequence is running
if (end_sequence) {
- level->stats.draw_endseq_panel(context, best_level_statistics, statistics_backdrop.get());
+ level->stats.draw_endseq_panel(context, best_level_statistics, statistics_backdrop);
}
}