Elaztek Developer Hub
Blamite Game Engine - blam!  00367.02.08.23.1815.blamite
The core library for the Blamite Game Engine.
ui.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include <Strings/components/resources/color/BlamColor.h>
6 #include <OGRE/Overlay/OgreTextAreaOverlayElement.h>
7 #include <OGRE/Overlay/OgreOverlayContainer.h>
8 #include <OGRE/Overlay/OgrePanelOverlayElement.h>
9 #include <OGRE/Overlay/OgreOverlay.h>
10 #include <vector>
11 #include <string>
12 
13 #ifndef BLAM
14 #define BLAM
15 #endif
16 
17 class BlamUIWidget_Group;
18 
20 {
21  class BlamUIEditor;
22 }
23 
29 enum class BlamWidgetAnchor
30 {
31  TopCenter,
32  Center,
33  BottomCenter,
34 
35  TopLeft,
36  CenterLeft,
37  BottomLeft,
38 
39  TopRight,
40  CenterRight,
41  BottomRight,
42 
43  TopFill,
44  LeftFill,
45  RightFill,
46  BottomFill,
47  Fill
48 };
49 
53 enum class BlamWidgetType
54 {
57  //Basic_Line,
58  Text,
59  Group,
60 
61  Console,
62  UIDCypher,
65 
67 };
68 
70 {
71 private:
74 
75  void ShowAnchorChangeButton(BlamWidgetAnchor new_anchor, int height_mul, int width_mul, bool text_multiline);
76 
77 protected:
78  BlamVector2 position_absolute = { 0, 0 };
79  BlamVector2 size_absolute = { 100, 100 };
80 
81 public:
82  std::string display_name = "unnamed";
83  std::string description = "";
84 
85  BlamVector2 position = { 0, 0 };
86  BlamVector2 size = { 100, 100 };
87  float rotation = 0.0f;
88  bool hidden = false;
89 
91 
94  virtual ~BlamUIWidget() {};
95 
96  virtual void Draw() {};
97  virtual void ShowImGuiPropertyEditor();
98  virtual void UpdateMetrics() {};
99 
101 
102  virtual void RefreshRelativePosition();
103  void RefreshRelativePosition(int viewport_width, int viewport_height, BlamVector2 initial_position);
104 
105  void SetSize(BlamVector2 new_size);
106  void SetPosition(BlamVector2 new_position);
107  void SetRotation(float new_rotation);
108  void SetAnchorPosition(BlamWidgetAnchor new_anchor_position);
109 
110  BlamVector2 GetAbsolutePosition();
111 };
112 
114 {
115 private:
116  Blam::DebugUI::Windows::BlamUIEditor* editor_window = nullptr;
117 
118 public:
119  std::vector<BlamUIWidget*> children = std::vector<BlamUIWidget*>();
120 
123 
124  void Draw();
127 
128  void ShowImGuiEditorWindow();
129 };
130 
132 {
133 public:
135 
136  void Draw();
137 };
138 
140 {
141 private:
142  Ogre::v1::TextAreaOverlayElement* text_element = nullptr;
143  Ogre::v1::TextAreaOverlayElement* text_element_shadow = nullptr;
144  Ogre::v1::Overlay* container = nullptr;
145  Ogre::v1::PanelOverlayElement* panel = nullptr;
146 
147  std::string previous_text = "";
148  bool last_hide_state = false;
149 
150 public:
151  bool auto_update = false;
152  bool auto_scale_shadow = true;
154  BlamVector2 shadow_offset = { 1, 1 };
155  BlamColor color = BlamColor(255, 255, 255);
156  BlamColor shadow_color = BlamColor(0, 0, 0);
157  std::string font_name = "fixedsys";
158 
159  std::string text = "blam!";
160 
163 
164  void Draw();
166  void UpdateMetrics() override;
167 };
168 
172 namespace Blam::UI
173 {
174  BLAM bool Initialize();
175  BLAM void Render();
176  BLAM void Shutdown();
177 
179 
180  BLAM std::string GetWidgetAnchorLabel(BlamWidgetAnchor anchor_position);
181 }
BlamUIWidget::hidden
bool hidden
Definition: ui.h:88
BlamWidgetAnchor::LeftFill
@ LeftFill
The widget will fill the left of the screen, while width is left unchanged.
BlamUIWidget::BlamUIWidget
BlamUIWidget(BlamWidgetType type)
Definition: BlamUIWidget.cpp:35
BlamWidgetAnchor::BottomRight
@ BottomRight
The widget will be placed at the bottom-right of the screen.
BlamWidgetAnchor::CenterLeft
@ CenterLeft
The widget will be placed at the center-left of the screen.
BlamUIWidget_Text::font_name
std::string font_name
Definition: ui.h:157
BlamUIWidget_Group
Definition: ui.h:113
BlamWidgetAnchor::CenterRight
@ CenterRight
The widget will be placed at the center-right of the screen.
BlamUIWidget::position
BlamVector2 position
Definition: ui.h:85
Blam::UI::GetWidgetAnchorLabel
BLAM std::string GetWidgetAnchorLabel(BlamWidgetAnchor anchor_position)
Definition: ui.cpp:75
BlamUIWidget_BasicRectangle::Draw
void Draw()
Definition: BlamUIWidget_BasicRectangle.cpp:10
Blam::UI::GetUIRoot
BLAM BlamUIWidget_Group * GetUIRoot()
Definition: ui.cpp:70
BlamWidgetAnchor::BottomFill
@ BottomFill
The widget will fill the bottom of the screen, while height is left unchanged.
BlamUIWidget_Text::ShowImGuiPropertyEditor
void ShowImGuiPropertyEditor()
Definition: BlamUIWidget_Text.cpp:98
BlamUIWidget::parent
BlamUIWidget_Group * parent
Definition: ui.h:90
BlamUIWidget::rotation
float rotation
Definition: ui.h:87
BlamUIWidget_Group::RefreshRelativePosition
void RefreshRelativePosition()
Definition: BlamUIWidget_Group.cpp:75
BlamUIWidget_Text::character_height
int character_height
Definition: ui.h:153
BlamUIWidget_Text::shadow_offset
BlamVector2 shadow_offset
Definition: ui.h:154
BlamWidgetType::Text
@ Text
A text object, used to show text on-screen.
BlamWidgetType::Basic_Rectangle
@ Basic_Rectangle
A basic filled rectangle.
BlamWidgetType::Basic_Ellipse
@ Basic_Ellipse
A basic filled ellipse.
world.h
BlamVersionStringDisplayMode::Console
@ Console
Indicates the build string should be formatted for the in-game console.
BlamUIWidget_Group::ShowImGuiEditorWindow
void ShowImGuiEditorWindow()
Definition: BlamUIWidget_Group.cpp:90
BlamWidgetAnchor::Center
@ Center
The widget will be placed at the center of the screen.
BlamUIWidget::GetType
BlamWidgetType GetType()
Definition: BlamUIWidget.cpp:147
color
BlamColor color
Typedef for a color field, used in tag definitions.
Definition: tags.h:319
BlamUIWidget::size
BlamVector2 size
Definition: ui.h:86
BlamWidgetAnchor::TopCenter
@ TopCenter
The widget will be placed at the top-center of the screen.
BlamUIWidget::Draw
virtual void Draw()
Definition: ui.h:96
BlamUIWidget::~BlamUIWidget
virtual ~BlamUIWidget()
Definition: ui.h:94
BlamWidgetType::UIDCypher
@ UIDCypher
Special widget. Used for the user ID cypher.
BlamUIWidget_Text::Draw
void Draw()
Definition: BlamUIWidget_Text.cpp:66
Blam::UI
Namespace containing functions relating to the Blamite UI system.
Definition: ui.h:172
BlamWidgetAnchor::Fill
@ Fill
The widget will fill the entire screen.
BlamUIWidget_Group::~BlamUIWidget_Group
~BlamUIWidget_Group()
Definition: BlamUIWidget_Group.cpp:13
BlamUIWidget_Text::~BlamUIWidget_Text
~BlamUIWidget_Text()
Definition: BlamUIWidget_Text.cpp:51
BlamUIWidget::SetPosition
void SetPosition(BlamVector2 new_position)
Definition: BlamUIWidget.cpp:297
BlamUIWidget::ShowImGuiPropertyEditor
virtual void ShowImGuiPropertyEditor()
Definition: BlamUIWidget.cpp:57
BlamUIWidget_Text::UpdateMetrics
void UpdateMetrics() override
Definition: BlamUIWidget_Text.cpp:124
BlamUIWidget_Group::children
std::vector< BlamUIWidget * > children
Definition: ui.h:119
BlamUIWidget::display_name
std::string display_name
Definition: ui.h:82
Blam::UI::Render
BLAM void Render()
Definition: ui.cpp:47
BlamUIWidget::SetSize
void SetSize(BlamVector2 new_size)
Definition: BlamUIWidget.cpp:290
BlamWidgetAnchor::TopLeft
@ TopLeft
The widget will be placed at the top-left of the screen.
Blam::UI::Shutdown
BLAM void Shutdown()
Definition: ui.cpp:61
BlamUIWidget::UpdateMetrics
virtual void UpdateMetrics()
Definition: ui.h:98
BlamUIWidget_Text::auto_update
bool auto_update
Definition: ui.h:151
BlamWidgetAnchor
BlamWidgetAnchor
Enumerator listing possible widget anchor positions.
Definition: ui.h:29
BlamWidgetAnchor::BottomLeft
@ BottomLeft
The widget will be placed at the bottom-left of the screen.
BlamUIWidget_BasicRectangle
Definition: ui.h:131
BlamUIWidget_Group::Draw
void Draw()
Definition: BlamUIWidget_Group.cpp:28
Blam::DebugUI::Windows::BlamUIEditor
Class for the Blam UI Editor debug utility.
Definition: blam_ui_editor.hpp:13
BlamUIWidget_Text::BlamUIWidget_Text
BlamUIWidget_Text(BlamUIWidget_Group *_parent)
Definition: BlamUIWidget_Text.cpp:18
BlamUIWidget
Definition: ui.h:69
BLAM
#define BLAM
Definition: ui.h:14
BlamOgreRenderSystemType::Unspecified
@ Unspecified
BlamWidgetType::CoordinatesDisplay
@ CoordinatesDisplay
Special widget. Used for the coordinates display.
BlamUIWidget_Text::text
std::string text
Definition: ui.h:159
BlamUIWidget::RefreshRelativePosition
virtual void RefreshRelativePosition()
Definition: BlamUIWidget.cpp:152
BlamWidgetType::Group
@ Group
A group widget, which can be used to contain any number of other widgets.
BlamUIWidget::description
std::string description
Definition: ui.h:83
BlamWidgetAnchor::TopFill
@ TopFill
The widget will fill the top of the screen, while height is left unchanged.
BlamUIWidget_Text::shadow_color
BlamColor shadow_color
Definition: ui.h:156
BlamWidgetType::FramerateDisplay
@ FramerateDisplay
Special widget. Used for the framerate display.
BlamUIWidget_Group::ShowImGuiPropertyEditor
void ShowImGuiPropertyEditor()
Definition: BlamUIWidget_Group.cpp:42
BlamWidgetType
BlamWidgetType
Enumerator listing possible UI widget types.
Definition: ui.h:53
Blam::UI::Initialize
BLAM bool Initialize()
Definition: ui.cpp:13
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: ui.h:19
BlamUIWidget_Group::BlamUIWidget_Group
BlamUIWidget_Group(BlamUIWidget_Group *_parent)
Definition: BlamUIWidget_Group.cpp:8
BlamUIWidget::position_absolute
BlamVector2 position_absolute
Definition: ui.h:78
BlamWidgetAnchor::RightFill
@ RightFill
The widget will fill the right of the screen, while width is left unchanged.
BlamUIWidget::size_absolute
BlamVector2 size_absolute
Definition: ui.h:79
BlamUIWidget_Text::auto_scale_shadow
bool auto_scale_shadow
Definition: ui.h:152
BlamUIWidget_BasicRectangle::BlamUIWidget_BasicRectangle
BlamUIWidget_BasicRectangle(BlamUIWidget_Group *_parent)
Definition: BlamUIWidget_BasicRectangle.cpp:5
BlamWidgetAnchor::BottomCenter
@ BottomCenter
The widget will be placed at the bottom-center of the screen.
BlamWidgetAnchor::TopRight
@ TopRight
The widget will be placed at the top-right of the screen.
BlamWidgetType::Unspecified
@ Unspecified
Indicates the widget is of an unspecified type. Will only appear when a widget is improperly construc...
BlamUIWidget::GetAbsolutePosition
BlamVector2 GetAbsolutePosition()
Definition: BlamUIWidget.cpp:316
BlamUIWidget_Text
Definition: ui.h:139
BlamUIWidget::SetAnchorPosition
void SetAnchorPosition(BlamWidgetAnchor new_anchor_position)
Definition: BlamUIWidget.cpp:310
BlamUIWidget::SetRotation
void SetRotation(float new_rotation)
Definition: BlamUIWidget.cpp:304