diff --git a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs index 7d548db40a..bf7d386fed 100644 --- a/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs +++ b/BizHawk.Client.Common/movie/tasproj/TasMovie.Editing.cs @@ -304,8 +304,9 @@ namespace BizHawk.Client.Common InsertInput(frame, inputLog); // Sets the ChangeLog } - public void CopyOverInput(int frame, IEnumerable inputStates) + public int CopyOverInput(int frame, IEnumerable 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) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 506667fcc0..9c34140b45 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -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;