improv: ImGui test engine window can now be opened and closed from debug menu (#2310)

This commit is contained in:
paxcut
2025-06-20 12:26:17 -07:00
committed by GitHub
parent ea4d71b26c
commit 755a53f821
4 changed files with 21 additions and 2 deletions

View File

@@ -362,6 +362,12 @@ namespace ImGuiExt {
else static_assert(hex::always_false<T>::value, "Invalid data type!");
}
struct ImGuiTestEngine {
ImGuiTestEngine() = delete;
static void setEnabled(bool enabled);
[[nodiscard]] static bool isEnabled();
};
}
// these functions are exception because they just allow conversion from string to char*, they do not really add anything

View File

@@ -1443,6 +1443,16 @@ namespace ImGuiExt {
// Return the button press state
ImGui::PopClipRect();
}
static bool s_imguiTestEngineEnabled = false;
void ImGuiTestEngine::setEnabled(bool enabled) {
s_imguiTestEngineEnabled = enabled;
}
bool ImGuiTestEngine::isEnabled() {
return s_imguiTestEngineEnabled;
}
}
namespace ImGui {

View File

@@ -407,9 +407,9 @@ namespace hex {
ImGui::NewFrame();
#if defined(IMGUI_TEST_ENGINE)
if (ImGuiExt::ImGuiTestEngine::isEnabled())
ImGuiTestEngine_ShowTestEngineWindows(m_testEngine, nullptr);
#endif
TutorialManager::drawTutorial();

View File

@@ -88,6 +88,7 @@ namespace hex::plugin::builtin {
static bool showImGuiDemo = false;
static bool showImPlotDemo = false;
static bool showImPlot3DDemo = false;
static bool showTestEngine = false;
ImGui::SetNextWindowSize(scaled({ 300, 150 }), ImGuiCond_Always);
if (ImGui::BeginPopup("DebugMenu")) {
@@ -109,6 +110,7 @@ namespace hex::plugin::builtin {
if (ImGui::BeginChild("Scrolling", ImGui::GetContentRegionAvail())) {
auto ctx = ImGui::GetCurrentContext();
ImGui::Checkbox("Show ImGui Demo", &showImGuiDemo);
ImGui::Checkbox("Show ImGui Test Engine",&showTestEngine);
ImGui::Checkbox("Show ImPlot Demo", &showImPlotDemo);
ImGui::Checkbox("Show ImPlot3D Demo", &showImPlot3DDemo);
@@ -158,6 +160,7 @@ namespace hex::plugin::builtin {
if (showImGuiDemo)
ImGui::ShowDemoWindow(&showImGuiDemo);
ImGuiExt::ImGuiTestEngine::setEnabled(showTestEngine);
if (showImPlotDemo)
ImPlot::ShowDemoWindow(&showImPlotDemo);
if (showImPlot3DDemo)