InputRec: Stop input recording on VM shutdown

This commit is contained in:
KamFretoZ 2024-01-28 21:52:30 +07:00 committed by refractionpcsx2
parent bb60058fa0
commit 18ae23b99d
2 changed files with 23 additions and 15 deletions

View File

@ -15,6 +15,7 @@
#include "GS/MultiISA.h"
#include "Host.h"
#include "Input/InputManager.h"
#include "Recording/InputRecording.h"
#include "MTGS.h"
#include "pcsx2/GS.h"
#include "GS/Renderers/Null/GSRendererNull.h"
@ -337,6 +338,9 @@ void GSclose()
if (GSCapture::IsCapturing())
GSCapture::EndCapture();
if (g_InputRecording.isActive())
g_InputRecording.stop();
CloseGSRenderer();
CloseGSDevice(true);
Host::ReleaseRenderWindow();
@ -499,6 +503,9 @@ void GSGameChanged()
if (!VMManager::HasValidVM() && GSCapture::IsCapturing())
GSCapture::EndCapture();
if (!VMManager::HasValidVM() && g_InputRecording.isActive())
g_InputRecording.stop();
}
bool GSHasDisplayWindow()

View File

@ -598,6 +598,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())
return;
const float shadow_offset = std::ceil(scale);
ImFont* const fixed_font = ImGuiManager::GetFixedFont();
@ -618,23 +621,21 @@ __ri void ImGuiManager::DrawInputRecordingOverlay(float& position_y, float scale
dl->AddText(font, font->FontSize, ImVec2(GetWindowWidth() - margin - text_size.x, position_y), color, (text)); \
position_y += text_size.y + spacing; \
} while (0)
if (g_InputRecording.isActive() && !FullscreenUI::HasActiveWindow())
{
// Status Indicators
if (g_InputRecording.getControls().isRecording())
{
DRAW_LINE(standard_font, TinyString::from_fmt("{} Recording Input", ICON_FA_RECORDING).c_str(), IM_COL32(255, 0, 0, 255));
}
else
{
DRAW_LINE(standard_font, TinyString::from_fmt("{} Replaying", ICON_FA_PLAY).c_str(), IM_COL32(97, 240, 84, 255));
}
// Input Recording Metadata
DRAW_LINE(fixed_font, TinyString::from_fmt("Input Recording Active: {}", g_InputRecording.getData().getFilename()).c_str(), IM_COL32(117, 255, 241, 255));
DRAW_LINE(fixed_font, TinyString::from_fmt("Frame: {}/{} ({})", g_InputRecording.getFrameCounter() + 1, g_InputRecording.getData().getTotalFrames(), g_FrameCount).c_str(), IM_COL32(117, 255, 241, 255));
DRAW_LINE(fixed_font, TinyString::from_fmt("Undo Count: {}", g_InputRecording.getData().getUndoCount()).c_str(), IM_COL32(117, 255, 241, 255));
// Status Indicators
if (g_InputRecording.getControls().isRecording())
{
DRAW_LINE(standard_font, TinyString::from_fmt("{} Recording Input", ICON_FA_RECORDING).c_str(), IM_COL32(255, 0, 0, 255));
}
else
{
DRAW_LINE(standard_font, TinyString::from_fmt("{} Replaying", ICON_FA_PLAY).c_str(), IM_COL32(97, 240, 84, 255));
}
// Input Recording Metadata
DRAW_LINE(fixed_font, TinyString::from_fmt("Input Recording Active: {}", g_InputRecording.getData().getFilename()).c_str(), IM_COL32(117, 255, 241, 255));
DRAW_LINE(fixed_font, TinyString::from_fmt("Frame: {}/{} ({})", g_InputRecording.getFrameCounter() + 1, g_InputRecording.getData().getTotalFrames(),g_FrameCount).c_str(), IM_COL32(117, 255, 241, 255));
DRAW_LINE(fixed_font, TinyString::from_fmt("Undo Count: {}", g_InputRecording.getData().getUndoCount()).c_str(), IM_COL32(117, 255, 241, 255));
#undef DRAW_LINE
}