X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fgame_session.hpp;h=59a4642806954ec9addfcbe4d5a61c8b2412b893;hb=72b0c42e383b0bfbe04cd9a0f9e1566578bf67f2;hp=bed98b2fd290ce77707b5eb50a5d32673417985c;hpb=07ddaed2a657e4d2a3d038fed223fc5827159caf;p=supertux.git diff --git a/src/game_session.hpp b/src/game_session.hpp index bed98b2fd..59a464280 100644 --- a/src/game_session.hpp +++ b/src/game_session.hpp @@ -28,40 +28,25 @@ #include "console.hpp" #include "video/surface.hpp" -/* GameLoop modes */ -enum GameSessionMode { - ST_GL_PLAY, - ST_GL_TEST, - ST_GL_LOAD_GAME, - ST_GL_LOAD_LEVEL_FILE, - ST_GL_DEMO_GAME -}; - -enum GameMenuIDs { - MNID_CONTINUE, - MNID_ABORTLEVEL -}; - -extern int game_started; - class Level; class Sector; class Statistics; class DrawingContext; class CodeController; +class Menu; /** * The GameSession class controlls the controll flow of the Game (the part * where you actually play a level) */ -class GameSession : public Screen, public ConsoleCommandReceiver +class GameSession : public Screen { public: - GameSession(const std::string& levelfile, GameSessionMode mode, - Statistics* statistics = NULL); + GameSession(const std::string& levelfile, Statistics* statistics = NULL); ~GameSession(); void record_demo(const std::string& filename); + int get_demo_random_seed(const std::string& filename); void play_demo(const std::string& filename); void draw(DrawingContext& context); @@ -75,10 +60,8 @@ public: /// ends the current level void finish(bool win = true); - void respawn(const std::string& sectorname, - const std::string& spawnpointname); - void set_reset_point(const std::string& sectorname, - const Vector& pos); + void respawn(const std::string& sectorname, const std::string& spawnpointname); + void set_reset_point(const std::string& sectorname, const Vector& pos); void display_info_box(const std::string& text); Sector* get_current_sector() @@ -89,16 +72,17 @@ public: void start_sequence(const std::string& sequencename); - /** returns the "working directory" usually this is the directory where the + /** + * returns the "working directory" usually this is the directory where the * currently played level resides. This is used when locating additional * resources for the current level/world */ std::string get_working_directory(); - bool consoleCommand(std::string command, std::vector arguments); /**< callback from Console; return false if command was unknown, true otherwise */ - -private: void restart_level(bool fromBeginning = true); + void toggle_pause(); + +private: void check_end_conditions(); void process_events(); void capture_demo_step(); @@ -107,6 +91,7 @@ private: void drawstatus(DrawingContext& context); void draw_pause(DrawingContext& context); + HSQUIRRELVM run_script(std::istream& in, const std::string& sourcename); void on_escape_press(); void process_menu(); @@ -114,11 +99,13 @@ private: std::auto_ptr level; std::auto_ptr statistics_backdrop; + // scripts + typedef std::vector ScriptList; + ScriptList scripts; + Sector* currentsector; - GameSessionMode mode; int levelnb; - float fps_fps; int pause_menu_frame; /** If true the end_sequence will be played, user input will be @@ -152,6 +139,10 @@ private: 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 */ }; #endif /*SUPERTUX_GAMELOOP_H*/