tastudio: AutoadjustInput

remove all consecutive was-lag frames in batch like taseditor does. current frame has no lag so they will all have to go anyway

still need to fix wrong pausing
This commit is contained in:
feos 2024-12-04 17:47:55 +03:00
parent cf464d4481
commit 1da3e4d773
4 changed files with 1033 additions and 1011 deletions

File diff suppressed because it is too large Load Diff

View File

@ -70,7 +70,7 @@ namespace BizHawk.Client.EmuHawk
}
var refreshNeeded = false;
if (AutoadjustInputMenuItem.Checked)
if (Settings.AutoadjustInput)
{
refreshNeeded = AutoAdjustInput();
}

View File

@ -768,6 +768,7 @@ namespace BizHawk.Client.EmuHawk
LoadBranchOnDoubleclickMenuItem.Checked = Settings.LoadBranchOnDoubleClick;
BindMarkersToInputMenuItem.Checked = CurrentTasMovie.BindMarkersToInput;
CopyIncludesFrameNoMenuItem.Checked = Settings.CopyIncludesFrameNo;
AutoadjustInputMenuItem.Checked = Settings.AutoadjustInput;
}
private void SetMaxUndoLevelsMenuItem_Click(object sender, EventArgs e)
@ -802,6 +803,9 @@ namespace BizHawk.Client.EmuHawk
private void CopyIncludesFrameNoMenuItem_Click(object sender, EventArgs e)
=> Settings.CopyIncludesFrameNo = !Settings.CopyIncludesFrameNo;
private void AutoadjustInputMenuItem_Click(object sender, EventArgs e)
=> Settings.AutoadjustInput = !Settings.AutoadjustInput;
private void SetAutosaveIntervalMenuItem_Click(object sender, EventArgs e)
{
using var prompt = new InputPrompt

View File

@ -78,6 +78,7 @@ namespace BizHawk.Client.EmuHawk
OldControlSchemeForBranches = false;
LoadBranchOnDoubleClick = true;
CopyIncludesFrameNo = false;
AutoadjustInput = false;
// default to taseditor fashion
DenoteStatesWithIcons = false;
@ -110,8 +111,9 @@ namespace BizHawk.Client.EmuHawk
public int BranchMarkerSplitDistance { get; set; }
public bool BindMarkersToInput { get; set; }
public bool CopyIncludesFrameNo { get; set; }
public bool AutoadjustInput { get; set; }
public TAStudioPalette Palette { get; set; }
public int MaxUndoSteps { get; set; } = 100;
public int MaxUndoSteps { get; set; } = 1000;
}
public TAStudio()
@ -1099,16 +1101,31 @@ namespace BizHawk.Client.EmuHawk
{
if (lagLog.WasLagged.Value && !isLag)
{
// remove all consecutive was-lag frames in batch like taseditor
// current frame has no lag so they will all have to go anyway
var framesToRemove = new List<int>{ Emulator.Frame - 1 };
for (int frame = Emulator.Frame; CurrentTasMovie[frame].WasLagged.HasValue; frame++)
{
if (CurrentTasMovie[frame].WasLagged.Value)
{
framesToRemove.Add(frame);
}
}
// Deleting this frame requires rewinding a frame.
CurrentTasMovie.ChangeLog.AddInputBind(Emulator.Frame - 1, true, $"Bind Input; Delete {Emulator.Frame - 1}");
bool wasRecording = CurrentTasMovie.ChangeLog.IsRecording;
CurrentTasMovie.ChangeLog.IsRecording = false;
CurrentTasMovie.RemoveFrame(Emulator.Frame - 1);
CurrentTasMovie.LagLog.RemoveHistoryAt(Emulator.Frame); // Removes from WasLag
CurrentTasMovie.RemoveFrames(framesToRemove);
foreach (int f in framesToRemove)
{
CurrentTasMovie.LagLog.RemoveHistoryAt(f + 1); // Removes from WasLag
}
CurrentTasMovie.ChangeLog.IsRecording = wasRecording;
GoToFrame(Emulator.Frame - 1);
GoToLastEmulatedFrameIfNecessary(Emulator.Frame - 1);
DoAutoRestore();
return true;
}