Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
menubar.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../debug_ui.h"
4 
5 #include <Strings/components/utils/io/io.h>
6 #include <Strings/components/utils/utilities.h>
7 
8 #include "devtools_bar.hpp"
17 #include "version_data.h"
18 
19 namespace Blam::DebugUI::Widgets
20 {
27  {
28  private:
29  DevToolsBar* old_menu;
30 
31  bool old_devtools_bar = false;
32  bool show_menubar = true;
33 
34  int commit_hash_label = 0;
35 
36  bool show_imgui_font_picker = false;
37  bool show_imgui_metrics = false;
38  bool show_imgui_style_picker = false;
39  bool show_imgui_style_editor = false;
40 
41  bool main_menu = true;
42 
43  public:
50  MenuBar(bool show_in_window)
51  {
52  if (show_in_window)
53  {
54  main_menu = false;
55  }
56  else
57  {
58  main_menu = true;
59 
60  old_menu = new DevToolsBar(false);
61  old_menu->SetDrawModeNotMainMenu();
62  }
63  }
64 
69  {
70  if (old_menu)
71  {
72  delete(old_menu);
73  }
74  }
75 
82  void Draw()
83  {
84  show_menubar = show;
85 
86  // Main Menu (titlebar)
87  if (show_menubar)
88  {
89  //if (ImGui::BeginMainMenuBar())
90  {
91  if (main_menu)
92  {
93  ImGui::BeginMainMenuBar();
94  }
95  else
96  {
97  ImGui::Begin("Final Hardcoded Menu", &show, ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize);
98  ImGui::BeginMenuBar();
99  }
100 
101  using namespace Blam::DebugUI::Windows;
102 
103  if (ImGui::BeginMenu("File"))
104  {
105  ImGui::MenuItem("Open .map file", NULL, false, false); ShowNYITooltip();
106  ImGui::MenuItem("Return to mainmenu", NULL, false, false); ShowNYITooltip();
107  if (ImGui::MenuItem("Open game dir", NULL)) BlamStrings::Utils::IO::OpenGameDirectory();
108  ImGui::Separator();
109  if (ImGui::MenuItem("Open Report Viewer", NULL))
110  {
111  std::string report_viewer_page = Blam::Config::GetConfig()->GetString("game_data_root") + "./"
112  + Blam::Config::GetConfig()->GetString("reports_dir") + "./index.html";
113 
114  BlamStrings::Utils::OpenLocalWebURL(report_viewer_page);
115  }
116  ImGui::Separator();
117  ImGui::MenuItem("Exit", NULL, duigvs("exit_via_menu"));
118  ImGui::EndMenu();
119  }
120  if (ImGui::BeginMenu("Tools"))
121  {
122  ImGui::MenuItem("Cheats", NULL, false, false); ShowNYITooltip();
123  ImGui::Separator();
124  if (ImGui::BeginMenu("Network"))
125  {
126  ImGui::MenuItem("Show Network Info", NULL, duigvs("network_stats"));
127  ImGui::MenuItem("Discord Rich Presence", NULL, duigvs("discord_rpc_ui"));
128  ImGui::EndMenu();
129  }
130 
131  if (ImGui::BeginMenu("Rendering"))
132  {
133  ImGui::MenuItem("Render Stack Editor", NULL, duigvs("render_stack_editor"));
134  ImGui::MenuItem("Font Editor", NULL, duigvs("font_editor"));
135 
136  ImGui::EndMenu();
137  }
138 
139  if (ImGui::BeginMenu("Test"))
140  {
141  if (ImGui::BeginMenu("Deprecated"))
142  {
143  ImGui::TextColored(ImVec4(1, 0, 0, 1), ENGINE_TEXT("imgui_menu_deprecated_warning").c_str());
144  ImGui::Separator();
145  ImGui::MenuItem("Crash Test", NULL, duigvs("crash_test_ui"));
146  ImGui::MenuItem("Access Key Dialog", NULL, duigvs("license_startup_prompt"));
147  ImGui::MenuItem("Old Menu", NULL, &old_devtools_bar);
148 
149  ImGui::EndMenu();
150  }
151 
152  if (ImGui::BeginMenu("Rendering"))
153  {
154  ImGui::MenuItem("Direct2D Test Window", NULL, duigvs("d2d_test"));
155  ImGui::MenuItem("bgfx Test Window", NULL, duigvs("bgfx_test"));
156  ImGui::MenuItem("Geometry Test", NULL, duigvs("geometry_test"));
157  ImGui::Separator();
158  ImGui::MenuItem("Toggle Render Target Clearing", "F3 + R", BlamRendering::DirectX::RenderTargetClearing());
159 
160  ImGui::EndMenu();
161  }
162  ImGui::MenuItem("Default Example Window", NULL, duigvs("dx11_window"));
163  ImGui::MenuItem("ImGui Demo Window", NULL, ((Windows::DirectX11Window*)GetDrawListItem("dx11_window"))->ShowTestWindow());
164 
165  ImGui::EndMenu();
166  }
167 
168  if (ImGui::BeginMenu("ImGUI"))
169  {
170  ImGui::MenuItem("Font Selector", NULL, &show_imgui_font_picker);
171  ImGui::MenuItem("Metrics", NULL, &show_imgui_metrics);
172  ImGui::MenuItem("Style Selector", NULL, &show_imgui_style_picker);
173  ImGui::MenuItem("Style Editor", NULL, &show_imgui_style_editor);
174 
175  ImGui::EndMenu();
176  }
177 
178  ImGui::Separator();
179  if (ImGui::MenuItem("Take Screenshot", "F2")) Blam::TakeScreenshot();
180 
181  ImGui::Separator();
182 
183  ImGui::MenuItem("Engine Text Viewer", NULL, duigvs("engine_text_viewer"));
184 
185  ImGui::Separator();
186 
187  ImGui::MenuItem("Tag Editor", NULL, duigvs("tag_editor"));
188  ImGui::MenuItem("Globals Editor", NULL, duigvs("globals_editor"));
189 
190  ImGui::Separator();
191 
192  ImGui::MenuItem("Director Debug", NULL, duigvs("director_tool"));
193  ImGui::MenuItem("Execute Command", NULL, duigvs("imgui_console"));
194 
195  ImGui::EndMenu();
196  }
197  if (ImGui::BeginMenu("Network Tools"))
198  {
199  ImGui::MenuItem(ENGINE_TEXT("imgui_menu_placeholder_notice").c_str(), NULL, false, false); ShowNYITooltip();
200  ImGui::EndMenu();
201  }
202  if (ImGui::BeginMenu("Debug"))
203  {
204  if (ImGui::MenuItem("Debug Menu", "PgUp"))
205  {
207 
208  if (debug_menu_stack_item)
209  {
210  debug_menu_stack_item->toggleVisibility();
211  }
212  else
213  {
214  Blam::Logger::LogEventForce("failed to find debug menu in render stack!", WSV_ERROR);
215  }
216  }
217  ImGui::MenuItem("Debug Menu (imgui)", "Shift + PgUp", duigvs("debug_menu"));
218  ImGui::EndMenu();
219  }
220  if (ImGui::BeginMenu("Settings"))
221  {
222  ImGui::MenuItem("Configuration Editor", NULL, false, false); ShowNYITooltip();
223  ImGui::MenuItem("Theme Selector", NULL, duigvs("theme_selector"));
224  ImGui::MenuItem("Theme Editor", NULL, duigvs("theme_editor"));
225  ImGui::EndMenu();
226  }
227  if (ImGui::BeginMenu("Monitoring"))
228  {
229  ImGui::MenuItem("Show FPS", NULL, false, false); ShowNYITooltip();
230  ImGui::Separator();
231  ImGui::MenuItem("Show Usage Info", NULL, false, false); ShowNYITooltip();
232  ImGui::EndMenu();
233  }
234  if (ImGui::BeginMenu("Help"))
235  {
236  ImGui::MenuItem("ImGui User Guide", NULL, duigvs("imgui_user_guide"));
237  ImGui::Separator();
238  ImGui::MenuItem("About ImGui", NULL, duigvs("imgui_info"));
239  ImGui::MenuItem("About Blamite", NULL, duigvs("engine_info_new"));
240  ImGui::EndMenu();
241  }
242 
243  if (main_menu)
244  {
245  ImGui::SameLine(ImGui::GetWindowWidth() - (commit_hash_label + 15));
246  }
247 
248  ImGui::TextDisabled(CURRENT_COMMIT);
249  if (ImGui::IsItemHovered())
250  {
251  ImGui::BeginTooltip();
252  ImGui::PushTextWrapPos(450.0f);
253  ImGui::TextUnformatted(ENGINE_TEXT("imgui_menu_commit_tooltip_title").c_str());
254 
255  ImGui::Separator();
256 
257  ImGui::TextUnformatted(ENGINE_TEXT("imgui_menu_commit_tooltip_text").c_str());
258 
259 
260  ImGui::PopTextWrapPos();
261  ImGui::EndTooltip();
262  }
263 
264  ImVec2 commit_label_size = ImGui::GetItemRectSize();
265 
266  commit_hash_label = commit_label_size.x;
267 
268  if (main_menu)
269  {
270  ImGui::EndMainMenuBar();
271  }
272  else
273  {
274  ImGui::EndMenuBar();
275 
276  ImGui::Text("this is the final iteration of the hardcoded menu bar");
277  ImGui::Text("all newer menu bar changes are controlled by menu_bar_init.xml");
278 
279  ImGui::End();
280  }
281  }
282  }
283 
284  if (old_devtools_bar)
285  {
286  ImGui::Begin("Old Menu", &old_devtools_bar, ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize);
287 
288  old_menu->Draw();
289 
290  ImGui::Text("can't imagine why you'd need it, but here it is");
291 
292  ImGui::End();
293  }
294 
295  if (show_imgui_font_picker)
296  {
297  ImGui::ShowFontSelector("Choose Font");
298  }
299 
300  if (show_imgui_metrics)
301  {
302  ImGui::ShowMetricsWindow(&show_imgui_metrics);
303  }
304 
305  if (show_imgui_style_picker)
306  {
307  ImGui::ShowStyleSelector("Choose Style");
308  }
309 
310  if (show_imgui_style_editor)
311  {
312  if (ImGui::Begin("ImGui Style Editor", &show_imgui_style_editor))
313  {
314  ImGui::ShowStyleEditor();
315  }
316  ImGui::End();
317  }
318  }
319  };
320 }
Blam::DebugUI::Widgets::MenuBar::Draw
void Draw()
Draws the menu bar contents and calculates the size of the commit hash text size.
Definition: menubar.hpp:82
render_stack.h
logger.h
Blam::DebugUI::Windows::DirectX11Window
Class for the default ImGUI DX11 sample window.
Definition: dx11_window.hpp:13
version_data.h
Blam::DebugUI::Widgets::MenuBar::~MenuBar
~MenuBar()
Cleans up the legacy menu bar data.
Definition: menubar.hpp:68
main_menu
BlamDebugMenu main_menu
The debug menu data.
Definition: debug_menu.cpp:18
Blam::Config::GetConfig
BLAM ConfigFile * GetConfig()
Definition: compat.cpp:5
engine_text.h
BlamRendering::RenderStack::DebugMenu
Stack item representing the debug menu.
Definition: debug_menu.hpp:20
BlamRendering::RenderStack::DebugMenu::toggleVisibility
void toggleVisibility()
Toggles the visibility of the debug menu.
Definition: debug_menu.hpp:602
Blam::DebugUI::Widgets::DevToolsBar
Class for the original menu bar shown with ImGUI.
Definition: devtools_bar.hpp:18
WSV_ERROR
#define WSV_ERROR
Macro for 'Error' log seveirty. Original pre-enum value was 2.
Definition: logger.h:17
dx11_window.hpp
Blam::Logger::LogEventForce
BLAM void LogEventForce(std::string message, BlamLogLevel severity)
Forcibly logs a message to the log and/or console.
Definition: aliases.cpp:218
debug_menu.hpp
Blam::TakeScreenshot
BLAM void TakeScreenshot()
Captures the current frame and saves it to a file.
Definition: screenshot.cpp:100
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:362
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:359
utilities.h
CURRENT_COMMIT
#define CURRENT_COMMIT
Definition: version_data.h:14
engine_definitions.h
Blam::DebugUI::Widgets::MenuBar::MenuBar
MenuBar(bool show_in_window)
Initializes data for the legacy menu bar and instructs it to draw as a standard menu rather than the ...
Definition: menubar.hpp:50
Blam::DebugUI::Widgets::ShowNYITooltip
BLAM void ShowNYITooltip()
Shows a tooltip with the text Not yet implemented upon hovered.
Definition: widgets.cpp:20
ENGINE_TEXT
#define ENGINE_TEXT(string_id)
Definition: engine_text.h:7
Blam::DebugUI::GetDrawListItem
BLAM ImGUIDrawingGroup * GetDrawListItem(std::string key)
Retrieves a drawing group with the specified ID.
Definition: drawing_list.cpp:30
Blam::Config::ConfigFile::GetString
std::string GetString(std::string option)
Definition: compat.cpp:58
Blam::DebugUI::Widgets::DevToolsBar::Draw
void Draw()
Draws the menu bar contents.
Definition: devtools_bar.hpp:48
config.h
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: debug_ui.h:434
Blam::DebugUI::Widgets
Namespace containing general-purpose widgets used in multiple ImGUI drawing groups/windows.
Definition: devtools_bar.hpp:10
Text
@ Text
Master text object that wraps around both BitmapText and DWText.
Definition: render_stack.h:73
Blam::DebugUI::Widgets::MenuBar
Class for the main ImGUI menu bar.
Definition: menubar.hpp:26
BlamRendering::DirectX::RenderTargetClearing
BLAM bool * RenderTargetClearing()
Retrieves whether or not to enable render target clearing.
Definition: render_manage.cpp:608
duigvs
#define duigvs(x)
Macro for Blam::DebugUI::GetVisibility().
Definition: debug_ui.h:19
devtools_bar.hpp
BlamRendering::RenderStack::GetStackItem
BLAM StackObjectBase * GetStackItem(std::string id)
Retrieves an item from the render stack.
Definition: render_stack.cpp:75
Blam::DebugUI::Widgets::DevToolsBar::SetDrawModeNotMainMenu
void SetDrawModeNotMainMenu()
Instructs the menu to draw as a menu bar within a window, rather than as part of the main menu bar.
Definition: devtools_bar.hpp:40