From b56b438f1f66081fcda2eac44ab26aad3a3b9135 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 24 Feb 2021 18:56:41 +1000 Subject: [PATCH] FullscreenUI: Only show debug menu bar in NoGUI --- .../nogui_host_interface.cpp | 3 ++ src/frontend-common/fullscreen_ui.cpp | 29 +++++++++++++------ src/frontend-common/fullscreen_ui.h | 2 +- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/duckstation-nogui/nogui_host_interface.cpp b/src/duckstation-nogui/nogui_host_interface.cpp index e8f9c5760..ffa35ec85 100644 --- a/src/duckstation-nogui/nogui_host_interface.cpp +++ b/src/duckstation-nogui/nogui_host_interface.cpp @@ -61,7 +61,10 @@ bool NoGUIHostInterface::Initialize() } if (m_fullscreen_ui_enabled) + { + FullscreenUI::SetDebugMenuAllowed(true); FullscreenUI::QueueGameListRefresh(); + } // process events to pick up controllers before updating input map PollAndUpdate(); diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp index 3ea5e995d..cd29d5358 100644 --- a/src/frontend-common/fullscreen_ui.cpp +++ b/src/frontend-common/fullscreen_ui.cpp @@ -85,11 +85,14 @@ static void DrawStatsOverlay(); static void DrawOSDMessages(); static void DrawAboutWindow(); static void OpenAboutWindow(); +static void SetDebugMenuEnabled(bool enabled); +static void UpdateDebugMenuVisibility(); static CommonHostInterface* s_host_interface; static MainWindowType s_current_main_window = MainWindowType::Landing; static std::bitset(FrontendCommon::ControllerNavigationButton::Count)> s_nav_input_values{}; static bool s_debug_menu_enabled = false; +static bool s_debug_menu_allowed = false; static bool s_quick_menu_was_open = false; static bool s_was_paused_on_quick_menu_open = false; static bool s_about_window_open = false; @@ -195,7 +198,7 @@ bool Initialize(CommonHostInterface* host_interface) return false; s_settings_copy.Load(*s_host_interface->GetSettingsInterface()); - SetDebugMenuEnabled(s_host_interface->GetSettingsInterface()->GetBoolValue("Main", "ShowDebugMenu", false)); + UpdateDebugMenuVisibility(); ImGuiFullscreen::UpdateLayoutScale(); ImGuiFullscreen::UpdateFonts(); @@ -1937,7 +1940,7 @@ void DrawSettingsWindow() if (ToggleButton("Enable Debug Menu", "Shows a debug menu bar with additional statistics and quick settings.", &debug_menu)) { - s_host_interface->RunLater([debug_menu]() { SetDebugMenuEnabled(debug_menu, true); }); + s_host_interface->RunLater([debug_menu]() { SetDebugMenuEnabled(debug_menu); }); } settings_changed |= @@ -2982,8 +2985,22 @@ bool DrawConfirmWindow(const char* message, bool* result) // Debug Menu ////////////////////////////////////////////////////////////////////////// -void SetDebugMenuEnabled(bool enabled, bool save_to_ini) +void SetDebugMenuAllowed(bool allowed) { + s_debug_menu_enabled = allowed; + UpdateDebugMenuVisibility(); +} + +void SetDebugMenuEnabled(bool enabled) +{ + s_host_interface->GetSettingsInterface()->SetBoolValue("Main", "ShowDebugMenu", enabled); + s_host_interface->GetSettingsInterface()->Save(); +} + +void UpdateDebugMenuVisibility() +{ + const bool enabled = + s_debug_menu_allowed && s_host_interface->GetSettingsInterface()->GetBoolValue("Main", "ShowDebugMenu", false); if (s_debug_menu_enabled == enabled) return; @@ -2994,12 +3011,6 @@ void SetDebugMenuEnabled(bool enabled, bool save_to_ini) if (ImGuiFullscreen::UpdateFonts()) s_host_interface->GetDisplay()->UpdateImGuiFontTexture(); s_debug_menu_enabled = enabled; - - if (save_to_ini) - { - s_host_interface->GetSettingsInterface()->SetBoolValue("Main", "ShowDebugMenu", enabled); - s_host_interface->GetSettingsInterface()->Save(); - } } static void DrawDebugStats(); diff --git a/src/frontend-common/fullscreen_ui.h b/src/frontend-common/fullscreen_ui.h index ec4268371..62052d3e8 100644 --- a/src/frontend-common/fullscreen_ui.h +++ b/src/frontend-common/fullscreen_ui.h @@ -60,7 +60,7 @@ void EnsureGameListLoaded(); Settings& GetSettingsCopy(); void SaveAndApplySettings(); -void SetDebugMenuEnabled(bool enabled, bool save_to_ini = false); +void SetDebugMenuAllowed(bool allowed); /// Only ImGuiNavInput_Activate, ImGuiNavInput_Cancel, and DPad should be forwarded. /// Returns true if the UI consumed the event, and it should not execute the normal handler.