Allow rewind during movies.

This commit is contained in:
J.D. Purcell 2017-04-29 11:06:00 -04:00
parent 7f3716a839
commit a72bdfe30f
1 changed files with 32 additions and 10 deletions

View File

@ -2768,7 +2768,8 @@ namespace BizHawk.Client.EmuHawk
runFrame = true; runFrame = true;
} }
bool isRewinding = Rewind(ref runFrame, currentTimestamp); bool returnToRecording;
bool isRewinding = Rewind(ref runFrame, currentTimestamp, out returnToRecording);
float atten = 0; float atten = 0;
@ -2845,6 +2846,16 @@ namespace BizHawk.Client.EmuHawk
Global.MovieSession.HandleMovieAfterFrameLoop(); Global.MovieSession.HandleMovieAfterFrameLoop();
if (returnToRecording)
{
Global.MovieSession.Movie.SwitchToRecord();
}
if (isRewinding && !IsRewindSlave && Global.MovieSession.Movie.IsRecording)
{
Global.MovieSession.Movie.Truncate(Global.Emulator.Frame);
}
Global.CheatList.Pulse(); Global.CheatList.Pulse();
if (!PauseAVI) if (!PauseAVI)
@ -3745,10 +3756,9 @@ namespace BizHawk.Client.EmuHawk
this.master = master; this.master = master;
} }
private bool IsSlave private bool IsSlave => master != null;
{
get { return master != null; } private bool IsRewindSlave => IsSlave && master.WantsToControlRewind;
}
public void TakeBackControl() public void TakeBackControl()
{ {
@ -3795,6 +3805,11 @@ namespace BizHawk.Client.EmuHawk
UpdateToolsLoadstate(); UpdateToolsLoadstate();
Global.AutoFireController.ClearStarts(); Global.AutoFireController.ClearStarts();
if (!IsRewindSlave && Global.MovieSession.Movie.IsActive)
{
ClearRewindData();
}
if (!supressOSD) if (!supressOSD)
{ {
GlobalWin.OSD.AddMessage("Loaded state: " + userFriendlyStateName); GlobalWin.OSD.AddMessage("Loaded state: " + userFriendlyStateName);
@ -4104,7 +4119,7 @@ namespace BizHawk.Client.EmuHawk
private void CaptureRewind(bool suppressCaptureRewind) private void CaptureRewind(bool suppressCaptureRewind)
{ {
if (IsSlave && master.WantsToControlRewind) if (IsRewindSlave)
{ {
master.CaptureRewind(); master.CaptureRewind();
} }
@ -4114,11 +4129,13 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private bool Rewind(ref bool runFrame, long currentTimestamp) private bool Rewind(ref bool runFrame, long currentTimestamp, out bool returnToRecording)
{ {
var isRewinding = false; var isRewinding = false;
if (IsSlave && master.WantsToControlRewind) returnToRecording = false;
if (IsRewindSlave)
{ {
if (Global.ClientControls["Rewind"] || PressRewind) if (Global.ClientControls["Rewind"] || PressRewind)
{ {
@ -4159,8 +4176,7 @@ namespace BizHawk.Client.EmuHawk
return isRewinding; return isRewinding;
} }
if (Global.Rewinder.RewindActive && (Global.ClientControls["Rewind"] || PressRewind) if (Global.Rewinder.RewindActive && (Global.ClientControls["Rewind"] || PressRewind))
&& !Global.MovieSession.Movie.IsRecording) // Rewind isn't "bulletproof" and can desync a recording movie!
{ {
if (EmulatorPaused) if (EmulatorPaused)
{ {
@ -4183,6 +4199,12 @@ namespace BizHawk.Client.EmuHawk
if (isRewinding) if (isRewinding)
{ {
runFrame = Global.Rewinder.Rewind(1); runFrame = Global.Rewinder.Rewind(1);
if (runFrame && Global.MovieSession.Movie.IsRecording)
{
Global.MovieSession.Movie.SwitchToPlay();
returnToRecording = true;
}
} }
} }
else else