tmxlite
lightweight Tiled tmx map parser for C++
ImageLayer.hpp
1 /*********************************************************************
2 Matt Marchant 2016
3 http://trederia.blogspot.com
4 
5 tmxlite - Zlib license.
6 
7 This software is provided 'as-is', without any express or
8 implied warranty. In no event will the authors be held
9 liable for any damages arising from the use of this software.
10 
11 Permission is granted to anyone to use this software for any purpose,
12 including commercial applications, and to alter it and redistribute
13 it freely, subject to the following restrictions:
14 
15 1. The origin of this software must not be misrepresented;
16 you must not claim that you wrote the original software.
17 If you use this software in a product, an acknowledgment
18 in the product documentation would be appreciated but
19 is not required.
20 
21 2. Altered source versions must be plainly marked as such,
22 and must not be misrepresented as being the original software.
23 
24 3. This notice may not be removed or altered from any
25 source distribution.
26 *********************************************************************/
27 
28 #ifndef TMXLITE_IMAGELAYER_HPP_
29 #define TMXLITE_IMAGELAYER_HPP_
30 
31 #include <tmxlite/Config.hpp>
32 #include <tmxlite/Layer.hpp>
33 #include <tmxlite/Types.hpp>
34 
35 namespace tmx
36 {
42  class TMXLITE_EXPORT_API ImageLayer final : public Layer
43  {
44  public:
45  explicit ImageLayer(const std::string&);
46  ~ImageLayer() = default;
47 
48  Type getType() const override { return Layer::Type::Image; }
49  void parse(const pugi::xml_node&) override;
50 
55  const std::string& getImagePath() const { return m_filePath; }
60  const Colour& getTransparencyColour() const { return m_transparencyColour; }
65  bool hasTransparency() const { return m_hasTransparency; }
69  const Vector2u& getImageSize() const { return m_imageSize; }
70 
71  private:
72  std::string m_workingDir;
73  std::string m_filePath;
74  Colour m_transparencyColour;
75  bool m_hasTransparency;
76  Vector2u m_imageSize;
77  };
78 }
79 #endif //TMXLITE_IMAGELAYER_HPP_
Definition: Log.hpp:58
Contains the red, green, blue and alpha values of a colour in the range 0 - 255.
Definition: Types.hpp:109
Type getType() const override
Returns a Type value representing the concrete type.
Definition: ImageLayer.hpp:48
const Vector2u & getImageSize() const
Returns the size of the image of the image layer in pixels.
Definition: ImageLayer.hpp:69
const Colour & getTransparencyColour() const
Returns the colour used by the image to represent transparent pixels. By default this is (0...
Definition: ImageLayer.hpp:60
Represents a layer of a tmx format tile map. This is an abstract base class from which all layer type...
Definition: Layer.hpp:52
const std::string & getImagePath() const
Returns the path, relative to the working directory, of the image used by the image layer...
Definition: ImageLayer.hpp:55
Image layers contain a single image which make up that layer. The parser contains the fully resolved ...
Definition: ImageLayer.hpp:42
bool hasTransparency() const
Returns true if the image used by this layer specifically states a colour to use as transparency...
Definition: ImageLayer.hpp:65