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