Game Develop Core: Layer.h Source File

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
Layer.h
Go to the documentation of this file.
1
5 #ifndef GDCORE_LAYER_H
6 #define GDCORE_LAYER_H
7 #include <string>
8 #include <vector>
9 namespace gd { class Camera; }
10 class TiXmlElement;
11
12 namespace gd
13 {
14
21 class GD_CORE_API Layer
22 {
23 public:
24 Layer();
25 virtual ~Layer() {};
26
30 void SetName(const std::string & name_) { name = name_; }
31
35 const std::string & GetName() const { return name; }
36
40 void SetVisibility(bool isVisible_) { isVisible = isVisible_; }
41
45 bool GetVisibility() const { return isVisible; }
46
50 void SetCameraCount(unsigned int n);
51
55 inline unsigned int GetCameraCount() const { return cameras.size(); };
56
60 inline const Camera & GetCamera(unsigned int n) const { if ( n >= GetCameraCount() ) return badCamera; return cameras[n]; }
61
65 inline Camera & GetCamera(unsigned int n) { if ( n >= GetCameraCount() ) return badCamera; return cameras[n]; }
66
70 inline void DeleteCamera(unsigned int n) { if ( n >= GetCameraCount() ) return; cameras.erase(cameras.begin()+n); }
71
75 inline void AddCamera(const Camera & camera) { cameras.push_back(camera); };
76
77 #if defined(GD_IDE_ONLY)
78
81 void EditLayer();
82
86 void SaveToXml(TiXmlElement * element) const;
87 #endif
88
92 void LoadFromXml(const TiXmlElement * element);
93
94 private:
95
96 std::string name;
97 bool isVisible;
98 std::vector < gd::Camera > cameras;
99
100 static gd::Camera badCamera;
101 };
102
108 struct LayerHasName : public std::binary_function<gd::Layer, std::string, bool> {
109 bool operator()(const Layer & layer, const std::string & name) const { return layer.GetName() == name; }
110 };
111
112
119 class GD_CORE_API Camera
120 {
121 public:
122 Camera();
123 ~Camera() {};
124
129 void SetViewport(float x1_, float y1_, float x2_, float y2_) { x1 = x1_; x2 = x2_; y1 = y1_; y2 = y2_; };
130 float GetViewportX1() const { return x1; };
131 float GetViewportY1() const { return y1; };
132 float GetViewportX2() const { return x2; };
133 float GetViewportY2() const { return y2; };
134
138 void SetSize(float width_, float height_) { width = width_; height = height_; };
139 float GetWidth() const { return width; };
140 float GetHeight() const { return height; };
141
142 void SetUseDefaultSize(bool useDefaultSize = true) { defaultSize = useDefaultSize; };
143 bool UseDefaultSize() const {return defaultSize;}
144
145 void SetUseDefaultViewport(bool useDefaultViewport = true) { defaultViewport = useDefaultViewport; };
146 bool UseDefaultViewport() const {return defaultViewport;}
147
148 private:
149
150 bool defaultSize;
151 bool defaultViewport;
152
153 float x1;
154 float y1;
155 float x2;
156 float y2;
157 float width;
158 float height;
159 };
160
161 }
162
163 #endif // GDCORE_LAYER_H