#include <tile_manager.hpp>
Public Member Functions | |
TileManager () | |
~TileManager () | |
TileSet * | get_tileset (const std::string &filename) |
TileSet * | parse_tileset_definition (const Reader &reader) |
Private Types | |
typedef std::map< std::string, TileSet * > | TileSets |
Private Attributes | |
TileSets | tilesets |
Definition at line 27 of file tile_manager.hpp.
typedef std::map<std::string, TileSet*> TileManager::TileSets [private] |
Definition at line 30 of file tile_manager.hpp.
TileManager::TileManager | ( | ) |
TileManager::~TileManager | ( | ) |
TileSet * TileManager::get_tileset | ( | const std::string & | filename | ) |
Definition at line 34 of file tile_manager.cpp.
References tilesets.
Referenced by worldmap::WorldMap::load(), Level::load(), and parse_tileset_definition().
00035 { 00036 TileSets::const_iterator i = tilesets.find(filename); 00037 if(i != tilesets.end()) 00038 return i->second; 00039 00040 std::auto_ptr<TileSet> tileset (new TileSet(filename)); 00041 tilesets.insert(std::make_pair(filename, tileset.get())); 00042 00043 return tileset.release(); 00044 }
Definition at line 46 of file tile_manager.cpp.
References lisp::Lisp::get(), get_tileset(), lisp::ListIterator::item(), lisp::ListIterator::lisp(), log_warning, and lisp::ListIterator::next().
Referenced by worldmap::WorldMap::load(), and Level::load().
00047 { 00048 std::auto_ptr<TileSet> result(new TileSet()); 00049 00050 lisp::ListIterator iter(&reader); 00051 while(iter.next()) { 00052 const std::string& token = iter.item(); 00053 if(token != "tileset") { 00054 log_warning << "Skipping unrecognized token \"" << token << "\" in tileset definition" << std::endl; 00055 continue; 00056 } 00057 const lisp::Lisp* tileset_reader = iter.lisp(); 00058 00059 std::string file; 00060 if (!tileset_reader->get("file", file)) { 00061 log_warning << "Skipping tileset import without file name" << std::endl; 00062 continue; 00063 } 00064 00065 const TileSet *tileset = get_tileset(file); 00066 00067 uint32_t start = 0; 00068 uint32_t end = std::numeric_limits<uint32_t>::max(); 00069 uint32_t offset = 0; 00070 tileset_reader->get("start", start); 00071 tileset_reader->get("end", end); 00072 tileset_reader->get("offset", offset); 00073 00074 result->merge(tileset, start, end, offset); 00075 } 00076 00077 return result.release(); 00078 }
TileSets TileManager::tilesets [private] |