@@ -92,6 +92,7 @@ public class TrainCarOperationsViewerWindow : Window
9292 public int WindowHeightMax ;
9393 public int WindowWidthMin ;
9494 public int WindowWidthMax ;
95+ public bool CabCameraEnabled ;
9596 public int windowHeight { get ; set ; } //required by TrainCarWindow
9697 public int CarPosition
9798 {
@@ -172,6 +173,8 @@ protected internal override void Restore(BinaryReader inf)
172173 CarPosition = inf . ReadInt32 ( ) ;
173174 ResetAllSymbols = inf . ReadBoolean ( ) ;
174175
176+ CabCameraEnabled = Owner . Viewer . Camera is CabCamera || Owner . Viewer . Camera == Owner . Viewer . ThreeDimCabCamera ;
177+
175178 // Display window
176179 SizeTo ( LocationRestore . Width , LocationRestore . Height ) ;
177180 MoveTo ( LocationRestore . X , LocationRestore . Y ) ;
@@ -472,10 +475,18 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
472475 {
473476 // Updates CarPosition
474477 CarPosition = CouplerChanged ? NewCarPosition : CarPosition ;
475-
476- if ( OldCarPosition != CarPosition || ( trainCarOperations . CarIdClicked && CarPosition == 0 ) )
478+
479+ if ( CabCameraEnabled ) // Displays camera 1
477480 {
478- Owner . Viewer . FrontCamera . Activate ( ) ;
481+ CabCameraEnabled = false ;
482+ }
483+ else if ( OldCarPosition != CarPosition || ( trainCarOperations . CarIdClicked && CarPosition == 0 ) )
484+ {
485+ if ( Owner . Viewer . FrontCamera . AttachedCar != null && Owner . Viewer . FrontCamera . IsCameraFront )
486+ Owner . Viewer . FrontCamera . Activate ( ) ;
487+
488+ if ( Owner . Viewer . BackCamera . AttachedCar != null && ! Owner . Viewer . FrontCamera . IsCameraFront )
489+ Owner . Viewer . BackCamera . Activate ( ) ;
479490 }
480491 OldCarPosition = CarPosition ;
481492 Layout ( ) ;
@@ -498,7 +509,7 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
498509
499510 for ( var position = 0 ; position < Owner . Viewer . PlayerTrain . Cars . Count ; position ++ )
500511 {
501- if ( trainCarOperations . WarningCarPosition [ position ] )
512+ if ( trainCarOperations . WarningCarPosition . Count > position && trainCarOperations . WarningCarPosition [ position ] )
502513 {
503514 var carAngleCockAOpenAmount = Owner . Viewer . PlayerTrain . Cars [ position ] . BrakeSystem . AngleCockAOpenAmount ;
504515 var carAngleCockBOpenAmount = Owner . Viewer . PlayerTrain . Cars [ position ] . BrakeSystem . AngleCockBOpenAmount ;
0 commit comments