@@ -390,18 +390,69 @@ private void TasView_ColumnClick(object sender, InputRoll.ColumnClickEventArgs e
390
390
if ( ModifierKeys != Keys . Alt )
391
391
{
392
392
// nifty taseditor logic
393
+ // your TAS Editor logic failed us (it didn't account for non-contiguous `SelectedRows`) --yoshi
393
394
var selection = TasView . SelectedRows . ToArray ( ) ; // sorted asc, length >= 1
394
395
bool allPressed = true ;
395
- foreach ( var index in selection )
396
+ var contiguous = true ;
397
+ var iSelection = 0 ;
398
+ var lastFrameIndexSeen = selection [ iSelection ] - 1 ;
399
+ while ( iSelection < selection . Length )
396
400
{
401
+ var index = selection [ iSelection ] ;
402
+ if ( index - lastFrameIndexSeen is not 1 )
403
+ {
404
+ contiguous = false ;
405
+ break ;
406
+ }
407
+ lastFrameIndexSeen = index ;
397
408
if ( index == CurrentTasMovie . FrameCount // last movie frame can't have input, but can be selected
398
409
|| ! CurrentTasMovie . BoolIsPressed ( index , buttonName ) )
399
410
{
400
411
allPressed = false ;
401
412
break ;
402
413
}
414
+ iSelection ++ ;
415
+ }
416
+ if ( ! allPressed )
417
+ {
418
+ // still need to check for discontinuity
419
+ while ( iSelection < selection . Length )
420
+ {
421
+ var index = selection [ iSelection ] ;
422
+ if ( index - lastFrameIndexSeen is not 1 )
423
+ {
424
+ contiguous = false ;
425
+ break ;
426
+ }
427
+ lastFrameIndexSeen = index ;
428
+ iSelection ++ ;
429
+ }
430
+ }
431
+ else if ( ! contiguous )
432
+ {
433
+ // still need to check for `false` values
434
+ allPressed = allPressed && selection . Skip ( iSelection - 1 ) // break'd before checking the next one, so less 1 (and can't get here if `iSelection` is 0 so that's safe)
435
+ . All ( index => index < CurrentTasMovie . FrameCount // last movie frame can't have input, but can be selected
436
+ && CurrentTasMovie . BoolIsPressed ( index , buttonName ) ) ;
437
+ }
438
+ // else all contiguous and all `true`
439
+
440
+ CurrentTasMovie . SetBoolStates ( frame : selection [ 0 ] , count : iSelection , buttonName , val : ! allPressed ) ;
441
+ var blockStart = iSelection ;
442
+ lastFrameIndexSeen = selection [ iSelection ] - 1 ;
443
+ while ( iSelection < selection . Length )
444
+ {
445
+ var index = selection [ iSelection ] ;
446
+ if ( index - lastFrameIndexSeen is not 1 )
447
+ {
448
+ // discontinuity; split off another block, and this is now the start of the next block
449
+ CurrentTasMovie . SetBoolStates ( frame : selection [ blockStart ] , count : iSelection - blockStart , buttonName , val : ! allPressed ) ;
450
+ blockStart = iSelection ;
451
+ }
452
+ lastFrameIndexSeen = index ;
453
+ iSelection ++ ;
403
454
}
404
- CurrentTasMovie . SetBoolStates ( frame : selection [ 0 ] , count : selection . Length , buttonName , val : ! allPressed ) ;
455
+ CurrentTasMovie . SetBoolStates ( frame : selection [ blockStart ] , count : iSelection - blockStart , buttonName , val : ! allPressed ) ;
405
456
}
406
457
else
407
458
{
0 commit comments