input-rec: facilitate changing controls immediately for certain edge-cases

This commit is contained in:
Tyler Wilding 2022-06-15 21:22:06 -04:00 committed by refractionpcsx2
parent a38fbb157d
commit 6ae9e7edb5
5 changed files with 12 additions and 33 deletions

View File

@ -47,7 +47,7 @@ void InputRecordingViewer::loadTable()
m_ui.tableWidget->setHorizontalHeaderLabels(headers);
int frameNum = 0;
for (auto& const frame : data)
for (const auto& frame : data)
{
// TODO - disgusting, clean it up
m_ui.tableWidget->setItem(frameNum, 0, new QTableWidgetItem(tr("%1 %2").arg(frame.leftAnalogX).arg(frame.leftAnalogY)));

View File

@ -701,11 +701,6 @@ u64 InputRecording::getFrameCounter() const
return m_frameCounter;
}
bool InputRecording::isInitialSavestateLoadComplete() const
{
return m_initialSavestateLoadComplete;
}
bool InputRecording::isActive() const
{
return m_isActive;
@ -716,7 +711,7 @@ void InputRecording::handleExceededFrameCounter()
// if we go past the end, switch to recording mode so nothing is lost
if (m_frameCounter >= m_file.getTotalFrames() && m_controls.isReplaying())
{
m_controls.setRecordMode();
m_controls.setRecordMode(false);
}
}
@ -729,15 +724,15 @@ void InputRecording::handleLoadingSavestate()
// Why?
// - When you re-record you load another save-state which has it's own frame counter
// stored within, we use this to adjust the frame we are replaying/recording to
if (isTypeSavestate() && !isInitialSavestateLoadComplete())
if (isTypeSavestate() && !m_initialSavestateLoadComplete)
{
setStartingFrame(g_FrameCount);
setInitialSavestateLoaded();
m_initialSavestateLoadComplete = true;
}
else
{
adjustFrameCounterOnReRecord(g_FrameCount);
watchForRerecords();
m_watchingForRerecords = true;
}
}
@ -756,11 +751,6 @@ void InputRecording::setStartingFrame(u64 startingFrame)
m_startingFrame = startingFrame;
}
void InputRecording::setInitialSavestateLoaded()
{
m_initialSavestateLoadComplete = true;
}
void InputRecording::adjustFrameCounterOnReRecord(u64 newFrameCounter)
{
if (newFrameCounter > m_startingFrame + (u64)m_file.getTotalFrames())
@ -792,11 +782,6 @@ void InputRecording::adjustFrameCounterOnReRecord(u64 newFrameCounter)
m_frameCounter = newFrameCounter - m_startingFrame;
}
void InputRecording::watchForRerecords()
{
m_watchingForRerecords = true;
}
InputRecordingControls& InputRecording::getControls()
{
return m_controls;

View File

@ -169,7 +169,6 @@ public:
void controllerInterrupt(u8& data, u8& port, u16& BufCount, u8 buf[]);
void incFrameCounter();
u64 getFrameCounter() const;
bool isInitialSavestateLoadComplete() const;
bool isActive() const;
// Main handler for ingesting input data and either saving it to the recording file (recording)
@ -178,15 +177,9 @@ public:
void handleExceededFrameCounter();
void handleLoadingSavestate();
bool isTypeSavestate() const;
void setStartingFrame(u64 startingFrame);
void setInitialSavestateLoaded();
void adjustFrameCounterOnReRecord(u64 newFrameCounter);
void watchForRerecords();
InputRecordingControls& getControls();
const InputRecordingFile& getData() const;
@ -211,6 +204,7 @@ private:
u64 m_startingFrame = 0;
void initializeState();
void setStartingFrame(u64 startingFrame);
private:
// Resolve the name and region of the game currently loaded using the GameDB

View File

@ -244,9 +244,9 @@ void InputRecordingControls::toggleRecordMode()
}
}
void InputRecordingControls::setRecordMode()
void InputRecordingControls::setRecordMode(bool waitForFrameToEnd)
{
if (VMManager::GetState() == VMState::Paused)
if (!waitForFrameToEnd || VMManager::GetState() == VMState::Paused)
{
m_state = Mode::Recording;
InputRec::log("Record mode ON");
@ -260,9 +260,9 @@ void InputRecordingControls::setRecordMode()
}
}
void InputRecordingControls::setReplayMode()
void InputRecordingControls::setReplayMode(bool waitForFrameToEnd)
{
if (VMManager::GetState() == VMState::Paused)
if (!waitForFrameToEnd || VMManager::GetState() == VMState::Paused)
{
m_state = Mode::Replaying;
InputRec::log("Replay mode ON");

View File

@ -116,8 +116,8 @@ public:
};
void toggleRecordMode();
void setRecordMode();
void setReplayMode();
void setRecordMode(bool waitForFrameToEnd = true);
void setReplayMode(bool waitForFrameToEnd = true);
bool isRecording() const;
bool isReplaying() const;