@@ -117,7 +117,7 @@ public class TrainCarOperationsWindow : Window
117
117
public bool updatingPowerSupply = false ;
118
118
119
119
public bool warningEnabled = false ;
120
-
120
+ public bool carIdClicked = false ;
121
121
public bool modifiedSetting
122
122
{
123
123
set ;
@@ -440,29 +440,21 @@ public void topCarPositionVisible()
440
440
{ // Allows to find the last carposition, visible at the window bottom.
441
441
if ( ( ! lastRowVisible && labelTop >= 0 ) || labelTop > DisplaySizeY )
442
442
{
443
- if ( DisplaySizeY > desiredHeight )
444
- {
445
- lastRowVisible = true ;
446
- carPositionVisible = rowsCount ;
447
- oldPositionHeight = vbox . Position . Height ;
448
- }
449
- else
443
+ for ( int carPosition = 0 ; carPosition < rowsCount ; carPosition ++ )
450
444
{
451
- for ( int carPosition = 0 ; carPosition < rowsCount ; carPosition ++ )
445
+ var labelTop = carPosition * rowHeight ;
446
+ if ( labelTop > vbox . Position . Height - Owner . TextFontDefault . Height )
452
447
{
453
- var labelTop = carPosition * rowHeight ;
454
- if ( labelTop > vbox . Position . Height - Owner . TextFontDefault . Height )
448
+ if ( ! lastRowVisible && labelTop > 0 )
455
449
{
456
- if ( ! lastRowVisible && labelTop > 0 )
457
- {
458
- lastRowVisible = true ;
459
- carPositionVisible = carPosition - 1 ;
460
- oldPositionHeight = vbox . Position . Height ;
461
- break ;
462
- }
450
+ lastRowVisible = true ;
451
+ carPositionVisible = carPosition - 1 ;
452
+ oldPositionHeight = vbox . Position . Height ;
453
+ var carid = PlayerTrain . Cars [ carPositionVisible ] . CarID ;
454
+ break ;
463
455
}
464
456
}
465
- }
457
+ }
466
458
}
467
459
}
468
460
public void localScrollLayout ( int selectedCarPosition )
@@ -512,7 +504,7 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
512
504
trainCarViewer . TrainCarOperationsChanged = ! trainCarViewer . Visible && trainCarViewer . TrainCarOperationsChanged ? false : trainCarViewer . TrainCarOperationsChanged ;
513
505
514
506
currentDisplaySizeY = DisplaySizeY ;
515
- if ( Owner . Viewer . DisplaySize . Y != DisplaySizeY || modifiedSetting )
507
+ if ( Owner . Viewer . DisplaySize . Y != DisplaySizeY || modifiedSetting || trainCarViewer . CouplerChanged )
516
508
{
517
509
lastRowVisible = false ;
518
510
supplyStatusChanged = false ;
@@ -568,13 +560,14 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
568
560
}
569
561
}
570
562
}
571
- if ( trainCarViewer . TrainCarOperationsChanged || trainCarViewer . RearBrakeHoseChanged
572
- || trainCarViewer . FrontBrakeHoseChanged || modifiedSetting || carOperations . CarOperationChanged )
563
+ if ( trainCarViewer . TrainCarOperationsChanged || trainCarViewer . TrainCarOperationsChanged || trainCarViewer . RearBrakeHoseChanged
564
+ || trainCarViewer . FrontBrakeHoseChanged || modifiedSetting || carIdClicked || carOperations . CarOperationChanged )
573
565
{
574
566
Layout ( ) ;
575
567
localScrollLayout ( selectedCarPosition ) ;
576
568
updateLayoutSize ( ) ;
577
569
modifiedSetting = false ;
570
+ carIdClicked = false ;
578
571
// Avoids bug
579
572
trainCarViewer . TrainCarOperationsChanged = warningEnabled ;
580
573
carOperations . CarOperationChanged = carOperations . Visible && carOperations . CarOperationChanged ;
@@ -613,7 +606,17 @@ public buttonArrowRight(int x, int y, int size, Viewer viewer, int carPosition)
613
606
TrainCarViewer = Viewer . TrainCarOperationsViewerWindow ;
614
607
CarPosition = carPosition ;
615
608
616
- Texture = TrainCarViewer . Visible && TrainCarViewer . CarPosition == CarPosition ? Viewer . TrainCarOperationsWindow . allSymbolsMode ? ArrowRight : ArrowLeft : Empty ;
609
+ // Coupler changed requires to modify the arrow position
610
+ var trainCarViewerCarPosition = TrainCarViewer . CouplerChanged ? TrainCarViewer . NewCarPosition : TrainCarViewer . CarPosition ;
611
+ if ( TrainCarViewer . CouplerChanged && trainCarViewerCarPosition == CarPosition )
612
+ {
613
+ Texture = TrainCarViewer . Visible ? Viewer . TrainCarOperationsWindow . allSymbolsMode ? ArrowRight : ArrowLeft : Empty ;
614
+ Viewer . TrainCarOperationsWindow . carIdClicked = true ;
615
+ TrainCarViewer . CarPosition = trainCarViewerCarPosition ;
616
+ }
617
+ else
618
+ Texture = TrainCarViewer . Visible && trainCarViewerCarPosition == CarPosition ? Viewer . TrainCarOperationsWindow . allSymbolsMode ? ArrowRight : ArrowLeft : Empty ;
619
+
617
620
Source = new Rectangle ( 0 , 0 , size , size ) ;
618
621
Click += new Action < Control , Point > ( buttonArrowRight_Click ) ;
619
622
}
@@ -639,7 +642,17 @@ public buttonArrowLeft(int x, int y, int size, Viewer viewer, int carPosition)
639
642
TrainCarViewer = Viewer . TrainCarOperationsViewerWindow ;
640
643
CarPosition = carPosition ;
641
644
Texture = Empty ;
642
- Texture = TrainCarViewer . CarPosition == CarPosition ? ArrowLeft : Empty ;
645
+ // Coupler changed requires to modify arrow position
646
+ var trainCarViewerCarPosition = TrainCarViewer . CouplerChanged ? TrainCarViewer . NewCarPosition : TrainCarViewer . CarPosition ;
647
+ if ( TrainCarViewer . CouplerChanged && trainCarViewerCarPosition == CarPosition )
648
+ {
649
+ Texture = trainCarViewerCarPosition == CarPosition ? ArrowLeft : Empty ;
650
+ Viewer . TrainCarOperationsWindow . carIdClicked = true ;
651
+ TrainCarViewer . CarPosition = trainCarViewerCarPosition ;
652
+ }
653
+ else
654
+ Texture = trainCarViewerCarPosition == CarPosition ? ArrowLeft : Empty ;
655
+
643
656
Source = new Rectangle ( 0 , 0 , size , size ) ;
644
657
Click += new Action < Control , Point > ( buttonArrowLeft_Click ) ;
645
658
}
@@ -700,10 +713,9 @@ public void buttonLabel_Click(Control arg1, Point arg2)
700
713
Control control = arg1 ;
701
714
702
715
TrainCar . carLabelText = Text ;
703
- TrainCarViewer . YPosition = control . Position . Y ;
704
716
TrainCarViewer . CarPosition = CarPosition ;
705
717
TrainCarViewer . Visible = true ;
706
- TrainCar . modifiedSetting = true ;
718
+ TrainCar . carIdClicked = true ;
707
719
708
720
// required by localScrollLayout()
709
721
TrainCar . selectedCarPosition = CarPosition ;
0 commit comments