tastudio: some dirty fixes to how undo/redo works with recording frames
This commit is contained in:
parent
ccc2ee1ba9
commit
215f9b9959
|
@ -152,7 +152,7 @@ namespace BizHawk.Client.Common
|
|||
ChangeLog.EndBatch();
|
||||
}
|
||||
}
|
||||
public void RemoveFrames(int removeStart, int removeUpTo)
|
||||
public void RemoveFrames(int removeStart, int removeUpTo, bool fromHistory = false)
|
||||
{
|
||||
bool endBatch = ChangeLog.BeginNewBatch("Remove Frames: " + removeStart + "-" + removeUpTo, true);
|
||||
ChangeLog.AddGeneralUndo(removeStart, InputLogLength - 1);
|
||||
|
@ -173,7 +173,7 @@ namespace BizHawk.Client.Common
|
|||
if (m.Frame < removeUpTo)
|
||||
Markers.Remove(m);
|
||||
else
|
||||
Markers.Move(m.Frame, m.Frame - (removeUpTo - removeStart));
|
||||
Markers.Move(m.Frame, m.Frame - (removeUpTo - removeStart), fromHistory);
|
||||
}
|
||||
}
|
||||
ChangeLog.IsRecording = wasRecording;
|
||||
|
@ -281,7 +281,7 @@ namespace BizHawk.Client.Common
|
|||
ChangeLog.SetGeneralRedo();
|
||||
}
|
||||
|
||||
public void InsertEmptyFrame(int frame, int count = 1)
|
||||
public void InsertEmptyFrame(int frame, int count = 1, bool fromHistory = false)
|
||||
{
|
||||
bool endBatch = ChangeLog.BeginNewBatch("Insert Empty Frame: " + frame, true);
|
||||
ChangeLog.AddGeneralUndo(frame, InputLogLength + count - 1);
|
||||
|
@ -289,6 +289,9 @@ namespace BizHawk.Client.Common
|
|||
var lg = LogGeneratorInstance();
|
||||
lg.SetSource(Global.MovieSession.MovieControllerInstance());
|
||||
|
||||
if (frame > _log.Count())
|
||||
frame = _log.Count();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
_log.Insert(frame, lg.EmptyEntry);
|
||||
|
||||
|
@ -302,7 +305,7 @@ namespace BizHawk.Client.Common
|
|||
for (int i = firstIndex; i < Markers.Count; i++)
|
||||
{
|
||||
TasMovieMarker m = Markers.ElementAt(i);
|
||||
Markers.Move(m.Frame, m.Frame + count);
|
||||
Markers.Move(m.Frame, m.Frame + count, fromHistory);
|
||||
}
|
||||
}
|
||||
ChangeLog.IsRecording = wasRecording;
|
||||
|
|
|
@ -174,7 +174,7 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
get
|
||||
{
|
||||
if (Names.Count == 0)
|
||||
if (Names.Count == 0 || UndoIndex < 0)
|
||||
return null;
|
||||
else
|
||||
return Names[UndoIndex];
|
||||
|
@ -332,7 +332,15 @@ namespace BizHawk.Client.Common
|
|||
LastFrame = lastFrame;
|
||||
oldLog = new List<string>(length);
|
||||
|
||||
undoLength = Math.Min(lastFrame + 1, movie.InputLogLength) - firstFrame;
|
||||
var minuend = Math.Min(lastFrame + 1, movie.InputLogLength);
|
||||
if (firstFrame > minuend)
|
||||
undoLength = minuend;
|
||||
else
|
||||
undoLength = minuend - firstFrame;
|
||||
|
||||
if (FirstFrame > oldLog.Count())
|
||||
FirstFrame = oldLog.Count();
|
||||
|
||||
for (int i = 0; i < undoLength; i++)
|
||||
oldLog.Add(movie.GetLogEntries()[FirstFrame + i]);
|
||||
|
||||
|
@ -354,9 +362,9 @@ namespace BizHawk.Client.Common
|
|||
movie.BindMarkersToInput = bindMarkers;
|
||||
|
||||
if (redoLength != length)
|
||||
movie.InsertEmptyFrame(FirstFrame, length - redoLength);
|
||||
movie.InsertEmptyFrame(FirstFrame, length - redoLength, true);
|
||||
if (undoLength != length)
|
||||
movie.RemoveFrames(FirstFrame, movie.InputLogLength - undoLength);
|
||||
movie.RemoveFrames(FirstFrame, movie.InputLogLength - undoLength, true);
|
||||
|
||||
for (int i = 0; i < undoLength; i++)
|
||||
movie.SetFrame(FirstFrame + i, oldLog[i]);
|
||||
|
|
|
@ -219,6 +219,8 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void Move(int fromFrame, int toFrame, bool fromHistory = false)
|
||||
{
|
||||
if (fromFrame == 0) // no thanks!
|
||||
return;
|
||||
TasMovieMarker m = Get(fromFrame);
|
||||
if (m == null) // TODO: Don't do this.
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue