Tidied up TAStudio's "GoToFrame" and fixed a runaway seek in "StartAtNearestFrameAndEmulate"
This commit is contained in:
parent
feb14ad948
commit
d84da62432
|
@ -28,74 +28,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
// SuuperW: I changed this to public so that it could be used by MarkerControl.cs
|
||||
public void GoToFrame(int frame)
|
||||
{
|
||||
// If past greenzone, emulate and capture states
|
||||
// If past greenzone AND movie, record input and capture states
|
||||
// If in greenzone, loadstate
|
||||
// If near a greenzone item, load and emulate
|
||||
// Do capturing and recording as needed
|
||||
// If seeking to a frame before or at the end of the movie, use StartAtNearestFrameAndEmulate
|
||||
// Otherwise, load the latest state (if not already there) and seek while recording.
|
||||
|
||||
if (frame < CurrentTasMovie.InputLogLength)
|
||||
if (frame <= CurrentTasMovie.InputLogLength)
|
||||
{
|
||||
if (frame < Emulator.Frame) // We are rewinding
|
||||
{
|
||||
int goToFrame = frame == 0 ? 0 : frame - 1;
|
||||
|
||||
if (CurrentTasMovie[goToFrame].HasState) // Go back 1 frame and emulate to get the display (we don't store that)
|
||||
{
|
||||
CurrentTasMovie.SwitchToPlay();
|
||||
LoadState(CurrentTasMovie.TasStateManager[goToFrame]); // STATE ACCESS
|
||||
|
||||
if (frame > 0) // We can't emulate up to frame 0!
|
||||
{
|
||||
bool wasPaused = GlobalWin.MainForm.EmulatorPaused;
|
||||
GlobalWin.MainForm.FrameAdvance();
|
||||
if (!wasPaused)
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
}
|
||||
|
||||
GlobalWin.DisplayManager.NeedsToPaint = true;
|
||||
if (TasPlaybackBox.FollowCursor)
|
||||
{
|
||||
SetVisibleIndex(frame);
|
||||
}
|
||||
}
|
||||
else // Get as close as we can then emulate there
|
||||
{
|
||||
StartAtNearestFrameAndEmulate(frame);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // We are going foward
|
||||
{
|
||||
if (frame == Emulator.Frame + 1) // Just emulate a frame we only have 1 to go!
|
||||
{
|
||||
bool wasPaused = GlobalWin.MainForm.EmulatorPaused;
|
||||
GlobalWin.MainForm.FrameAdvance();
|
||||
if (!wasPaused)
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
}
|
||||
else
|
||||
{
|
||||
var goToFrame = frame == 0 ? 0 : frame - 1;
|
||||
if (CurrentTasMovie[goToFrame].HasState) // Can we go directly there?
|
||||
{
|
||||
CurrentTasMovie.SwitchToPlay();
|
||||
LoadState(CurrentTasMovie.TasStateManager[goToFrame]); // STATE ACCESS
|
||||
Emulator.FrameAdvance(true);
|
||||
GlobalWin.DisplayManager.NeedsToPaint = true;
|
||||
|
||||
if (TasPlaybackBox.FollowCursor)
|
||||
{
|
||||
SetVisibleIndex(frame);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StartAtNearestFrameAndEmulate(frame);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get as close as we can then emulate there
|
||||
StartAtNearestFrameAndEmulate(frame);
|
||||
return;
|
||||
}
|
||||
else // Emulate to a future frame
|
||||
{
|
||||
|
@ -108,27 +48,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else
|
||||
{
|
||||
// TODO: get the last greenzone frame and go there
|
||||
CurrentTasMovie.SwitchToPlay();
|
||||
|
||||
// no reason to loadstate when we can emulate a frame instead
|
||||
if (frame - Emulator.Frame != 1)
|
||||
{
|
||||
LoadState(CurrentTasMovie.TasStateManager[CurrentTasMovie.TasStateManager.LastEmulatedFrame]); // STATE ACCESS
|
||||
}
|
||||
int lastState = CurrentTasMovie.TasStateManager.GetStateClosestToFrame(frame).Key; // Simply getting the last state doesn't work if that state is the frame. [dispaly isn't saved in the state, need to emulate to frame]
|
||||
if (lastState > Emulator.Frame)
|
||||
LoadState(CurrentTasMovie.TasStateManager[lastState]); // STATE ACCESS
|
||||
|
||||
if (frame != Emulator.Frame) // If we aren't already at our destination, seek
|
||||
{
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
if (Settings.AutoPause && frame < CurrentTasMovie.InputLogLength)
|
||||
{
|
||||
GlobalWin.MainForm.PauseOnFrame = CurrentTasMovie.InputLogLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
GlobalWin.MainForm.PauseOnFrame = frame;
|
||||
}
|
||||
}
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
GlobalWin.MainForm.PauseOnFrame = frame;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,7 +98,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
GoToFrame(marker.Frame);
|
||||
}
|
||||
|
||||
public void SetVisibleIndex(int? indexThatMustBeVisible = null)
|
||||
public void SetVisibleIndex(int? indexThatMustBeVisible = null)
|
||||
{
|
||||
if (!indexThatMustBeVisible.HasValue)
|
||||
{
|
||||
|
|
|
@ -542,7 +542,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
LoadState(closestState);
|
||||
}
|
||||
|
||||
if (GlobalWin.MainForm.EmulatorPaused || _mouseWheelTimer.Enabled) // make seek frame keep up with emulation on fast scrolls
|
||||
if (GlobalWin.MainForm.EmulatorPaused || GlobalWin.MainForm.IsSeeking || _mouseWheelTimer.Enabled) // make seek frame keep up with emulation on fast scrolls
|
||||
{
|
||||
GlobalWin.MainForm.PauseOnFrame = frame;
|
||||
GlobalWin.MainForm.UnpauseEmulator();
|
||||
|
|
Loading…
Reference in New Issue