Blamite Game Engine - blam!  00272.10.26.20.0001.blamite
The core library for the Blamite Game Engine.
debug_menu.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../debug_ui.h"
4 
7 
9 {
21  {
22  private:
24  public:
29  {
31  }
32 
37 
46  {
47  switch (item->item_type)
48  {
50  {
51  if (ImGui::TreeNode(item->title.c_str()))
52  {
53  for (int i = 0; i < item->items.size(); i++)
54  {
55  GenerateItemControl(&item->items.at(i));
56  }
57 
58  ImGui::TreePop();
59  }
60 
61  return;
62  }
64  {
65  if (ImGui::Button(item->title.c_str(), ImVec2(ImGui::GetWindowContentRegionWidth(), ImGui::GetTextLineHeightWithSpacing())))
66  {
67  item->HandleKeyEnter();
68  }
69 
70  return;
71  }
73  {
74  using namespace Blam::Globals;
75 
76  EngineGlobal* global = GetGlobal(item->global_id);
77 
78  if (global)
79  {
80  switch (global->type)
81  {
82  case GvarType::Boolean:
83  {
84  ImGui::Checkbox(item->title.c_str(), &global->boolean_value);
85  return;
86  }
87  case GvarType::Int:
88  {
89  if (item->use_bounds)
90  {
91  ImGui::SliderInt(item->title.c_str(), &global->int_value, item->min, item->max);
92  }
93  else
94  {
95  ImGui::InputInt(item->title.c_str(), &global->int_value, 1, item->inc);
96  }
97 
98  return;
99  }
100  case GvarType::Long:
101  {
102  if (item->use_bounds)
103  {
104  ImGui::SliderInt(item->title.c_str(), (int*)&global->long_value, item->min, item->max);
105  }
106  else
107  {
108  ImGui::InputInt(item->title.c_str(), (int*)&global->long_value, 1, item->inc);
109  }
110 
111  return;
112  }
113  case GvarType::Short:
114  {
115  if (item->use_bounds)
116  {
117  ImGui::SliderInt(item->title.c_str(), (int*)&global->short_value, item->min, item->max);
118  }
119  else
120  {
121  ImGui::InputInt(item->title.c_str(), (int*)&global->short_value, 1, item->inc);
122  }
123 
124  return;
125  }
126  case GvarType::Float:
127  {
128  if (item->use_bounds)
129  {
130  ImGui::SliderFloat(item->title.c_str(), &global->float_value, item->min, item->max);
131  }
132  else
133  {
134  ImGui::InputFloat(item->title.c_str(), &global->float_value, 1, item->inc);
135  }
136 
137  return;
138  }
139  default:
140  {
141  std::string text = "UNSUPPORTED: " + item->title + " (" + global->name + ")";
142  ImGui::TextColored(ImVec4(1, 0, 0, 1), text.c_str());
143 
144  return;
145  }
146  }
147  }
148  else
149  {
150  std::string text = "UNDEFINED: " + item->title + " (" + item->global_id + ")";
151  ImGui::TextColored(ImVec4(1, 0, 0, 1), text.c_str());
152  }
153 
154  return;
155  }
157  {
158  if (ImGui::Button(item->title.c_str(), ImVec2(ImGui::GetWindowContentRegionWidth(), ImGui::GetTextLineHeightWithSpacing())))
159  {
160  item->HandleKeyEnter();
161  }
162 
163  return;
164  }
166  {
167  ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 0, 0, 1));
168 
169  if (ImGui::Button(item->title.c_str(), ImVec2(ImGui::GetWindowContentRegionWidth(), ImGui::GetTextLineHeightWithSpacing())))
170  {
171  item->HandleKeyEnter();
172  }
173 
174  ImGui::PopStyleColor();
175 
176  return;
177  }
178  default:
179  {
180  return;
181  }
182  }
183  }
184 
188  void Draw()
189  {
190  if (show)
191  {
192  if (ImGui::Begin(menu.title.c_str(), &show))
193  {
194  ImGui::TextColored(ImVec4(1, 0, 0, 1), "this debug menu is not supported, please use PgUp and use the primary debug menu");
195  ImGui::TextColored(ImVec4(1, 0, 0, 1), "only use this if you seriously can't stand that one");
196 
197  for (int i = 0; i < menu.items.size(); i++)
198  {
199  if (menu.items.at(i).item_type == MENU_ITEM_TYPE_CATEGORY)
200  {
201  if (ImGui::CollapsingHeader(menu.items.at(i).title.c_str()))
202  {
203  for (int x = 0; x < menu.items.at(i).items.size();x++)
204  {
205  GenerateItemControl(&menu.items.at(i).items.at(x));
206  }
207  }
208  }
209  else
210  {
211  GenerateItemControl(&menu.items.at(i));
212  }
213  }
214  }
215  ImGui::End();
216  }
217  }
218  };
219 }
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
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
Blam::Globals::GetGlobal
BLAM EngineGlobal * GetGlobal(std::string name)
Retrieves a global with the specified ID.
Definition: globals.cpp:193
Blam::Globals::EngineGlobal::float_value
float float_value
The float value of the global.
Definition: globals.h:250
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::Globals::Int
@ Int
Represents an int.
Definition: globals.h:219
Blam::DebugUI::Windows::DebugMenu::~DebugMenu
~DebugMenu()
Empty destructor.
Definition: debug_menu.hpp:36
Blam::Globals::Long
@ Long
Represents a long.
Definition: globals.h:216
Blam::Globals
Namespace containing things relating to game engine globals.
Definition: globals.h:193
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:20
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::Globals::EngineGlobal::name
std::string name
The name of the global.
Definition: globals.h:237
Blam::Globals::EngineGlobal::short_value
short short_value
The short value of the global.
Definition: globals.h:247
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
MENU_ITEM_TYPE_UNKNOWN
#define MENU_ITEM_TYPE_UNKNOWN
Macro for Unknown. See Blam::DebugMenu::Unknown for details.
Definition: blam_ui.h:6
Blam::Globals::EngineGlobal
Structure containing data for a game engine global.
Definition: globals.h:234
Blam::DebugUI::Windows::DebugMenu::DebugMenu
DebugMenu()
Retrieves the debug menu data.
Definition: debug_menu.hpp:28
MENU_ITEM_TYPE_EXEC
#define MENU_ITEM_TYPE_EXEC
Macro for Executor. See Blam::DebugMenu::Executor for details.
Definition: blam_ui.h:7
Blam::Globals::Float
@ Float
Represents a float.
Definition: globals.h:220
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:45
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:442
Blam::Globals::EngineGlobal::long_value
long long_value
The long value of the global.
Definition: globals.h:248
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:409
MENU_ITEM_TYPE_MULTIEXEC
#define MENU_ITEM_TYPE_MULTIEXEC
Macro for ExecSequence. See Blam::DebugMenu::ExecSequence for details.
Definition: blam_ui.h:10
Blam::Globals::Short
@ Short
Represents a short.
Definition: globals.h:215
Blam::DebugUI::Windows::DebugMenu::Draw
void Draw()
Draws the debug menu window.
Definition: debug_menu.hpp:188
Blam::Globals::EngineGlobal::int_value
int int_value
The int value of the global.
Definition: globals.h:249
blam_ui.h
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
Blam::Globals::Boolean
@ Boolean
Represents a boolean. Can be true or false.
Definition: globals.h:213
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:494
Blam::DebugMenu::MenuItem::min
double min
The minimum value specified in debug_menu_init.
Definition: blam_ui.h:69
Blam::Globals::EngineGlobal::type
GvarType type
The type of the global.
Definition: globals.h:236
Blam::DebugMenu::MenuItem::global_id
std::string global_id
The ID of the engine global to modify upon activation.
Definition: blam_ui.h:65
Blam::Globals::EngineGlobal::boolean_value
bool boolean_value
The boolean value of the global.
Definition: globals.h:246