X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftile_manager.h;h=db8a70ccb88bbf6cb3bfb91df5fdac243f54700d;hb=74dd78e6fe41f686057eeca65a88dc23547f9803;hp=6c2e8cc1323304e4a1e0bfd82358b8a11c982dd1;hpb=9474517395e69ac4962164c58b3d1f8b0c8b88f6;p=supertux.git diff --git a/src/tile_manager.h b/src/tile_manager.h index 6c2e8cc13..db8a70ccb 100644 --- a/src/tile_manager.h +++ b/src/tile_manager.h @@ -27,8 +27,7 @@ #include #include #include - -class Tile; +#include "tile.h" struct TileGroup { @@ -43,24 +42,20 @@ struct TileGroup class TileManager { - private: - TileManager(); - ~TileManager(); - +private: typedef std::vector Tiles; Tiles tiles; static TileManager* instance_ ; std::set tilegroups; - void load_tileset(std::string filename); - std::string current_tileset; + std::string tiles_path; - public: - static TileManager* instance() - { return instance_ ? instance_ : instance_ = new TileManager(); } - static void destroy_instance() - { delete instance_; instance_ = 0; } + void load_tileset(std::string filename); + +public: + TileManager(const std::string& filename); + ~TileManager(); const std::set& get_tilegroups() const { @@ -70,16 +65,16 @@ class TileManager const Tile* get(uint32_t id) const { assert(id < tiles.size()); - Tile* t = tiles[id]; - if (t) - { - return t; - } - else - { - std::cout << "TileManager: Invalid tile: " << id << std::endl; - return tiles[0]; - } + Tile* tile = tiles[id]; + if(!tile) { + std::cout << "TileManager: Invalid tile: " << id << std::endl; + return tiles[0]; + } + + if(tile->images.size() == 0 && tile->imagespecs.size() != 0) + tile->load_images(tiles_path); + + return tile; } uint32_t get_max_tileid() const @@ -89,5 +84,3 @@ class TileManager }; #endif - -/* EOF */