@@ -41,7 +41,7 @@ public interface IMovieChangeLog
41
41
int MaxSteps { get ; set ; }
42
42
43
43
void AddGeneralUndo ( int first , int last , string name = "" ) ;
44
- void SetGeneralRedo ( ) ;
44
+ int SetGeneralRedo ( ) ;
45
45
void AddBoolToggle ( int frame , string button , bool oldState , string name = "" ) ;
46
46
void AddAxisChange ( int frame , string button , int oldState , int newState , string name = "" ) ;
47
47
void AddMarkerChange ( TasMovieMarker newMarker , int oldPosition = - 1 , string oldMessage = "" , string name = "" ) ;
@@ -263,13 +263,25 @@ public void AddGeneralUndo(int first, int last, string name = "")
263
263
}
264
264
}
265
265
266
- public void SetGeneralRedo ( )
266
+ public int SetGeneralRedo ( )
267
267
{
268
268
if ( IsRecording )
269
269
{
270
270
Debug . Assert ( _lastGeneral == LatestBatch . Count - 1 , "GeneralRedo should not see changes from other undo actions." ) ;
271
- ( ( MovieAction ) LatestBatch [ _lastGeneral ] ) . SetRedoLog ( _movie ) ;
271
+ int changed = ( ( MovieAction ) LatestBatch [ _lastGeneral ] ) . SetRedoLog ( _movie ) ;
272
+ if ( changed == - 1 )
273
+ {
274
+ LatestBatch . RemoveAt ( _lastGeneral ) ;
275
+ if ( LatestBatch . Count == 0 && ! _recordingBatch )
276
+ {
277
+ // Remove this undo item
278
+ _recordingBatch = true ;
279
+ EndBatch ( ) ;
280
+ }
281
+ }
282
+ return changed ;
272
283
}
284
+ return - 1 ;
273
285
}
274
286
275
287
public void AddBoolToggle ( int frame , string button , bool oldState , string name = "" )
@@ -387,14 +399,21 @@ public MovieAction(int firstFrame, int lastFrame, ITasMovie movie)
387
399
_bindMarkers = movie . BindMarkersToInput ;
388
400
}
389
401
390
- public void SetRedoLog ( ITasMovie movie )
402
+ /// <returns>Returns the first frame that has changed, or -1 if no changes.</returns>
403
+ public int SetRedoLog ( ITasMovie movie )
391
404
{
392
405
_redoLength = Math . Min ( LastFrame + 1 , movie . InputLogLength ) - FirstFrame ;
393
406
_newLog = new List < string > ( _redoLength ) ;
407
+ int changed = Math . Min ( _redoLength , _undoLength ) ;
394
408
for ( int i = 0 ; i < _redoLength ; i ++ )
395
409
{
396
- _newLog . Add ( movie . GetInputLogEntry ( FirstFrame + i ) ) ;
410
+ string newEntry = movie . GetInputLogEntry ( FirstFrame + i ) ;
411
+ _newLog . Add ( newEntry ) ;
412
+ if ( i < changed && newEntry != _oldLog [ i ] ) changed = i ;
397
413
}
414
+
415
+ if ( changed == _redoLength && changed == _undoLength ) return - 1 ;
416
+ else return changed + FirstFrame ;
398
417
}
399
418
400
419
public void Undo ( ITasMovie movie )
0 commit comments