TileManager Class Reference

#include <tile_manager.hpp>

List of all members.

Public Member Functions

 TileManager ()
 ~TileManager ()
TileSetget_tileset (const std::string &filename)
TileSetparse_tileset_definition (const Reader &reader)

Private Types

typedef std::map< std::string,
TileSet * > 
TileSets

Private Attributes

TileSets tilesets


Detailed Description

Definition at line 27 of file tile_manager.hpp.


Member Typedef Documentation

typedef std::map<std::string, TileSet*> TileManager::TileSets [private]

Definition at line 30 of file tile_manager.hpp.


Constructor & Destructor Documentation

TileManager::TileManager (  ) 

Definition at line 25 of file tile_manager.cpp.

00025                          :
00026   tilesets()
00027 {
00028 }

TileManager::~TileManager (  ) 

Definition at line 30 of file tile_manager.cpp.

00031 {
00032 }


Member Function Documentation

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 }

TileSet * TileManager::parse_tileset_definition ( const Reader reader  ) 

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 }


Member Data Documentation

TileSets TileManager::tilesets [private]

Definition at line 31 of file tile_manager.hpp.

Referenced by get_tileset().


The documentation for this class was generated from the following files:
Generated on Mon Apr 21 03:38:31 2014 for SuperTux by  doxygen 1.5.1