Pass test MarkersUnaffectedByMovieExtension

This commit is contained in:
SuuperW 2025-07-04 15:54:16 -05:00
parent 2d0c856341
commit 3871359694
No known key found for this signature in database
2 changed files with 57 additions and 7 deletions

View File

@ -258,19 +258,16 @@ namespace BizHawk.Client.Common
private void ExtendMovieForEdit(int numFrames)
{
int oldLength = InputLogLength;
ChangeLog.AddGeneralUndo(oldLength, oldLength + numFrames - 1);
Session.MovieController.SetFrom(Session.StickySource);
// account for autohold. needs autohold pattern to be already recorded in the current frame
// account for autohold TODO: What about auto-fire?
string inputs = Bk2LogEntryGenerator.GenerateLogEntry(Session.StickySource);
for (int i = 0; i < numFrames; i++)
{
Log.Add(Bk2LogEntryGenerator.GenerateLogEntry(Session.MovieController));
Log.Add(inputs);
}
Changes = true;
ChangeLog.SetGeneralRedo();
ChangeLog.AddExtend(oldLength, numFrames, inputs);
}
public void ToggleBoolState(int frame, string buttonName)

View File

@ -29,6 +29,7 @@ namespace BizHawk.Client.Common
void AddInsertFrames(int frame, int count, string name = "", bool force = false);
void AddInsertInput(int frame, List<string> newInputs, string name = "", bool force = false);
void AddRemoveFrames(int removeStart, int removeUpTo, List<string> oldInputs, List<TasMovieMarker> removedMarkers, string name = "", bool force = false);
void AddExtend(int originalLength, int count, string inputs);
}
public class TasMovieChangeLog : IMovieChangeLog
@ -380,6 +381,15 @@ namespace BizHawk.Client.Common
LatestBatch.Add(new MovieActionRemoveFrames(removeStart, removeUpTo, oldInputs, removedMarkers));
}
}
public void AddExtend(int originalLength, int count, string inputs)
{
if (IsRecording)
{
AddMovieAction("extend movie");
LatestBatch.Add(new MovieActionExtend(originalLength, count, inputs));
}
}
}
public interface IMovieAction
@ -844,4 +854,47 @@ namespace BizHawk.Client.Common
movie.ChangeLog.IsRecording = wasRecording;
}
}
public class MovieActionExtend : IMovieAction
{
public int FirstFrame { get; }
public int LastFrame => FirstFrame + _count - 1;
private int _count;
private string _inputs;
public MovieActionExtend(int currentEndOfMovie, int count, string inputs)
{
FirstFrame = currentEndOfMovie;
_count = count;
_inputs = inputs;
}
public void Undo(ITasMovie movie)
{
bool wasRecording = movie.ChangeLog.IsRecording;
movie.ChangeLog.IsRecording = false;
bool wasMarkerBound = movie.BindMarkersToInput;
movie.BindMarkersToInput = false;
movie.RemoveFrames(FirstFrame, LastFrame + 1);
movie.ChangeLog.IsRecording = wasRecording;
movie.BindMarkersToInput = wasMarkerBound;
}
public void Redo(ITasMovie movie)
{
bool wasRecording = movie.ChangeLog.IsRecording;
movie.ChangeLog.IsRecording = false;
bool wasMarkerBound = movie.BindMarkersToInput;
movie.BindMarkersToInput = false;
movie.InsertInput(FirstFrame, Enumerable.Repeat(_inputs, _count));
movie.ChangeLog.IsRecording = wasRecording;
movie.BindMarkersToInput = wasMarkerBound;
}
}
}