src/supertux/game_session.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_SUPERTUX_GAME_SESSION_HPP
00018 #define HEADER_SUPERTUX_SUPERTUX_GAME_SESSION_HPP
00019 
00020 #include <memory>
00021 #include <vector>
00022 #include <squirrel.h>
00023 
00024 #include "object/endsequence.hpp"
00025 #include "supertux/screen.hpp"
00026 #include "util/currenton.hpp"
00027 #include "video/surface.hpp"
00028 
00029 class Level;
00030 class Sector;
00031 class Statistics;
00032 class PlayerStatus;
00033 class DrawingContext;
00034 class CodeController;
00035 class Menu;
00036 
00040 class GameSession : public Screen,
00041                     public Currenton<GameSession>
00042 {
00043 public:
00044   GameSession(const std::string& levelfile, PlayerStatus* player_status, Statistics* statistics = NULL);
00045   ~GameSession();
00046 
00047   void record_demo(const std::string& filename);
00048   int get_demo_random_seed(const std::string& filename);
00049   void play_demo(const std::string& filename);
00050 
00051   void draw(DrawingContext& context);
00052   void update(float frame_ratio);
00053   void setup();
00054 
00056   void finish(bool win = true);
00057   void respawn(const std::string& sectorname, const std::string& spawnpointname);
00058   void set_reset_point(const std::string& sectorname, const Vector& pos);
00059   std::string get_reset_point_sectorname()
00060   { return reset_sector; }
00061 
00062   Vector get_reset_point_pos()
00063   { return reset_pos; }
00064 
00065   Sector* get_current_sector()
00066   { return currentsector; }
00067 
00068   Level* get_current_level()
00069   { return level.get(); }
00070 
00071   PlayerStatus* get_player_status()
00072   { return player_status; }
00073 
00074   void start_sequence(const std::string& sequencename);
00075 
00081   std::string get_working_directory();
00082   int restart_level();
00083 
00084   void toggle_pause();
00085 
00089   void set_editmode(bool edit_mode = true);
00090 
00094   void force_ghost_mode();
00095 
00096 private:
00097   void check_end_conditions();
00098   void process_events();
00099   void capture_demo_step();
00100 
00101   void drawstatus(DrawingContext& context);
00102   void draw_pause(DrawingContext& context);
00103 
00104   HSQUIRRELVM run_script(std::istream& in, const std::string& sourcename);
00105   void on_escape_press();
00106   void process_menu();
00107 
00108   std::auto_ptr<Level> level;
00109   SurfacePtr statistics_backdrop;
00110 
00111   // scripts
00112   typedef std::vector<HSQOBJECT> ScriptList;
00113   ScriptList scripts;
00114 
00115   Sector* currentsector;
00116 
00117   int levelnb;
00118   int pause_menu_frame;
00119 
00120   EndSequence* end_sequence;
00121 
00122   bool  game_pause;
00123   float speed_before_pause;
00124 
00125   std::string levelfile;
00126 
00127   // reset point (the point where tux respawns if he dies)
00128   std::string reset_sector;
00129   Vector reset_pos;
00130 
00131   // the sector and spawnpoint we should spawn after this frame
00132   std::string newsector;
00133   std::string newspawnpoint;
00134 
00135   Statistics* best_level_statistics;
00136   PlayerStatus* player_status;
00137 
00138   std::ostream* capture_demo_stream;
00139   std::string capture_file;
00140   std::istream* playback_demo_stream;
00141   CodeController* demo_controller;
00142 
00143   std::auto_ptr<Menu> game_menu;
00144 
00145   float play_time; 
00147   bool edit_mode; 
00148   bool levelintro_shown; 
00150 private:
00151   GameSession(const GameSession&);
00152   GameSession& operator=(const GameSession&);
00153 };
00154 
00155 #endif /*SUPERTUX_GAMELOOP_H*/
00156 
00157 /* EOF */

Generated on Mon Jun 9 03:38:22 2014 for SuperTux by  doxygen 1.5.1