X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fsupertux%2Fgame_session.hpp;h=5356ee130d61a578d01b4db972d5f2705b75f514;hb=590805b8b24971ca43f777abfbf79fce21792804;hp=57d613f2c6799cdfb26a73bdbac80e2ccdbb6add;hpb=e70165f7a2caf2f7234c3635b8e7d2c452c3c787;p=supertux.git diff --git a/src/supertux/game_session.hpp b/src/supertux/game_session.hpp index 57d613f2c..5356ee130 100644 --- a/src/supertux/game_session.hpp +++ b/src/supertux/game_session.hpp @@ -23,15 +23,18 @@ #include "object/endsequence.hpp" #include "supertux/screen.hpp" +#include "supertux/player_status.hpp" #include "util/currenton.hpp" #include "video/surface.hpp" +class CodeController; +class DrawingContext; class Level; +class Menu; +class PlayerStatus; class Sector; class Statistics; -class DrawingContext; -class CodeController; -class Menu; +class Savegame; /** * Screen that runs a Level, where Players run and jump through Sectors. @@ -40,7 +43,7 @@ class GameSession : public Screen, public Currenton { public: - GameSession(const std::string& levelfile, Statistics* statistics = NULL); + GameSession(const std::string& levelfile, Savegame& savegame, Statistics* statistics = NULL); ~GameSession(); void record_demo(const std::string& filename); @@ -49,7 +52,8 @@ public: void draw(DrawingContext& context); void update(float frame_ratio); - void setup(); + void setup() override; + void leave() override; /// ends the current level void finish(bool win = true); @@ -75,9 +79,11 @@ public: * resources for the current level/world */ std::string get_working_directory(); - void restart_level(); + int restart_level(bool after_death = false); void toggle_pause(); + void abort_level(); + bool is_active() const; /** * Enters or leaves level editor mode @@ -89,6 +95,8 @@ public: */ void force_ghost_mode(); + Savegame& get_savegame() { return m_savegame; } + private: void check_end_conditions(); void process_events(); @@ -99,9 +107,8 @@ private: HSQUIRRELVM run_script(std::istream& in, const std::string& sourcename); void on_escape_press(); - void process_menu(); - std::auto_ptr level; + std::unique_ptr level; SurfacePtr statistics_backdrop; // scripts @@ -113,7 +120,7 @@ private: int levelnb; int pause_menu_frame; - EndSequence* end_sequence; + std::shared_ptr end_sequence; bool game_pause; float speed_before_pause; @@ -129,19 +136,25 @@ private: std::string newspawnpoint; Statistics* best_level_statistics; + Savegame& m_savegame; std::ostream* capture_demo_stream; std::string capture_file; std::istream* playback_demo_stream; CodeController* demo_controller; - std::auto_ptr game_menu; - float play_time; /**< total time in seconds that this session ran interactively */ bool edit_mode; /**< true if GameSession runs in level editor mode */ bool levelintro_shown; /**< true if the LevelIntro screen was already shown */ + int coins_at_start; /** How many coins does the player have at the start */ + BonusType bonus_at_start; /** What bonuses does the player have at the start */ + int max_fire_bullets_at_start; /** How many fire bullets does the player have */ + int max_ice_bullets_at_start; /** How many ice bullets does the player have */ + + bool active; /** Game active? **/ + private: GameSession(const GameSession&); GameSession& operator=(const GameSession&);