Game Develop C++ Platform: RuntimeLayer.h Source File

| Game Develop C++ Platform Platform for developing native games based on OpenGL and SFML with Game Develop

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
RuntimeLayer.h
1 #ifndef RUNTIMELAYER_H
2 #define RUNTIMELAYER_H
3 #include <SFML/Graphics.hpp>
4 namespace gd { class Camera; }
5 namespace gd { class Layer; }
6
13 class GD_API RuntimeCamera
14 {
15 public:
21 RuntimeCamera() : originalWidth(0), originalHeight(0),angle(0), zoomFactor(1) {};
22
26 RuntimeCamera(sf::View & view);
27
31 RuntimeCamera(gd::Camera & camera, const sf::View & defaultView);
32
36 const sf::View & GetSFMLView() const { return sfmlView; };
37
41 void SetZoom(float newZoom);
42
46 float GetZoom() const { return zoomFactor; };
47
52 void SetRotation(float newAngle);
53
57 float GetRotation() const { return angle; };
58
62 void SetViewCenter(const sf::Vector2f & newCenter);
63
67 const sf::Vector2f & GetViewCenter() const {return sfmlView.getCenter(); };
68
73 void SetSize(float width, float height);
74
78 float GetWidth() const { return zoomFactor != 0 ? originalWidth*1.0/zoomFactor : 0; };
79
83 float GetHeight() const { return zoomFactor != 0 ? originalHeight*1.0/zoomFactor : 0; };
84
88 void SetViewport(float x1, float y1, float x2, float y2);
89
90 private:
91
92 float originalWidth;
93 float originalHeight;
94 float angle;
95 float zoomFactor;
96
97 sf::View sfmlView;
98 };
99
105 class GD_API RuntimeLayer
106 {
107 public:
108 RuntimeLayer() : isVisible(true) {};
109 RuntimeLayer(gd::Layer & layer, const sf::View & defaultView);
110 virtual ~RuntimeLayer() {};
111
115 virtual void SetName(const std::string & name_) { name = name_; }
116
120 virtual const std::string & GetName() const { return name; }
121
125 virtual void SetVisibility(bool isVisible_) { isVisible = isVisible_; }
126
130 virtual bool GetVisibility() const { return isVisible; }
131
135 inline unsigned int GetCameraCount() const { return cameras.size(); };
136
140 inline const RuntimeCamera & GetCamera(unsigned int n) const { if ( n >= cameras.size() ) return badCamera; return cameras[n]; }
141
145 inline RuntimeCamera & GetCamera(unsigned int n) { if ( n >= cameras.size() ) return badCamera; return cameras[n]; }
146
150 inline void DeleteCamera(unsigned int n) { if ( n < cameras.size() ) cameras.erase(cameras.begin()+n); }
151
155 inline void AddCamera(const RuntimeCamera & camera) { cameras.push_back(camera); };
156
157 private:
158
159 std::string name;
160 bool isVisible;
161 std::vector < RuntimeCamera > cameras;
162
163 static RuntimeCamera badCamera;
164 };
165
166 #endif // RUNTIMELAYER_H