mirror of https://github.com/PCSX2/pcsx2.git
recording: Recording mode-based refactors
* Recording mode enum, NoneActive -> NotActive * Changed IsMode method names and added an IsRecording method. * Add methods designated to setting a recording to a certain mode. Co-authored-by: Tyler Wilding <xtvaser@gmail.com>
This commit is contained in:
parent
74bba35765
commit
0304b124ed
|
@ -39,7 +39,7 @@ void SaveStateBase::InputRecordingFreeze()
|
|||
Freeze(g_FrameCount);
|
||||
|
||||
#ifndef DISABLE_RECORDING
|
||||
if (g_InputRecording.IsRecordingActive())
|
||||
if (g_InputRecording.IsActive())
|
||||
{
|
||||
// Explicitly set the frame change tracking variable as to not
|
||||
// detect loading a savestate as a frame being drawn
|
||||
|
@ -73,7 +73,6 @@ void SaveStateBase::InputRecordingFreeze()
|
|||
g_InputRecording.SetFrameCounter(newFrameCounter);
|
||||
}
|
||||
}
|
||||
|
||||
// Loading a save-state is an asynchronous task, if we are playing a recording
|
||||
// that starts from a savestate (not power-on) and the starting (pcsx2 internal) frame
|
||||
// marker has not been set (which comes from the save-state), we initialize it.
|
||||
|
@ -127,7 +126,7 @@ void InputRecording::ControllerInterrupt(u8 &data, u8 &port, u16 &bufCount, u8 b
|
|||
}
|
||||
|
||||
// We do not want to record or save the first two bytes in the data returned from the PAD plugin
|
||||
if (!fInterruptFrame || state == InputRecordingMode::NoneActive || bufCount < 3)
|
||||
if (!fInterruptFrame || state == InputRecordingMode::NotActive || bufCount < 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -177,9 +176,9 @@ bool InputRecording::IsInterruptFrame()
|
|||
return fInterruptFrame;
|
||||
}
|
||||
|
||||
bool InputRecording::IsRecordingActive()
|
||||
bool InputRecording::IsActive()
|
||||
{
|
||||
return state != InputRecordingMode::NoneActive;
|
||||
return state != InputRecordingMode::NotActive;
|
||||
}
|
||||
|
||||
bool InputRecording::IsSavestateInitializing()
|
||||
|
@ -187,9 +186,14 @@ bool InputRecording::IsSavestateInitializing()
|
|||
return savestateInitializing;
|
||||
}
|
||||
|
||||
bool InputRecording::IsRecordingReplaying()
|
||||
bool InputRecording::IsReplaying()
|
||||
{
|
||||
return IsRecordingActive() && state == InputRecordingMode::Replaying;
|
||||
return state == InputRecordingMode::Replaying;
|
||||
}
|
||||
|
||||
bool InputRecording::IsRecording()
|
||||
{
|
||||
return state == InputRecordingMode::Recording;
|
||||
}
|
||||
|
||||
wxString InputRecording::RecordingModeTitleSegment()
|
||||
|
@ -208,17 +212,27 @@ wxString InputRecording::RecordingModeTitleSegment()
|
|||
}
|
||||
}
|
||||
|
||||
void InputRecording::SetToRecordMode()
|
||||
{
|
||||
state = InputRecordingMode::Recording;
|
||||
recordingConLog("[REC]: Record mode ON.\n");
|
||||
}
|
||||
|
||||
void InputRecording::SetToReplayMode()
|
||||
{
|
||||
state = InputRecordingMode::Replaying;
|
||||
recordingConLog("[REC]: Replay mode ON.\n");
|
||||
}
|
||||
|
||||
void InputRecording::RecordModeToggle()
|
||||
{
|
||||
if (state == InputRecordingMode::Replaying)
|
||||
{
|
||||
state = InputRecordingMode::Recording;
|
||||
recordingConLog("[REC]: Record mode ON.\n");
|
||||
SetToRecordMode();
|
||||
}
|
||||
else if (state == InputRecordingMode::Recording)
|
||||
{
|
||||
state = InputRecordingMode::Replaying;
|
||||
recordingConLog("[REC]: Replay mode ON.\n");
|
||||
SetToReplayMode();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +261,7 @@ void InputRecording::Stop()
|
|||
frameCounter = 0;
|
||||
startingFrame = 0;
|
||||
savestateInitializing = false;
|
||||
state = InputRecordingMode::NoneActive;
|
||||
state = InputRecordingMode::NotActive;
|
||||
if (inputRecordingData.Close())
|
||||
{
|
||||
recordingConLog(L"[REC]: InputRecording Recording Stopped.\n");
|
||||
|
@ -281,7 +295,7 @@ bool InputRecording::Create(wxString FileName, bool fromSaveState, wxString auth
|
|||
|
||||
bool InputRecording::Play(wxString fileName)
|
||||
{
|
||||
if (IsRecordingActive())
|
||||
if (IsActive())
|
||||
Stop();
|
||||
|
||||
if (!inputRecordingData.OpenExisting(fileName))
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
bool IsInterruptFrame();
|
||||
|
||||
// If there is currently an input recording being played back or actively being recorded
|
||||
bool IsRecordingActive();
|
||||
bool IsActive();
|
||||
|
||||
// Whether or not the recording's initial save state has yet to be loaded or saved and
|
||||
// the rest of the recording can be initialized
|
||||
|
@ -49,11 +49,20 @@ public:
|
|||
bool IsSavestateInitializing();
|
||||
|
||||
// If there is currently an input recording being played back
|
||||
bool IsRecordingReplaying();
|
||||
bool IsReplaying();
|
||||
|
||||
// If there are inputs currently being recorded to a file
|
||||
bool IsRecording();
|
||||
|
||||
// String representation of the current recording mode to be interpolated into the title
|
||||
wxString RecordingModeTitleSegment();
|
||||
|
||||
// Sets input recording to Record Mode
|
||||
void SetToRecordMode();
|
||||
|
||||
// Sets input recording to Replay Mode
|
||||
void SetToReplayMode();
|
||||
|
||||
// Switches between recording and replaying the active input recording file
|
||||
void RecordModeToggle();
|
||||
|
||||
|
@ -78,7 +87,7 @@ public:
|
|||
private:
|
||||
enum class InputRecordingMode
|
||||
{
|
||||
NoneActive,
|
||||
NotActive,
|
||||
Recording,
|
||||
Replaying,
|
||||
};
|
||||
|
@ -88,8 +97,9 @@ private:
|
|||
InputRecordingFile inputRecordingData;
|
||||
bool savestateInitializing = false;
|
||||
u32 startingFrame = 0;
|
||||
InputRecordingMode state = InputRecording::InputRecordingMode::NoneActive;
|
||||
u32 frameCounter = 0;
|
||||
InputRecordingMode state = InputRecording::InputRecordingMode::NotActive;
|
||||
|
||||
|
||||
// Resolve the name and region of the game currently loaded using the GameDB
|
||||
// If the game cannot be found in the DB, the fallback is the ISO filename
|
||||
|
|
|
@ -54,7 +54,7 @@ void InputRecordingControls::HandleFrameAdvanceAndPausing()
|
|||
return;
|
||||
}
|
||||
|
||||
if (g_InputRecording.IsRecordingReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|
||||
if (g_InputRecording.IsReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|
||||
{
|
||||
pauseEmulation = true;
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ void InputRecordingControls::ResumeCoreThreadIfStarted()
|
|||
|
||||
void InputRecordingControls::FrameAdvance()
|
||||
{
|
||||
if (g_InputRecording.IsRecordingReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|
||||
if (g_InputRecording.IsReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|
||||
{
|
||||
g_InputRecording.RecordModeToggle();
|
||||
g_InputRecording.SetToRecordMode();
|
||||
return;
|
||||
}
|
||||
frameAdvanceMarker = g_InputRecording.GetFrameCounter();
|
||||
|
@ -123,9 +123,9 @@ void InputRecordingControls::PauseImmediately()
|
|||
|
||||
void InputRecordingControls::Resume()
|
||||
{
|
||||
if (g_InputRecording.IsRecordingReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|
||||
if (g_InputRecording.IsReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|
||||
{
|
||||
g_InputRecording.RecordModeToggle();
|
||||
g_InputRecording.SetToRecordMode();
|
||||
return;
|
||||
}
|
||||
pauseEmulation = false;
|
||||
|
@ -139,9 +139,9 @@ void InputRecordingControls::SetFrameCountTracker(u32 newFrame)
|
|||
|
||||
void InputRecordingControls::TogglePause()
|
||||
{
|
||||
if (pauseEmulation && g_InputRecording.IsRecordingReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|
||||
if (pauseEmulation && g_InputRecording.IsReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames())
|
||||
{
|
||||
g_InputRecording.RecordModeToggle();
|
||||
g_InputRecording.SetToRecordMode();
|
||||
return;
|
||||
}
|
||||
pauseEmulation = !pauseEmulation;
|
||||
|
|
|
@ -1059,7 +1059,7 @@ void Pcsx2App::OnProgramLogClosed( wxWindowID id )
|
|||
void Pcsx2App::OnMainFrameClosed( wxWindowID id )
|
||||
{
|
||||
#ifndef DISABLE_RECORDING
|
||||
if (g_InputRecording.IsRecordingActive())
|
||||
if (g_InputRecording.IsActive())
|
||||
{
|
||||
g_InputRecording.Stop();
|
||||
}
|
||||
|
|
|
@ -732,7 +732,7 @@ void GSFrame::OnUpdateTitle( wxTimerEvent& evt )
|
|||
#ifndef DISABLE_RECORDING
|
||||
wxString title;
|
||||
wxString movieMode;
|
||||
if (g_InputRecording.IsRecordingActive())
|
||||
if (g_InputRecording.IsActive())
|
||||
{
|
||||
title = templates.RecordingTemplate;
|
||||
title.Replace(L"${frame}", pxsFmt(L"%d", g_InputRecording.GetFrameCounter()));
|
||||
|
|
|
@ -529,7 +529,7 @@ void MainEmuFrame::Menu_EnableRecordingTools_Click(wxCommandEvent& event)
|
|||
else
|
||||
{
|
||||
//Properly close any currently loaded recording file before disabling
|
||||
if (g_InputRecording.IsRecordingActive())
|
||||
if (g_InputRecording.IsActive())
|
||||
Menu_Recording_Stop_Click(event);
|
||||
GetMenuBar()->Remove(TopLevelMenu_InputRecording);
|
||||
// Always turn controller logs off, but never turn it on by default
|
||||
|
@ -912,7 +912,7 @@ void MainEmuFrame::Menu_Recording_Play_Click(wxCommandEvent &event)
|
|||
}
|
||||
|
||||
wxString path = openFileDialog.GetPath();
|
||||
const bool recordingLoaded = g_InputRecording.IsRecordingActive();
|
||||
const bool recordingLoaded = g_InputRecording.IsActive();
|
||||
if (!g_InputRecording.Play(path))
|
||||
{
|
||||
if (recordingLoaded)
|
||||
|
|
Loading…
Reference in New Issue