diff --git a/.gitignore b/.gitignore index e70ad36..5c6bff4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,9 @@ ReleaseStatic /tmxlite/bin Debug Release +build *.swp +/.vscode /.vs/tmxlite /tmxlite/tmxlite.vcxproj.user diff --git a/ParseTest/maps/platform.tmx b/ParseTest/maps/platform.tmx index fb75d46..23c515a 100644 --- a/ParseTest/maps/platform.tmx +++ b/ParseTest/maps/platform.tmx @@ -1,10 +1,10 @@ - + - + @@ -12,7 +12,7 @@ - + eJzt2VsKwyAQBdCsoo8VNN3/BvvbQC1Em9iZOQeE/AQcyFXjLAuc69YxIKuePMgLVckCtNkz4LvrjgGVXHYMqGZPPuSFSuQCPrt3Dshudt/jOfAuZLfOngD8MfmANvkY43ya22P2BIKzvkCbfECbfECb8ykAAABnqNb/qlYvY6rdX0avV77PVe3+Mnq90fMNv/a+Z8gHbK2NZ2B7Jox+PqQO/8rQZi0HAAAAiCf7nWf2+jhW9v5u9vo41sj3E2Ftlg9GjPTMIvTbIswRYKYXswgSvA== diff --git a/ParseTest/src/main.cpp b/ParseTest/src/main.cpp index ccd05ff..3b41e7f 100644 --- a/ParseTest/src/main.cpp +++ b/ParseTest/src/main.cpp @@ -62,6 +62,14 @@ int main() } const auto& mapProperties = map.getProperties(); + std::cout << "Map class: " << map.getClass() << std::endl; + + std::cout << "Map tileset has " << map.getTilesets().size() << " tilesets" << std::endl; + for (const auto& tileset : map.getTilesets()) { + std::cout << "Tileset: " << tileset.getName() << std::endl; + std::cout << "Tileset class: " << tileset.getClass() << std::endl; + } + std::cout << "Map has " << mapProperties.size() << " properties" << std::endl; for (const auto& prop : mapProperties) { @@ -89,6 +97,7 @@ int main() { std::cout << "Found Layer: " << sublayer->getName() << std::endl; std::cout << "Sub-layer Type: " << LayerStrings[static_cast(sublayer->getType())] << std::endl; + std::cout << "Sub-layer Class: " << sublayer->getClass() << std::endl; std::cout << "Sub-layer Dimensions: " << sublayer->getSize() << std::endl; std::cout << "Sub-layer Tint: " << sublayer->getTintColour() << std::endl; diff --git a/tmxlite/include/tmxlite/Layer.hpp b/tmxlite/include/tmxlite/Layer.hpp index 26e2611..01d8fa1 100644 --- a/tmxlite/include/tmxlite/Layer.hpp +++ b/tmxlite/include/tmxlite/Layer.hpp @@ -82,6 +82,11 @@ namespace tmx */ virtual Type getType() const = 0; + /*! + \brief Returns the class of the Layer, as defined in the editor Tiled 1.9+ + */ + const std::string& getClass() const { return m_class; } + /*! \brief Use this to get a reference to the concrete layer type which this layer points to. @@ -146,6 +151,7 @@ namespace tmx protected: void setName(const std::string& name) { m_name = name; } + void setClass(const std::string& cls) { m_class = cls; } void setOpacity(float opacity) { m_opacity = opacity; } void setVisible(bool visible) { m_visible = visible; } void setOffset(std::int32_t x, std::int32_t y) { m_offset = Vector2i(x, y); } @@ -156,6 +162,7 @@ namespace tmx private: std::string m_name; + std::string m_class; float m_opacity; bool m_visible; Vector2i m_offset; diff --git a/tmxlite/include/tmxlite/Map.hpp b/tmxlite/include/tmxlite/Map.hpp index 00f4068..e9681ee 100644 --- a/tmxlite/include/tmxlite/Map.hpp +++ b/tmxlite/include/tmxlite/Map.hpp @@ -195,6 +195,11 @@ namespace tmx */ const std::vector& getLayers() const { return m_layers; } + /*! + \brief Returns the class of the Map, as defined in the editor Tiled 1.9+ + */ + const std::string& getClass() const { return m_class; } + /*! \brief Returns a vector of Property objects loaded by the map */ @@ -242,6 +247,7 @@ namespace tmx private: Version m_version; + std::string m_class; Orientation m_orientation; RenderOrder m_renderOrder; bool m_infinite; diff --git a/tmxlite/include/tmxlite/Object.hpp b/tmxlite/include/tmxlite/Object.hpp index cb3ff6d..d641cda 100644 --- a/tmxlite/include/tmxlite/Object.hpp +++ b/tmxlite/include/tmxlite/Object.hpp @@ -117,8 +117,8 @@ namespace tmx const std::string& getType() const { return m_class; } /*! - \brief Returns the class (equal to type) of the Object, as defined in the editor Tiled 1.9 - */ + \brief Returns the class (equal to type) of the Object, as defined in the editor Tiled 1.9+ + */ const std::string& getClass() const { return m_class; } /*! diff --git a/tmxlite/include/tmxlite/Tileset.hpp b/tmxlite/include/tmxlite/Tileset.hpp index 805b396..7ce963d 100644 --- a/tmxlite/include/tmxlite/Tileset.hpp +++ b/tmxlite/include/tmxlite/Tileset.hpp @@ -155,6 +155,11 @@ namespace tmx */ const std::string& getName() const { return m_name; } + /*! + \brief Returns the class of the Tileset, as defined in the editor Tiled 1.9+ + */ + const std::string& getClass() const { return m_class; } + /*! \brief Returns the width and height of a tile in the tile set, in pixels. @@ -260,6 +265,7 @@ namespace tmx std::uint32_t m_firstGID; std::string m_source; std::string m_name; + std::string m_class; Vector2u m_tileSize; std::uint32_t m_spacing; std::uint32_t m_margin; diff --git a/tmxlite/src/ImageLayer.cpp b/tmxlite/src/ImageLayer.cpp index 416e450..b2f44ad 100644 --- a/tmxlite/src/ImageLayer.cpp +++ b/tmxlite/src/ImageLayer.cpp @@ -57,6 +57,7 @@ void ImageLayer::parse(const pugi::xml_node& node, Map*) //TODO this gets repeated foreach layer type and could all be moved to base class... setName(node.attribute("name").as_string()); + setClass(node.attribute("class").as_string()); setOpacity(node.attribute("opacity").as_float(1.f)); setVisible(node.attribute("visible").as_bool(true)); setOffset(node.attribute("offsetx").as_int(0), node.attribute("offsety").as_int(0)); diff --git a/tmxlite/src/LayerGroup.cpp b/tmxlite/src/LayerGroup.cpp index c68a19e..04551b5 100644 --- a/tmxlite/src/LayerGroup.cpp +++ b/tmxlite/src/LayerGroup.cpp @@ -57,6 +57,7 @@ void LayerGroup::parse(const pugi::xml_node& node, Map* map) } setName(node.attribute("name").as_string()); + setClass(node.attribute("class").as_string()); setOpacity(node.attribute("opacity").as_float(1.f)); setVisible(node.attribute("visible").as_bool(true)); setOffset(node.attribute("offsetx").as_int(0), node.attribute("offsety").as_int(0)); diff --git a/tmxlite/src/Map.cpp b/tmxlite/src/Map.cpp index 610159f..5cb9ca7 100644 --- a/tmxlite/src/Map.cpp +++ b/tmxlite/src/Map.cpp @@ -143,6 +143,8 @@ bool Map::parseMapNode(const pugi::xml_node& mapNode) m_version.upper = STOI(attribString.substr(0, pointPos)); m_version.lower = STOI(attribString.substr(pointPos + 1)); + m_class = mapNode.attribute("class").as_string(); + attribString = mapNode.attribute("orientation").as_string(); if (attribString.empty()) { diff --git a/tmxlite/src/ObjectGroup.cpp b/tmxlite/src/ObjectGroup.cpp index a85ac09..6a9dbdf 100644 --- a/tmxlite/src/ObjectGroup.cpp +++ b/tmxlite/src/ObjectGroup.cpp @@ -56,6 +56,7 @@ void ObjectGroup::parse(const pugi::xml_node& node, Map* map) } setName(node.attribute("name").as_string()); + setClass(node.attribute("class").as_string()); attribString = node.attribute("color").as_string(); if (!attribString.empty()) diff --git a/tmxlite/src/TileLayer.cpp b/tmxlite/src/TileLayer.cpp index a184fa1..8049bd1 100644 --- a/tmxlite/src/TileLayer.cpp +++ b/tmxlite/src/TileLayer.cpp @@ -72,6 +72,7 @@ void TileLayer::parse(const pugi::xml_node& node, Map*) } setName(node.attribute("name").as_string()); + setClass(node.attribute("class").as_string()); setOpacity(node.attribute("opacity").as_float(1.f)); setVisible(node.attribute("visible").as_bool(true)); setOffset(node.attribute("offsetx").as_int(0), node.attribute("offsety").as_int(0)); diff --git a/tmxlite/src/Tileset.cpp b/tmxlite/src/Tileset.cpp index 462b8e8..c261fae 100644 --- a/tmxlite/src/Tileset.cpp +++ b/tmxlite/src/Tileset.cpp @@ -109,6 +109,7 @@ void Tileset::parse(pugi::xml_node node, Map* map) m_name = node.attribute("name").as_string(); LOG("found tile set " + m_name, Logger::Type::Info); + m_class = node.attribute("class").as_string(); m_tileSize.x = node.attribute("tilewidth").as_int(); m_tileSize.y = node.attribute("tileheight").as_int(); @@ -253,6 +254,7 @@ void Tileset::reset() m_firstGID = 0; m_source = ""; m_name = ""; + m_class = ""; m_tileSize = { 0,0 }; m_spacing = 0; m_margin = 0;