Blamite Game Engine - blam!  00272.10.26.20.0001.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"
15 #include "version_data.h"
16 
17 namespace Blam::DebugUI::Widgets
18 {
25  {
26  private:
27  DevToolsBar* old_menu;
28 
29  bool old_devtools_bar = false;
30  bool show_menubar = true;
31 
32  int commit_hash_label = 0;
33 
34  bool show_imgui_font_picker = false;
35  bool show_imgui_metrics = false;
36  bool show_imgui_style_picker = false;
37  bool show_imgui_style_editor = false;
38 
39  public:
44  {
45  old_menu = new DevToolsBar();
46 
47  old_menu->SetDrawModeNotMainMenu();
48  }
49 
54  {
55  delete(old_menu);
56  }
57 
64  void Draw()
65  {
66 
67  // Main Menu (titlebar)
68  if (show_menubar)
69  {
70  if (ImGui::BeginMainMenuBar())
71  {
72  using namespace Blam::DebugUI::Windows;
73 
74  if (ImGui::BeginMenu("File"))
75  {
76  ImGui::MenuItem("Open .map file", NULL, false, false); ShowNYITooltip();
77  ImGui::MenuItem("Return to mainmenu", NULL, false, false); ShowNYITooltip();
78  if (ImGui::MenuItem("Open game dir", NULL)) BlamStrings::Utils::IO::OpenGameDirectory();
79  ImGui::Separator();
80  if (ImGui::MenuItem("Open Report Viewer", NULL)) BlamStrings::Utils::OpenLocalWebURL("/reports/index.html");
81  ImGui::Separator();
82  ImGui::MenuItem("Exit", NULL, duigvs(exit_via_menu));
83  ImGui::EndMenu();
84  }
85  if (ImGui::BeginMenu("Tools"))
86  {
87  ImGui::MenuItem("Cheats", NULL, false, false); ShowNYITooltip();
88  ImGui::Separator();
89  if (ImGui::BeginMenu("Network"))
90  {
91  ImGui::MenuItem("Show Network Info", NULL, duigvs(network_stats));
92  ImGui::MenuItem("Discord Rich Presence", NULL, duigvs(discord_rpc_ui));
93  ImGui::EndMenu();
94  }
95 
96  if (ImGui::BeginMenu("Rendering"))
97  {
98  ImGui::MenuItem("Render Stack Editor", NULL, duigvs(render_stack_editor));
99  ImGui::MenuItem("Font Editor", NULL, duigvs(font_editor));
100 
101  ImGui::EndMenu();
102  }
103 
104  if (ImGui::BeginMenu("Test"))
105  {
106  if (ImGui::BeginMenu("Deprecated"))
107  {
108  ImGui::TextColored(ImVec4(1, 0, 0, 1), "These items will be replaced/removed in the future.");
109  ImGui::Separator();
110  ImGui::MenuItem("Crash Test", NULL, duigvs(crash_test_ui));
111  ImGui::MenuItem("Access Key Dialog", NULL, duigvs(license_startup_prompt));
112  ImGui::MenuItem("Old Menu", NULL, &old_devtools_bar);
113 
114  ImGui::EndMenu();
115  }
116 
117  if (ImGui::BeginMenu("Rendering"))
118  {
119  ImGui::MenuItem("Direct2D Test Window", NULL, duigvs(d2d_test));
120  ImGui::Separator();
121  ImGui::MenuItem("Toggle Render Target Clearing", "F3 + R", BlamRendering::DirectX::RenderTargetClearing());
122 
123  ImGui::EndMenu();
124  }
125  ImGui::MenuItem("Default Example Window", NULL, duigvs(dx11_window));
126  ImGui::MenuItem("ImGui Demo Window", NULL, ((Windows::DirectX11Window*)GetDrawListItem(dx11_window))->ShowTestWindow());
127 
128  ImGui::EndMenu();
129  }
130 
131  if (ImGui::BeginMenu("ImGUI"))
132  {
133  ImGui::MenuItem("Font Selector", NULL, &show_imgui_font_picker);
134  ImGui::MenuItem("Metrics", NULL, &show_imgui_metrics);
135  ImGui::MenuItem("Style Selector", NULL, &show_imgui_style_picker);
136  ImGui::MenuItem("Style Editor", NULL, &show_imgui_style_editor);
137 
138  ImGui::EndMenu();
139  }
140 
141  ImGui::Separator();
142  if (ImGui::MenuItem("Take Screenshot", "F2")) Blam::TakeScreenshot();
143 
144  ImGui::Separator();
145 
146  ImGui::MenuItem("Tag Editor", NULL, duigvs(tag_editor));
147 
148  ImGui::EndMenu();
149  }
150  if (ImGui::BeginMenu("Network Tools"))
151  {
152  ImGui::MenuItem("this menu is a placeholder, come back later", NULL, false, false); ShowNYITooltip();
153  ImGui::EndMenu();
154  }
155  if (ImGui::BeginMenu("Debug"))
156  {
157  if (ImGui::MenuItem("Debug Menu", "PgUp"))
158  {
160 
161  if (debug_menu_stack_item)
162  {
163  debug_menu_stack_item->toggleVisibility();
164  }
165  else
166  {
167  Blam::Logger::LogEventForce("### ERROR failed to find debug menu in render stack!", WSV_ERROR);
168  }
169  }
170  ImGui::MenuItem("Debug Menu (imgui)", "Shift + PgUp", duigvs(debug_menu));
171  ImGui::EndMenu();
172  }
173  if (ImGui::BeginMenu("Settings"))
174  {
175  ImGui::MenuItem("Configuration Editor", NULL, false, false); ShowNYITooltip();
176  ImGui::MenuItem("Theme Selector", NULL, duigvs(theme_selector));
177  ImGui::MenuItem("Theme Editor", NULL, duigvs(theme_editor));
178  ImGui::EndMenu();
179  }
180  if (ImGui::BeginMenu("Monitoring"))
181  {
182  ImGui::MenuItem("Show FPS", NULL, false, false); ShowNYITooltip();
183  ImGui::Separator();
184  ImGui::MenuItem("Show Usage Info", NULL, false, false); ShowNYITooltip();
185  ImGui::EndMenu();
186  }
187  if (ImGui::BeginMenu("Help"))
188  {
189  ImGui::MenuItem("ImGui User Guide", NULL, duigvs(imgui_user_guide));
190  ImGui::Separator();
191  ImGui::MenuItem("About ImGui", NULL, duigvs(imgui_info));
192  ImGui::MenuItem("About Blamite", NULL, duigvs(engine_info_new));
193  ImGui::EndMenu();
194  }
195 
196 
197  ImGui::SameLine(ImGui::GetWindowWidth() - (commit_hash_label + 15));
198  ImGui::TextDisabled(CURRENT_COMMIT);
199  if (ImGui::IsItemHovered())
200  {
201  ImGui::BeginTooltip();
202  ImGui::PushTextWrapPos(450.0f);
203  ImGui::TextUnformatted("Current git commit of this build");
204 
205  ImGui::Separator();
206 
207  ImGui::TextUnformatted("If this build was created locally, this number will be inaccurate. Only builds acquired from Jenkins or BuildMaster will be accurate.");
208 
209 
210  ImGui::PopTextWrapPos();
211  ImGui::EndTooltip();
212  }
213 
214  ImVec2 commit_label_size = ImGui::GetItemRectSize();
215 
216  commit_hash_label = commit_label_size.x;
217 
218  ImGui::EndMainMenuBar();
219  }
220  }
221 
222  if (old_devtools_bar)
223  {
224  ImGui::Begin("Old Menu", &old_devtools_bar, ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize);
225 
226  old_menu->Draw();
227 
228  ImGui::Text("can't imagine why you'd need it, but here it is");
229 
230  ImGui::End();
231  }
232 
233  if (show_imgui_font_picker)
234  {
235  ImGui::ShowFontSelector("Choose Font");
236  }
237 
238  if (show_imgui_metrics)
239  {
240  ImGui::ShowMetricsWindow(&show_imgui_metrics);
241  }
242 
243  if (show_imgui_style_picker)
244  {
245  ImGui::ShowStyleSelector("Choose Style");
246  }
247 
248  if (show_imgui_style_editor)
249  {
250  if (ImGui::Begin("ImGui Style Editor", &show_imgui_style_editor))
251  {
252  ImGui::ShowStyleEditor();
253  }
254  ImGui::End();
255  }
256  }
257  };
258 }
Blam::DebugUI::d2d_test
@ d2d_test
Definition: debug_ui.h:382
Blam::DebugUI::tag_editor
@ tag_editor
Definition: debug_ui.h:389
Blam::DebugUI::discord_rpc_ui
@ discord_rpc_ui
Definition: debug_ui.h:383
Blam::DebugUI::theme_editor
@ theme_editor
Definition: debug_ui.h:399
Blam::DebugUI::dx11_window
@ dx11_window
Definition: debug_ui.h:367
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:64
render_stack.h
Blam::DebugUI::render_stack_editor
@ render_stack_editor
Definition: debug_ui.h:386
logger.h
Blam::DebugUI::Widgets::MenuBar::MenuBar
MenuBar()
Initializes data for the legacy menu bar and instructs it to draw as a standard menu rather than the ...
Definition: menubar.hpp:43
Blam::DebugUI::Windows::DirectX11Window
Class for the default ImGUI DX11 sample window.
Definition: dx11_window.hpp:13
version_data.h
Blam::DebugUI::engine_info_new
@ engine_info_new
Definition: debug_ui.h:392
Blam::DebugUI::imgui_info
@ imgui_info
Definition: debug_ui.h:393
Blam::DebugUI::Widgets::MenuBar::~MenuBar
~MenuBar()
Cleans up the legacy menu bar data.
Definition: menubar.hpp:53
Blam::DebugUI::imgui_user_guide
@ imgui_user_guide
Definition: debug_ui.h:397
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:17
WSV_ERROR
#define WSV_ERROR
Macro for 'Error' log seveirty. Original pre-enum value was 2.
Definition: logger.h:17
dx11_window.hpp
Blam::DebugUI::debug_menu
@ debug_menu
Definition: debug_ui.h:394
debug_menu.hpp
Blam::TakeScreenshot
BLAM void TakeScreenshot()
Captures the current frame and saves it to a file.
Definition: screenshot.cpp:100
Blam::DebugUI::font_editor
@ font_editor
Definition: debug_ui.h:384
Blam::DebugUI::theme_selector
@ theme_selector
Definition: debug_ui.h:398
Blam::DebugUI::license_startup_prompt
@ license_startup_prompt
Definition: debug_ui.h:375
Blam::DebugUI::ImGUIDrawingGroup
Class representing an ImGUI drawing group/draw list item.
Definition: debug_ui.h:409
utilities.h
CURRENT_COMMIT
#define CURRENT_COMMIT
Definition: version_data.h:14
Blam::DebugUI::GetDrawListItem
BLAM ImGUIDrawingGroup * GetDrawListItem(DrawListItem key)
Retrieves a drawing group with the specified ID.
Definition: drawing_list.cpp:21
engine_definitions.h
Blam::DebugUI::crash_test_ui
@ crash_test_ui
Definition: debug_ui.h:381
Blam::DebugUI::Widgets::ShowNYITooltip
BLAM void ShowNYITooltip()
Shows a tooltip with the text Not yet implemented upon hovered.
Definition: widgets.cpp:20
Blam::Logger::LogEventForce
BLAM void LogEventForce(std::string message, LogSeverity severity)
Forcibly logs a message to the log and/or console.
Definition: aliases.cpp:150
Blam::DebugUI::Widgets::DevToolsBar::Draw
void Draw()
Draws the menu bar contents.
Definition: devtools_bar.hpp:44
Blam::DebugUI::exit_via_menu
@ exit_via_menu
Definition: debug_ui.h:396
Blam::DebugUI::Windows
Legacy namespace to contain data for the legacy ImGUI console.
Definition: debug_ui.h:494
Blam::DebugUI::Widgets
Namespace containing general-purpose widgets used in multiple ImGUI drawing groups/windows.
Definition: devtools_bar.hpp:9
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:24
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:20
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:36
Blam::DebugUI::network_stats
@ network_stats
Definition: debug_ui.h:385