TAStudio - Rewind button - fix logic when movie is finished or inactive
This commit is contained in:
parent
644caa4786
commit
7bc1e88d1d
|
@ -164,11 +164,17 @@ namespace BizHawk.MultiClient
|
|||
for (int i = 0; i < frames; i++)
|
||||
{
|
||||
if (RewindBuf.Count == 0 || (true == Global.MovieSession.Movie.Loaded && 0 == Global.MovieSession.Movie.LogLength()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (LastState.Length < 0x10000)
|
||||
{
|
||||
Rewind64K();
|
||||
}
|
||||
else
|
||||
{
|
||||
RewindLarge();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,10 @@ namespace BizHawk.MultiClient
|
|||
|
||||
public void RewindToFrame(int frame)
|
||||
{
|
||||
if (Mode == MOVIEMODE.INACTIVE || Mode == MOVIEMODE.FINISHED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (frame <= Global.Emulator.Frame)
|
||||
{
|
||||
if (frame <= Log.StateFirstIndex())
|
||||
|
@ -126,15 +130,18 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
else
|
||||
{
|
||||
if (0 == frame)
|
||||
if (frame == 0)
|
||||
{
|
||||
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Log.GetInitState())));
|
||||
}
|
||||
else
|
||||
{
|
||||
//frame-1 because we need to go back an extra frame and then run a frame, otherwise the display doesn't get updated.
|
||||
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Log.GetState(frame - 1))));
|
||||
Global.MainForm.UpdateFrame = true;
|
||||
if (frame - 1 < Log.StateCount)
|
||||
{
|
||||
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Log.GetState(frame - 1))));
|
||||
Global.MainForm.UpdateFrame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace BizHawk.MultiClient
|
|||
private byte[] InitState;
|
||||
//TODO: Make this size limit configurable by the user
|
||||
private int MaxStateRecordSize = 1024 * 1024 * 1024; //To limit memory usage.
|
||||
public int StateCount { get { return StateRecords.Count; } }
|
||||
|
||||
public MovieLog()
|
||||
{
|
||||
|
|
|
@ -357,7 +357,18 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void RewindButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.MovieSession.Movie.RewindToFrame(Global.Emulator.Frame - 1);
|
||||
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED || Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE)
|
||||
{
|
||||
Global.MainForm.Rewind(1);
|
||||
if (Global.Emulator.Frame <= Global.MovieSession.Movie.LogLength())
|
||||
{
|
||||
Global.MovieSession.Movie.StartPlayback();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Global.MovieSession.Movie.RewindToFrame(Global.Emulator.Frame - 1);
|
||||
}
|
||||
UpdateValues();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue