Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes

TileSet Class Reference

Implementation of a TileSet class. More...

#include <TileSet.h>

List of all members.

Classes

struct  _SheetInfo

Public Member Functions

 TileSet (const std::string &filePath)
 TileSet (int width, int height)
 TileSet (const TileSet &copy)
 ~TileSet ()
TileSetoperator= (const TileSet &copy)
const std::string & getName ()
const std::string & getFileName ()
ImagegetTile (Uint index)
int getNumTiles () const
int getTileWidth () const
int getTileHeight () const
int getTileThickness () const
const std::string & getTileName (Uint index) const
bool isLoaded () const

Private Types

enum  _ImageEncoding { ENCODING_FLATFILE, ENCODING_EMBEDDED }

Private Member Functions

void readXml (const std::string &filePath)
bool parseHeader (TiXmlNode *node)
bool parseChildren (TiXmlNode *node)
bool parseSheet (TiXmlNode *node)
bool processSheet (const std::string &filePath, _ImageEncoding encoding)

Private Attributes

ImageList mTiles
StringList mTileNames
TiXmlDocument * mDocXml
string mName
string mFileName
string mFilePath
int mTileWidth
int mTileHeight
int mTileThickness
bool mIsLoaded

Detailed Description

Implementation of a TileSet class.

Todo:
Fucking hell this should really be a base class with derived implementations for each type of tile (square, isometric, hexagonal, whatever else).

Member Enumeration Documentation

enum TileSet::_ImageEncoding [private]
Enumerator:
ENCODING_FLATFILE 
ENCODING_EMBEDDED 

Constructor & Destructor Documentation

TileSet::TileSet ( const std::string &  filePath  ) 
TileSet::TileSet ( int  width,
int  height 
)

'Default' TileSet constructor.

This constructor is used to create a 'default' TileSet which contains a single default tile.

TileSet::TileSet ( const TileSet copy  ) 

Copy Constructor

TileSet::~TileSet (  ) 

Member Function Documentation

const std::string& TileSet::getFileName (  )  [inline]

Gets the source file name.

Returns:
Returns a std::string containing the flat file of the TileSet.
const std::string& TileSet::getName (  )  [inline]

Gets the name of the TileSet.

Returns:
Returns a std::string containing the name of the TileSet.
int TileSet::getNumTiles (  )  const [inline]

Gets the number of tiles stored in the TileSet.

Returns:
Returns an int indicating the number of stored tiles.
Image * TileSet::getTile ( Uint  index  ) 

Gets a tile.

Parameters:
index Index of the Tile to grab from the TileSet.
Returns:
Returns an Image Resource containing the tile. Returns NULL if the index was out of bounds.

Returns a pointer to an Image at specified index.

Parameters:
index Non-negative tile index.
Returns:
Pointer to an Image object. NULL on error.
int TileSet::getTileHeight (  )  const [inline]

Gets height of the tiles stored in the TileSet.

Returns:
Returns an int indicating the height of the stored tiles.
const std::string & TileSet::getTileName ( Uint  index  )  const

Gets the name of an individual tile.

int TileSet::getTileThickness (  )  const [inline]

Gets height in pixels of the tiles stored in the TileSet.

Some tiles in a TileSet may be 'taller' than the standard tile. This value indicated the actual height of the tiles.

Note:
This function should not be confused with getSizeHeight().
Returns:
Returns an int indicating the height in pixels of the stored tiles.
int TileSet::getTileWidth (  )  const [inline]

Gets width of the tiles stored in the TileSet.

Returns:
Returns an int indicating the width of the stored tiles.
bool TileSet::isLoaded (  )  const [inline]

Gets width of the tiles stored in the TileSet.

Returns:
Returns an int indicating the width of the stored tiles.
TileSet & TileSet::operator= ( const TileSet copy  ) 

Assignment Operator

bool TileSet::parseChildren ( TiXmlNode *  node  )  [private]

Parses all children of the TileSet node.

Parameters:
node A pointer to the first child node of the root node.
Returns:
Returns true if no errors occured during all low-level processing and parsing. False otherwise.
bool TileSet::parseHeader ( TiXmlNode *  node  )  [private]

Parses the attributes of the TileSet node.

Parameters:
node A pointer to the root XML node.
Returns:
Returns true if no errors occured while parsing the TileSet.
bool TileSet::parseSheet ( TiXmlNode *  node  )  [private]

Parses an individual sheet node.

Parameters:
node A pointer to a 'sheet' node.
Returns:
Returns true if no errors occured during sheet parsing. False otherwise.
Todo:
Implement processing of the various attributes of sheet.
Todo:
The current method of processing allows for the user to define more than one 'img' or 'blend' node and the parser will blindly accept it. A sheet should have exactly one 'img' node and exactly one 'blend' node.
Todo:
The current method of processing allows the user to define the 'img' and 'blend' nodes in whatever order they want and it goes ahead and calls functions whenever if finds a valid node. This should instead first check for the 'blend' node and, once that's been found, should then go and find the 'img' node.
bool TileSet::processSheet ( const std::string &  filePath,
_ImageEncoding  encoding 
) [private]
void TileSet::readXml ( const std::string &  filePath  )  [private]

Member Data Documentation

TiXmlDocument* TileSet::mDocXml [private]

XML Document Object.

string TileSet::mFileName [private]

Source file name.

string TileSet::mFilePath [private]

Source filepath.

bool TileSet::mIsLoaded [private]

Flag indicating that the TileSet loaded properly.

string TileSet::mName [private]

Full name of the TileSet.

int TileSet::mTileHeight [private]

Tile Height.

List of names for each tile.

Set of tiles.

int TileSet::mTileThickness [private]

Tile's thickness.

int TileSet::mTileWidth [private]

Tile Width.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines