Blamite Game Engine - Blam (Core)
debug_menu.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../debug_ui.h"
6 
8 {
20  {
21  private:
23  public:
28  {
30  }
31 
36 
45  {
46  switch (item->item_type)
47  {
49  {
50  if (ImGui::TreeNode(item->title.c_str()))
51  {
52  for (int i = 0; i < item->items.size(); i++)
53  {
54  GenerateItemControl(&item->items.at(i));
55  }
56 
57  ImGui::TreePop();
58  }
59 
60  return;
61  }
63  {
64  if (ImGui::Button(item->title.c_str(), ImVec2(ImGui::GetWindowContentRegionWidth(), ImGui::GetTextLineHeightWithSpacing())))
65  {
66  item->HandleKeyEnter();
67  }
68 
69  return;
70  }
72  {
73  using namespace BlamScript::Globals;
74 
75  ScriptGlobal* global = GetGlobal(item->global_id);
76 
77  if (global)
78  {
79  switch (global->type)
80  {
81  case GvarType::Boolean:
82  {
83  ImGui::Checkbox(item->title.c_str(), &global->boolean_value);
84  return;
85  }
86  case GvarType::Int:
87  {
88  if (item->use_bounds)
89  {
90  ImGui::SliderInt(item->title.c_str(), &global->int_value, item->min, item->max);
91  }
92  else
93  {
94  ImGui::InputInt(item->title.c_str(), &global->int_value, 1, item->inc);
95  }
96 
97  return;
98  }
99  case GvarType::Long:
100  {
101  if (item->use_bounds)
102  {
103  ImGui::SliderInt(item->title.c_str(), (int*)&global->long_value, item->min, item->max);
104  }
105  else
106  {
107  ImGui::InputInt(item->title.c_str(), (int*)&global->long_value, 1, item->inc);
108  }
109 
110  return;
111  }
112  case GvarType::Short:
113  {
114  if (item->use_bounds)
115  {
116  ImGui::SliderInt(item->title.c_str(), (int*)&global->short_value, item->min, item->max);
117  }
118  else
119  {
120  ImGui::InputInt(item->title.c_str(), (int*)&global->short_value, 1, item->inc);
121  }
122 
123  return;
124  }
125  default:
126  {
127  std::string text = "UNSUPPORTED: " + item->title + " (" + global->name + ")";
128  ImGui::TextColored(ImVec4(1, 0, 0, 1), text.c_str());
129 
130  return;
131  }
132  }
133  }
134  else
135  {
136  std::string text = "UNDEFINED: " + item->title + " (" + item->global_id + ")";
137  ImGui::TextColored(ImVec4(1, 0, 0, 1), text.c_str());
138  }
139 
140  return;
141  }
143  {
144  if (ImGui::Button(item->title.c_str(), ImVec2(ImGui::GetWindowContentRegionWidth(), ImGui::GetTextLineHeightWithSpacing())))
145  {
146  item->HandleKeyEnter();
147  }
148 
149  return;
150  }
152  {
153  ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 0, 0, 1));
154 
155  if (ImGui::Button(item->title.c_str(), ImVec2(ImGui::GetWindowContentRegionWidth(), ImGui::GetTextLineHeightWithSpacing())))
156  {
157  item->HandleKeyEnter();
158  }
159 
160  ImGui::PopStyleColor();
161 
162  return;
163  }
164  default:
165  {
166  return;
167  }
168  }
169  }
170 
174  void Draw()
175  {
176  if (show)
177  {
178  if (ImGui::Begin(menu.title.c_str(), &show))
179  {
180  ImGui::TextColored(ImVec4(1, 0, 0, 1), "this debug menu is not supported, please use PgUp and use the primary debug menu");
181  ImGui::TextColored(ImVec4(1, 0, 0, 1), "only use this if you seriously can't stand that one");
182 
183  for (int i = 0; i < menu.items.size(); i++)
184  {
185  if (menu.items.at(i).item_type == MENU_ITEM_TYPE_CATEGORY)
186  {
187  if (ImGui::CollapsingHeader(menu.items.at(i).title.c_str()))
188  {
189  for (int x = 0; x < menu.items.at(i).items.size();x++)
190  {
191  GenerateItemControl(&menu.items.at(i).items.at(x));
192  }
193  }
194  }
195  else
196  {
197  GenerateItemControl(&menu.items.at(i));
198  }
199  }
200  }
201  ImGui::End();
202  }
203  }
204  };
205 }
Blam::DebugMenu::MenuItem
Class used to store data and functions relating to an item within the engine's debug menu.
Definition: blam_ui.h:52
BlamScript::Globals
Namespace containing things relating to game engine globals.
Definition: haloscript.h:61
Blam::DebugMenu::GetDebugMenu
BLAM Menu GetDebugMenu()
Retrieves the debug menu data.
Definition: debug_menu.cpp:26
Blam::DebugMenu::Menu
Structure containing data for the root of the debug menu.
Definition: blam_ui.h:112
Blam::DebugMenu::Menu::title
std::string title
The title of the main page of the debug menu. Defaults to Main.
Definition: blam_ui.h:114
BlamScript::Globals::ScriptGlobal::long_value
long long_value
The long value of the global.
Definition: haloscript.h:116
Blam::DebugMenu::MenuItem::title
std::string title
The title of the debug menu item as shown in the menu.
Definition: blam_ui.h:56
Blam::DebugUI::Windows::DebugMenu::~DebugMenu
~DebugMenu()
Empty destructor.
Definition: debug_menu.hpp:35
BlamScript::Globals::ScriptGlobal::boolean_value
bool boolean_value
The boolean value of the global.
Definition: haloscript.h:114
BlamScript::Globals::ScriptGlobal::type
GvarType type
The type of the global.
Definition: haloscript.h:104
Blam::DebugMenu::MenuItem::item_type
MenuItemType item_type
The type of menu item. See Blam::DebugMenu::MenuItemType for details.
Definition: blam_ui.h:55
MENU_ITEM_TYPE_CATEGORY
#define MENU_ITEM_TYPE_CATEGORY
Macro for Submenu. See Blam::DebugMenu::Submenu for details.
Definition: blam_ui.h:8
Blam::DebugMenu::MenuItem::max
double max
The maximum value specified in debug_menu_init.
Definition: blam_ui.h:70
Blam::DebugUI::Windows::DebugMenu
Class for the ImGUI-based debug menu implementation.
Definition: debug_menu.hpp:19
console.h
Blam::DebugMenu::MenuItem::use_bounds
bool use_bounds
Whether or not arbitrary bounds are specified in debug_menu_init.
Definition: blam_ui.h:66
Blam::DebugMenu::MenuItem::items
std::vector< MenuItem > items
The contents of the submenu to show upon activation.
Definition: blam_ui.h:62
Blam::DebugMenu::Menu::items
std::vector< MenuItem > items
The list of items within the debug menu.
Definition: blam_ui.h:116
BlamScript::Globals::Int
@ Int
Represents an int.
Definition: haloscript.h:87
MENU_ITEM_TYPE_UNKNOWN
#define MENU_ITEM_TYPE_UNKNOWN
Macro for Unknown. See Blam::DebugMenu::Unknown for details.
Definition: blam_ui.h:6
BlamScript::Globals::ScriptGlobal::name
std::string name
The name of the global.
Definition: haloscript.h:105
BlamScript::Globals::Boolean
@ Boolean
Represents a boolean. Can be true or false.
Definition: haloscript.h:81
Blam::DebugUI::Windows::DebugMenu::DebugMenu
DebugMenu()
Retrieves the debug menu data.
Definition: debug_menu.hpp:27
MENU_ITEM_TYPE_EXEC
#define MENU_ITEM_TYPE_EXEC
Macro for Executor. See Blam::DebugMenu::Executor for details.
Definition: blam_ui.h:7
Blam::DebugMenu::MenuItem::HandleKeyEnter
void HandleKeyEnter()
Called when the menu item is active and the enter key is pressed.
Definition: debug_menu.cpp:366
Blam::DebugUI::Windows::DebugMenu::GenerateItemControl
void GenerateItemControl(Blam::DebugMenu::MenuItem *item)
Creates the appropriate control for the debug menu item.
Definition: debug_menu.hpp:44
Blam::DebugUI::ImGUIDrawingGroup::show
bool show
Controls whether or not the group should be shown. May not be used in all groups.
Definition: debug_ui.h:441
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:408
MENU_ITEM_TYPE_MULTIEXEC
#define MENU_ITEM_TYPE_MULTIEXEC
Macro for ExecSequence. See Blam::DebugMenu::ExecSequence for details.
Definition: blam_ui.h:10
Blam::DebugUI::Windows::DebugMenu::Draw
void Draw()
Draws the debug menu window.
Definition: debug_menu.hpp:174
blam_ui.h
BlamScript::Globals::Long
@ Long
Represents a long.
Definition: haloscript.h:84
Blam::DebugMenu::MenuItem::inc
double inc
How much to add or remove from the value at a time upon activation.
Definition: blam_ui.h:68
BlamScript::Globals::GetGlobal
HSC ScriptGlobal * GetGlobal(std::string name)
Retrieves a global with the specified ID.
Definition: script_globals.cpp:193
BlamScript::Globals::ScriptGlobal
Structure containing data for a game engine global.
Definition: haloscript.h:102
MENU_ITEM_TYPE_GLOBAL
#define MENU_ITEM_TYPE_GLOBAL
Macro for Global. See Blam::DebugMenu::Global for details.
Definition: blam_ui.h:9
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: debug_ui.h:493
Blam::DebugMenu::MenuItem::min
double min
The minimum value specified in debug_menu_init.
Definition: blam_ui.h:69
BlamScript::Globals::ScriptGlobal::int_value
int int_value
The int value of the global.
Definition: haloscript.h:117
Blam::DebugMenu::MenuItem::global_id
std::string global_id
The ID of the engine global to modify upon activation.
Definition: blam_ui.h:65
BlamScript::Globals::ScriptGlobal::short_value
short short_value
The short value of the global.
Definition: haloscript.h:115
BlamScript::Globals::Short
@ Short
Represents a short.
Definition: haloscript.h:83