Elaztek Developer Hub
Blamite Game Engine - blam!  00357.06.18.22.0809.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,
63 
65 };
66 
68 {
69 private:
72 
73  void ShowAnchorChangeButton(BlamWidgetAnchor new_anchor, int height_mul, int width_mul, bool text_multiline);
74 
75 protected:
76  BlamVector2 position_absolute = { 0, 0 };
77  BlamVector2 size_absolute = { 100, 100 };
78 
79 public:
80  std::string display_name = "unnamed";
81  std::string description = "";
82 
83  BlamVector2 position = { 0, 0 };
84  BlamVector2 size = { 100, 100 };
85  float rotation = 0.0f;
86  bool hidden = false;
87 
89 
92  virtual ~BlamUIWidget() {};
93 
94  virtual void Draw() {};
95  virtual void ShowImGuiPropertyEditor();
96  virtual void UpdateMetrics() {};
97 
99 
100  virtual void RefreshRelativePosition();
101  void RefreshRelativePosition(int viewport_width, int viewport_height, BlamVector2 initial_position);
102 
103  void SetSize(BlamVector2 new_size);
104  void SetPosition(BlamVector2 new_position);
105  void SetRotation(float new_rotation);
106  void SetAnchorPosition(BlamWidgetAnchor new_anchor_position);
107 
108  BlamVector2 GetAbsolutePosition();
109 };
110 
112 {
113 private:
114  Blam::DebugUI::Windows::BlamUIEditor* editor_window = nullptr;
115 
116 public:
117  std::vector<BlamUIWidget*> children = std::vector<BlamUIWidget*>();
118 
121 
122  void Draw();
125 
126  void ShowImGuiEditorWindow();
127 };
128 
130 {
131 public:
133 
134  void Draw();
135 };
136 
138 {
139 private:
140  Ogre::v1::TextAreaOverlayElement* text_element = nullptr;
141  Ogre::v1::TextAreaOverlayElement* text_element_shadow = nullptr;
142  Ogre::v1::Overlay* container = nullptr;
143  Ogre::v1::PanelOverlayElement* panel = nullptr;
144 
145 public:
146  bool auto_update = false;
147  bool auto_scale_shadow = true;
149  BlamVector2 shadow_offset = { 1, 1 };
150  BlamColor color = BlamColor(255, 255, 255);
151  BlamColor shadow_color = BlamColor(0, 0, 0);
152  std::string font_name = "fixedsys";
153 
154  std::string text = "blam!";
155 
158 
159  void Draw();
161  void UpdateMetrics() override;
162 };
163 
167 namespace Blam::UI
168 {
169  BLAM bool Initialize();
170  BLAM void Render();
171  BLAM void Shutdown();
172 
174 
175  BLAM std::string GetWidgetAnchorLabel(BlamWidgetAnchor anchor_position);
176 }
BlamUIWidget::hidden
bool hidden
Definition: ui.h:86
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:152
BlamUIWidget_Group
Definition: ui.h:111
BlamWidgetAnchor::CenterRight
@ CenterRight
The widget will be placed at the center-right of the screen.
BlamUIWidget::position
BlamVector2 position
Definition: ui.h:83
Blam::UI::GetWidgetAnchorLabel
BLAM std::string GetWidgetAnchorLabel(BlamWidgetAnchor anchor_position)
Definition: ui.cpp:57
BlamUIWidget_BasicRectangle::Draw
void Draw()
Definition: BlamUIWidget_BasicRectangle.cpp:10
Blam::UI::GetUIRoot
BLAM BlamUIWidget_Group * GetUIRoot()
Definition: ui.cpp:52
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:86
BlamUIWidget::parent
BlamUIWidget_Group * parent
Definition: ui.h:88
BlamUIWidget::rotation
float rotation
Definition: ui.h:85
BlamUIWidget_Group::RefreshRelativePosition
void RefreshRelativePosition()
Definition: BlamUIWidget_Group.cpp:75
BlamUIWidget_Text::character_height
int character_height
Definition: ui.h:148
BlamUIWidget_Text::shadow_offset
BlamVector2 shadow_offset
Definition: ui.h:149
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
BlamUIWidget::size
BlamVector2 size
Definition: ui.h:84
BlamWidgetAnchor::TopCenter
@ TopCenter
The widget will be placed at the top-center of the screen.
BlamUIWidget::Draw
virtual void Draw()
Definition: ui.h:94
BlamUIWidget::~BlamUIWidget
virtual ~BlamUIWidget()
Definition: ui.h:92
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:167
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:290
BlamUIWidget::ShowImGuiPropertyEditor
virtual void ShowImGuiPropertyEditor()
Definition: BlamUIWidget.cpp:57
BlamUIWidget_Text::UpdateMetrics
void UpdateMetrics() override
Definition: BlamUIWidget_Text.cpp:112
BlamUIWidget_Group::children
std::vector< BlamUIWidget * > children
Definition: ui.h:117
BlamUIWidget::display_name
std::string display_name
Definition: ui.h:80
BlamUIWidget_Text::color
BlamColor color
Definition: ui.h:150
Blam::UI::Render
BLAM void Render()
Definition: ui.cpp:29
BlamUIWidget::SetSize
void SetSize(BlamVector2 new_size)
Definition: BlamUIWidget.cpp:283
BlamWidgetAnchor::TopLeft
@ TopLeft
The widget will be placed at the top-left of the screen.
Blam::UI::Shutdown
BLAM void Shutdown()
Definition: ui.cpp:43
BlamUIWidget::UpdateMetrics
virtual void UpdateMetrics()
Definition: ui.h:96
BlamUIWidget_Text::auto_update
bool auto_update
Definition: ui.h:146
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:129
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:67
BLAM
#define BLAM
Definition: ui.h:14
BlamOgreRenderSystemType::Unspecified
@ Unspecified
BlamUIWidget_Text::text
std::string text
Definition: ui.h:154
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:81
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:151
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:11
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:76
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:77
BlamUIWidget_Text::auto_scale_shadow
bool auto_scale_shadow
Definition: ui.h:147
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:309
BlamUIWidget_Text
Definition: ui.h:137
BlamUIWidget::SetAnchorPosition
void SetAnchorPosition(BlamWidgetAnchor new_anchor_position)
Definition: BlamUIWidget.cpp:303
BlamUIWidget::SetRotation
void SetRotation(float new_rotation)
Definition: BlamUIWidget.cpp:297