Thrive
text_overlay.h
1 #pragma once
2 
3 #include "engine/component.h"
4 #include "engine/system.h"
5 #include "engine/touchable.h"
6 
7 #include <Ogre.h>
8 #include <OgreTextAreaOverlayElement.h>
9 
10 namespace luabind {
11  class scope;
12 }
13 
14 namespace thrive {
15 
20  COMPONENT(TextOverlay)
21 
22 public:
23 
27  struct Properties : public Touchable {
28 
32  Ogre::Real charHeight = 16.0f;
33 
37  Ogre::ColourValue colour = Ogre::ColourValue::White;
38 
42  Ogre::String fontName = "Thrive";
43 
47  Ogre::Real height = 100.0f;
48 
52  Ogre::GuiHorizontalAlignment horizontalAlignment = Ogre::GHA_LEFT;
53 
59  Ogre::Real left = 0.0;
60 
64  Ogre::String text = "";
65 
71  Ogre::Real top = 0.0;
72 
76  Ogre::GuiVerticalAlignment verticalAlignment = Ogre::GVA_TOP;
77 
81  Ogre::Real width = 100.0f;
82  };
83 
103  static luabind::scope
104  luaBindings();
105 
113  Ogre::String name
114  );
115 
117 
118  void
119  load(
121  ) override;
122 
127  Ogre::String
128  name() const {
129  return m_name;
130  }
131 
133  storage() const override;
134 
138  Ogre::TextAreaOverlayElement* m_overlayElement = nullptr;
139 
144 
145 private:
146 
147  Ogre::String m_name;
148 };
149 
150 
154 class TextOverlaySystem : public System {
155 
156 public:
157 
166  static luabind::scope
167  luaBindings();
168 
173 
178 
179  void activate() override;
180 
181  void deactivate() override;
182 
187  void init(GameState* gameState) override;
188 
192  void shutdown() override;
193 
197  void update(int, int) override;
198 
199 private:
200 
201  struct Implementation;
202  std::unique_ptr<Implementation> m_impl;
203 
204 };
205 
206 }
Ogre::TextAreaOverlayElement * m_overlayElement
Pointer to internal overlay element.
Definition: text_overlay.h:138
Helper class for keeping track of changing data.
Definition: touchable.h:18
Properties.
Definition: text_overlay.h:27
Ogre::Real width
Textbox width in pixels.
Definition: text_overlay.h:81
Ogre::String fontName
Font name.
Definition: text_overlay.h:42
void load(const StorageContainer &storage) override
Loads the component.
Definition: text_overlay.cpp:67
void deactivate() override
Called by GameState::deactivate()
Definition: text_overlay.cpp:224
TextOverlaySystem()
Constructor.
Definition: text_overlay.cpp:207
Ogre::String name() const
The overlay's name.
Definition: text_overlay.h:128
Creates, updates and removes text overlays.
Definition: text_overlay.h:154
Base class for components.
Definition: component.h:31
static luabind::scope luaBindings()
Lua bindings.
Definition: text_overlay.cpp:20
Properties m_properties
Properties.
Definition: text_overlay.h:143
A system handles one specific part of the game.
Definition: system.h:23
void init(GameState *gameState) override
Initializes the system.
Definition: text_overlay.cpp:230
Ogre::Real top
Offset relative to screen anchor in pixels.
Definition: text_overlay.h:71
Ogre::Real left
Offset relative to screen anchor in pixels.
Definition: text_overlay.h:59
Ogre::ColourValue colour
Text colour.
Definition: text_overlay.h:37
Ogre::GuiVerticalAlignment verticalAlignment
Vertical alignment relative to screen.
Definition: text_overlay.h:76
Ogre::Real charHeight
The character height in pixels.
Definition: text_overlay.h:32
static luabind::scope luaBindings()
Lua bindings.
Definition: text_overlay.cpp:115
Definition: bullet_to_ogre_system.h:5
Definition: bullet_ogre_conversion.h:6
Ogre::String text
Text to display.
Definition: text_overlay.h:64
GameState * gameState() const
Returns the system's game state.
Definition: system.cpp:183
StorageContainer storage() const override
Serializes the component.
Definition: text_overlay.cpp:90
Represents a distinct set of active systems and entities.
Definition: game_state.h:41
void shutdown() override
Shuts the system down.
Definition: text_overlay.cpp:240
A component for a text overlay.
Definition: text_overlay.h:19
void update(int, int) override
Updates the system.
Definition: text_overlay.cpp:248
Ogre::Real height
Textbox height in pixels.
Definition: text_overlay.h:47
~TextOverlaySystem()
Destructor.
Definition: text_overlay.cpp:213
void activate() override
Called by GameState::activate()
Definition: text_overlay.cpp:217
A key-value storage for serialization.
Definition: serialization.h:36
Ogre::GuiHorizontalAlignment horizontalAlignment
Horizontal alignment relative to screen.
Definition: text_overlay.h:52