30#include <tmxlite/Tileset.hpp>
31#include <tmxlite/Layer.hpp>
32#include <tmxlite/Property.hpp>
33#include <tmxlite/Types.hpp>
34#include <tmxlite/Object.hpp>
39#include <unordered_map>
51 Version(std::uint16_t maj = 0, std::uint16_t min = 0)
52 : upper(maj), lower(min) {}
55 enum class Orientation
64 enum class RenderOrder
73 enum class StaggerAxis
78 enum class StaggerIndex
93 class TMXLITE_EXPORT_API
Map final
100 Map& operator = (
const Map&) =
delete;
102 Map& operator = (
Map&&) =
default;
154 FloatRect getBounds()
const {
return FloatRect(0.f, 0.f,
static_cast<float>(m_tileCount.x * m_tileSize.x),
static_cast<float>(m_tileCount.y * m_tileSize.y)); }
188 const std::vector<Tileset>&
getTilesets()
const {
return m_tilesets; }
196 const std::vector<Layer::Ptr>&
getLayers()
const {
return m_layers; }
201 const std::string&
getClass()
const {
return m_class; }
211 const std::map<std::uint32_t, Tileset::Tile>&
getAnimatedTiles()
const {
return m_animTiles; }
223 const std::unordered_map<std::string, Object>& getTemplateObjects()
const {
return m_templateObjects; }
232 const std::unordered_map<std::string, Tileset>& getTemplateTilesets()
const {
return m_templateTilesets; }
246 Vector2f getParallaxOrigin()
const {
return m_parallaxOrigin; }
251 Orientation m_orientation;
252 RenderOrder m_renderOrder;
255 Vector2u m_tileCount;
258 float m_hexSideLength;
259 StaggerAxis m_staggerAxis;
260 StaggerIndex m_staggerIndex;
262 Vector2f m_parallaxOrigin;
264 Colour m_backgroundColour;
266 std::string m_workingDirectory;
268 std::vector<Tileset> m_tilesets;
269 std::vector<Layer::Ptr> m_layers;
270 std::vector<Property> m_properties;
271 std::map<std::uint32_t, Tileset::Tile> m_animTiles;
273 std::unordered_map<std::string, Object> m_templateObjects;
274 std::unordered_map<std::string, Tileset> m_templateTilesets;
276 bool parseMapNode(
const pugi::xml_node&);
Parser for TMX format tile maps. This class can be used to parse the XML format tile maps created wit...
Definition Map.hpp:94
bool load(const std::string &)
Attempts to parse the tilemap at the given location.
bool loadFromString(const std::string &data, const std::string &workingDir)
Loads a map from a document stored in a string.
FloatRect getBounds() const
Returns the bounds of the map.
Definition Map.hpp:154
const Vector2u & getTileSize() const
Returns the size of the tile grid in this map. Actual tile sizes may vary and will be extended / shru...
Definition Map.hpp:149
StaggerIndex getStaggerIndex() const
Stagger Index of the loaded map. If a Staggered or Hexagonal map is loaded this returns whether the e...
Definition Map.hpp:178
StaggerAxis getStaggerAxis() const
Stagger axis of the map. If either a Staggered or Hexagonal tile map is loaded this returns which axi...
Definition Map.hpp:171
const std::vector< Tileset > & getTilesets() const
Returns a reference to the vector of tile sets used by the map.
Definition Map.hpp:188
const std::string & getClass() const
Returns the class of the Map, as defined in the editor Tiled 1.9+.
Definition Map.hpp:201
std::unordered_map< std::string, Tileset > & getTemplateTilesets()
Returns an unordered_map of tilesets used by templated objects. If Object::getTilesetName() is not em...
Definition Map.hpp:231
Orientation getOrientation() const
Returns the orientation of the map if one is loaded, else returns None.
Definition Map.hpp:131
float getHexSideLength() const
Returns the length of an edge of a tile if a Hexagonal map is loaded. The length returned is in pixel...
Definition Map.hpp:164
const std::vector< Layer::Ptr > & getLayers() const
Returns a reference to the vector containing the layer data. Layers are pointer-to-baseclass,...
Definition Map.hpp:196
const std::map< std::uint32_t, Tileset::Tile > & getAnimatedTiles() const
Returns a Hashmap of all animated tiles accessible by TileID.
Definition Map.hpp:211
const Colour & getBackgroundColour() const
Returns the background colour of the map.
Definition Map.hpp:183
std::unordered_map< std::string, Object > & getTemplateObjects()
Returns an unordered_map of template objects indexed by file name.
Definition Map.hpp:222
const std::vector< Property > & getProperties() const
Returns a vector of Property objects loaded by the map.
Definition Map.hpp:206
const Version & getVersion() const
Returns the version of the tile map last parsed. If no tile map has yet been parsed the version will ...
Definition Map.hpp:125
const std::string & getWorkingDirectory() const
Returns the current working directory of the map. Images and other resources are loaded relative to t...
Definition Map.hpp:217
RenderOrder getRenderOrder() const
Returns the RenderOrder of the map if one is loaded, else returns None.
Definition Map.hpp:137
const Vector2u & getTileCount() const
Returns the tile count of the map in the X and Y directions.
Definition Map.hpp:142
bool isInfinite() const
Returns true if this is in infinite tile map. Infinite maps store their tile data in for tile layers ...
Definition Map.hpp:241
Contains the red, green, blue and alpha values of a colour in the range 0 - 255.
Definition Types.hpp:111
Holds the xml version of the loaded map.
Definition Map.hpp:47