paste - only invalidate on the first different frame pasted, rather than the first selected frame

This commit is contained in:
adelikat 2019-11-24 19:14:49 -06:00
parent cb912bea58
commit 6eef264f91
2 changed files with 16 additions and 11 deletions

View File

@ -304,8 +304,9 @@ namespace BizHawk.Client.Common
InsertInput(frame, inputLog); // Sets the ChangeLog
}
public void CopyOverInput(int frame, IEnumerable<IController> inputStates)
public int CopyOverInput(int frame, IEnumerable<IController> inputStates)
{
int firstChangedFrame = -1;
ChangeLog.BeginNewBatch($"Copy Over Input: {frame}");
var lg = LogGeneratorInstance();
var states = inputStates.ToList();
@ -315,7 +316,7 @@ namespace BizHawk.Client.Common
ExtendMovieForEdit(states.Count + frame - Log.Count);
}
ChangeLog.AddGeneralUndo(frame, frame + inputStates.Count() - 1, $"Copy Over Input: {frame}");
ChangeLog.AddGeneralUndo(frame, frame + states.Count - 1, $"Copy Over Input: {frame}");
for (int i = 0; i < states.Count; i++)
{
@ -325,7 +326,13 @@ namespace BizHawk.Client.Common
}
lg.SetSource(states[i]);
Log[frame + i] = lg.GenerateLogEntry();
var entry = lg.GenerateLogEntry();
if (Log[frame + i] != entry)
{
firstChangedFrame = frame + i;
}
Log[frame + i] = entry;
}
ChangeLog.EndBatch();
@ -333,6 +340,7 @@ namespace BizHawk.Client.Common
InvalidateAfter(frame);
ChangeLog.SetGeneralRedo();
return firstChangedFrame;
}
public void InsertEmptyFrame(int frame, int count = 1, bool fromHistory = false)

View File

@ -522,11 +522,10 @@ namespace BizHawk.Client.EmuHawk
_tasClipboard.Add(new TasClipboardEntry(i, line));
}
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
CurrentTasMovie.CopyOverInput(TasView.FirstSelectedIndex ?? 0, _tasClipboard.Select(x => x.ControllerState));
if (needsToRollback)
var rollbackFrame = CurrentTasMovie.CopyOverInput(TasView.FirstSelectedIndex ?? 0, _tasClipboard.Select(x => x.ControllerState));
if (rollbackFrame > 0)
{
GoToLastEmulatedFrameIfNecessary(TasView.FirstSelectedIndex.Value);
GoToLastEmulatedFrameIfNecessary(rollbackFrame);
DoAutoRestore();
}
else
@ -561,10 +560,8 @@ namespace BizHawk.Client.EmuHawk
{
return;
}
else
{
_tasClipboard.Add(new TasClipboardEntry(i, line));
}
_tasClipboard.Add(new TasClipboardEntry(i, line));
}
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;