 |
Blamite Game Engine - blam!
00310.02.05.21.0336.blamite
The core library for the Blamite Game Engine.
|
Go to the documentation of this file.
3 #include "../../debug_ui.h"
6 #include "components/3rdparty/imgui/misc/imgui_stdlib.h"
23 std::string input_buffer =
"";
24 std::vector<BlamLogMessage> history;
27 bool needs_scroll =
false;
28 bool needs_reclaim_focus =
false;
58 needs_reclaim_focus =
true;
67 if (ImGui::Begin(
"Console", &
show))
69 float window_width = ImGui::GetWindowContentRegionWidth();
72 if (ImGui::BeginChildFrame(ImGuiID(
"log_output"), ImVec2(window_width, window_height),
73 ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_HorizontalScrollbar))
75 for (
int i = 0; i < history.size(); i++)
77 BlamColor
color = history.at(i).color;
78 ImVec4 message_color = ImVec4(
color.GetRedAsFloat(),
color.GetGreenAsFloat(),
color.GetBlueAsFloat(),
color.GetAlphaAsFloat());
80 ImGui::PushID(std::string(
"console_item_" + std::to_string(i)).c_str());
81 ImGui::TextColored(message_color, history.at(i).message.c_str());
87 ImGui::SetScrollHereY(1.0f);
91 ImGui::EndChildFrame();
99 ImGui::SetItemDefaultFocus();
100 ImGui::InputText(
"", &input_buffer);
102 if (needs_reclaim_focus)
104 ImGui::SetKeyboardFocusHere(-1);
105 needs_reclaim_focus =
false;
108 focused = ImGui::IsItemActive();
112 if (ImGui::Button(
"Run Command"))
BLAM void RegisterListener(BlamEventListener *listener)
Registers a an event listener.
Definition: events.cpp:80
void Draw()
Draws the contents of the group.
Definition: console.hpp:63
void OnKeyPressEvent(KeyPressEvent *event)
Called when the listener is subscribed to Key Press events, and a new KeyPressEvent is fired.
Definition: console.hpp:51
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:400
@ color
Definition: render_model.h:13
Class representing a virtual key press.
Definition: KeyPressEvent.h:12
int GetVirtualKey()
Retrieves the virtual key code that was pressed.
Definition: KeyPressEvent.cpp:8
@ EventType_LogMessage
Definition: BlamEvent.h:12
BLAM HRESULT RunCommandLine(std::string command_line)
Executed the provided string as a console command.
Definition: console.cpp:205
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: debug_ui.h:362
Class for the ImGUI console implementation.
Definition: console.hpp:20
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:359
ImGuiConsole()
Definition: console.hpp:38
Class representing a log message event.
Definition: LogMessage.h:12
@ EventType_KeyPress
Definition: BlamEvent.h:5
BlamLogMessage GetLogMessage()
Retrieves the message that was logged.
Definition: LogMessage.cpp:8
void Subscribe(BlamEventType type)
Subscribes to an event type.
Definition: BlamEventListener.cpp:3
#define ENGINE_TEXT(string_id)
Definition: engine_text.h:7
Legacy namespace to contain data for the legacy ImGUI console.
Definition: debug_ui.h:434
Class representing an Event Listener.
Definition: events.h:28
@ Text
Master text object that wraps around both BitmapText and DWText.
Definition: render_stack.h:73
void OnLogMessageEvent(LogMessageEvent *event)
Called when the listener is subscribed to Log Message events, and a new LogMessageEvent is fired.
Definition: console.hpp:45