Elaztek Developer Hub
Blamite Game Engine - blam!  00423.10.27.24.0533.blamite
The core library for the Blamite Game Engine.
console.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <Strings/components/classes/events/events.h>
6 
11 {
12 private:
13  bool needs_reconfigure = false;
14  bool needs_deconfigure = false;
15 
16 public:
19  byte opacity = 255;
20  BlamLogMessage message;
21 
22  int visible_ticks = 0;
23 
26 
35  void Reconfigure(BlamLogMessage _message);
36 
43  void Deconfigure();
44 
45  void Draw();
46 };
47 
54 class BlamUIWidget_Console : public BlamUIWidget, public BlamEventListener
55 {
56 private:
57  BlamUIWidget_Text* prompt = nullptr;
58  BlamUIWidget_Text* input = nullptr;
59 
60  std::vector<BlamConsoleHistoryEntry*> history = std::vector<BlamConsoleHistoryEntry*>();
61 
62  std::vector<std::vector<BlamConsoleHistoryEntry*>> help_columns = std::vector<std::vector<BlamConsoleHistoryEntry*>>();
63 
64  std::vector<std::string> input_history = std::vector<std::string>();
65  int selected_history_index = -1;
66 
67  std::string command_input = "";
68  int cursor_position = 0;
69  bool prompt_hidden = true;
70 
71  int column_count = 6;
72  int column_width = 346;
73  int max_output_lines = 32;
74  float output_line_height = 16.0f;
75 
79  void ResizeColumns();
80 
86  void RebuildHelpColumns(bool keep_content);
87 
91  void BuildHelpGuide();
92 
93 public:
94 
101 
103 
104  void Draw() override;
105  void ShowImGuiPropertyEditor() override;
106  void UpdateMetrics() override;
107  void RefreshRelativePosition() override;
108 
109  void OnKeyPressEvent(KeyPressEvent* event) override;
110  void OnCharacterInputEvent(CharacterInputEvent* event) override;
111  void OnTickEvent(TickEvent* event) override;
112  void OnLogMessageEvent(LogMessageEvent* event) override;
113 
124  void PrintAsColumns(std::vector<std::string> items);
125 
138  void PrintAsColumns(std::vector<BlamLogMessage> items);
139 
143  void ClearOutput();
144 };
ui.h
BlamUIWidget_Console::ShowImGuiPropertyEditor
void ShowImGuiPropertyEditor() override
Displays an ImGUI-based property editor.
Definition: BlamUIWidget_Console.cpp:176
BlamConsoleHistoryEntry::text_element
BlamUIWidget_Text * text_element
The UI widget used for displaying the message.
Definition: console.h:18
BlamConsoleHistoryEntry::visible_ticks
int visible_ticks
The amount of ticks that the message has been visible.
Definition: console.h:22
BlamConsoleHistoryEntry::BlamConsoleHistoryEntry
BlamConsoleHistoryEntry()
Definition: BlamConsoleHistoryEntry.cpp:5
BlamUIWidget_Group
Class representing a Group widget.
Definition: ui.h:265
logger.h
BlamConsoleHistoryEntry::creation_tick
uint64_t creation_tick
The tick when this entry was created.
Definition: console.h:17
BlamUIWidget_Console::UpdateMetrics
void UpdateMetrics() override
Updates metrics for the widget.
Definition: BlamUIWidget_Console.cpp:189
BlamUIWidget_Console::~BlamUIWidget_Console
~BlamUIWidget_Console()
Definition: BlamUIWidget_Console.cpp:61
BlamUIWidget_Console::OnCharacterInputEvent
void OnCharacterInputEvent(CharacterInputEvent *event) override
Definition: BlamUIWidget_Console.cpp:326
BlamUIWidget_Console::PrintAsColumns
void PrintAsColumns(std::vector< std::string > items)
Displays a list of strings within the console column display.
Definition: BlamUIWidget_Console.cpp:652
BlamUIWidget_Console::BlamUIWidget_Console
BlamUIWidget_Console(BlamUIWidget_Group *_parent)
Constructs a new console widget.
Definition: BlamUIWidget_Console.cpp:16
BlamConsoleHistoryEntry::~BlamConsoleHistoryEntry
~BlamConsoleHistoryEntry()
Definition: BlamConsoleHistoryEntry.cpp:17
BlamConsoleHistoryEntry::Draw
void Draw()
Definition: BlamConsoleHistoryEntry.cpp:38
BlamUIWidget_Console::RefreshRelativePosition
void RefreshRelativePosition() override
Updates the relative position of the widget, relative to its parent.
Definition: BlamUIWidget_Console.cpp:227
uint64_t
unsigned long long uint64_t
Definition: stdint.h:18
BlamUIWidget_Console::Draw
void Draw() override
Draws the widget on-screen.
Definition: BlamUIWidget_Console.cpp:89
BlamConsoleHistoryEntry::Reconfigure
void Reconfigure(BlamLogMessage _message)
Reconfigures this console history entry.
Definition: BlamConsoleHistoryEntry.cpp:23
BlamConsoleHistoryEntry::opacity
byte opacity
The opacity of the message text.
Definition: console.h:19
BlamUIWidget_Console::ClearOutput
void ClearOutput()
Clears the console output.
Definition: BlamUIWidget_Console.cpp:741
BlamUIWidget
Base class for a UI widget.
Definition: ui.h:89
BlamConsoleHistoryEntry::Deconfigure
void Deconfigure()
Deconfigures this console history entry.
Definition: BlamConsoleHistoryEntry.cpp:33
BlamUIWidget_Console
Class for the console UI widget.
Definition: console.h:54
BlamUIWidget_Console::OnLogMessageEvent
void OnLogMessageEvent(LogMessageEvent *event) override
Definition: BlamUIWidget_Console.cpp:423
BlamConsoleHistoryEntry
Class representing a console history entry.
Definition: console.h:10
BlamUIWidget_Console::OnTickEvent
void OnTickEvent(TickEvent *event) override
Definition: BlamUIWidget_Console.cpp:356
BlamConsoleHistoryEntry::message
BlamLogMessage message
The message that this entry is displaying.
Definition: console.h:20
BlamUIWidget_Text
Class representing a Text widget.
Definition: ui.h:485
BlamUIWidget_Console::OnKeyPressEvent
void OnKeyPressEvent(KeyPressEvent *event) override
Definition: BlamUIWidget_Console.cpp:245