Elaztek Developer Hub
Blamite Game Engine - blam!  00398.09.22.23.2015.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 public:
15  byte opacity = 255;
16  BlamLogMessage message;
17 
18  int visible_ticks = 0;
19 
22 
31  void Reconfigure(BlamLogMessage _message);
32 
39  void Deconfigure();
40 };
41 
48 class BlamUIWidget_Console : public BlamUIWidget, public BlamEventListener
49 {
50 private:
51  BlamUIWidget_Text* prompt = nullptr;
52  BlamUIWidget_Text* input = nullptr;
53 
54  std::vector<BlamConsoleHistoryEntry*> history = std::vector<BlamConsoleHistoryEntry*>();
55 
56  std::vector<std::vector<BlamConsoleHistoryEntry*>> help_columns = std::vector<std::vector<BlamConsoleHistoryEntry*>>();
57 
58  std::vector<std::string> input_history = std::vector<std::string>();
59  int selected_history_index = -1;
60 
61  std::string command_input = "";
62  int cursor_position = 0;
63  bool prompt_hidden = true;
64 
65  int column_count = 6;
66  int column_width = 346;
67  int max_output_lines = 32;
68  float output_line_height = 32.0f;
69 
73  void ResizeColumns();
74 
80  void RebuildHelpColumns(bool keep_content);
81 
85  void BuildHelpGuide();
86 
87 public:
88 
95 
97 
98  void Draw() override;
99  void ShowImGuiPropertyEditor() override;
100  void UpdateMetrics() override;
101  void RefreshRelativePosition() override;
102 
103  void OnKeyPressEvent(KeyPressEvent* event) override;
104  void OnCharacterInputEvent(CharacterInputEvent* event) override;
105  void OnTickEvent(TickEvent* event) override;
106  void OnLogMessageEvent(LogMessageEvent* event) override;
107 
118  void PrintAsColumns(std::vector<std::string> items);
119 
132  void PrintAsColumns(std::vector<BlamLogMessage> items);
133 
137  void ClearOutput();
138 };
ui.h
BlamUIWidget_Console::ShowImGuiPropertyEditor
void ShowImGuiPropertyEditor() override
Definition: BlamUIWidget_Console.cpp:172
BlamConsoleHistoryEntry::text_element
BlamUIWidget_Text * text_element
The UI widget used for displaying the message.
Definition: console.h:14
BlamConsoleHistoryEntry::visible_ticks
int visible_ticks
The amount of ticks that the message has been visible.
Definition: console.h:18
BlamConsoleHistoryEntry::BlamConsoleHistoryEntry
BlamConsoleHistoryEntry()
Definition: BlamConsoleHistoryEntry.cpp:5
BlamUIWidget_Group
Definition: ui.h:141
logger.h
BlamConsoleHistoryEntry::creation_tick
uint64_t creation_tick
The tick when this entry was created.
Definition: console.h:13
BlamUIWidget_Console::UpdateMetrics
void UpdateMetrics() override
Definition: BlamUIWidget_Console.cpp:185
BlamUIWidget_Console::~BlamUIWidget_Console
~BlamUIWidget_Console()
Definition: BlamUIWidget_Console.cpp:61
BlamUIWidget_Console::OnCharacterInputEvent
void OnCharacterInputEvent(CharacterInputEvent *event) override
Definition: BlamUIWidget_Console.cpp:378
BlamUIWidget_Console::PrintAsColumns
void PrintAsColumns(std::vector< std::string > items)
Displays a list of strings within the console column display.
Definition: BlamUIWidget_Console.cpp:690
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
BlamUIWidget_Console::RefreshRelativePosition
void RefreshRelativePosition() override
Definition: BlamUIWidget_Console.cpp:223
uint64_t
unsigned long long uint64_t
Definition: stdint.h:18
BlamUIWidget_Console::Draw
void Draw() override
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:15
BlamUIWidget_Console::ClearOutput
void ClearOutput()
Clears the console output.
Definition: BlamUIWidget_Console.cpp:779
BlamUIWidget
Definition: ui.h:82
BlamConsoleHistoryEntry::Deconfigure
void Deconfigure()
Deconfigures this console history entry.
Definition: BlamConsoleHistoryEntry.cpp:36
BlamUIWidget_Console
Class for the console UI widget.
Definition: console.h:48
BlamUIWidget_Console::OnLogMessageEvent
void OnLogMessageEvent(LogMessageEvent *event) override
Definition: BlamUIWidget_Console.cpp:475
BlamConsoleHistoryEntry
Class representing a console history entry.
Definition: console.h:10
BlamUIWidget_Console::OnTickEvent
void OnTickEvent(TickEvent *event) override
Definition: BlamUIWidget_Console.cpp:408
BlamConsoleHistoryEntry::message
BlamLogMessage message
The message that this entry is displaying.
Definition: console.h:16
BlamUIWidget_Text
Definition: ui.h:293
BlamUIWidget_Console::OnKeyPressEvent
void OnKeyPressEvent(KeyPressEvent *event) override
Definition: BlamUIWidget_Console.cpp:241