Added simple cheat menu to grow/fire/ice/shrink/... Tux
[supertux.git] / src / supertux / game_session.cpp
index d0cc127..3ddedfc 100644 (file)
 #include "supertux/gameconfig.hpp"
 #include "supertux/globals.hpp"
 #include "supertux/levelintro.hpp"
+#include "supertux/levelset_screen.hpp"
 #include "supertux/menu/menu_storage.hpp"
 #include "supertux/menu/options_menu.hpp"
 #include "supertux/player_status.hpp"
+#include "supertux/savegame.hpp"
 #include "supertux/screen_fade.hpp"
 #include "supertux/screen_manager.hpp"
 #include "supertux/sector.hpp"
-#include "supertux/world_state.hpp"
 #include "util/file_system.hpp"
 #include "util/gettext.hpp"
 #include "worldmap/worldmap.hpp"
 
-GameSession::GameSession(const std::string& levelfile_, WorldState& world_state, Statistics* statistics) :
+GameSession::GameSession(const std::string& levelfile_, Savegame& savegame, Statistics* statistics) :
   level(),
   statistics_backdrop(Surface::create("images/engine/menu/score-backdrop.png")),
   scripts(),
@@ -61,7 +62,7 @@ GameSession::GameSession(const std::string& levelfile_, WorldState& world_state,
   newsector(),
   newspawnpoint(),
   best_level_statistics(statistics),
-  m_world_state(world_state),
+  m_savegame(savegame),
   capture_demo_stream(0),
   capture_file(),
   playback_demo_stream(0),
@@ -81,7 +82,7 @@ GameSession::GameSession(const std::string& levelfile_, WorldState& world_state,
 int
 GameSession::restart_level()
 {
-    PlayerStatus* currentStatus = m_world_state.get_player_status();
+    PlayerStatus* currentStatus = m_savegame.get_player_status();
     coins_at_start = currentStatus->coins;
     bonus_at_start = currentStatus->bonus;
     max_fire_bullets_at_start = currentStatus->max_fire_bullets;
@@ -257,7 +258,7 @@ GameSession::abort_level()
   MenuManager::instance().clear_menu_stack();
   g_screen_manager->pop_screen();
   currentsector->player->set_bonus(bonus_at_start);
-  PlayerStatus *currentStatus = m_world_state.get_player_status();
+  PlayerStatus *currentStatus = m_savegame.get_player_status();
   currentStatus->coins = coins_at_start;
   currentStatus->max_fire_bullets = max_fire_bullets_at_start;
   currentStatus->max_ice_bullets = max_ice_bullets_at_start;
@@ -407,11 +408,24 @@ GameSession::setup()
 }
 
 void
+GameSession::leave()
+{
+}
+
+void
 GameSession::update(float elapsed_time)
 {
   // handle controller
   if(g_input_manager->get_controller()->pressed(Controller::PAUSE_MENU))
+  {
     on_escape_press();
+  }
+
+  if(g_input_manager->get_controller()->pressed(Controller::CHEAT_MENU))
+  {
+    game_pause = true;
+    MenuManager::instance().set_menu(MenuStorage::CHEAT_MENU);
+  }
 
   process_events();
   MenuManager::instance().check_menu();
@@ -488,7 +502,14 @@ GameSession::finish(bool win)
 
   if(win) {
     if(WorldMap::current())
+    {
       WorldMap::current()->finished_level(level.get());
+    }
+
+    if (LevelsetScreen::current())
+    {
+      LevelsetScreen::current()->finished_level(win);
+    }
   }
 
   g_screen_manager->pop_screen();
@@ -575,7 +596,7 @@ GameSession::start_sequence(const std::string& sequencename)
 void
 GameSession::drawstatus(DrawingContext& context)
 {
-  m_world_state.get_player_status()->draw(context);
+  m_savegame.get_player_status()->draw(context);
 
   // draw level stats while end_sequence is running
   if (end_sequence) {