tmxparser  2.1.0
 All Classes Functions Variables Pages
TmxTileset.h
1 //-----------------------------------------------------------------------------
2 // TmxTileset.h
3 //
4 // Copyright (c) 2010-2014, Tamir Atias
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 // DISCLAIMED. IN NO EVENT SHALL TAMIR ATIAS BE LIABLE FOR ANY
19 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Author: Tamir Atias
27 //-----------------------------------------------------------------------------
28 #pragma once
29 
30 #include <string>
31 #include <vector>
32 
33 #include "TmxPropertySet.h"
34 
35 namespace tinyxml2 {
36  class XMLNode;
37 }
38 
39 namespace Tmx
40 {
41  class Image;
42  class TileOffset;
43  class Terrain;
44  class Tile;
45 
46  //-------------------------------------------------------------------------
50  //-------------------------------------------------------------------------
51  class Tileset
52  {
53  public:
54  Tileset();
55  ~Tileset();
56 
58  void Parse(const tinyxml2::XMLNode *tilesetNode, const std::string& file_path);
59 
61  int GetFirstGid() const { return first_gid; }
62 
64  const std::string &GetName() const { return name; }
65 
67  int GetTileWidth() const { return tile_width; }
68 
70  int GetTileHeight() const { return tile_height; }
71 
73  int GetMargin() const { return margin; }
74 
76  int GetSpacing() const { return spacing; }
77 
79  int GetTileCount() const { return tile_count; }
80 
82  int GetColumns() const { return columns;}
83 
85  const Tmx::TileOffset* GetTileOffset() const { return tileOffset; }
86 
89  const Tmx::Image* GetImage() const { return image; }
90 
92  const Tmx::Tile *GetTile(int index) const;
93 
95  const std::vector< Tmx::Tile *> &GetTiles() const { return tiles; }
96 
98  const Tmx::PropertySet &GetProperties() const { return properties; }
99 
100  private:
101  int first_gid;
102 
103  std::string name;
104 
105  int tile_width;
106  int tile_height;
107  int margin;
108  int spacing;
109  int tile_count;
110  int columns;
111 
112  Tmx::TileOffset* tileOffset;
113  Tmx::Image* image;
114 
115  std::vector< Tmx::Terrain* > terrainTypes;
116  std::vector< Tmx::Tile* > tiles;
117 
118  Tmx::PropertySet properties;
119  };
120 }
int GetMargin() const
Get the margin of the tileset.
Definition: TmxTileset.h:73
int GetTileHeight() const
Get the height of a single tile.
Definition: TmxTileset.h:70
int GetFirstGid() const
Returns the global id of the first tile.
Definition: TmxTileset.h:61
const std::string & GetName() const
Returns the name of the tileset.
Definition: TmxTileset.h:64
A class used for used to specify an offset in pixels, to be applied when drawing a tile from the rela...
Definition: TmxTileOffset.h:43
int GetSpacing() const
Get the spacing of the tileset.
Definition: TmxTileset.h:76
A class used for storing information about each of the tilesets.
Definition: TmxTileset.h:51
void Parse(const tinyxml2::XMLNode *tilesetNode, const std::string &file_path)
Parse a tileset element.
Definition: TmxTileset.cpp:102
This class contains a map of properties.
Definition: TmxPropertySet.h:47
int GetTileWidth() const
Get the width of a single tile.
Definition: TmxTileset.h:67
int GetColumns() const
Get the number of columns in the tileset(since 0.15)
Definition: TmxTileset.h:82
const Tmx::PropertySet & GetProperties() const
Get a set of properties regarding the tile.
Definition: TmxTileset.h:98
const Tmx::TileOffset * GetTileOffset() const
Get the offset of tileset.
Definition: TmxTileset.h:85
int GetTileCount() const
Get the number of tiles in this tileset(since 0.13)
Definition: TmxTileset.h:79
const Tmx::Image * GetImage() const
Returns a variable containing information about the image of the tileset.
Definition: TmxTileset.h:89
const std::vector< Tmx::Tile * > & GetTiles() const
Returns the whole tile collection.
Definition: TmxTileset.h:95
Class to contain information about every tile in the tileset/tiles element.
Definition: TmxTile.h:51
const Tmx::Tile * GetTile(int index) const
Returns a a single tile of the set.
Definition: TmxTileset.cpp:187
A class used for storing information about an image within a tileset.
Definition: TmxImage.h:42