lua - implement tastudio.submitclearframes(), fixes #2170

This commit is contained in:
adelikat 2020-07-11 12:19:27 -05:00
parent 4639c1f2ca
commit 9820fb0879
2 changed files with 43 additions and 3 deletions

View File

@ -41,7 +41,8 @@ namespace BizHawk.Client.EmuHawk
{ {
InputChange, InputChange,
InsertFrames, InsertFrames,
DeleteFrames DeleteFrames,
ClearFrames
} }
private enum InputChangeTypes private enum InputChangeTypes
@ -267,6 +268,21 @@ namespace BizHawk.Client.EmuHawk
} }
} }
[LuaMethodExample("")]
[LuaMethod("submitclearframes", "")]
public void SubmitClearFrames(int frame, int number)
{
if (Engaged() && 0.RangeToExclusive(Tastudio.CurrentTasMovie.InputLogLength).Contains(frame) && number > 0)
{
_changeList.Add(new PendingChanges
{
Type = LuaChangeTypes.ClearFrames,
Frame = frame,
Number = number
});
}
}
[LuaMethodExample("")] [LuaMethodExample("")]
[LuaMethod("applyinputchanges", "")] [LuaMethod("applyinputchanges", "")]
public void ApplyInputChanges() public void ApplyInputChanges()
@ -298,6 +314,9 @@ namespace BizHawk.Client.EmuHawk
case LuaChangeTypes.DeleteFrames: case LuaChangeTypes.DeleteFrames:
Tastudio.DeleteFrames(_changeList[i].Frame, _changeList[i].Number); Tastudio.DeleteFrames(_changeList[i].Frame, _changeList[i].Number);
break; break;
case LuaChangeTypes.ClearFrames:
Tastudio.ClearFrames(_changeList[i].Frame, _changeList[i].Number);
break;
} }
} }
_changeList.Clear(); _changeList.Clear();
@ -305,8 +324,6 @@ namespace BizHawk.Client.EmuHawk
Tastudio.JumpToGreenzone(); Tastudio.JumpToGreenzone();
Tastudio.DoAutoRestore(); Tastudio.DoAutoRestore();
} }
} }
} }

View File

@ -1106,6 +1106,29 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void ClearFrames(int beginningFrame, int numberOfFrames)
{
if (beginningFrame < CurrentTasMovie.InputLogLength)
{
bool needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
int last = Math.Min(beginningFrame + numberOfFrames, CurrentTasMovie.InputLogLength);
for (int i = beginningFrame; i < last; i++)
{
CurrentTasMovie.ClearFrame(i);
}
if (needsToRollback)
{
GoToLastEmulatedFrameIfNecessary(beginningFrame);
DoAutoRestore();
}
else
{
RefreshDialog();
}
}
}
private void Tastudio_Closing(object sender, FormClosingEventArgs e) private void Tastudio_Closing(object sender, FormClosingEventArgs e)
{ {
if (!_initialized) if (!_initialized)