Uranus  1.0.1.0
Uranus is a GameEngine written in C++
Loading...
Searching...
No Matches
tson::Map Class Reference
Collaboration diagram for tson::Map:
[legend]

Public Member Functions

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

Private Member Functions

bool createTilesetData (IJson &json)
 
void processData ()
 

Private Attributes

Colori m_backgroundColor
 
std::shared_ptr< tson::TiledClassm_class {}
 
std::string m_classType {}
 
int m_compressionLevel {-1}
 
tson::DecompressorContainerm_decompressors {nullptr}
 
std::map< uint32_t, tson::Tilem_flaggedTileMap {}
 
int m_hexsideLength {}
 
bool m_isInfinite {}
 
std::vector< tson::Layerm_layers
 
int m_nextLayerId {}
 
int m_nextObjectId {}
 
std::string m_orientation
 
tson::Vector2f m_parallaxOrigin
 
tson::Projectm_project {nullptr}
 
tson::PropertyCollection m_properties
 
std::string m_renderOrder
 
Vector2i m_size
 
std::string m_staggerAxis
 
std::string m_staggerIndex
 
ParseStatus m_status {ParseStatus::OK}
 
std::string m_statusMessage {"OK"}
 
std::string m_tiledVersion
 
std::map< uint32_t, tson::Tile * > m_tileMap {}
 
std::vector< tson::Tilesetm_tilesets
 
Vector2i m_tileSize
 
std::string m_type
 

Constructor & Destructor Documentation

◆ Map() [1/2]

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() [2/2]

tson::Map::Map ( IJson json,
tson::DecompressorContainer decompressors,
tson::Project project 
)
inlineexplicit

Parses a json of a Tiled map.

Parameters
jsonA json object with the format of Map
Returns
true if all mandatory fields was found. false otherwise.

Member Function Documentation

◆ createTilesetData()

bool tson::Map::createTilesetData ( IJson json)
inlineprivate

Tileset data must be created in two steps to prevent malformed tson::Tileset pointers inside tson::Tile

◆ 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.

◆ 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

◆ getHexsideLength()

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

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

Returns

◆ 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.

◆ 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

◆ 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 
)
inline

Parses a json of a Tiled map.

Parameters
jsonA json object with the format of Map
Returns
true if all mandatory fields was found. false otherwise.

◆ processData()

void tson::Map::processData ( )
inlineprivate

Processes the parsed data and uses the data to create helpful objects, like tile maps.

Field Documentation

◆ m_class

std::shared_ptr<tson::TiledClass> tson::Map::m_class {}
private

'class': The class of this map (since 1.9, defaults to “”).

◆ m_classType

std::string tson::Map::m_classType {}
private

key: Tile ID. Value: Tile

◆ m_compressionLevel

int tson::Map::m_compressionLevel {-1}
private

key: Tile ID. Value: Pointer to Tile

◆ m_decompressors

tson::DecompressorContainer* tson::Map::m_decompressors {nullptr}
private

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

◆ m_hexsideLength

int tson::Map::m_hexsideLength {}
private

'width' and 'height' of a Tiled map

◆ m_isInfinite

bool tson::Map::m_isInfinite {}
private

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

◆ m_layers

std::vector<tson::Layer> tson::Map::m_layers
private

'infinite': Whether the map has infinite dimensions

◆ m_nextLayerId

int tson::Map::m_nextLayerId {}
private

'layers': Array of layers. group on

◆ m_nextObjectId

int tson::Map::m_nextObjectId {}
private

'nextlayerid': Auto-increments for each layer

◆ m_orientation

std::string tson::Map::m_orientation
private

'nextobjectid': Auto-increments for each placed object

◆ m_parallaxOrigin

tson::Vector2f tson::Map::m_parallaxOrigin
private

'type': map (since 1.0)

◆ m_properties

tson::PropertyCollection tson::Map::m_properties
private

'orientation': orthogonal, isometric, staggered or hexagonal

◆ m_renderOrder

std::string tson::Map::m_renderOrder
private

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

◆ m_size

Vector2i tson::Map::m_size
private

'backgroundcolor': Hex-formatted color (#RRGGBB or #AARRGGBB) (optional)

◆ m_staggerAxis

std::string tson::Map::m_staggerAxis
private

'renderorder': Rendering direction (orthogonal maps only)

◆ m_staggerIndex

std::string tson::Map::m_staggerIndex
private

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

◆ m_status

ParseStatus tson::Map::m_status {ParseStatus::OK}
private

Tiled v1.8: parallax origin in pixels. Defaults to 0.

◆ m_tiledVersion

std::string tson::Map::m_tiledVersion
private

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

◆ m_tilesets

std::vector<tson::Tileset> tson::Map::m_tilesets
private

'tilewidth': and 'tileheight' of a map

◆ m_tileSize

Vector2i tson::Map::m_tileSize
private

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

◆ m_type

std::string tson::Map::m_type
private

'tilesets': Array of Tilesets


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