[Update] Tmx Parser updated to latest revision.

This commit is contained in:
Tamir Atias 2012-09-02 14:11:42 +03:00
parent b56261e987
commit 1fcb935d79
29 changed files with 2544 additions and 2465 deletions

View File

@ -38,20 +38,6 @@ HEADERS += ../src/Actor/Player.h \
../src/System/ResourceManager.h \ ../src/System/ResourceManager.h \
../src/Texture/Texture.h \ ../src/Texture/Texture.h \
../src/Sound/Music.h \ ../src/Sound/Music.h \
../src/TMXParser/TmxUtil.h \
../src/TMXParser/TmxTileset.h \
../src/TMXParser/TmxTile.h \
../src/TMXParser/TmxPropertySet.h \
../src/TMXParser/TmxPolyline.h \
../src/TMXParser/TmxPolygon.h \
../src/TMXParser/TmxObjectGroup.h \
../src/TMXParser/TmxObject.h \
../src/TMXParser/TmxMapTile.h \
../src/TMXParser/TmxImage.h \
../src/TMXParser/TmxPoint.h \
../src/TMXParser/TmxMap.h \
../src/TMXParser/TmxLayer.h \
../src/TMXParser/Tmx.h \
../src/TMXParser/base64.h \ ../src/TMXParser/base64.h \
../src/Collision/TileCollision.h \ ../src/Collision/TileCollision.h \
../src/Actor/NPC.h \ ../src/Actor/NPC.h \
@ -68,7 +54,21 @@ HEADERS += ../src/Actor/Player.h \
../src/Main/TitleScreen.h \ ../src/Main/TitleScreen.h \
../src/Level/Warp.h \ ../src/Level/Warp.h \
../src/Math/Rect.h \ ../src/Math/Rect.h \
../src/BattleSys/Slot.h ../src/BattleSys/Slot.h \
../src/TMXParser/TmxTile.h \
../src/TMXParser/TmxPropertySet.h \
../src/TMXParser/TmxPolyline.h \
../src/TMXParser/TmxPolygon.h \
../src/TMXParser/TmxPoint.h \
../src/TMXParser/TmxObjectGroup.h \
../src/TMXParser/TmxObject.h \
../src/TMXParser/TmxMapTile.h \
../src/TMXParser/TmxMap.h \
../src/TMXParser/TmxLayer.h \
../src/TMXParser/TmxImage.h \
../src/TMXParser/Tmx.h \
../src/TMXParser/base64/base64.h \
../src/TMXParser/TmxUtil.h
SOURCES += ../src/Actor/Player.cpp \ SOURCES += ../src/Actor/Player.cpp \
../src/Collision/AABB.cpp \ ../src/Collision/AABB.cpp \
@ -87,18 +87,6 @@ SOURCES += ../src/Actor/Player.cpp \
../src/System/Debug.cpp \ ../src/System/Debug.cpp \
../src/Texture/Texture.cpp \ ../src/Texture/Texture.cpp \
../src/Sound/Music.cpp \ ../src/Sound/Music.cpp \
../src/TMXParser/TmxUtil.cpp \
../src/TMXParser/TmxTileset.cpp \
../src/TMXParser/TmxTile.cpp \
../src/TMXParser/TmxPropertySet.cpp \
../src/TMXParser/TmxPolyline.cpp \
../src/TMXParser/TmxPolygon.cpp \
../src/TMXParser/TmxObjectGroup.cpp \
../src/TMXParser/TmxObject.cpp \
../src/TMXParser/TmxMap.cpp \
../src/TMXParser/TmxLayer.cpp \
../src/TMXParser/TmxImage.cpp \
../src/TMXParser/base64.cpp \
../src/Actor/NPC.cpp \ ../src/Actor/NPC.cpp \
../src/Sound/SoundEffect.cpp \ ../src/Sound/SoundEffect.cpp \
../src/Actor/Actor.cpp \ ../src/Actor/Actor.cpp \
@ -111,6 +99,18 @@ SOURCES += ../src/Actor/Player.cpp \
../src/UI/Button.cpp \ ../src/UI/Button.cpp \
../src/Main/TitleScreen.cpp \ ../src/Main/TitleScreen.cpp \
../src/Level/Warp.cpp \ ../src/Level/Warp.cpp \
../src/BattleSys/Slot.cpp ../src/BattleSys/Slot.cpp \
../src/TMXParser/TmxTileset.cpp \
../src/TMXParser/TmxTile.cpp \
../src/TMXParser/TmxPropertySet.cpp \
../src/TMXParser/TmxPolyline.cpp \
../src/TMXParser/TmxPolygon.cpp \
../src/TMXParser/TmxObjectGroup.cpp \
../src/TMXParser/TmxObject.cpp \
../src/TMXParser/TmxMap.cpp \
../src/TMXParser/TmxLayer.cpp \
../src/TMXParser/TmxImage.cpp \
../src/TMXParser/base64/base64.cpp \
../src/TMXParser/TmxUtil.cpp
QMAKE_CLEAN += LibD Debug.log QMAKE_CLEAN += LibD Debug.log

View File

@ -102,7 +102,7 @@ bool Level::Load(const std::string& filename) {
for(int x = 0; x < _width; x++) { for(int x = 0; x < _width; x++) {
for(int y = 0; y < _height; y++) { for(int y = 0; y < _height; y++) {
Tmx::MapTile tile = tmxLayer->GetTile(x, y); Tmx::MapTile tile = tmxLayer->GetTile(x, y);
_collisions[y * _width + x] = tile.gid != 0; _collisions[y * _width + x] = tile.tilesetId > -1;
} }
} }
continue; continue;
@ -119,11 +119,10 @@ bool Level::Load(const std::string& filename) {
for(int y = 0; y < layer->GetHeight(); y++) { for(int y = 0; y < layer->GetHeight(); y++) {
Tmx::MapTile tmxTile = tmxLayer->GetTile(x, y); Tmx::MapTile tmxTile = tmxLayer->GetTile(x, y);
const Tmx::Tileset* tmxTileset = map.FindTileset(tmxTile.gid);
MapTile tile; MapTile tile;
if(tmxTile.gid != 0) { if(tmxTile.tilesetId != -1) {
tile.id = tmxTile.gid - tmxTileset->GetFirstGid(); const Tmx::Tileset* tmxTileset = map.GetTileset(tmxTile.tilesetId);
tile.id = tmxTile.id;
tile.tileset = tilesetMap.find(tmxTileset)->second; tile.tileset = tilesetMap.find(tmxTileset)->second;
} else { } else {
tile.id = 0; tile.id = 0;

View File

@ -25,17 +25,21 @@
// //
// Author: Tamir Atias // Author: Tamir Atias
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <stdlib.h>
#include <zlib.h>
#include <tinyxml.h> #include <tinyxml.h>
#include <zlib.h>
#include <stdlib.h>
#include <stdio.h>
#include "TmxLayer.h" #include "TmxLayer.h"
#include "TmxUtil.h" #include "TmxUtil.h"
#include "TmxMap.h"
#include "TmxTileset.h"
namespace Tmx namespace Tmx
{ {
Layer::Layer() Layer::Layer(const Map *_map)
: name() : map(_map)
, name()
, width(0) , width(0)
, height(0) , height(0)
, opacity(1.0f) , opacity(1.0f)
@ -148,15 +152,30 @@ namespace Tmx
{ {
const TiXmlElement *tileElem = tileNode->ToElement(); const TiXmlElement *tileElem = tileNode->ToElement();
int gid = 0; unsigned gid = 0;
// Read the Global-ID of the tile directly into the array entry. // Read the Global-ID of the tile.
tileElem->Attribute("gid", &gid); const char* gidText = tileElem->Attribute("gid");
// Convert the gid to a map tile. // Convert to an unsigned.
tile_map[tileCount++] = MapTile((unsigned)gid); sscanf(gidText, "%u", &gid);
// Find the tileset index.
const int tilesetIndex = map->FindTilesetIndex(gid);
if (tilesetIndex != -1)
{
// If valid, set up the map tile with the tileset.
const Tmx::Tileset* tileset = map->GetTileset(tilesetIndex);
tile_map[tileCount] = MapTile(gid, tileset->GetFirstGid(), tilesetIndex);
}
else
{
// Otherwise, make it null.
tile_map[tileCount] = MapTile(gid, 0, -1);
}
tileNode = dataNode->IterateChildren("tile", tileNode); tileNode = dataNode->IterateChildren("tile", tileNode);
tileCount++;
} }
} }
@ -199,7 +218,21 @@ namespace Tmx
{ {
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
tile_map[y * width + x] = MapTile(out[y * width + x]); unsigned gid = out[y * width + x];
// Find the tileset index.
const int tilesetIndex = map->FindTilesetIndex(gid);
if (tilesetIndex != -1)
{
// If valid, set up the map tile with the tileset.
const Tmx::Tileset* tileset = map->GetTileset(tilesetIndex);
tile_map[y * width + x] = MapTile(gid, tileset->GetFirstGid(), tilesetIndex);
}
else
{
// Otherwise, make it null.
tile_map[y * width + x] = MapTile(gid, 0, -1);
}
} }
} }
@ -213,15 +246,30 @@ namespace Tmx
char *csv = strdup(innerText.c_str()); char *csv = strdup(innerText.c_str());
// Iterate through every token of ';' in the CSV string. // Iterate through every token of ';' in the CSV string.
char *pch = strtok(csv, ";"); char *pch = strtok(csv, ",");
int tileCount = 0; int tileCount = 0;
while (pch) while (pch)
{ {
tile_map[tileCount] = MapTile((unsigned)atoi(pch)); unsigned gid;
sscanf(pch, "%u", &gid);
++tileCount; // Find the tileset index.
pch = strtok(NULL, ";"); const int tilesetIndex = map->FindTilesetIndex(gid);
if (tilesetIndex != -1)
{
// If valid, set up the map tile with the tileset.
const Tmx::Tileset* tileset = map->GetTileset(tilesetIndex);
tile_map[tileCount] = MapTile(gid, tileset->GetFirstGid(), tilesetIndex);
}
else
{
// Otherwise, make it null.
tile_map[tileCount] = MapTile(gid, 0, -1);
}
pch = strtok(NULL, ",");
tileCount++;
} }
free(csv); free(csv);

View File

@ -36,98 +36,105 @@ class TiXmlNode;
namespace Tmx namespace Tmx
{ {
//------------------------------------------------------------------------- class Map;
// Type used for the encoding of the layer data.
//-------------------------------------------------------------------------
enum LayerEncodingType
{
TMX_ENCODING_XML,
TMX_ENCODING_BASE64,
TMX_ENCODING_CSV
};
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// Type used for the compression of the layer data. // Type used for the encoding of the layer data.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
enum LayerCompressionType enum LayerEncodingType
{ {
TMX_COMPRESSION_NONE, TMX_ENCODING_XML,
TMX_COMPRESSION_ZLIB, TMX_ENCODING_BASE64,
TMX_COMPRESSION_GZIP TMX_ENCODING_CSV
}; };
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// Used for storing information about the tile ids for every layer. // Type used for the compression of the layer data.
// This class also have a property set. //-------------------------------------------------------------------------
//------------------------------------------------------------------------- enum LayerCompressionType
class Layer {
{ TMX_COMPRESSION_NONE,
public: TMX_COMPRESSION_ZLIB,
Layer(); TMX_COMPRESSION_GZIP
~Layer(); };
// Parse a layer node. //-------------------------------------------------------------------------
void Parse(const TiXmlNode *layerNode); // Used for storing information about the tile ids for every layer.
// This class also have a property set.
//-------------------------------------------------------------------------
class Layer
{
public:
Layer(const Tmx::Map *_map);
~Layer();
// Get the name of the layer. // Parse a layer node.
const std::string &GetName() const { return name; } void Parse(const TiXmlNode *layerNode);
// Get the width of the layer, in tiles. // Get the name of the layer.
float GetWidth() const { return width; } const std::string &GetName() const { return name; }
// Get the height of the layer, in tiles. // Get the width of the layer, in tiles.
float GetHeight() const { return height; } int GetWidth() const { return width; }
// Get the visibility of the layer // Get the height of the layer, in tiles.
bool IsVisible() const { return visible; } int GetHeight() const { return height; }
// Get the property set. // Get the visibility of the layer
const PropertySet &GetProperties() const { return properties; } bool IsVisible() const { return visible; }
// Pick a specific tile from the list. // Get the property set.
unsigned GetTileGid(int x, int y) const { return tile_map[y * width + x].gid; } const Tmx::PropertySet &GetProperties() const { return properties; }
// Get whether the tile is flipped horizontally. // Pick a specific tile from the list.
bool IsTileFlippedHorizontally(int x, int y) const unsigned GetTileId(int x, int y) const { return tile_map[y * width + x].id; }
{ return tile_map[y * width + x].flippedHorizontally; }
// Get whether the tile is flipped vertically. // Get the tileset index for a tileset from the list.
bool IsTileFlippedVertically(int x, int y) const int GetTileTilesetIndex(int x, int y) const { return tile_map[y * width + x].tilesetId; }
{ return tile_map[y * width + x].flippedVertically; }
// Get whether the tile is flipped diagonally. // Get whether a tile is flipped horizontally.
bool IsTileFlippedDiagonally(int x, int y) const bool IsTileFlippedHorizontally(int x, int y) const
{ return tile_map[y * width + x].flippedDiagonally; } { return tile_map[y * width + x].flippedHorizontally; }
// Get the tile specific to the map. // Get whether a tile is flipped vertically.
MapTile GetTile(int x, int y) const { return tile_map[y * width + x]; } bool IsTileFlippedVertically(int x, int y) const
{ return tile_map[y * width + x].flippedVertically; }
// Get the type of encoding that was used for parsing the layer data. // Get whether a tile is flipped diagonally.
// See: LayerEncodingType bool IsTileFlippedDiagonally(int x, int y) const
LayerEncodingType GetEncoding() const { return encoding; } { return tile_map[y * width + x].flippedDiagonally; }
// Get the type of compression that was used for parsing the layer data. // Get a tile specific to the map.
// See: LayerCompressionType const Tmx::MapTile& GetTile(int x, int y) const { return tile_map[y * width + x]; }
LayerCompressionType GetCompression() const { return compression; }
private: // Get the type of encoding that was used for parsing the layer data.
void ParseXML(const TiXmlNode *dataNode); // See: LayerEncodingType
void ParseBase64(const std::string &innerText); Tmx::LayerEncodingType GetEncoding() const { return encoding; }
void ParseCSV(const std::string &innerText);
std::string name; // Get the type of compression that was used for parsing the layer data.
// See: LayerCompressionType
Tmx::LayerCompressionType GetCompression() const { return compression; }
int width; private:
int height; void ParseXML(const TiXmlNode *dataNode);
void ParseBase64(const std::string &innerText);
void ParseCSV(const std::string &innerText);
float opacity; const Tmx::Map *map;
bool visible;
PropertySet properties; std::string name;
MapTile *tile_map; int width;
int height;
LayerEncodingType encoding; float opacity;
LayerCompressionType compression; bool visible;
};
Tmx::PropertySet properties;
Tmx::MapTile *tile_map;
Tmx::LayerEncodingType encoding;
Tmx::LayerCompressionType compression;
};
}; };

View File

@ -25,8 +25,8 @@
// //
// Author: Tamir Atias // Author: Tamir Atias
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <cstdio>
#include <tinyxml.h> #include <tinyxml.h>
#include <stdio.h>
#include "TmxMap.h" #include "TmxMap.h"
#include "TmxTileset.h" #include "TmxTileset.h"
@ -209,7 +209,7 @@ namespace Tmx
while (layerNode) while (layerNode)
{ {
// Allocate a new layer and parse it. // Allocate a new layer and parse it.
Layer *layer = new Layer(); Layer *layer = new Layer(this);
layer->Parse(layerNode); layer->Parse(layerNode);
// Add the layer to the list. // Add the layer to the list.
@ -233,6 +233,23 @@ namespace Tmx
} }
} }
int Map::FindTilesetIndex(int gid) const
{
// Clean up the flags from the gid (thanks marwes91).
gid &= ~(FlippedHorizontallyFlag | FlippedVerticallyFlag | FlippedDiagonallyFlag);
for (int i = tilesets.size() - 1; i > -1; --i)
{
// If the gid beyond the tileset gid return its index.
if (gid >= tilesets[i]->GetFirstGid())
{
return i;
}
}
return -1;
}
const Tileset *Map::FindTileset(int gid) const const Tileset *Map::FindTileset(int gid) const
{ {
for (int i = tilesets.size() - 1; i > -1; --i) for (int i = tilesets.size() - 1; i > -1; --i)

View File

@ -91,7 +91,7 @@ namespace Tmx
double GetVersion() const { return version; } double GetVersion() const { return version; }
// Get the orientation of the map. // Get the orientation of the map.
MapOrientation GetOrientation() const { return orientation; } Tmx::MapOrientation GetOrientation() const { return orientation; }
// Get the width of the map, in tiles. // Get the width of the map, in tiles.
int GetWidth() const { return width; } int GetWidth() const { return width; }
@ -106,34 +106,37 @@ namespace Tmx
int GetTileHeight() const { return tile_height; } int GetTileHeight() const { return tile_height; }
// Get the layer at a certain index. // Get the layer at a certain index.
const Layer *GetLayer(int index) const { return layers.at(index); } const Tmx::Layer *GetLayer(int index) const { return layers.at(index); }
// Get the amount of layers. // Get the amount of layers.
int GetNumLayers() const { return layers.size(); } int GetNumLayers() const { return layers.size(); }
// Get the whole layers collection. // Get the whole layers collection.
const std::vector< Layer* > &GetLayers() const { return layers; } const std::vector< Tmx::Layer* > &GetLayers() const { return layers; }
// Get the object group at a certain index. // Get the object group at a certain index.
const ObjectGroup *GetObjectGroup(int index) const { return object_groups.at(index); } const Tmx::ObjectGroup *GetObjectGroup(int index) const { return object_groups.at(index); }
// Get the amount of object groups. // Get the amount of object groups.
int GetNumObjectGroups() const { return object_groups.size(); } int GetNumObjectGroups() const { return object_groups.size(); }
// Get the whole object group collection. // Get the whole object group collection.
const std::vector< ObjectGroup* > &GetObjectGroups() const { return object_groups; } const std::vector< Tmx::ObjectGroup* > &GetObjectGroups() const { return object_groups; }
// Find the tileset index for a tileset using a tile gid.
int FindTilesetIndex(int gid) const;
// Find a tileset for a specific gid. // Find a tileset for a specific gid.
const Tileset *FindTileset(int gid) const; const Tmx::Tileset *FindTileset(int gid) const;
// Get a tileset by an index. // Get a tileset by an index.
const Tileset *GetTileset(int index) const { return tilesets.at(index); } const Tmx::Tileset *GetTileset(int index) const { return tilesets.at(index); }
// Get the amount of tilesets. // Get the amount of tilesets.
int GetNumTilesets() const { return tilesets.size(); } int GetNumTilesets() const { return tilesets.size(); }
// Get the collection of tilesets. // Get the collection of tilesets.
const std::vector< Tileset* > &GetTilesets() const { return tilesets; } const std::vector< Tmx::Tileset* > &GetTilesets() const { return tilesets; }
// Get whether there was an error or not. // Get whether there was an error or not.
bool HasError() const { return has_error; } bool HasError() const { return has_error; }
@ -145,28 +148,28 @@ namespace Tmx
unsigned char GetErrorCode() const { return error_code; } unsigned char GetErrorCode() const { return error_code; }
// Get the property set. // Get the property set.
const PropertySet &GetProperties() { return properties; } const Tmx::PropertySet &GetProperties() { return properties; }
private: private:
std::string file_name; std::string file_name;
std::string file_path; std::string file_path;
double version; double version;
MapOrientation orientation; Tmx::MapOrientation orientation;
int width; int width;
int height; int height;
int tile_width; int tile_width;
int tile_height; int tile_height;
std::vector< Layer* > layers; std::vector< Tmx::Layer* > layers;
std::vector< ObjectGroup* > object_groups; std::vector< Tmx::ObjectGroup* > object_groups;
std::vector< Tileset* > tilesets; std::vector< Tmx::Tileset* > tilesets;
bool has_error; bool has_error;
unsigned char error_code; unsigned char error_code;
std::string error_text; std::string error_text;
PropertySet properties; Tmx::PropertySet properties;
}; };
}; };

View File

@ -43,7 +43,8 @@ namespace Tmx
{ {
// Default constructor. // Default constructor.
MapTile() MapTile()
: gid(0) : tilesetId(0)
, id(0)
, flippedHorizontally(false) , flippedHorizontally(false)
, flippedVertically(false) , flippedVertically(false)
, flippedDiagonally(false) , flippedDiagonally(false)
@ -51,17 +52,21 @@ namespace Tmx
// Will take a gid and read the attributes from the first // Will take a gid and read the attributes from the first
// two bits of it. // two bits of it.
MapTile(unsigned _gid) MapTile(unsigned _gid, int _tilesetFirstGid, unsigned _tilesetId)
: gid(_gid) : tilesetId(_tilesetId)
, id(_gid & ~(FlippedHorizontallyFlag | FlippedVerticallyFlag | FlippedDiagonallyFlag))
, flippedHorizontally((_gid & FlippedHorizontallyFlag) != 0) , flippedHorizontally((_gid & FlippedHorizontallyFlag) != 0)
, flippedVertically((_gid & FlippedVerticallyFlag) != 0) , flippedVertically((_gid & FlippedVerticallyFlag) != 0)
, flippedDiagonally((_gid & FlippedDiagonallyFlag) != 0) , flippedDiagonally((_gid & FlippedDiagonallyFlag) != 0)
{ {
gid &= ~(FlippedHorizontallyFlag | FlippedVerticallyFlag | FlippedDiagonallyFlag); id -= _tilesetFirstGid;
} }
// Global id. // Tileset id.
unsigned gid; int tilesetId;
// Id.
unsigned id;
// True when the tile should be drawn flipped horizontally. // True when the tile should be drawn flipped horizontally.
bool flippedHorizontally; bool flippedHorizontally;

View File

@ -72,13 +72,13 @@ namespace Tmx
int GetGid() const { return gid; } int GetGid() const { return gid; }
// Get the Polygon. // Get the Polygon.
const Polygon *GetPolygon() const { return polygon; } const Tmx::Polygon *GetPolygon() const { return polygon; }
// Get the Polyline. // Get the Polyline.
const Polyline *GetPolyline() const { return polyline; } const Tmx::Polyline *GetPolyline() const { return polyline; }
// Get the property set. // Get the property set.
const PropertySet &GetProperties() const { return properties; } const Tmx::PropertySet &GetProperties() const { return properties; }
private: private:
std::string name; std::string name;
@ -90,9 +90,9 @@ namespace Tmx
int height; int height;
int gid; int gid;
Polygon *polygon; Tmx::Polygon *polygon;
Polyline *polyline; Tmx::Polyline *polyline;
PropertySet properties; Tmx::PropertySet properties;
}; };
}; };

View File

@ -61,7 +61,7 @@ namespace Tmx
int GetHeight() const { return height; } int GetHeight() const { return height; }
// Get a single object. // Get a single object.
const Object *GetObject(int index) const { return objects.at(index); } const Tmx::Object *GetObject(int index) const { return objects.at(index); }
// Get the number of objects in the list. // Get the number of objects in the list.
int GetNumObjects() const { return objects.size(); } int GetNumObjects() const { return objects.size(); }
@ -70,7 +70,7 @@ namespace Tmx
int GetVisibility() const { return visible; } int GetVisibility() const { return visible; }
// Get the whole list of objects. // Get the whole list of objects.
const std::vector< Object* > &GetObjects() const { return objects; } const std::vector< Tmx::Object* > &GetObjects() const { return objects; }
private: private:
std::string name; std::string name;
@ -79,6 +79,6 @@ namespace Tmx
int height; int height;
int visible; int visible;
std::vector< Object* > objects; std::vector< Tmx::Object* > objects;
}; };
}; };

View File

@ -47,12 +47,12 @@ namespace Tmx
void Parse(const TiXmlNode *polygonNode); void Parse(const TiXmlNode *polygonNode);
// Get one of the vertices. // Get one of the vertices.
const Point &GetPoint(int index) const { return points[index]; } const Tmx::Point &GetPoint(int index) const { return points[index]; }
// Get the number of vertices. // Get the number of vertices.
int GetNumPoints() const { return points.size(); } int GetNumPoints() const { return points.size(); }
private: private:
std::vector< Point > points; std::vector< Tmx::Point > points;
}; };
}; };

View File

@ -47,12 +47,12 @@ namespace Tmx
void Parse(const TiXmlNode *polylineNode); void Parse(const TiXmlNode *polylineNode);
// Get one of the vertices. // Get one of the vertices.
const Point &GetPoint(int index) const { return points[index]; } const Tmx::Point &GetPoint(int index) const { return points[index]; }
// Get the number of vertices. // Get the number of vertices.
int GetNumPoints() const { return points.size(); } int GetNumPoints() const { return points.size(); }
private: private:
std::vector< Point > points; std::vector< Tmx::Point > points;
}; };
}; };

View File

@ -51,11 +51,11 @@ namespace Tmx
int GetId() const { return id; } int GetId() const { return id; }
// Get a set of properties regarding the tile. // Get a set of properties regarding the tile.
const PropertySet &GetProperties() const { return properties; } const Tmx::PropertySet &GetProperties() const { return properties; }
private: private:
int id; int id;
PropertySet properties; Tmx::PropertySet properties;
}; };
}; };

View File

@ -71,13 +71,13 @@ namespace Tmx
// Returns a variable containing information // Returns a variable containing information
// about the image of the tileset. // about the image of the tileset.
const Image* GetImage() const { return image; } const Tmx::Image* GetImage() const { return image; }
// Returns a a single tile of the set. // Returns a a single tile of the set.
const Tile *GetTile(int index) const; const Tmx::Tile *GetTile(int index) const;
// Returns the whole tile collection. // Returns the whole tile collection.
const std::vector< Tile *> &GetTiles() const { return tiles; } const std::vector< Tmx::Tile *> &GetTiles() const { return tiles; }
private: private:
int first_gid; int first_gid;
@ -89,8 +89,8 @@ namespace Tmx
int margin; int margin;
int spacing; int spacing;
Image* image; Tmx::Image* image;
std::vector< Tile* > tiles; std::vector< Tmx::Tile* > tiles;
}; };
}; };

View File

@ -29,7 +29,7 @@
#include <zlib.h> #include <zlib.h>
#include "TmxUtil.h" #include "TmxUtil.h"
#include "base64.h" #include "base64/base64.h"
namespace Tmx { namespace Tmx {
std::string Util::DecodeBase64(const std::string &str) std::string Util::DecodeBase64(const std::string &str)