From a2a00843b039e94f5ba3aad03317a5644b539c23 Mon Sep 17 00:00:00 2001 From: Adaleigh Martin Date: Thu, 8 Feb 2018 19:51:46 -0800 Subject: [PATCH 1/2] 2.1.0 Release Prep --- CHANGELOG.md | 14 +++++++++++++- LICENSE | 3 ++- README.md | 5 +++-- src/TmxGroupLayer.cpp | 2 +- src/TmxGroupLayer.h | 4 ++-- test/test.cpp | 3 ++- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 101c129..09a3308 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -### Next release +### 2.1.0 * georgerbr: - Make tileset parsing not depend on optional attrs of @@ -41,6 +41,18 @@ * Tardo: - Get tile by index + * dylanetaft + - TinyXML2 6.x GetErrStr1 -> ErrorStr + - Support for Object Group in Tile + + * Adaleigh Martin (sainteos): + - Add cstdlib include for TmxColor for std::strtol, Clarify C++11 Requirement + - Travis-CI Integration + - Denote TMX v0.18 version support, tinyxml2 version requirement, and Test Running Instructions + - Implement Group Layers as specified by TMX v1.0 + - Test for object types + - Implement Text Object (TmxText) and corresponding test. + ### 2.0.1 * georgerbr: diff --git a/LICENSE b/LICENSE index f06b52d..24c7270 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,6 @@ Copyright (c) 2010-2014, Tamir Atias Copyright (c) 2014, Andrew Kelley +Copyright (c) 2018, Adaleigh Martin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -43,4 +44,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index ebcc3fc..416095f 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,13 @@ An example file is provided to understand how to use the library. ## Features - * Conformity with the [TMX specification page](http://doc.mapeditor.org/en/latest/reference/tmx-map-format/). (Current Version Support is 0.18) + * Conformity with the [TMX specification page](http://doc.mapeditor.org/en/latest/reference/tmx-map-format/). (Current Version Support is 1.0) * Decodes and decompresses tile data. - * Can parse properties as both integers, real numbers and literals (strings). + * Can parse properties as integers, real numbers, and literals (strings). * Can parse the map file when stored in memory. * Does not rely on any graphics library. * Animated tile support. + * Group Layer support. ## Dependencies diff --git a/src/TmxGroupLayer.cpp b/src/TmxGroupLayer.cpp index 63e53a7..eed8bdd 100644 --- a/src/TmxGroupLayer.cpp +++ b/src/TmxGroupLayer.cpp @@ -13,7 +13,7 @@ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY +// DISCLAIMED. IN NO EVENT SHALL ADALEIGH MARTIN BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND diff --git a/src/TmxGroupLayer.h b/src/TmxGroupLayer.h index 6cf1b40..b35c9b5 100644 --- a/src/TmxGroupLayer.h +++ b/src/TmxGroupLayer.h @@ -13,7 +13,7 @@ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY +// DISCLAIMED. IN NO EVENT SHALL ADALEIGH MARTIN BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND @@ -51,7 +51,7 @@ namespace Tmx void AddChild(Tmx::Layer* childLayer); Tmx::Layer* GetChild(const int index) const; - + /// Returns a variable containing information /// about the image of the ImageLayer. const std::vector GetChildren() const noexcept; diff --git a/test/test.cpp b/test/test.cpp index 068be19..e45bcce 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,5 +1,6 @@ //----------------------------------------------------------------------------- // Copyright (c) 2010-2014, Tamir Atias +// Copyright (c) 2018 Adaleigh Martin // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -13,7 +14,7 @@ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY +// DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS OR ADALEIGH MARTIN BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND From 6806eb8ea267a92222c6f673eec71ecd9656bcd9 Mon Sep 17 00:00:00 2001 From: Adaleigh Martin Date: Fri, 9 Feb 2018 13:42:01 -0800 Subject: [PATCH 2/2] Add optional 'type' to TmxTile. --- CHANGELOG.md | 1 + src/TmxTile.cpp | 14 ++++++++++---- src/TmxTile.h | 14 +++++++++++--- test/test.cpp | 4 +++- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09a3308..e8af5f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ - Implement Group Layers as specified by TMX v1.0 - Test for object types - Implement Text Object (TmxText) and corresponding test. + - Update Tile with optional Type ### 2.0.1 diff --git a/src/TmxTile.cpp b/src/TmxTile.cpp index 85ef74f..d6eead1 100644 --- a/src/TmxTile.cpp +++ b/src/TmxTile.cpp @@ -33,11 +33,11 @@ namespace Tmx { Tile::Tile() : - id(0), properties(), isAnimated(false), hasObjects(false), hasObjectGroup(false), objectGroup(NULL), totalDuration(0), image(NULL) + id(0), properties(), isAnimated(false), hasObjects(false), hasObjectGroup(false), objectGroup(NULL), totalDuration(0), image(NULL), type() { } Tile::Tile(int id) : - id(id), properties(), isAnimated(false), hasObjects(false), hasObjectGroup(false), objectGroup(NULL), totalDuration(0), image(NULL) + id(id), properties(), isAnimated(false), hasObjects(false), hasObjectGroup(false), objectGroup(NULL), totalDuration(0), image(NULL), type() { } @@ -62,6 +62,12 @@ namespace Tmx // Parse the attributes. id = tileElem->IntAttribute("id"); + // Parse tile type if it has one. + if(tileElem->FindAttribute("type")) + { + type = std::string(tileElem->Attribute("type")); + } + // Parse the properties if any. const tinyxml2::XMLNode *propertiesNode = tileNode->FirstChildElement( "properties"); @@ -100,7 +106,7 @@ namespace Tmx totalDuration = durationSum; } - + const tinyxml2::XMLNode *objectGroupNode = tileNode->FirstChildElement( "objectgroup"); if (objectGroupNode) @@ -110,7 +116,7 @@ namespace Tmx objectGroup = new ObjectGroup(this); objectGroup->Parse(objectGroupNode); if (objectGroup->GetNumObjects() > 0) hasObjects = true; - + } const tinyxml2::XMLNode *imageNode = tileNode->FirstChildElement("image"); diff --git a/src/TmxTile.h b/src/TmxTile.h index 3811e15..3546038 100644 --- a/src/TmxTile.h +++ b/src/TmxTile.h @@ -29,6 +29,7 @@ #include "TmxImage.h" #include "TmxObjectGroup.h" #include +#include namespace tinyxml2 { @@ -89,6 +90,12 @@ namespace Tmx return image; } + /// Returns the object type of the tile. + std::string GetType() const + { + return type; + } + /// Returns the frames of the animation. const std::vector &GetFrames() const { @@ -100,20 +107,20 @@ namespace Tmx { return properties; } - + //// Get the object group, which contains additional tile properties const Tmx::ObjectGroup *GetObjectGroup() const { return objectGroup; } - + //// Get the object group's properties, convenience function const Tmx::PropertySet &GetObjectGroupProperties() const { if (!objectGroup) throw std::runtime_error ("Tile has no ObjectGroup on attempt to get ObjectGroup properties. Cannot return null ref."); return objectGroup->GetProperties(); } - + /// Get set of Collision Objects, convenience function std::vector GetObjects() const { @@ -153,6 +160,7 @@ namespace Tmx unsigned int totalDuration; std::vector frames; Tmx::Image* image; + std::string type; }; //------------------------------------------------------------------------- diff --git a/test/test.cpp b/test/test.cpp index e45bcce..6510305 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -176,7 +176,9 @@ int main(int argc, char * argv[]) printf( "Tile has objects.\n"); - + if(tile->GetType() != "") + printf("Tile has type: %s\n", tile->GetType().c_str()); + // Iterate through all Collision objects in the tile. for (int j = 0; j < tile->GetNumObjects(); ++j) {