Elaztek Developer Hub
Blamite Game Engine - blam!  00406.12.10.23.1457.blamite
The core library for the Blamite Game Engine.
debug_menu.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #define DEBUG_MENU_FILE "debug_menu_init"
7 
8 #ifndef BLAM
9 #define BLAM
10 #endif
11 
16 {
17  Command,
18 
27  Global,
28  Submenu,
29  Unknown
30 };
31 
38 {
39 public:
41  std::string title = "";
42 
43  // Properties specific to #BlamDebugMenuItemType::Command
44 
45  std::string exec_line = "";
46 
47  // Properties specific to #BlamDebugMenuItemType::CommandSequence
48 
49  std::vector<std::string> exec_sequence = std::vector<std::string>();
51 
52  // Properties specific to #BlamDebugMenuItemType::Global
53 
54  std::string global_id = "";
55  bool use_bounds = false;
56  double inc = 1;
57  double min = 0;
58  double max = 0;
59 
60  // Properties specific to #BlamDebugMenuItemType::Submenu
61  std::vector<BlamDebugMenuItem> items;
62 
67 
71  void HandleKeyEnter();
72 
76  void HandleKeyLeft();
77 
81  void HandleKeyRight();
82 };
83 
88 {
89  std::string title = "";
90  std::vector<BlamDebugMenuItem> items = std::vector<BlamDebugMenuItem>();
91 };
92 
97 {
112  BLAM void InitializeDebugMenu();
113 
117  BLAM void ReleaseDebugMenu();
118 
122  BLAM void ReloadDebugMenu();
123 
130 }
BlamUIWidget_Group::RefreshRelativePosition
void RefreshRelativePosition() override
Updates the relative position of the widget, relative to its parent.
Definition: group.cpp:140
SDLK_BACKSPACE
@ SDLK_BACKSPACE
Definition: SdlEmulationLayer.h:387
BlamUIWidget::hidden
bool hidden
Whether or not the widget is hidden.
Definition: ui.h:107
BlamDebugMenuItem::title
std::string title
The title of the debug menu item as shown in the menu.
Definition: debug_menu.h:41
BlamWidgetType::DebugMenu
@ DebugMenu
Special widget. Used for the in-game debug menu.
BlamUIWidget_DebugMenu::Draw
void Draw() override
Draws the widget on-screen.
Definition: debug_menu.cpp:111
BlamUIWidget_DebugMenu::OnKeyPressEvent
void OnKeyPressEvent(KeyPressEvent *event) override
Definition: debug_menu.cpp:282
Short
@ Short
!< Represents a float.
Definition: globals.h:36
BlamUIWidget_DebugMenu::menu_item_size
BlamVector2 menu_item_size
The size of each debug menu item widget.
Definition: debug_menu.h:197
BlamUIWidget::update
bool update
Whether or not the widget needs to be updated before the next draw call.
Definition: ui.h:106
Blam::Animation::ColorTransitionAnimation::GetColor
BlamColor GetColor()
Returns the evaluated color data.
Definition: ColorTransition.h:170
Blam::Logger::LogEvent
BLAM void LogEvent(std::string message)
Logs a message to the log and/or console.
Definition: aliases.cpp:130
BlamEngineDataFolder::DataRoot
@ DataRoot
The root of all game engine data. Defaults to ./
BlamUIWidget_VLayoutGroup::item_spacing
int item_spacing
The amount of space to display between items, in pixels.
Definition: ui.h:320
BlamDebugMenuItem::exec_line
std::string exec_line
The command to run upon activation for an Executor menu item type.
Definition: debug_menu.h:45
BlamDebugMenuItem::inc
double inc
How much to add or remove from the value at a time upon activation.
Definition: debug_menu.h:56
BlamUIWidget_Group
Class representing a Group widget.
Definition: ui.h:263
BlamUIWidget::position
BlamVector2 position
The position of the widget, relative to its parent.
Definition: ui.h:121
BlamDebugMenuItemType::Submenu
@ Submenu
Enters into a submenu/subscreen upon activation.
SDLK_HOME
@ SDLK_HOME
Definition: SdlEmulationLayer.h:477
BlamDebugMenuItem::exec_sequence
std::vector< std::string > exec_sequence
The command sequence to run upon activation for an ExecSequence menu item type.
Definition: debug_menu.h:49
Blam::Resources::DebugMenu::GetDebugMenu
BLAM BlamDebugMenu * GetDebugMenu()
Retrieves the debug menu data.
Definition: debug_menu.cpp:411
logger.h
BlamUIWidget::MarkForUpdate
void MarkForUpdate()
Marks the widget as needing to be updated on the next draw call.
Definition: BlamUIWidget.cpp:392
BlamUIWidget_DebugMenu_Item::ConfigureHotkeyText
void ConfigureHotkeyText(int index)
Reconfigures the widget's hotkey text based on its index.
Definition: debug_menu_item.cpp:313
BlamDebugMenuItem::BlamDebugMenuItem
BlamDebugMenuItem()
Creates a new debug menu item.
Definition: BlamDebugMenuItem.cpp:6
imgui.h
BlamUIWidget_DebugMenu::GetAnimatedActiveItemBackground
BlamColor GetAnimatedActiveItemBackground()
Retrieves the animating active item background color.
Definition: debug_menu.cpp:540
BlamUIWidget_2DPrimitive::color
BlamColor color
The color of the widget.
Definition: ui.h:371
Real
@ Real
Definition: globals.h:35
BlamFontPackageType::Unknown
@ Unknown
Indicates the font package has an unknown type. Should generally be considered an error.
Blam::Animation::ColorTransitionAnimation::Initialize
void Initialize(BlamColor _c1, BlamColor _c2, float fade_duration, bool _loop)
Prepares data needed for the animation.
Definition: ColorTransition.h:132
BlamDebugMenuItem::current_exec_index
int current_exec_index
The index of the next item to run within the execution sequence.
Definition: debug_menu.h:50
BlamUIWidget_VLayoutGroup::padding
BlamVector4 padding
The padding around the layout group. Padding order is top, right, bottom, left.
Definition: ui.h:319
BlamDebugMenuItem::HandleKeyLeft
void HandleKeyLeft()
Called when the menu item is active and the left arrow key is pressed.
Definition: BlamDebugMenuItem.cpp:41
Blam::Globals::GetGlobalAsFloat
BLAM float * GetGlobalAsFloat(std::string name)
Retrieves a global's value as a float.
Definition: globals.cpp:403
BlamUIWidget_DebugMenu::cached_scale_factor
float cached_scale_factor
The current cached UI scale factor. Used to automatically scale the UI when the scale factor is chang...
Definition: debug_menu.h:196
BlamUIWidget_Text::SetHidden
void SetHidden(bool new_hidden) override
Sets the hidden state of the widget.
Definition: text.cpp:451
SDLK_UP
@ SDLK_UP
Definition: SdlEmulationLayer.h:485
BlamUIWidget::GetType
BlamWidgetType GetType()
Retrieves the type of this widget.
Definition: BlamUIWidget.cpp:207
BlamUIWidget_DebugMenu::RefreshRelativePosition
void RefreshRelativePosition() override
Updates the relative position of the widget, relative to its parent.
Definition: debug_menu.cpp:189
BlamEngineGlobal::boolean_value
bool boolean_value
The boolean value of the global.
Definition: globals.h:66
load_menu_item
BlamResult load_menu_item(rapidxml::xml_node<> *entry_node, BlamDebugMenuItem *menu_item)
Loads data for a debug menu item from an XML node.
Definition: debug_menu.cpp:27
USER_DATA_PATH
#define USER_DATA_PATH(path)
Macro to quickly access a user data folder.
Definition: config.h:41
BlamDebugMenuItem::items
std::vector< BlamDebugMenuItem > items
The contents of the submenu to show upon activation.
Definition: debug_menu.h:61
BlamUIWidget_Group::UpdateMetrics
void UpdateMetrics() override
Updates metrics for the widget.
Definition: group.cpp:155
console.h
BlamUIWidget::size
BlamVector2 size
The size of the widget, relative to its parent.
Definition: ui.h:122
BlamUIWidget_DebugMenu_Item::UpdateMetrics
void UpdateMetrics() override
Updates metrics for the widget.
Definition: debug_menu_item.cpp:165
BlamUIWidget_VLayoutGroup::ShowImGuiPropertyEditor
void ShowImGuiPropertyEditor() override
Displays an ImGUI-based property editor.
Definition: vlayout.cpp:26
Blam::Resources::DebugMenu::InitializeDebugMenu
BLAM void InitializeDebugMenu()
Initializes the debug menu.
Definition: debug_menu.cpp:309
Int
@ Int
Represents an int.
Definition: globals.h:40
BlamUIWidget_DebugMenu_Item
Class used for a debug menu UI item.
Definition: debug_menu.h:16
BlamUIWidget::SetPosition
virtual void SetPosition(BlamVector2 new_position)
Sets the position of the widget.
Definition: BlamUIWidget.cpp:368
SDLK_RETURN
@ SDLK_RETURN
Definition: SdlEmulationLayer.h:385
errors.h
BLAM
#define BLAM
Definition: debug_menu.h:9
BlamEngineGlobal::type
BlamGlobalType type
The type of the global.
Definition: globals.h:56
BlamUIWidget_DebugMenu_Item::SetMenuItem
void SetMenuItem(BlamDebugMenuItem _menu_item)
Sets the debug menu item information associated with this widget.
Definition: debug_menu_item.cpp:293
Blam::Resources::DebugMenu
Namespace containing data for the engine's debug menu.
Definition: debug_menu.h:96
BlamUIWidget_Group::ShowImGuiPropertyEditor
void ShowImGuiPropertyEditor() override
Displays an ImGUI-based property editor.
Definition: group.cpp:98
ImGui::CollapsingHeader
IMGUI_API bool CollapsingHeader(const char *label, ImGuiTreeNodeFlags flags=0)
Definition: imgui_widgets.cpp:5422
BlamUIWidget_Text::Draw
void Draw() override
Draws the widget on-screen.
Definition: text.cpp:53
BlamWidgetAnchor::TopLeft
@ TopLeft
The widget will be placed at the top-left of the screen.
BlamUIWidget_Group::children
std::vector< BlamUIWidget * > children
The list of child widgets within this group.
Definition: ui.h:270
debug_menu.h
BlamUIWidget::display_name
std::string display_name
The display name of the widget.
Definition: ui.h:118
BlamUIWidget_DebugMenu::LoadMenuRootPage
void LoadMenuRootPage()
Loads the default menu root page.
Definition: debug_menu.cpp:389
BlamUIWidget_Text::color
BlamColor color
The text foreground color.
Definition: ui.h:522
BlamUIWidget_2DPrimitive::SetHidden
void SetHidden(bool new_hidden) override
Sets the hidden state of the widget.
Definition: 2d_primitive.cpp:172
SDLK_PAGEUP
@ SDLK_PAGEUP
Definition: SdlEmulationLayer.h:478
BlamUIWidget::SetHidden
virtual void SetHidden(bool new_hidden)
Sets the hidden state of the widget.
Definition: BlamUIWidget.cpp:415
BlamUIWidget::SetSize
void SetSize(BlamVector2 new_size)
Sets the size of the widget.
Definition: BlamUIWidget.cpp:361
BlamUIWidget_2DPrimitive::Draw
void Draw() override
Draws the widget on-screen.
Definition: 2d_primitive.cpp:87
BlamWidgetType::DebugMenuItem
@ DebugMenuItem
Special widget. Represents an item within the debug menu.
SDLK_RIGHT
@ SDLK_RIGHT
Definition: SdlEmulationLayer.h:482
ENGINE_DATA_PATH
#define ENGINE_DATA_PATH(path)
Macro to quickly access a game engine data folder.
Definition: config.h:34
BlamDebugMenuItem::HandleKeyRight
void HandleKeyRight()
Called when the menu item is active and the right arrow key is pressed.
Definition: BlamDebugMenuItem.cpp:166
BlamDebugMenuItemType::CommandSequence
@ CommandSequence
Runs a sequence of console commands upon activation.
parse_debug_menu_xml_contents
BlamResult parse_debug_menu_xml_contents(std::string file_path)
Reads the specified file as an XML document and builds debug menu data from it.
Definition: debug_menu.cpp:213
BlamUIWidget_DebugMenu::GetHotkeyCharacterFromIndex
char GetHotkeyCharacterFromIndex(int index)
Determines the hotkey character for an item at a given index.
Definition: debug_menu.cpp:556
main_menu
BlamDebugMenu * main_menu
The current debug menu information.
Definition: debug_menu.cpp:15
BlamUIWidget_DebugMenu::OnTickEvent
void OnTickEvent(TickEvent *event) override
Definition: debug_menu.cpp:194
BlamEngineGlobal
Structure containing data for a game engine global.
Definition: globals.h:54
BlamDebugMenuItemType::Global
@ Global
Modifies an engine global upon activation.
BlamUIWidget_VLayoutGroup::auto_height
bool auto_height
Whether or not to automatically adjust the layout height to match its children.
Definition: ui.h:321
BlamUIWidget_DebugMenu::UpdateMetrics
void UpdateMetrics() override
Updates metrics for the widget.
Definition: debug_menu.cpp:161
BlamDebugMenuItem::item_type
BlamDebugMenuItemType item_type
The type of menu item. See BlamDebugMenuItemType for details.
Definition: debug_menu.h:40
globals.h
BlamUIWidget_DebugMenu_Item::SetSize
void SetSize(float scale)
Sets the scale factor of the widget.
Definition: debug_menu_item.cpp:340
BlamDebugMenuItemType::Unknown
@ Unknown
Fallback in the event that debug_menu_init contained an invalid option.
BlamUIWidget_VLayoutGroup::Draw
void Draw() override
Draws the widget on-screen.
Definition: vlayout.cpp:15
BlamEngineGlobal::short_value
short short_value
The short value of the global.
Definition: globals.h:67
BlamDebugMenuItem
Class used to store data and functions relating to an item within the engine's debug menu.
Definition: debug_menu.h:37
BlamEngineGlobal::read_only
bool read_only
Whether or not the global is protected from modification.
Definition: globals.h:60
BlamUIWidget_BasicRectangle
Class representing a basic rectangle widget.
Definition: ui.h:402
BlamUIWidget_VLayoutGroup::RefreshRelativePosition
void RefreshRelativePosition() override
Updates the relative position of the widget, relative to its parent.
Definition: vlayout.cpp:48
BlamEngineDataFolder::DefaultConfigs
@ DefaultConfigs
Directory containing default configuration files. Defaults to ./content/blam/default_configs/
Blam::Globals::GetGlobalTypeLabel
BLAM std::string GetGlobalTypeLabel(BlamGlobalType type)
Retrieves a string representation of a global's type, for use in UI.
Definition: globals.cpp:40
BlamUIWidget
Base class for a UI widget.
Definition: ui.h:87
Blam::Globals::GetGlobal
BLAM BlamEngineGlobal * GetGlobal(std::string name)
Retrieves a global with the specified ID.
Definition: globals.cpp:189
BlamDebugMenu::items
std::vector< BlamDebugMenuItem > items
The list of items within the debug menu.
Definition: debug_menu.h:90
BlamDebugMenuItemType::Command
@ Command
Runs a console command upon activation.
SDLK_LEFT
@ SDLK_LEFT
Definition: SdlEmulationLayer.h:483
DEBUG_MENU_FILE
#define DEBUG_MENU_FILE
The file name to load the debug menu contents from - without the extension.
Definition: debug_menu.h:6
Long
@ Long
Represents a long.
Definition: globals.h:37
Blam::Resources::Console::RunCommandLine
BLAM BlamResult RunCommandLine(std::string command_line)
Executed the provided string as a console command.
Definition: console.cpp:260
BlamDebugMenuItem::global_id
std::string global_id
The ID of the engine global to modify upon activation.
Definition: debug_menu.h:54
Boolean
@ Boolean
Represents a boolean. Can be true or false.
Definition: globals.h:34
SDLK_DOWN
@ SDLK_DOWN
Definition: SdlEmulationLayer.h:484
BlamUIWidget_2DPrimitive::UpdateMetrics
void UpdateMetrics() override
Updates metrics for the widget.
Definition: 2d_primitive.cpp:130
Blam::Resources::DebugMenu::ReloadDebugMenu
BLAM void ReloadDebugMenu()
Clears all existing data for the debug menu and reloads it from the file.
Definition: debug_menu.cpp:405
Blam::Resources::DebugMenu::ReleaseDebugMenu
BLAM void ReleaseDebugMenu()
Releases all debug menu contents.
Definition: debug_menu.cpp:393
BlamDebugMenuItem::HandleKeyEnter
void HandleKeyEnter()
Called when the menu item is active and the enter key is pressed.
Definition: BlamDebugMenuItem.cpp:11
BlamDebugMenuItem::max
double max
The maximum value specified in debug_menu_init.
Definition: debug_menu.h:58
BlamUIWidget_Text::text
std::string text
The text to display within this text widget.
Definition: ui.h:526
BlamDebugMenuItem::use_bounds
bool use_bounds
Whether or not arbitrary bounds are specified in debug_menu_init.
Definition: debug_menu.h:55
BlamUIWidget_DebugMenu::BlamUIWidget_DebugMenu
BlamUIWidget_DebugMenu()
Definition: debug_menu.cpp:12
BlamUIWidget::RefreshRelativePosition
virtual void RefreshRelativePosition()
Updates the relative position of the widget, relative to its parent.
Definition: BlamUIWidget.cpp:212
SDLK_TAB
@ SDLK_TAB
Definition: SdlEmulationLayer.h:388
Blam::Animation::ColorTransitionAnimation::Start
void Start()
Instructs the listener to start animating.
Definition: ColorTransition.h:156
BlamUIWidget_VLayoutGroup
Class representing a Vertical Layout Group widget.
Definition: ui.h:313
BlamDebugMenu::title
std::string title
The title of the main page of the debug menu. Defaults to Main.
Definition: debug_menu.h:89
BlamUIWidget_DebugMenu::ShowImGuiPropertyEditor
void ShowImGuiPropertyEditor() override
Displays an ImGUI-based property editor.
Definition: debug_menu.cpp:143
BlamUIWidget_Group::ClearChildren
void ClearChildren()
Clears and destroys all child widgets within the group.
Definition: group.cpp:193
BlamUIWidget_DebugMenu_Item::SetActive
void SetActive(bool _active)
Definition: debug_menu_item.cpp:244
BlamEngineGlobal::int_value
int int_value
The int value of the global.
Definition: globals.h:69
BlamUIWidget::IsHidden
bool IsHidden()
Checks whether or not the widget is hidden.
Definition: BlamUIWidget.cpp:420
Blam::Logger::LogEventForce
BLAM void LogEventForce(std::string message)
Forcibly logs a message to the log and/or console.
Definition: aliases.cpp:262
BlamUIWidget::z_index
int z_index
The Z index of the widget, where higher Z orders are drawn on top.
Definition: ui.h:125
BlamDebugMenuItemType
BlamDebugMenuItemType
Menu item type enumerator.
Definition: debug_menu.h:15
BlamUIWidget_DebugMenu_Item::IsHeader
bool IsHeader()
Checks whether or not the current item is a header or not.
Definition: debug_menu_item.cpp:288
BlamWidgetType
BlamWidgetType
Enumerator listing possible UI widget types.
Definition: ui.h:60
BlamUIWidget_DebugMenu::OnCharacterInputEvent
void OnCharacterInputEvent(CharacterInputEvent *event) override
Definition: debug_menu.cpp:231
config.h
BlamDebugMenu
Structure containing data for the root of the debug menu.
Definition: debug_menu.h:87
BlamUIWidget_DebugMenu::SetHidden
void SetHidden(bool new_hidden) override
Sets the hidden state of the widget.
Definition: debug_menu.cpp:532
BlamUserDataFolder::DataRoot
@ DataRoot
The root of all user data. Defaults to BlamStrings::Utils::IO::GetEngineDataRoot().
BlamUIWidget_BasicRectangle::ShowImGuiPropertyEditor
void ShowImGuiPropertyEditor() override
Displays an ImGUI-based property editor.
Definition: rectangle.cpp:57
BlamUIWidget_DebugMenu::GetIndexFromHotkeyCharacter
int GetIndexFromHotkeyCharacter(char hotkey)
Determines the index of a debug menu item based on a pressed hotkey.
Definition: debug_menu.cpp:545
BlamUIWidget_DebugMenu::~BlamUIWidget_DebugMenu
~BlamUIWidget_DebugMenu()
Definition: debug_menu.cpp:106
BlamEngineGlobal::float_value
float float_value
The float value of the global.
Definition: globals.h:70
BlamUIWidget::ignore_scale_factor
bool ignore_scale_factor
Whether or not this widget should ignore the UI scale factor settings.
Definition: ui.h:133
BlamUIWidget_Group::SetHidden
void SetHidden(bool new_hidden) override
Sets the hidden state of the widget.
Definition: group.cpp:170
BlamEngineGlobal::value_raw
std::string value_raw
The raw value of the global as a string.
Definition: globals.h:59
BlamUIWidget_Text
Class representing a Text widget.
Definition: ui.h:483
BlamDebugMenuItem::min
double min
The minimum value specified in debug_menu_init.
Definition: debug_menu.h:57
BlamUIWidget::SetAnchorPosition
void SetAnchorPosition(BlamWidgetAnchor new_anchor_position)
Sets the anchor position of the widget.
Definition: BlamUIWidget.cpp:381
BlamEngineGlobal::long_value
long long_value
The long value of the global.
Definition: globals.h:68