tmxlite: D:/W/B/src/tmxlite-1.4.5/tmxlite/include/tmxlite/ImageLayer.hpp Source File

tmxlite 1.0.0 lightweight parse for Tiled maps

ImageLayer.hpp
1/*********************************************************************
2Matt Marchant 2016 - 2022
3http://trederia.blogspot.com
4
5tmxlite - Zlib license.
6
7This software is provided 'as-is', without any express or
8implied warranty. In no event will the authors be held
9liable for any damages arising from the use of this software.
10
11Permission is granted to anyone to use this software for any purpose,
12including commercial applications, and to alter it and redistribute
13it freely, subject to the following restrictions:
14
151. The origin of this software must not be misrepresented;
16you must not claim that you wrote the original software.
17If you use this software in a product, an acknowledgment
18in the product documentation would be appreciated but
19is not required.
20
212. Altered source versions must be plainly marked as such,
22and must not be misrepresented as being the original software.
23
243. This notice may not be removed or altered from any
25source distribution.
26*********************************************************************/
27
28#pragma once
29
30#include <tmxlite/Config.hpp>
31#include <tmxlite/Layer.hpp>
32#include <tmxlite/Types.hpp>
33
34namespace tmx
35{
41 class TMXLITE_EXPORT_API ImageLayer final : public Layer
42 {
43 public:
44 explicit ImageLayer(const std::string&);
45
46 Type getType() const override { return Layer::Type::Image; }
47 void parse(const pugi::xml_node&, Map*) override;
48
53 const std::string& getImagePath() const { return m_filePath; }
54
59 const Colour& getTransparencyColour() const { return m_transparencyColour; }
60
65 bool hasTransparency() const { return m_hasTransparency; }
66
70 const Vector2u& getImageSize() const { return m_imageSize; }
71
76 bool hasRepeatX() const { return m_hasRepeatX; }
77
82 bool hasRepeatY() const { return m_hasRepeatY; }
83
87 bool locked() const {return m_locked;}
88
89 private:
90 std::string m_workingDir;
91 std::string m_filePath;
92 Colour m_transparencyColour;
93 bool m_hasTransparency;
94 Vector2u m_imageSize;
95 bool m_hasRepeatX;
96 bool m_hasRepeatY;
97 bool m_locked;
98 };
99
100 template <>
101 inline ImageLayer& Layer::getLayerAs<ImageLayer>()
102 {
103 assert(getType() == Type::Image);
104 return *static_cast<ImageLayer*>(this);
105 }
106
107 template <>
108 inline const ImageLayer& Layer::getLayerAs<ImageLayer>() const
109 {
110 assert(getType() == Type::Image);
111 return *static_cast<const ImageLayer*>(this);
112 }
113}
tmx::ImageLayer
Image layers contain a single image which make up that layer. The parser contains the fully resolved ...
Definition ImageLayer.hpp:42
tmx::ImageLayer::hasRepeatY
bool hasRepeatY() const
Returns true if the image drawn by this layer is repeated along the Y axis.
Definition ImageLayer.hpp:82
tmx::ImageLayer::getType
Type getType() const override
Returns a Type value representing the concrete type. Use this when deciding which concrete layer type...
Definition ImageLayer.hpp:46
tmx::ImageLayer::getTransparencyColour
const Colour & getTransparencyColour() const
Returns the colour used by the image to represent transparent pixels. By default this is (0,...
Definition ImageLayer.hpp:59
tmx::ImageLayer::getImagePath
const std::string & getImagePath() const
Returns the path, relative to the working directory, of the image used by the image layer.
Definition ImageLayer.hpp:53
tmx::ImageLayer::getImageSize
const Vector2u & getImageSize() const
Returns the size of the image of the image layer in pixels.
Definition ImageLayer.hpp:70
tmx::ImageLayer::hasRepeatX
bool hasRepeatX() const
Returns true if the image drawn by this layer is repeated along the X axis.
Definition ImageLayer.hpp:76
tmx::ImageLayer::hasTransparency
bool hasTransparency() const
Returns true if the image used by this layer specifically states a colour to use as transparency.
Definition ImageLayer.hpp:65
tmx::ImageLayer::locked
bool locked() const
Returns true if the image drawn by this layer is locked.
Definition ImageLayer.hpp:87
tmx::ImageLayer::parse
void parse(const pugi::xml_node &, Map *) override
Attempts to parse the specific node layer type.
tmx::Layer::getLayerAs
T & getLayerAs()
Use this to get a reference to the concrete layer type which this layer points to....
tmx::Layer::Type
Type
Layer type as returned by getType() Tile: this layer is a TileLayer type Object: This layer is an Obj...
Definition Layer.hpp:71
tmx::Layer::getType
virtual Type getType() const =0
Returns a Type value representing the concrete type. Use this when deciding which concrete layer type...
tmx::Map
Parser for TMX format tile maps. This class can be used to parse the XML format tile maps created wit...
Definition Map.hpp:94
tmx::Colour
Contains the red, green, blue and alpha values of a colour in the range 0 - 255.
Definition Types.hpp:111