several bugfixes to squirrel serialisation code, serializer/load worldmap state from...
[supertux.git] / src / worldmap.hpp
index 1256d6c..67b697e 100644 (file)
@@ -2,6 +2,7 @@
 // 
 //  SuperTux
 //  Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
+//  Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
 #include "control/controller.hpp"
 #include "statistics.hpp"
 #include "timer.hpp"
+#include "screen.hpp"
 #include "tile_manager.hpp"
 #include "game_object.hpp"
+#include "console.hpp"
 
 class Sprite;
 class Menu;
@@ -102,17 +105,18 @@ public:
 };
 
 /** */
-class WorldMap
+class WorldMap : public Screen
 {
 private:
   Tux* tux;
 
-  bool quit;
-
   Surface* leveldot_green;
   Surface* leveldot_red;
   Surface* messagedot;
-  Surface* teleporterdot;
+  Sprite* teleporterdot;
+  static WorldMap* current_;
+
+  Vector camera_offset;
 
   std::string name;
   std::string music;
@@ -122,6 +126,8 @@ private:
   TileMap* solids;
   
   TileManager* tile_manager;
+  
+  Console* console;
 
 public:
   struct SpecialTile
@@ -130,6 +136,9 @@ public:
 
     /** Optional flags: */
 
+    /** Sprite to render instead of guessing what image to draw */
+    Sprite* sprite;
+
     /** Position to swap to player */
     Vector teleport_dest;
 
@@ -218,16 +227,16 @@ public:
   WorldMap();
   ~WorldMap();
 
-  /** Busy loop */
-  void display();
-
   void load_map();
   
-  void get_input();
-
   void add_object(GameObject* object);
   void clear_objects();
 
+  static WorldMap* current()
+  { return current_; }
+
+  void setup();
+
   /** Update Tux position */
   void update(float delta);
 
@@ -237,6 +246,12 @@ public:
   Vector get_next_tile(Vector pos, Direction direction);
   const Tile* at(Vector pos);
 
+  /**
+   * gets called from the GameSession when a level has been successfully
+   * finished
+   */
+  void finished_level(const std::string& filename);
+
   WorldMap::Level* at_level();
   WorldMap::SpecialTile* at_special_tile();
 
@@ -244,12 +259,17 @@ public:
       if possible, write the new position to \a new_pos */
   bool path_ok(Direction direction, Vector pos, Vector* new_pos);
 
-  /* Save map to slot */
-  void savegame(const std::string& filename);
-  /* Load map from slot
-     You should call set_map_filename() before this */
-  void loadgame(const std::string& filename);
-  /* Load map directly from file */
+  /**
+   * Save worldmap state to squirrel state table
+   */
+  void save_state();
+  /**
+   * Load worldmap state from squirrel state table
+   */
+  void load_state();
+  /**
+   * Load a worldmap
+   */
   void loadmap(const std::string& filename);
 
   const std::string& get_world_title() const