 |
Blamite Game Engine - blam!
00272.10.26.20.0001.blamite
The core library for the Blamite Game Engine.
|
Go to the documentation of this file.
6 #include "../../render_stack.h"
8 #include <Strings/components/utils/string/string.h>
11 #include <Strings/components/utils/math/math.h>
67 float x_offset_base = 9;
68 float y_offset_base = 10;
70 float x_offset = x_offset_base;
71 float y_offset = y_offset_base;
76 int prompt_stack_index = -1;
77 int input_stack_index = -1;
80 char active_index_char =
'_';
81 std::string font_id =
"";
82 bool extra_padding =
false;
86 std::string current_input_display =
"";
87 std::string current_input =
"";
89 int temp_line_height_base = 14;
90 int temp_line_height = temp_line_height_base;
92 int max_recent_items = 30;
94 std::vector<ConsoleMessage*> recent_output;
95 std::vector<std::string> recent_input;
96 int current_history_index = 0;
98 int console_bottom_margin_base = 12;
99 int input_field_offset_base = 46;
101 int console_bottom_margin = console_bottom_margin_base;
102 int input_field_offset = input_field_offset_base;
104 float c_scale_factor = 1.0f;
106 float message_show_duration = 4.0f;
107 float message_fade_duration = 1.0f;
122 prompt->
color = D2D1::ColorF(1, 0.298, 1, 1);
123 prompt->
text =
"halo(";
132 input->
color = D2D1::ColorF(1, 0.298, 1, 1);
153 for (
int i = 0; i < recent_output.size(); i++)
155 delete recent_output[i]->message;
156 delete recent_output[i];
169 if (scale_factor != c_scale_factor)
171 c_scale_factor = scale_factor;
173 console_bottom_margin = console_bottom_margin_base * (int)round(scale_factor);
174 input_field_offset = input_field_offset_base * (int)round(scale_factor);
176 x_offset = x_offset_base * (int)round(scale_factor);
177 y_offset = y_offset_base * (int)round(scale_factor);
179 temp_line_height = temp_line_height_base * (int)round(scale_factor);
184 for (
int i = 0; i < recent_output.size(); i++)
191 for (
int i = recent_output.size() - 1; i >= 0; i--)
195 if (item->
color.a == 0)
197 delete recent_output[i]->message;
198 delete recent_output[i];
200 recent_output.erase(recent_output.begin() + i);
217 current_input.insert(active_index, c);
232 event->setCancelled(
true);
238 event->setCancelled(
true);
244 event->setCancelled(
true);
250 event->setCancelled(
true);
256 event->setCancelled(
true);
262 event->setCancelled(
true);
268 event->setCancelled(
true);
286 current_input_display = current_input;
288 if (active_index == current_input.length())
290 current_input_display += active_index_char;
294 current_input_display[active_index] = active_index_char;
297 input->
text = current_input_display;
315 int line_multiplier = recent_output.size();
316 for (
int i = 0; i < recent_output.size(); i++)
324 y_placement -= temp_line_height;
327 y_placement -= (temp_line_height * line_multiplier);
358 message.
message =
"too many errors, only printing to debug.txt";
369 float new_r = (float)message.
color.
r / 255;
370 float new_g = (
float)message.
color.
g / 255;
371 float new_b = (float)message.
color.
b / 255;
373 log_msg->
color = D2D1::ColorF(new_r, new_g, new_b, 1);
388 c_msg->
anim.
Initialize(D2D1::ColorF(1.0f, 1.0f, 1.0f, 0.0f), log_msg->
color, message_fade_duration,
false);
390 recent_output.push_back(c_msg);
393 if (recent_output.size() >= max_recent_items)
395 recent_output.erase(recent_output.begin() + 0);
398 for (
int i = 0; i < recent_output.size(); i++)
422 for (
int i = 0; i < recent_output.size(); i++)
424 while (recent_output[i]->message->currently_locked)
429 delete recent_output[i]->message;
432 recent_output.clear();
458 if (current_input.length() > 0)
460 current_input.erase(active_index - 1, 1);
474 if (active_index > 0)
488 if (active_index < current_input.length())
499 if (current_history_index > 0)
501 current_history_index--;
503 current_input = recent_input[current_history_index];
505 active_index = current_input.size();
513 current_history_index++;
515 if (current_history_index < recent_input.size())
517 current_input = recent_input[current_history_index];
519 active_index = current_input.size();
523 current_history_index = recent_input.size();
524 current_input.clear();
543 if (current_input.length() > 0)
549 recent_input.push_back(current_input);
550 current_history_index = recent_input.size();
552 current_input.clear();
568 std::map<std::string, Blam::Console::ConsoleCommand*>::iterator it;
571 for (it = map.begin(); it != map.end(); it++)
573 std::string command_name = it->second->name;
575 if (BlamStrings::Utils::String::StartsWith(command_name, current_input,
true))
587 std::set<std::string>::iterator list_it;
591 std::string cmd_name = *list_it;
D2D1_COLOR_F shadow_color
The color to use for the drop shadow.
Definition: render_stack.h:851
bool visible
Whether or not the object is visible.
Definition: render_stack.h:375
BLAM HRESULT RunCommandLine(std::string command_line)
Executed the provided string as a console command.
Definition: console.cpp:184
BLAM std::map< std::string, ConsoleCommand * > GetCommandList()
Retrieves the list of all loaded console commands.
Definition: console.cpp:150
void handleCursorLeft()
Definition: console.hpp:470
ConsoleUI()
Definition: console.hpp:110
std::string font_id
The ID of the font.
Definition: render_stack.h:844
Animation used to handle an alternating fade between two colors.
Definition: ColorTransition.h:22
std::map< std::string, ConsoleCommand * > command_list
The list of all loaded console commands.
Definition: console.cpp:35
void onCharacterInputEvent(Blam::Events::CharacterInputEvent *event)
Called when the listener is subscribed to Character Input events, and a new CharacterInputEvent is fi...
Definition: console.hpp:205
void handleCursorRight()
Definition: console.hpp:484
short g
The Green value of the color.
Definition: globals.h:24
BLAM ConfigFile * GetConfig(std::string filename)
Retrieves the specified configuration file.
Definition: config.cpp:232
BLAM void RegisterListener(EventListener *listener)
Registers a an event listener.
Definition: events.cpp:62
@ BitmapText
Bitmap-based text, uses Blamite font system.
Definition: render_stack.h:72
LogSeverity severity
The message severity. Defaults to None.
Definition: logger.h:93
Structure to store log message data.
Definition: logger.h:87
StackType type_label
The type of the object.
Definition: render_stack.h:372
@ Tick
Definition: events.h:9
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:399
void toggleVisibility()
Definition: console.hpp:532
Namespace containing things relating to the Render Stack.
Definition: drawing.h:14
void Subscribe(EventType type)
Subscribes to an event type.
Definition: events.h:51
BLAM int MaxTicksPerSecond()
Retrieves the maximum number of ticks per second.
Definition: tick.cpp:144
void Draw()
Draws the stack object.
Definition: console.hpp:165
int error_count
Definition: console.hpp:337
Class representing an engine tick event.
Definition: TickEvent.hpp:12
Definition: console.hpp:19
void updateInputDisplay()
Definition: console.hpp:284
ConsoleMessage(bool *_console_visible)
Definition: console.hpp:27
#define WSV_ERROR
Macro for 'Error' log seveirty. Original pre-enum value was 2.
Definition: logger.h:17
bool force_regenerate
If enabled, will force the bitmap to regenerate on the next frame.
Definition: render_stack.h:864
#define WVIS_FILE_ONLY
Macro for 'FileOnly' log visibility. Original pre-enum value was 2.
Definition: logger.h:27
D2D1_COLOR_F GetColor()
Returns the evaluated color data.
Definition: ColorTransition.h:171
short r
The Red value of the color.
Definition: globals.h:23
std::vector< std::string > getRecentInput()
Definition: console.hpp:415
std::string text
The text to display.
Definition: render_stack.h:846
BLAM DXGI_SWAP_CHAIN_DESC GetSwapChainDesc()
Retrieves the current Direct3D Swap Chain description.
Definition: render_manage.cpp:618
void Initialize(D2D1_COLOR_F _c1, D2D1_COLOR_F _c2, float fade_duration, bool _loop)
Prepares data needed for the animation.
Definition: ColorTransition.h:133
void handleCursorDown()
Definition: console.hpp:511
D2D1_COLOR_F color
The color of the object.
Definition: render_stack.h:370
void onTickEvent(Blam::Events::TickEvent *event)
Called when the listener is subscribed to Key Press events, and a new TickEvent is fired.
Definition: console.hpp:35
int ticks_left
Definition: console.hpp:23
float y
The Y coordinate of the object.
Definition: render_stack.h:378
void Pause()
Definition: ColorTransition.h:184
BlamColor color
The overridden color information. Overrules any severity-based coloring.
Definition: logger.h:97
void handleCursorUp()
Definition: console.hpp:497
void Draw()
Draws the stack object.
Definition: BitmapText.cpp:13
#define WSV_NONE
Macro for 'None' log seveirty. Original pre-enum value was 0.
Definition: logger.h:15
void handleBackspace()
Definition: console.hpp:454
Blam::Animation::ColorTransitionAnimation anim
Definition: console.hpp:24
void Resume()
Definition: ColorTransition.h:189
bool use_shadow
Whether or not to draw the text with a drop shadow.
Definition: render_stack.h:852
short b
The Blue value of the color.
Definition: globals.h:25
bool * console_visible
Definition: console.hpp:25
#define WSV_INFO
Macro for 'Info' log seveirty. Original pre-enum value was 1.
Definition: logger.h:16
bool supression_message_shown
Definition: console.hpp:338
void SetTranslation(float new_x, float new_y)
Sets the translation of the object.
Definition: StackObjectBase.cpp:55
#define STACKTYPE_CONSOLE
Definition: render_stack.h:26
void showCommandList()
Definition: console.hpp:561
BLAM int AddToStack(std::string id, StackObjectBase *object)
Adds an item to the render stack.
Definition: render_stack.cpp:12
int GetVirtualKey()
Retrieves the virtual key code that was pressed.
Definition: KeyPressEvent.hpp:35
void handleKeyPress(char character)
Definition: console.hpp:440
void Start()
Instructs the listener to start animating.
Definition: ColorTransition.h:157
void clearScrollback()
Definition: console.hpp:420
@ CharacterInput
Definition: events.h:8
BLAM void LogEventForce(std::string message, LogSeverity severity)
Forcibly logs a message to the log and/or console.
Definition: aliases.cpp:150
BLAM void RemoveFromStack(std::string id)
Removes an item from the render stack.
Definition: render_stack.cpp:26
void HandleResize()
Called upon window resize events.
Definition: console.hpp:301
@ KeyPress
Definition: events.h:7
Class representing text drawn using a Bitmap-based engine font.
Definition: render_stack.h:794
BitmapText * message
Definition: console.hpp:22
Base class for all render stack objects.
Definition: render_stack.h:194
bool GetBoolean(std::string option)
Retrieves the specified config option's value as a bool
Definition: config_accessors.cpp:61
void onKeyPressEvent(Blam::Events::KeyPressEvent *event)
Called when the listener is subscribed to Key Press events, and a new KeyPressEvent is fired.
Definition: console.hpp:225
~ConsoleUI()
Definition: console.hpp:151
Class representing a virtual key press.
Definition: KeyPressEvent.hpp:14
Namespace containing things related to the Blamite Logger.
Definition: logger.h:82
std::string message
The message contents.
Definition: logger.h:92
void sendCommand()
Definition: console.hpp:541
void handleNewOutput(Blam::Logger::LogMessage message)
Definition: console.hpp:341
#define WSV_WARNING
Macro for 'Warning' log seveirty. Original pre-enum value was 3.
Definition: logger.h:18
void ShowImPropertyEditor()
Shows a set of ImGUI properties associated with the object.
Definition: console.hpp:278
bool HasStarted()
Determines whether or not the animation has been started.
Definition: ColorTransition.h:179
Definition: console.hpp:63
float x
The X coordinate of the object.
Definition: render_stack.h:377
std::string GetString(std::string option)
Retrieves the specified config option's value as a string.
Definition: config_accessors.cpp:10
Class representing an Event Listener.
Definition: events.h:38