Thrive
viewport_system.h
1 #pragma once
2 
3 #include "engine/component.h"
4 #include "engine/system.h"
5 #include "engine/touchable.h"
6 
7 #include <memory>
8 #include <OgreCommon.h>
9 #include <OgreColourValue.h>
10 
11 namespace luabind {
12 class scope;
13 }
14 
15 namespace Ogre {
16 class Viewport;
17 }
18 
19 namespace thrive {
20 
26  COMPONENT(OgreViewport)
27 
28 public:
29 
33  struct Properties : public Touchable {
34 
38  Ogre::ColourValue backgroundColour;
39 
46  EntityId cameraEntity = NULL_ENTITY;
47 
54  Ogre::Real height = 1.0f;
55 
62  Ogre::Real left = 0.0f;
63 
70  Ogre::Real top = 0.0f;
71 
78  Ogre::Real width = 1.0f;
79 
80  };
81 
99  static luabind::scope
100  luaBindings();
101 
109  int zOrder = 0
110  );
111 
112  void
113  load(
115  ) override;
116 
118  storage() const override;
119 
126  int
127  zOrder() const;
128 
132  Properties
134 
138  Ogre::Viewport* m_viewport = nullptr;
139 
140 private:
141 
145  int32_t m_zOrder = 0;
146 
147 
148 };
149 
150 
154 class OgreViewportSystem : public System {
155 
156 public:
157 
166  static luabind::scope
167  luaBindings();
168 
173 
178 
179  void
180  activate() override;
181 
182  void
183  deactivate() override;
184 
190  void init(GameState* gameState) override;
191 
195  void shutdown() override;
196 
200  void update(int, int) override;
201 
202 private:
203 
204  struct Implementation;
205  std::unique_ptr<Implementation> m_impl;
206 };
207 
208 }
209 
Helper class for keeping track of changing data.
Definition: touchable.h:18
Ogre::ColourValue backgroundColour
The viewport's background colour.
Definition: viewport_system.h:38
void load(const StorageContainer &storage) override
Loads the component.
Definition: viewport_system.cpp:70
void init(GameState *gameState) override
Initializes the system.
Definition: viewport_system.cpp:222
Ogre::Real height
The viewport's height relative to the window.
Definition: viewport_system.h:54
void shutdown() override
Shuts the system down.
Definition: viewport_system.cpp:234
int zOrder() const
The viewport's z order.
Definition: viewport_system.cpp:99
static luabind::scope luaBindings()
Lua bindings.
Definition: viewport_system.cpp:110
Ogre::Real width
The viewport's width relative to the window.
Definition: viewport_system.h:78
Base class for components.
Definition: component.h:31
OgreViewportComponent(int zOrder=0)
Constructor.
Definition: viewport_system.cpp:62
A system handles one specific part of the game.
Definition: system.h:23
void update(int, int) override
Updates the system.
Definition: viewport_system.cpp:242
void deactivate() override
Called by GameState::deactivate()
Definition: viewport_system.cpp:216
Creates, updates and removes viewports.
Definition: viewport_system.h:154
void activate() override
Called by GameState::activate()
Definition: viewport_system.cpp:209
Ogre::Real top
Top edge of the viewport within the window.
Definition: viewport_system.h:70
Definition: bullet_to_ogre_system.h:5
Definition: bullet_ogre_conversion.h:6
Ogre::Viewport * m_viewport
Pointer to internal Ogre::Viewport.
Definition: viewport_system.h:138
GameState * gameState() const
Returns the system's game state.
Definition: system.cpp:183
OgreViewportSystem()
Constructor.
Definition: viewport_system.cpp:199
Represents a distinct set of active systems and entities.
Definition: game_state.h:41
Definition: debug_drawing.h:8
StorageContainer storage() const override
Serializes the component.
Definition: viewport_system.cpp:85
Properties.
Definition: viewport_system.h:33
EntityId cameraEntity
The camera entity to use.
Definition: viewport_system.h:46
Ogre::Real left
Left edge of the viewport within the window.
Definition: viewport_system.h:62
Properties m_properties
Properties.
Definition: viewport_system.h:133
~OgreViewportSystem()
Destructor.
Definition: viewport_system.cpp:205
static luabind::scope luaBindings()
Lua bindings.
Definition: viewport_system.cpp:44
A proxy for Ogre::Viewport.
Definition: viewport_system.h:25
A key-value storage for serialization.
Definition: serialization.h:36