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

Public Member Functions

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

Static Public Member Functions

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

Private Member Functions

void generateMissingTiles ()
 

Private Attributes

std::shared_ptr< tson::TiledClassm_class {}
 
std::string m_classType {}
 
int m_columns {}
 
FillMode m_fillMode {}
 
int m_firstgid {}
 
tson::Grid m_grid
 
fs::path m_image
 
tson::Vector2i m_imageSize
 
tson::Mapm_map
 
int m_margin {}
 
std::string m_name
 
tson::ObjectAlignment m_objectAlignment {tson::ObjectAlignment::Unspecified}
 
fs::path m_path {}
 
tson::PropertyCollection m_properties
 
fs::path m_source {}
 
int m_spacing {}
 
std::vector< tson::Terrainm_terrains
 
int m_tileCount {}
 
tson::Vector2i m_tileOffset
 
TileRenderSize m_tileRenderSize {}
 
std::vector< tson::Tilem_tiles
 
tson::Vector2i m_tileSize
 
Transformations m_transformations {}
 
tson::Colori m_transparentColor
 
std::string m_type
 
std::vector< tson::WangSetm_wangsets
 

Member Function Documentation

◆ generateMissingTiles()

void tson::Tileset::generateMissingTiles ( )
inlineprivate

Tiled only has tiles with a property stored in the map. This function makes sure even the ones with no properties will exist.

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

◆ getColumns()

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

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

Returns

◆ 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

◆ 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

◆ 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

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

Field Documentation

◆ m_class

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

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

◆ m_classType

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

'fillmode': The fill mode to use when rendering tiles from this tileset. Valid values are 'stretch' (the default) and 'preserve-aspect-fit'. Only relevant when the tiles are not rendered at their native size, so this applies to resized tile objects or in combination with 'tilerendersize' set to 'grid'. (since 1.9)

◆ m_fillMode

FillMode tson::Tileset::m_fillMode {}
private

'tilerendersize': The size to use when rendering tiles from this tileset on a tile layer. Valid values are 'tile' (the default) and 'grid'. When set to 'grid', the tile is drawn at the tile grid size of the map. (since 1.9)

◆ m_firstgid

int tson::Tileset::m_firstgid {}
private

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

◆ m_grid

tson::Grid tson::Tileset::m_grid
private

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

◆ m_image

fs::path tson::Tileset::m_image
private

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

◆ m_imageSize

tson::Vector2i tson::Tileset::m_imageSize
private

'image': Image used for tiles in this set

◆ m_map

tson::Map* tson::Tileset::m_map
private

'objectalignment': Alignment to use for tile objects. Tiled 1.4.

◆ m_margin

int tson::Tileset::m_margin {}
private

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

◆ m_name

std::string tson::Tileset::m_name
private

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

◆ m_objectAlignment

tson::ObjectAlignment tson::Tileset::m_objectAlignment {tson::ObjectAlignment::Unspecified}
private

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

◆ m_path

fs::path tson::Tileset::m_path {}
private

'source': exists only when tileset is contained in an external file

◆ m_properties

tson::PropertyCollection tson::Tileset::m_properties
private

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

◆ m_source

fs::path tson::Tileset::m_source {}
private

The map who owns this tileset

◆ m_spacing

int tson::Tileset::m_spacing {}
private

'name': Name given to this tileset

◆ m_terrains

std::vector<tson::Terrain> tson::Tileset::m_terrains
private

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

◆ m_tileCount

int tson::Tileset::m_tileCount {}
private

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

◆ m_tileOffset

tson::Vector2i tson::Tileset::m_tileOffset
private

'terrains': Array of Terrains (optional)

◆ m_tileRenderSize

TileRenderSize tson::Tileset::m_tileRenderSize {}
private

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

◆ m_tiles

std::vector<tson::Tile> tson::Tileset::m_tiles
private

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

◆ m_tileSize

tson::Vector2i tson::Tileset::m_tileSize
private

'tilecount': The number of tiles in this tileset

◆ m_transformations

Transformations tson::Tileset::m_transformations {}
private

Has the full path to the tileset if 'source' has an existing value

◆ m_transparentColor

tson::Colori tson::Tileset::m_transparentColor
private

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

◆ m_type

std::string tson::Tileset::m_type
private

'transparentcolor': Hex-formatted color (#RRGGBB) (optional)

◆ m_wangsets

std::vector<tson::WangSet> tson::Tileset::m_wangsets
private

'tiles': Array of Tiles (optional)


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