From 72034da6ac8f7ce8c36ebb82d2ef5c13ec19fafb Mon Sep 17 00:00:00 2001 From: KamFretoZ <14798312+kamfretoz@users.noreply.github.com> Date: Fri, 2 Aug 2024 20:51:02 +0700 Subject: [PATCH] OSD: Add InputRec/VideoCapture OSD Toggle --- pcsx2-qt/Settings/GraphicsSettingsWidget.cpp | 10 +- pcsx2-qt/Settings/GraphicsSettingsWidget.ui | 112 +++++++++++-------- pcsx2/Config.h | 2 + pcsx2/GS/GS.cpp | 2 + pcsx2/ImGui/FullscreenUI.cpp | 6 + pcsx2/ImGui/ImGuiOverlays.cpp | 29 +++-- pcsx2/Pcsx2Config.cpp | 4 + 7 files changed, 107 insertions(+), 58 deletions(-) diff --git a/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp b/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp index be1257d226..b8e6a21288 100644 --- a/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp +++ b/pcsx2-qt/Settings/GraphicsSettingsWidget.cpp @@ -127,6 +127,8 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.osdShowFrameTimes, "EmuCore/GS", "OsdShowFrameTimes", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.osdShowVersion, "EmuCore/GS", "OsdShowVersion", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.osdShowHardwareInfo, "EmuCore/GS", "OsdShowHardwareInfo", false); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.osdShowVideoCapture, "EmuCore/GS", "OsdShowVideoCapture", true); + SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.osdShowInputRec, "EmuCore/GS", "OsdShowInputRec", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.warnAboutUnsafeSettings, "EmuCore", "WarnAboutUnsafeSettings", true); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.fxaa, "EmuCore/GS", "fxaa", false); SettingWidgetBinder::BindWidgetToBoolSetting(sif, m_ui.shadeBoost, "EmuCore/GS", "ShadeBoost", false); @@ -735,7 +737,13 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget* tr("Displays a graph showing the average frametimes.")); dialog->registerWidgetHelp(m_ui.osdShowVersion, tr("Show PCSX2 Version"), tr("Unchecked"), - tr("Shows the current PCSX2 version on the top-right corner of the display")); + tr("Shows the current PCSX2 version on the top-right corner of the display.")); + + dialog->registerWidgetHelp(m_ui.osdShowVideoCapture, tr("Show Video Capture Status"), tr("Checked"), + tr("Shows the currently active video capture status.")); + + dialog->registerWidgetHelp(m_ui.osdShowInputRec, tr("Show Input Recording Status"), tr("Checked"), + tr("Shows the currently active input recording status.")); dialog->registerWidgetHelp(m_ui.osdShowHardwareInfo, tr("Show Hardware Info"), tr("Unchecked"), tr("Shows the current system hardware information on the OSD.")); diff --git a/pcsx2-qt/Settings/GraphicsSettingsWidget.ui b/pcsx2-qt/Settings/GraphicsSettingsWidget.ui index 6ce24d6962..464b82e497 100644 --- a/pcsx2-qt/Settings/GraphicsSettingsWidget.ui +++ b/pcsx2-qt/Settings/GraphicsSettingsWidget.ui @@ -7,7 +7,7 @@ 0 0 720 - 552 + 562 @@ -1583,7 +1583,7 @@ - + On-Screen Display @@ -1661,7 +1661,21 @@ - + + + + + Show Resolution + + + + + + + Show FPS + + + @@ -1669,10 +1683,24 @@ - - + + - Show PCSX2 Version + Show GPU Usage + + + + + + + Show Inputs + + + + + + + Show Settings @@ -1690,6 +1718,34 @@ + + + + Show Hardware Info + + + + + + + Show PCSX2 Version + + + + + + + Show Input Recording Status + + + + + + + Show Video Capture Status + + + @@ -1697,13 +1753,6 @@ - - - - Show GPU Usage - - - @@ -1711,48 +1760,13 @@ - + Warn About Unsafe Settings - - - - Show Settings - - - - - - - Show FPS - - - - - - - Show Resolution - - - - - - - Show Inputs - - - - - - - Show Hardware Info - - - diff --git a/pcsx2/Config.h b/pcsx2/Config.h index fc6d6d2bc7..8e885dc48f 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -628,6 +628,8 @@ struct Pcsx2Config OsdShowInputs : 1, OsdShowFrameTimes : 1, OsdShowVersion : 1, + OsdShowVideoCapture: 1, + OsdShowInputRec : 1, OsdShowHardwareInfo : 1, HWSpinGPUForReadbacks : 1, HWSpinCPUForReadbacks : 1, diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index cd66eeca14..98bb62ba50 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -1045,6 +1045,8 @@ static void HotkeyToggleOSD() { GSConfig.OsdShowSettings ^= EmuConfig.GS.OsdShowSettings; GSConfig.OsdShowInputs ^= EmuConfig.GS.OsdShowInputs; + GSConfig.OsdShowInputRec ^= EmuConfig.GS.OsdShowInputRec; + GSConfig.OsdShowVideoCapture ^= EmuConfig.GS.OsdShowVideoCapture; GSConfig.OsdMessagesPos = GSConfig.OsdMessagesPos == OsdOverlayPos::None ? EmuConfig.GS.OsdMessagesPos : OsdOverlayPos::None; diff --git a/pcsx2/ImGui/FullscreenUI.cpp b/pcsx2/ImGui/FullscreenUI.cpp index 104ef077ab..21902be5c7 100644 --- a/pcsx2/ImGui/FullscreenUI.cpp +++ b/pcsx2/ImGui/FullscreenUI.cpp @@ -3146,6 +3146,12 @@ void FullscreenUI::DrawInterfaceSettingsPage() DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_PLAY, "Show Status Indicators"), FSUI_CSTR("Shows indicators when fast forwarding, pausing, and other abnormal states are active."), "EmuCore/GS", "OsdShowIndicators", true); + DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_KEYBOARD, "Show Input Recording Status"), + FSUI_CSTR("Shows the currently active input recording status."), "EmuCore/GS", + "OsdShowInputRec", true); + DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_VIDEO, "Show Video Capture Status"), + FSUI_CSTR("Shows the currently active video capture status."), "EmuCore/GS", + "OsdShowVideoCapture", true); DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_FA_SLIDERS_H, "Show Settings"), FSUI_CSTR("Shows the current configuration in the bottom-right corner of the display."), "EmuCore/GS", "OsdShowSettings", false); DrawToggleSetting(bsi, FSUI_ICONSTR(ICON_PF_GAMEPAD_ALT, "Show Inputs"), diff --git a/pcsx2/ImGui/ImGuiOverlays.cpp b/pcsx2/ImGui/ImGuiOverlays.cpp index 093d0e9c69..b9bc9eefc6 100644 --- a/pcsx2/ImGui/ImGuiOverlays.cpp +++ b/pcsx2/ImGui/ImGuiOverlays.cpp @@ -148,7 +148,7 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f } first = false; } - + if (GSConfig.OsdShowSpeed) { text.append_format("{}{}%", first ? "" : " | ", static_cast(std::round(speed))); @@ -324,9 +324,10 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f text.append_format("{:.1f} ms", max); text_size = fixed_font->CalcTextSizeA(fixed_font->FontSize, FLT_MAX, 0.0f, text.c_str(), text.c_str() + text.length()); win_dl->AddText(ImVec2((GSConfig.OsdPerformancePos == OsdOverlayPos::TopLeft ? 2.0f * spacing : wpos.x + history_size.x - text_size.x - spacing) + shadow_offset, - wpos.y + shadow_offset), IM_COL32(0, 0, 0, 100), text.c_str(), text.c_str() + text.length()); + wpos.y + shadow_offset), + IM_COL32(0, 0, 0, 100), text.c_str(), text.c_str() + text.length()); win_dl->AddText(ImVec2((GSConfig.OsdPerformancePos == OsdOverlayPos::TopLeft ? 2.0f * spacing : wpos.x + history_size.x - text_size.x - spacing), wpos.y), - IM_COL32(255, 255, 255, 255), text.c_str(), text.c_str() + text.length()); + IM_COL32(255, 255, 255, 255), text.c_str(), text.c_str() + text.length()); text.clear(); text.append_format("{:.1f} ms", min); @@ -335,7 +336,8 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f wpos.y + history_size.y - fixed_font->FontSize + shadow_offset), IM_COL32(0, 0, 0, 100), text.c_str(), text.c_str() + text.length()); win_dl->AddText(ImVec2((GSConfig.OsdPerformancePos == OsdOverlayPos::TopLeft ? 2.0f * spacing : wpos.x + history_size.x - text_size.x - spacing), - wpos.y + history_size.y - fixed_font->FontSize), IM_COL32(255, 255, 255, 255), text.c_str(), text.c_str() + text.length()); + wpos.y + history_size.y - fixed_font->FontSize), + IM_COL32(255, 255, 255, 255), text.c_str(), text.c_str() + text.length()); } ImGui::End(); ImGui::PopFont(); @@ -356,7 +358,8 @@ __ri void ImGuiManager::DrawPerformanceOverlay(float& position_y, float scale, f __ri void ImGuiManager::DrawSettingsOverlay(float scale, float margin, float spacing) { - if (!GSConfig.OsdShowSettings || VMManager::GetState() != VMState::Running) + if (!GSConfig.OsdShowSettings || + FullscreenUI::HasActiveWindow()) return; std::string text; @@ -491,7 +494,8 @@ __ri void ImGuiManager::DrawSettingsOverlay(float scale, float margin, float spa __ri void ImGuiManager::DrawInputsOverlay(float scale, float margin, float spacing) { // Technically this is racing the CPU thread.. but it doesn't really matter, at worst, the inputs get displayed onscreen late. - if (!GSConfig.OsdShowInputs || VMManager::GetState() != VMState::Running) + if (!GSConfig.OsdShowInputs || + FullscreenUI::HasActiveWindow()) return; const float shadow_offset = std::ceil(scale); @@ -639,7 +643,9 @@ __ri void ImGuiManager::DrawInputsOverlay(float scale, float margin, float spaci __ri void ImGuiManager::DrawInputRecordingOverlay(float& position_y, float scale, float margin, float spacing) { - if (!g_InputRecording.isActive() || FullscreenUI::HasActiveWindow()) + if (!GSConfig.OsdShowInputRec || + !g_InputRecording.isActive() || + FullscreenUI::HasActiveWindow()) return; const float shadow_offset = std::ceil(scale); @@ -683,7 +689,10 @@ __ri void ImGuiManager::DrawInputRecordingOverlay(float& position_y, float scale __ri void ImGuiManager::DrawVideoCaptureOverlay(float& position_y, float scale, float margin, float spacing) { - if (!GSCapture::IsCapturing() || FullscreenUI::HasActiveWindow()) + if (!GSConfig.OsdShowVideoCapture || + !GSCapture::IsCapturing() || + FullscreenUI::HasActiveWindow() + ) return; const float shadow_offset = std::ceil(scale); @@ -1104,10 +1113,14 @@ void SaveStateSelectorUI::ShowSlotOSDMessage() void ImGuiManager::RenderOverlays() { + if (VMManager::GetState() != VMState::Running) + return; + const float scale = ImGuiManager::GetGlobalScale(); const float margin = std::ceil(10.0f * scale); const float spacing = std::ceil(5.0f * scale); float position_y = margin; + DrawVideoCaptureOverlay(position_y, scale, margin, spacing); DrawInputRecordingOverlay(position_y, scale, margin, spacing); if (GSConfig.OsdPerformancePos != OsdOverlayPos::None) diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index e1a2dc5674..2edeef3bc2 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -632,6 +632,8 @@ Pcsx2Config::GSOptions::GSOptions() OsdShowFrameTimes = false; OsdShowVersion = false; OsdShowHardwareInfo = false; + OsdShowVideoCapture = true; + OsdShowInputRec = true; HWDownloadMode = GSHardwareDownloadMode::Enabled; HWSpinGPUForReadbacks = false; @@ -840,6 +842,8 @@ void Pcsx2Config::GSOptions::LoadSave(SettingsWrapper& wrap) SettingsWrapBitBool(OsdShowFrameTimes); SettingsWrapBitBool(OsdShowVersion); SettingsWrapBitBool(OsdShowHardwareInfo); + SettingsWrapBitBool(OsdShowVideoCapture); + SettingsWrapBitBool(OsdShowInputRec); SettingsWrapBitBool(HWSpinGPUForReadbacks); SettingsWrapBitBool(HWSpinCPUForReadbacks);