Skip to content

Commit

Permalink
Merge pull request #66 from sainteos/2.1.0-release-prep
Browse files Browse the repository at this point in the history
2.1.0 Release
  • Loading branch information
sainteos authored Feb 10, 2018
2 parents 542a825 + 6806eb8 commit 74deeda
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 16 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

### Next release
### 2.1.0

* georgerbr:
- Make tileset parsing not depend on optional attrs of <image>
Expand Down Expand Up @@ -41,6 +41,19 @@
* 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.
- Update Tile with optional Type

### 2.0.1

* georgerbr:
Expand Down
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
SOFTWARE.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/TmxGroupLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/TmxGroupLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Tmx::Layer*> GetChildren() const noexcept;
Expand Down
14 changes: 10 additions & 4 deletions src/TmxTile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
}

Expand All @@ -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");
Expand Down Expand Up @@ -100,7 +106,7 @@ namespace Tmx

totalDuration = durationSum;
}

const tinyxml2::XMLNode *objectGroupNode = tileNode->FirstChildElement(
"objectgroup");
if (objectGroupNode)
Expand All @@ -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");
Expand Down
14 changes: 11 additions & 3 deletions src/TmxTile.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "TmxImage.h"
#include "TmxObjectGroup.h"
#include <stdexcept>
#include <string>

namespace tinyxml2
{
Expand Down Expand Up @@ -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<AnimationFrame> &GetFrames() const
{
Expand All @@ -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<Tmx::Object*> GetObjects() const
{
Expand Down Expand Up @@ -153,6 +160,7 @@ namespace Tmx
unsigned int totalDuration;
std::vector<AnimationFrame> frames;
Tmx::Image* image;
std::string type;
};

//-------------------------------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions test/test.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -175,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)
{
Expand Down

0 comments on commit 74deeda

Please # to comment.