/
GuiWindowDef.h
93 lines (67 loc) · 2.44 KB
/
GuiWindowDef.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
#include "igui.h"
#include "ishaders.h"
#include "math/Vector4.h"
#include "GuiExpression.h"
#include "RenderableText.h"
namespace parser { class DefTokeniser; }
namespace gui
{
class Gui;
class GuiWindowDef;
typedef std::shared_ptr<GuiWindowDef> GuiWindowDefPtr;
class GuiScript;
typedef std::shared_ptr<GuiScript> GuiScriptPtr;
/**
* greebo: This is the base class for all windowDef-like objects in a GUI,
* including windowDef, choiceDef, bindDef, etc.
*/
class GuiWindowDef :
public IGuiWindowDef
{
private:
// The owning GUI
IGui& _owner;
// The renderable text object for submission to a Renderer
RenderableText _renderableText;
// Whether the text has changed
bool _textChanged;
// The text to be rendered in this window (private, use getText() and setText())
std::string _text;
// The mapping between time and GUI scripts
typedef std::multimap<std::size_t, GuiScriptPtr> TimedEventMap;
TimedEventMap _timedEvents;
public:
// Default constructor
GuiWindowDef(IGui& owner);
// Returns the GUI
IGui& getGui() const override;
void constructFromTokens(parser::DefTokeniser& tokeniser);
void addWindow(const IGuiWindowDefPtr& window) override;
// Recursively looks for a named child windowDef
// Returns NULL if not found
IGuiWindowDefPtr findWindowDef(const std::string& name) override;
const std::string& getText() const override;
void setText(const std::string& newText) override;
// Get the renderable text object containing the OpenGLRenderables
IRenderableText& getRenderableText() override;
/**
* greebo: This is some sort of "think" method, giving this windowDef
* a chance to handle timed events.
*
* @updateChildren: recursively updates child windowDef if true
*/
void update(const std::size_t timeStep, bool updateChildren = true) override;
// Initialises the time of this windowDef and all children
void initTime(const std::size_t time, bool updateChildren = true) override;
// Prepares renderable objects, to be called by the parent Gui only
void pepareRendering(bool prepareChildren = true) override;
public:
static Vector4 parseVector4(parser::DefTokeniser& tokeniser);
static float parseFloat(parser::DefTokeniser& tokeniser);
static int parseInt(parser::DefTokeniser& tokeniser);
static std::string parseString(parser::DefTokeniser& tokeniser);
static bool parseBool(parser::DefTokeniser& tokeniser);
static GuiExpressionPtr getExpression(parser::DefTokeniser& tokeniser);
};
} // namespace