slight tastudio tweaks wrt 12830bab4e
This commit is contained in:
parent
1ebc006873
commit
ba8656e345
|
@ -196,7 +196,7 @@ namespace BizHawk.Client.Common
|
||||||
LagLog[Emulator.Frame] = _inputPollable.IsLagFrame;
|
LagLog[Emulator.Frame] = _inputPollable.IsLagFrame;
|
||||||
|
|
||||||
// We will forbibly capture a state for the last edited frame (requested by #916 for case of "platforms with analog stick")
|
// We will forbibly capture a state for the last edited frame (requested by #916 for case of "platforms with analog stick")
|
||||||
TasStateManager.Capture(Emulator.Frame, Emulator.AsStatable(), !Emulator.AsStatable().AvoidRewind && Emulator.Frame == LastEditedFrame - 1);
|
TasStateManager.Capture(Emulator.Frame, Emulator.AsStatable(), Emulator.Frame == LastEditedFrame - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -327,6 +327,12 @@ namespace BizHawk.Client.Common
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// avoid capturing in this case
|
||||||
|
if (source.AvoidRewind)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// We use the gap buffer for forced capture to avoid crowding the "current" buffer and thus reducing it's actual span of covered frames.
|
// We use the gap buffer for forced capture to avoid crowding the "current" buffer and thus reducing it's actual span of covered frames.
|
||||||
if (NeedsGap(frame) || force)
|
if (NeedsGap(frame) || force)
|
||||||
{
|
{
|
||||||
|
@ -334,12 +340,6 @@ namespace BizHawk.Client.Common
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// avoid capturing in this case
|
|
||||||
if (source.AvoidRewind)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_current.Capture(frame,
|
_current.Capture(frame,
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,6 +152,24 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used to capture a reserved state immediately on branch creation
|
||||||
|
// while also not doing a double state
|
||||||
|
private class BufferedStatable : IStatable
|
||||||
|
{
|
||||||
|
private readonly byte[] _bufferedState;
|
||||||
|
|
||||||
|
public BufferedStatable(byte[] state)
|
||||||
|
=> _bufferedState = state;
|
||||||
|
|
||||||
|
public bool AvoidRewind => true;
|
||||||
|
|
||||||
|
public void SaveStateBinary(BinaryWriter writer)
|
||||||
|
=> writer.Write(_bufferedState);
|
||||||
|
|
||||||
|
public void LoadStateBinary(BinaryReader reader)
|
||||||
|
=> throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a new branch.
|
/// Add a new branch.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -163,6 +181,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
BranchView.RowCount = Branches.Count;
|
BranchView.RowCount = Branches.Count;
|
||||||
Branches.Current = Branches.Count - 1;
|
Branches.Current = Branches.Count - 1;
|
||||||
Movie.TasSession.UpdateValues(Tastudio.Emulator.Frame, Branches.Current);
|
Movie.TasSession.UpdateValues(Tastudio.Emulator.Frame, Branches.Current);
|
||||||
|
Movie.TasStateManager.Capture(Tastudio.Emulator.Frame, new BufferedStatable(branch.CoreData));
|
||||||
BranchView.ScrollToIndex(Branches.Current);
|
BranchView.ScrollToIndex(Branches.Current);
|
||||||
BranchView.DeselectAll();
|
BranchView.DeselectAll();
|
||||||
Select(Branches.Current, true);
|
Select(Branches.Current, true);
|
||||||
|
@ -174,36 +193,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public TasBranch SelectedBranch
|
public TasBranch SelectedBranch
|
||||||
=> BranchView.AnyRowsSelected ? Branches[BranchView.FirstSelectedRowIndex] : null;
|
=> BranchView.AnyRowsSelected ? Branches[BranchView.FirstSelectedRowIndex] : null;
|
||||||
|
|
||||||
// to avoid a double (potentially slow) state
|
|
||||||
private class BufferedStatable : IStatable
|
|
||||||
{
|
|
||||||
private readonly Lazy<byte[]> _bufferedState;
|
|
||||||
public byte[] BufferedState => _bufferedState.Value;
|
|
||||||
|
|
||||||
public BufferedStatable(IStatable statable)
|
|
||||||
{
|
|
||||||
_bufferedState = new(statable.CloneSavestate);
|
|
||||||
AvoidRewind = statable.AvoidRewind;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AvoidRewind { get; }
|
|
||||||
|
|
||||||
public void SaveStateBinary(BinaryWriter writer)
|
|
||||||
=> writer.Write(BufferedState);
|
|
||||||
|
|
||||||
public void LoadStateBinary(BinaryReader reader)
|
|
||||||
=> throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private TasBranch CreateBranch()
|
private TasBranch CreateBranch()
|
||||||
{
|
{
|
||||||
var bufferedStatable = new BufferedStatable(Tastudio.Emulator.AsStatable());
|
|
||||||
Movie.TasStateManager.Capture(Tastudio.Emulator.Frame, bufferedStatable, bufferedStatable.AvoidRewind);
|
|
||||||
|
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
Frame = Tastudio.Emulator.Frame,
|
Frame = Tastudio.Emulator.Frame,
|
||||||
CoreData = bufferedStatable.BufferedState,
|
CoreData = Tastudio.Emulator.AsStatable().CloneSavestate(),
|
||||||
InputLog = Movie.GetLogEntries().Clone(),
|
InputLog = Movie.GetLogEntries().Clone(),
|
||||||
CoreFrameBuffer = MainForm.MakeScreenshotImage(),
|
CoreFrameBuffer = MainForm.MakeScreenshotImage(),
|
||||||
OSDFrameBuffer = MainForm.CaptureOSD(),
|
OSDFrameBuffer = MainForm.CaptureOSD(),
|
||||||
|
@ -224,7 +219,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
Movie.LoadBranch(branch);
|
Movie.LoadBranch(branch);
|
||||||
Tastudio.LoadState(new(branch.Frame, new MemoryStream(branch.CoreData, false)));
|
Tastudio.LoadState(new(branch.Frame, new MemoryStream(branch.CoreData, false)));
|
||||||
Movie.TasStateManager.Capture(Tastudio.Emulator.Frame, Tastudio.Emulator.AsStatable(), Tastudio.Emulator.AsStatable().AvoidRewind);
|
Movie.TasStateManager.Capture(Tastudio.Emulator.Frame, Tastudio.Emulator.AsStatable());
|
||||||
Tastudio.MainForm.QuickBmpFile.Copy(new BitmapBufferVideoProvider(branch.CoreFrameBuffer), Tastudio.VideoProvider);
|
Tastudio.MainForm.QuickBmpFile.Copy(new BitmapBufferVideoProvider(branch.CoreFrameBuffer), Tastudio.VideoProvider);
|
||||||
|
|
||||||
if (Tastudio.Settings.OldControlSchemeForBranches && Tastudio.TasPlaybackBox.RecordingMode)
|
if (Tastudio.Settings.OldControlSchemeForBranches && Tastudio.TasPlaybackBox.RecordingMode)
|
||||||
|
@ -312,7 +307,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_branchUndo = BranchUndo.Update;
|
_branchUndo = BranchUndo.Update;
|
||||||
|
|
||||||
BranchView.ScrollToIndex(Branches.Current);
|
BranchView.ScrollToIndex(Branches.Current);
|
||||||
Branches.Replace(SelectedBranch, CreateBranch());
|
var branch = CreateBranch();
|
||||||
|
Branches.Replace(SelectedBranch, branch);
|
||||||
|
Movie.TasStateManager.Capture(Tastudio.Emulator.Frame, new BufferedStatable(branch.CoreData));
|
||||||
Tastudio.RefreshDialog();
|
Tastudio.RefreshDialog();
|
||||||
SavedCallback?.Invoke(Branches.Current);
|
SavedCallback?.Invoke(Branches.Current);
|
||||||
Tastudio.MainForm.AddOnScreenMessage($"Saved branch {Branches.Current + 1}");
|
Tastudio.MainForm.AddOnScreenMessage($"Saved branch {Branches.Current + 1}");
|
||||||
|
|
Loading…
Reference in New Issue