recording: Handle mode toggle in InputRecordingControls

This commit is contained in:
sonicfind 2020-09-13 13:36:11 -05:00 committed by refractionpcsx2
parent 975a37f209
commit 5c5d3a770f
5 changed files with 27 additions and 16 deletions

View File

@ -217,18 +217,6 @@ void InputRecording::SetToReplayMode()
recordingConLog("[REC]: Replay mode ON.\n");
}
void InputRecording::RecordModeToggle()
{
if (state == InputRecordingMode::Replaying)
{
SetToRecordMode();
}
else if (state == InputRecordingMode::Recording)
{
SetToReplayMode();
}
}
void InputRecording::SetFrameCounter(u32 newGFrameCount)
{
// Forces inputRecording to wait for a confirmed pause before resetting

View File

@ -63,9 +63,6 @@ public:
// Sets input recording to Replay Mode
void SetToReplayMode();
// Switches between recording and replaying the active input recording file
void RecordModeToggle();
// Set the running frame counter for the input recording to an arbitrary value
void SetFrameCounter(u32 newGFrameCount);

View File

@ -54,6 +54,12 @@ void InputRecordingControls::HandleFrameAdvanceAndPausing()
return;
}
if (switchToReplay)
{
g_InputRecording.SetToReplayMode();
switchToReplay = false;
}
if (g_InputRecording.IsReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
{
pauseEmulation = true;
@ -148,4 +154,20 @@ void InputRecordingControls::TogglePause()
resumeEmulation = !pauseEmulation;
}
void InputRecordingControls::RecordModeToggle()
{
if (IsRecordingPaused() || g_InputRecording.IsReplaying() || g_InputRecording.GetFrameCounter() < g_InputRecording.GetInputRecordingData().GetTotalFrames())
{
if (g_InputRecording.IsReplaying())
{
g_InputRecording.SetToRecordMode();
}
else if (g_InputRecording.IsRecording())
{
g_InputRecording.SetToReplayMode();
}
}
else if (g_InputRecording.IsRecording())
switchToReplay = true;
}
#endif

View File

@ -51,6 +51,8 @@ public:
void SetFrameCountTracker(u32 newFrame);
// Alternates emulation between a paused and unpaused state
void TogglePause();
// Switches between recording and replaying the active input recording file
void RecordModeToggle();
private:
// Indicates if the input recording controls have explicitly paused emulation or not
@ -66,6 +68,8 @@ private:
bool pauseEmulation = false;
// Indicates if we intend to call CoreThread.Resume() when the next pcsx2 App event is handled
bool resumeEmulation = false;
// Indicates to switch to replay mode after the next vsync
bool switchToReplay = false;
};
extern InputRecordingControls g_InputRecordingControls;

View File

@ -489,7 +489,7 @@ namespace Implementations
{
if (g_Conf->EmuOptions.EnableRecordingTools)
{
g_InputRecording.RecordModeToggle();
g_InputRecordingControls.RecordModeToggle();
}
}