Tileson 1.4.0
A helpful json parser for Tiled maps
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
tson::Map Class Reference

#include <Map.hpp>

Public Member Functions

 Map ()=default
 
 Map (ParseStatus status, std::string description)
 
 Map (IJson &json, tson::DecompressorContainer *decompressors, tson::Project *project, tson::LinkedFileParser linkedFileParser=nullptr)
 
bool parse (IJson &json, tson::DecompressorContainer *decompressors, tson::Project *project, tson::LinkedFileParser linkedFileParser=nullptr)
 
const ColorigetBackgroundColor () const
 
const Vector2igetSize () const
 
int getHexsideLength () const
 
bool isInfinite () const
 
int getNextLayerId () const
 
int getNextObjectId () const
 
const std::string & getOrientation () const
 
const std::string & getRenderOrder () const
 
const std::string & getStaggerAxis () const
 
const std::string & getStaggerIndex () const
 
const std::string & getTiledVersion () const
 
const Vector2igetTileSize () const
 
const std::string & getType () const
 
const std::string & getClassType () const
 
tson::TiledClassgetClass ()
 
const Vector2fgetParallaxOrigin () const
 
std::vector< tson::Layer > & getLayers ()
 
PropertyCollectiongetProperties ()
 
std::vector< tson::Tileset > & getTilesets ()
 
ParseStatus getStatus () const
 
const std::string & getStatusMessage () const
 
const std::map< uint32_t, tson::Tile * > & getTileMap () const
 
LayergetLayer (const std::string &name)
 
TilesetgetTileset (const std::string &name)
 
template<typename T >
get (const std::string &name)
 
tson::PropertygetProp (const std::string &name)
 
int getCompressionLevel () const
 
DecompressorContainergetDecompressors ()
 
ProjectgetProject ()
 
TilesetgetTilesetByGid (uint32_t gid)
 

Friends

class Object
 

Constructor & Destructor Documentation

◆ Map() [1/3]

tson::Map::Map ( )
inlinedefault

◆ Map() [2/3]

tson::Map::Map ( tson::ParseStatus  status,
std::string  description 
)
inline

When errors have happened before the map starts parsing, just keep the statuses

Parameters
statusThe status
descriptionDescription of the status

◆ Map() [3/3]

tson::Map::Map ( IJson json,
tson::DecompressorContainer decompressors,
tson::Project project,
tson::LinkedFileParser  linkedFileParser = nullptr 
)
inlineexplicit

Parses a json of a Tiled map.

Parameters
jsonA json object with the format of Map
linkedFileParserA callback function that must return a IJson object when a linked file is found in the map
Returns
true if all mandatory fields was found. false otherwise.

Member Function Documentation

◆ get()

template<typename T >
T tson::Map::get ( const std::string &  name)
inline

A shortcut for getting a property. Alternative to getProperties().getValue<T>("<name>")

Template Parameters
TThe template value
Parameters
nameName of the property
Returns
The actual value, if it exists. Otherwise: The default value of the type.

◆ getBackgroundColor()

const tson::Colori & tson::Map::getBackgroundColor ( ) const
inline

'backgroundcolor': Color created from a hex-formatted color string (#RRGGBB or #AARRGGBB) (optional)

Returns
string as color

◆ getClass()

tson::TiledClass * tson::Map::getClass ( )
inline

T I L E S O N F O R W A R D D E C L A R A T I O N S

Due to cross-references we have forward declarations that cannot be resolved during the implementation, thus the implementations must be done later when the class definition itself is known.

All those forward declarations can be found below.

◆ getClassType()

const std::string & tson::Map::getClassType ( ) const
inline

◆ getCompressionLevel()

int tson::Map::getCompressionLevel ( ) const
inline

'compressionlevel': The compression level to use for tile layer data (defaults to -1, which means to use the algorithm default)

Returns
The compression level

◆ getDecompressors()

tson::DecompressorContainer * tson::Map::getDecompressors ( )
inline

◆ getHexsideLength()

int tson::Map::getHexsideLength ( ) const
inline

'hexsidelength': Length of the side of a hex tile in pixels

Returns

◆ getLayer()

tson::Layer * tson::Map::getLayer ( const std::string &  name)
inline

◆ getLayers()

std::vector< tson::Layer > & tson::Map::getLayers ( )
inline

'version': The JSON format version

Returns

'layers': Array of layers. group on

Returns

◆ getNextLayerId()

int tson::Map::getNextLayerId ( ) const
inline

'nextlayerid': Auto-increments for each layer

Returns

◆ getNextObjectId()

int tson::Map::getNextObjectId ( ) const
inline

'nextobjectid': Auto-increments for each placed object

Returns

◆ getOrientation()

const std::string & tson::Map::getOrientation ( ) const
inline

'orientation': orthogonal, isometric, staggered or hexagonal

Returns

◆ getParallaxOrigin()

const tson::Vector2f & tson::Map::getParallaxOrigin ( ) const
inline

Declared in tileson_forward.hpp

New in Tiled v1.8 Gets the parallax origin in pixels. Defaults to 0.

Returns
A vector with the x and y values of the parallax origin.

◆ getProject()

tson::Project * tson::Map::getProject ( )
inline

◆ getProp()

tson::Property * tson::Map::getProp ( const std::string &  name)
inline

Shortcut for getting a property object. Alternative to getProperties().getProperty("<name>");

Parameters
nameName of the property
Returns

◆ getProperties()

tson::PropertyCollection & tson::Map::getProperties ( )
inline

'properties': A list of properties (name, value, type).

Returns

◆ getRenderOrder()

const std::string & tson::Map::getRenderOrder ( ) const
inline

'renderorder': Rendering direction (orthogonal maps only)

Returns

◆ getSize()

const tson::Vector2< int > & tson::Map::getSize ( ) const
inline

'width' and 'height' of a Tiled map

Returns

◆ getStaggerAxis()

const std::string & tson::Map::getStaggerAxis ( ) const
inline

'staggeraxis': x or y (staggered / hexagonal maps only)

Returns

◆ getStaggerIndex()

const std::string & tson::Map::getStaggerIndex ( ) const
inline

'staggerindex': odd or even (staggered / hexagonal maps only)

Returns

◆ getStatus()

tson::ParseStatus tson::Map::getStatus ( ) const
inline

◆ getStatusMessage()

const std::string & tson::Map::getStatusMessage ( ) const
inline

◆ getTiledVersion()

const std::string & tson::Map::getTiledVersion ( ) const
inline

'tiledversion': The Tiled version used to save the file

Returns

◆ getTileMap()

const std::map< uint32_t, tson::Tile * > & tson::Map::getTileMap ( ) const
inline

Get a tile map with pointers to every existing tile.

Returns

◆ getTileset()

tson::Tileset * tson::Map::getTileset ( const std::string &  name)
inline

Gets a tileset by name

Parameters
nameName of the tileset
Returns
tileset with the matching name

◆ getTilesetByGid()

tson::Tileset * tson::Map::getTilesetByGid ( uint32_t  gid)
inline

Gets a tileset by gid (graphical ID of a tile). These are always unique, no matter how many tilesets you have

Parameters
gidGraphical ID of a tile
Returns
tileset related to the actual gid

◆ getTilesets()

std::vector< tson::Tileset > & tson::Map::getTilesets ( )
inline

'tilesets': Array of Tilesets

Returns

◆ getTileSize()

const tson::Vector2< int > & tson::Map::getTileSize ( ) const
inline

'tilewidth': and 'tileheight' of a map

Returns

◆ getType()

const std::string & tson::Map::getType ( ) const
inline

'type': map (since 1.0)

Returns

◆ isInfinite()

bool tson::Map::isInfinite ( ) const
inline

'infinite': Whether the map has infinite dimensions

Returns

◆ parse()

bool tson::Map::parse ( IJson json,
tson::DecompressorContainer decompressors,
tson::Project project,
tson::LinkedFileParser  linkedFileParser = nullptr 
)
inline

Parses a json of a Tiled map.

Parameters
jsonA json object with the format of Map
linkedFileParserA callback function that must return a IJson object when a linked file is found in the map
Returns
true if all mandatory fields was found. false otherwise.

Friends And Related Symbol Documentation

◆ Object

friend class Object
friend

The documentation for this class was generated from the following files: