bonusblock can now contain custom MovingObjects, added possibility to execute script...
[supertux.git] / src / game_session.h
index ab0a777..a1ed467 100644 (file)
 #ifndef SUPERTUX_GAMELOOP_H
 #define SUPERTUX_GAMELOOP_H
 
+#include <string>
 #include <SDL.h>
 #include "timer.h"
 #include "statistics.h"
-
-using namespace SuperTux;
+#include "math/vector.h"
 
 /* GameLoop modes */
-
 enum GameSessionMode {
   ST_GL_PLAY,
   ST_GL_TEST,
@@ -60,7 +59,6 @@ public:
 
 public:
   DrawingContext* context;
-  Timer2 time_left;
 
   GameSession(const std::string& levelfile, GameSessionMode mode,
               Statistics* statistics=0);
@@ -69,13 +67,17 @@ public:
   /** Enter the busy loop */
   ExitStatus run();
 
+  void record_demo(const std::string& filename);
+  void play_demo(const std::string& filename);
   void draw();
-  void action(float frame_ratio);
+  void update(float frame_ratio);
 
   void set_current()
   { current_ = this; }
   static GameSession* current() { return current_; }
 
+  /// 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,
@@ -84,16 +86,25 @@ public:
   Sector* get_current_sector()
   { return currentsector; }
 
+  Level* get_current_level()
+  { return level; }
+
   void start_sequence(const std::string& sequencename);
   /// called by JoystickKeyboardController after an ascii key has been pressed
   void try_cheats();
+
+  /** 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();
   
 private:
   void restart_level();
 
   void check_end_conditions();
-  void start_timers();
   void process_events();
+  void capture_demo_step();
 
   void levelintro();
   void drawstatus(DrawingContext& context);
@@ -104,8 +115,7 @@ private:
   void on_escape_press();
   void process_menu();
 
-  Uint32 fps_ticks;
-  Timer2 endsequence_timer;
+  Timer endsequence_timer;
   Level* level;
   Sector* currentsector;
 
@@ -139,12 +149,13 @@ private:
 
   static GameSession* current_;
 
-  // for cheating
-  std::string last_keys;
-
   Statistics* best_level_statistics;
-
   ExitStatus exit_status;
+
+  std::ostream* capture_demo_stream;
+  std::string capture_file;
+  std::istream* playback_demo_stream;
+  CodeController* demo_controller;
 };
 
 std::string slotinfo(int slot);