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

#include <Tileset.hpp>

Public Member Functions

 Tileset ()=default
 
 Tileset (IJson &json, tson::Map *map)
 
bool parse (IJson &json, tson::Map *map)
 
int getColumns () const
 
int getFirstgid () const
 
const fs::path & getImagePath () const
 
const fs::path & getImage () const
 
const Vector2igetImageSize () const
 
int getMargin () const
 
const std::string & getName () const
 
int getSpacing () const
 
int getTileCount () const
 
const Vector2igetTileSize () const
 
const ColorigetTransparentColor () const
 
const std::string & getType () const
 
const std::string & getClassType () const
 
tson::TiledClassgetClass ()
 
std::vector< tson::Tile > & getTiles ()
 
const std::vector< tson::WangSet > & getWangsets () const
 
PropertyCollectiongetProperties ()
 
const std::vector< tson::Terrain > & getTerrains () const
 
const Vector2igetTileOffset () const
 
const GridgetGrid () const
 
TileRenderSize getTileRenderSize () const
 
FillMode getFillMode () const
 
tson::TilegetTile (uint32_t id)
 
tson::TerraingetTerrain (const std::string &name)
 
template<typename T >
get (const std::string &name)
 
tson::PropertygetProp (const std::string &name)
 
tson::MapgetMap () const
 
ObjectAlignment getObjectAlignment () const
 
tson::Vector2i getMarginSpacingOffset (const tson::Vector2i &posInTileUnits)
 
tson::WangSetgetWangset (const std::string &name)
 
const TransformationsgetTransformations () const
 

Static Public Member Functions

static tson::ObjectAlignment StringToAlignment (std::string_view str)
 

Constructor & Destructor Documentation

◆ Tileset() [1/2]

tson::Tileset::Tileset ( )
inlinedefault

◆ Tileset() [2/2]

tson::Tileset::Tileset ( IJson json,
tson::Map map 
)
inlineexplicit

Member Function Documentation

◆ get()

template<typename T >
T tson::Tileset::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.

◆ getClass()

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

◆ getClassType()

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

◆ getColumns()

int tson::Tileset::getColumns ( ) const
inline

'columns': The number of tile columns in the tileset

Returns

◆ getFillMode()

tson::FillMode tson::Tileset::getFillMode ( ) const
inline

◆ getFirstgid()

int tson::Tileset::getFirstgid ( ) const
inline

'firstgid': GID corresponding to the first tile in the set

Returns

◆ getGrid()

const tson::Grid & tson::Tileset::getGrid ( ) const
inline

'grid': This element is only used in case of isometric orientation, and determines how tile overlays for terrain and collision information are rendered.

Returns

◆ getImage()

const fs::path & tson::Tileset::getImage ( ) const
inline

'image': Image used for tiles in this set

Returns

◆ getImagePath()

const fs::path & tson::Tileset::getImagePath ( ) const
inline

'image': Image used for tiles in this set

Returns

◆ getImageSize()

const tson::Vector2i & tson::Tileset::getImageSize ( ) const
inline

x = 'imagewidth' and y = 'imageheight': in pixels

Returns

◆ getMap()

tson::Map * tson::Tileset::getMap ( ) const
inline

Used for getting the tson::Map who is the parent of this Tileset.

Returns
a pointer to the tson::Map where this tileset is contained.

◆ getMargin()

int tson::Tileset::getMargin ( ) const
inline

'margin': Buffer between image edge and first tile (pixels)

Returns

◆ getMarginSpacingOffset()

tson::Vector2i tson::Tileset::getMarginSpacingOffset ( const tson::Vector2i posInTileUnits)
inline

Helper function to calculate the correct additional offset when margin and/or spacing is used in a tileset Created to solve issue #31.

Parameters
posInTileUnitsPosition of the current tile in tile units.
Returns
Calculated additional offset in pixels.

◆ getName()

const std::string & tson::Tileset::getName ( ) const
inline

'name': Name given to this tileset

Returns

◆ getObjectAlignment()

tson::ObjectAlignment tson::Tileset::getObjectAlignment ( ) const
inline

◆ getProp()

tson::Property * tson::Tileset::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::Tileset::getProperties ( )
inline

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

Returns

◆ getSpacing()

int tson::Tileset::getSpacing ( ) const
inline

'spacing': Spacing between adjacent tiles in image (pixels)

Returns

◆ getTerrain()

tson::Terrain * tson::Tileset::getTerrain ( const std::string &  name)
inline

Get an existing Terrain object by name

Parameters
name
Returns
A pointer to the Terrain if found. nullptr otherwise.

◆ getTerrains()

const std::vector< tson::Terrain > & tson::Tileset::getTerrains ( ) const
inline

'terrains': Array of Terrains (optional)

Returns

◆ getTile()

tson::Tile * tson::Tileset::getTile ( uint32_t  id)
inline

Gets a tile by ID (Tiled ID + 1)

Parameters
idThe ID of the tile stored in Tiled map + 1. Example: If ID was stored in Tiled map as 0, the corresponding value in Tileson is 1. This is to make sure the IDs of tiles matches their references in containers.
Returns
A pointer to the Tile if found. nullptr otherwise.

◆ getTileCount()

int tson::Tileset::getTileCount ( ) const
inline

'tilecount': The number of tiles in this tileset

Returns

◆ getTileOffset()

const tson::Vector2i & tson::Tileset::getTileOffset ( ) const
inline

'x' and 'y': See <tileoffset> (optional)

Returns

◆ getTileRenderSize()

tson::TileRenderSize tson::Tileset::getTileRenderSize ( ) const
inline

◆ getTiles()

std::vector< tson::Tile > & tson::Tileset::getTiles ( )
inline

Declared in tileson_forward.hpp

'tiles': Array of Tiles (optional)

Returns

◆ getTileSize()

const tson::Vector2i & tson::Tileset::getTileSize ( ) const
inline

x = 'tilewidth' and y = 'tileheight': Maximum size of tiles in this set

Returns

◆ getTransformations()

const tson::Transformations & tson::Tileset::getTransformations ( ) const
inline

New in Tiled v1.5 - This element is used to describe which transformations can be applied to the tiles (e.g. to extend a Wang set by transforming existing tiles).

Returns

◆ getTransparentColor()

const tson::Colori & tson::Tileset::getTransparentColor ( ) const
inline

'transparentcolor': Color object created by hex-formatted color (#RRGGBB) (optional)

Returns

◆ getType()

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

'type': tileset (for tileset files, since 1.0)

Returns

◆ getWangset()

tson::WangSet * tson::Tileset::getWangset ( const std::string &  name)
inline

Get a wangset by name

Parameters
name
Returns

◆ getWangsets()

const std::vector< tson::WangSet > & tson::Tileset::getWangsets ( ) const
inline

'wangsets':Array of Wang sets (since Tiled 1.1.5)

Returns

◆ parse()

bool tson::Tileset::parse ( IJson json,
tson::Map map 
)
inline

◆ StringToAlignment()

tson::ObjectAlignment tson::Tileset::StringToAlignment ( std::string_view  str)
inlinestatic
Parameters
strThe string you want to convert
Returns
Alignment enum based on the string from the input.

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