Debian Codegraph @

plugins/dm.gui/gui/GuiWindowDef.h

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