From 3f3607548f39256b3cd6e5bf0bede4194d1e5414 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 11 Aug 2021 00:03:44 +1000 Subject: [PATCH] CommonHostInterface: Make status indicators toggleable --- src/core/host_interface.cpp | 1 + src/core/settings.cpp | 2 ++ src/core/settings.h | 1 + src/duckstation-qt/advancedsettingswidget.cpp | 2 +- src/frontend-common/common_host_interface.cpp | 20 +++++++++++++------ src/frontend-common/fullscreen_ui.cpp | 16 ++++++--------- 6 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index d2faf2bbe..a734beab6 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -560,6 +560,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si) si.SetBoolValue("Display", "ShowVPS", false); si.SetBoolValue("Display", "ShowSpeed", false); si.SetBoolValue("Display", "ShowResolution", false); + si.SetBoolValue("Display", "ShowStatusIndicators", false); si.SetBoolValue("Display", "Fullscreen", false); si.SetBoolValue("Display", "VSync", Settings::DEFAULT_VSYNC_VALUE); si.SetBoolValue("Display", "DisplayAllFrames", false); diff --git a/src/core/settings.cpp b/src/core/settings.cpp index a329415f5..02636528e 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -238,6 +238,7 @@ void Settings::Load(SettingsInterface& si) display_show_vps = si.GetBoolValue("Display", "ShowVPS", false); display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false); display_show_resolution = si.GetBoolValue("Display", "ShowResolution", false); + display_show_status_indicators = si.GetBoolValue("Display", "ShowStatusIndicators", true); display_all_frames = si.GetBoolValue("Display", "DisplayAllFrames", false); video_sync_enabled = si.GetBoolValue("Display", "VSync", DEFAULT_VSYNC_VALUE); display_post_process_chain = si.GetStringValue("Display", "PostProcessChain", ""); @@ -413,6 +414,7 @@ void Settings::Save(SettingsInterface& si) const si.SetBoolValue("Display", "ShowVPS", display_show_vps); si.SetBoolValue("Display", "ShowSpeed", display_show_speed); si.SetBoolValue("Display", "ShowResolution", display_show_resolution); + si.SetBoolValue("Display", "ShowStatusIndicators", display_show_status_indicators); si.SetBoolValue("Display", "DisplayAllFrames", display_all_frames); si.SetBoolValue("Display", "VSync", video_sync_enabled); if (display_post_process_chain.empty()) diff --git a/src/core/settings.h b/src/core/settings.h index b71003b70..bbc7c4709 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -147,6 +147,7 @@ struct Settings bool display_show_vps = false; bool display_show_speed = false; bool display_show_resolution = false; + bool display_show_status_indicators = true; bool display_all_frames = false; bool video_sync_enabled = DEFAULT_VSYNC_VALUE; float display_max_fps = DEFAULT_DISPLAY_MAX_FPS; diff --git a/src/duckstation-qt/advancedsettingswidget.cpp b/src/duckstation-qt/advancedsettingswidget.cpp index c0df26f28..d589330f9 100644 --- a/src/duckstation-qt/advancedsettingswidget.cpp +++ b/src/duckstation-qt/advancedsettingswidget.cpp @@ -145,7 +145,7 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(QtHostInterface* host_interface, addBooleanTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("Disable All Enhancements"), "Main", "DisableAllEnhancements", false); - addBooleanTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("Show Fullscreen Status Indicators"), "Display", + addBooleanTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("Show Status Indicators"), "Display", "ShowStatusIndicators", true); addIntRangeTweakOption(m_host_interface, m_ui.tweakOptionTable, tr("Display FPS Limit"), "Display", "MaxFPS", 0, 1000, 0); diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 423d410b1..60ac41067 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -1228,7 +1228,8 @@ void CommonHostInterface::DrawFPSWindow() position_y += text_size.y + spacing; \ } while (0) - if (System::GetState() == System::State::Running) + const System::State state = System::GetState(); + if (state == System::State::Running) { const float speed = System::GetEmulationSpeed(); if (g_settings.display_show_fps) @@ -1267,13 +1268,21 @@ void CommonHostInterface::DrawFPSWindow() DRAW_LINE(IM_COL32(255, 255, 255, 255)); } - const bool rewinding = System::IsRewinding(); - if (rewinding || IsFastForwardEnabled() || IsTurboEnabled()) + if (g_settings.display_show_status_indicators) { - text.Assign(rewinding ? ICON_FA_FAST_BACKWARD : ICON_FA_FAST_FORWARD); - DRAW_LINE(IM_COL32(255, 255, 255, 255)); + const bool rewinding = System::IsRewinding(); + if (rewinding || IsFastForwardEnabled() || IsTurboEnabled()) + { + text.Assign(rewinding ? ICON_FA_FAST_BACKWARD : ICON_FA_FAST_FORWARD); + DRAW_LINE(IM_COL32(255, 255, 255, 255)); + } } } + else if (g_settings.display_show_status_indicators && state == System::State::Paused) + { + text.Assign(ICON_FA_PAUSE); + DRAW_LINE(IM_COL32(255, 255, 255, 255)); + } #undef DRAW_LINE } @@ -3055,7 +3064,6 @@ void CommonHostInterface::SetDefaultSettings(SettingsInterface& si) ControllerInterface::GetBackendName(ControllerInterface::GetDefaultBackend())); si.SetBoolValue("Display", "InternalResolutionScreenshots", false); - si.SetBoolValue("Display", "ShowStatusIndicators", true); #ifdef WITH_DISCORD_PRESENCE si.SetBoolValue("Main", "EnableDiscordPresence", false); diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp index b78ec1d41..8249fea64 100644 --- a/src/frontend-common/fullscreen_ui.cpp +++ b/src/frontend-common/fullscreen_ui.cpp @@ -113,7 +113,6 @@ 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_show_status_indicators = 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; @@ -247,10 +246,7 @@ bool HasActiveWindow() ImGuiFullscreen::IsChoiceDialogOpen() || ImGuiFullscreen::IsFileSelectorOpen(); } -void LoadSettings() -{ - s_show_status_indicators = s_host_interface->GetBoolSettingValue("Display", "ShowStatusIndicators", true); -} +void LoadSettings() {} void UpdateSettings() { @@ -2527,9 +2523,9 @@ void DrawSettingsWindow() "General", "CreateSaveStateBackups", false); MenuHeading("Display Settings"); - settings_changed |= ToggleButtonForNonSetting("Show Status Indicators", - "Shows persistent icons when turbo is active or when paused.", - "Display", "ShowStatusIndicators", true); + settings_changed |= + ToggleButton("Show Status Indicators", "Shows persistent icons when turbo is active or when paused.", + &g_settings.display_show_status_indicators); settings_changed |= RangeButton( "Display FPS Limit", "Limits how many frames are displayed to the screen. These frames are still rendered.", &s_settings_copy.display_max_fps, 0.0f, 500.0f, 1.0f, "%.2f FPS"); @@ -3406,7 +3402,7 @@ void DrawStatsOverlay() DRAW_LINE(g_large_font, g_large_font->FontSize, 0.0f, IM_COL32(255, 255, 255, 255)); } - if (s_show_status_indicators) + if (g_settings.display_show_status_indicators) { const bool rewinding = System::IsRewinding(); if (rewinding || s_host_interface->IsFastForwardEnabled() || s_host_interface->IsTurboEnabled()) @@ -3416,7 +3412,7 @@ void DrawStatsOverlay() } } } - else if (s_show_status_indicators && state == System::State::Paused) + else if (g_settings.display_show_status_indicators && state == System::State::Paused) { text.Assign(ICON_FA_PAUSE); DRAW_LINE(g_large_font, g_large_font->FontSize * 2.0f, margin, IM_COL32(255, 255, 255, 255));