From 33935be5db789ce9925ca0469a9fc04e7f61974b Mon Sep 17 00:00:00 2001 From: Archez Date: Sun, 24 Nov 2024 19:26:20 -0500 Subject: [PATCH] Fix gamepad nav flag not updating when closing menu with X button (#872) --- mm/2s2h/BenGui/Menu.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/2s2h/BenGui/Menu.cpp b/mm/2s2h/BenGui/Menu.cpp index ca8f04925..628ce59dc 100644 --- a/mm/2s2h/BenGui/Menu.cpp +++ b/mm/2s2h/BenGui/Menu.cpp @@ -234,6 +234,15 @@ void BenMenu::DrawElement() { } if (UIWidgets::Button(ICON_FA_TIMES_CIRCLE, { .size = UIWidgets::Sizes::Inline, .tooltip = "Close Menu (Esc)" })) { ToggleVisibility(); + + // Update gamepad navigation after close based on if other menus are still visible + auto mImGuiIo = &ImGui::GetIO(); + if (CVarGetInteger(CVAR_IMGUI_CONTROLLER_NAV, 0) && + Ship::Context::GetInstance()->GetWindow()->GetGui()->GetMenuOrMenubarVisible()) { + mImGuiIo->ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; + } else { + mImGuiIo->ConfigFlags &= ~ImGuiConfigFlags_NavEnableGamepad; + } } ImGui::SameLine(); ImGui::SetNextWindowSizeConstraints({ 0, headerHeight }, { headerWidth, headerHeight });