recording: Disable currently active frame advancing when opening a different recording

This commit is contained in:
sonicfind 2020-09-18 10:44:50 -05:00 committed by refractionpcsx2
parent 9936fc7f15
commit 11fe2619eb
4 changed files with 14 additions and 7 deletions

View File

@ -265,6 +265,7 @@ bool InputRecording::Create(wxString FileName, bool fromSaveState, wxString auth
// Write header contents
inputRecordingData.WriteHeader();
state = InputRecordingMode::Recording;
g_InputRecordingControls.DisableFrameAdvance();
recordingConLog(wxString::Format(L"[REC]: Started new recording - [%s]\n", FileName));
return true;
}
@ -309,6 +310,7 @@ bool InputRecording::Play(wxString fileName)
incrementUndo = true;
state = InputRecordingMode::Replaying;
g_InputRecordingControls.DisableFrameAdvance();
recordingConLog(wxString::Format(L"[REC]: Replaying input recording - [%s]\n", inputRecordingData.GetFilename()));
recordingConLog(wxString::Format(L"[REC]: PCSX2 Version Used: %s\n", inputRecordingData.GetHeader().emu));
recordingConLog(wxString::Format(L"[REC]: Recording File Version: %d\n", inputRecordingData.GetHeader().version));

View File

@ -80,13 +80,12 @@ void InputRecordingControls::HandleFrameAdvanceAndPausing()
switchToReplay = false;
}
if (g_InputRecording.IsReplaying()
&& g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
if ((g_InputRecording.IsReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|| g_InputRecording.GetFrameCounter() == INT_MAX)
pauseEmulation = true;
// If we havn't yet advanced atleast a single frame from when we paused, setup things to be paused
if (frameAdvancing
&& (frameAdvanceMarker < g_InputRecording.GetFrameCounter() || g_InputRecording.GetFrameCounter() == INT_MAX))
// If we haven't yet advanced atleast a single frame from when we paused, setup things to be paused
if (frameAdvancing && frameAdvanceMarker < g_InputRecording.GetFrameCounter())
{
frameAdvancing = false;
pauseEmulation = true;
@ -163,6 +162,11 @@ void InputRecordingControls::SetFrameCountTracker(u32 newFrame)
frameCountTracker = newFrame;
}
void InputRecordingControls::DisableFrameAdvance()
{
frameAdvancing = false;
}
void InputRecordingControls::TogglePause()
{
if (pauseEmulation && g_InputRecording.IsReplaying()

View File

@ -49,6 +49,9 @@ public:
// Resume emulation when the next pcsx2 App event is handled
void Resume();
void SetFrameCountTracker(u32 newFrame);
// Sets frameAdvancing variable to false
// Used to restrict a frameAdvaceTravker value from transferring between recordings
void DisableFrameAdvance();
// Alternates emulation between a paused and unpaused state
void TogglePause();
// Switches between recording and replaying the active input recording file

View File

@ -82,8 +82,6 @@ public:
// Writes the current frame's input data to the file so it can be replayed
bool WriteKeyBuffer(const uint &frame, const uint port, const uint bufIndex, const u8 &buf);
unsigned long recordingFrameCounter = 0;
private:
static const int controllerPortsSupported = 2;
static const int controllerInputBytes = 18;