@@ -71,43 +71,44 @@ public class TrainCarOperationsWindow : Window
7171 internal static Texture2D RearAngleCockClosed ;
7272 internal static Texture2D RearAngleCockOpened ;
7373
74- public int DisplaySizeY ;
75- public bool LayoutUpdated = false ;
7674 public bool AllSymbolsMode = true ;
75+ public int DisplaySizeY ;
76+ public bool LayoutUpdated ;
7777 public int LocoRowCount ;
7878 public int RowsCount ;
7979 public int SeparatorCount ;
8080 public int SpacerRowCount ;
8181 public int SymbolsRowCount ;
8282
83- public int CarPositionVisible ;
8483 public ControlLayout Client ;
84+ public bool CarPositionChanged ;
85+ public int CarPositionVisible ;
8586 public int CurrentCarPosition ;
8687 public int LabelTop ;
87- public bool LastRowVisible = false ;
88+ public bool LastRowVisible ;
8889 public int LocalScrollPosition ;
8990 public int SelectedCarPosition ;
9091 const int SymbolSize = 16 ;
9192
93+ public int CurrentDisplaySizeY ;
94+ public bool IsFullScreen ;
95+ public int OldPositionHeight ;
96+ public int RowHeight ;
97+ public bool UpdateTrainCarOperation ;
9298 public int WindowHeightMax ;
9399 public int WindowHeightMin ;
94100 public int WindowWidthMax ;
95101 public int WindowWidthMin ;
96- public int CurrentDisplaySizeY ;
97- public bool IsFullScreen = false ;
98- public int RowHeight ;
99- public int OldPositionHeight ;
100- public bool UpdateTrainCarOperation = false ;
101102 public List < int > LabelPositionTop = new List < int > ( ) ;
102103
103104 //Rectangle carLabelPosition;
105+ public ControlLayoutVertical Vbox ;
104106 public string CarLabelText ;
105107 public int CarPosition ;
106108 public int CarUIDLenght ;
107109 public int DesiredHeight ;
108110 public static bool FontChanged ;
109111 public static bool FontToBold ;
110- public ControlLayoutVertical Vbox ;
111112
112113 //Electrical power
113114 public string BatteryStatus ;
@@ -116,10 +117,10 @@ public class TrainCarOperationsWindow : Window
116117 public string PowerSupplyStatus ;
117118 public bool PowerSupplyUpdating ;
118119 public bool SupplyStatusChanged ;
119- public bool UpdatingPowerSupply = false ;
120+ public bool UpdatingPowerSupply ;
120121
121- public bool WarningEnabled = false ;
122- public bool CarIdClicked = false ;
122+ public bool CarIdClicked ;
123+ public bool WarningEnabled ;
123124 public bool ModifiedSetting
124125 {
125126 set ;
@@ -460,7 +461,7 @@ public void topCarPositionVisible()
460461 break ;
461462 }
462463 }
463- }
464+ }
464465 }
465466 }
466467 public void localScrollLayout ( int selectedCarPosition )
@@ -502,6 +503,9 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
502503 {
503504 base . PrepareFrame ( elapsedTime , updateFull ) ;
504505
506+ if ( UserInput . IsPressed ( UserCommand . CameraCarNext ) || UserInput . IsPressed ( UserCommand . CameraCarPrevious ) || UserInput . IsPressed ( UserCommand . CameraCarFirst ) || UserInput . IsPressed ( UserCommand . CameraCarLast ) )
507+ CarPositionChanged = true ;
508+
505509 if ( updateFull )
506510 {
507511 var trainCarViewer = Owner . Viewer . TrainCarOperationsViewerWindow ;
@@ -580,14 +584,16 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
580584 carOperations . CarOperationChanged = carOperations . Visible && carOperations . CarOperationChanged ;
581585 }
582586
583- if ( trainCarWebpage != null && CarPosition != trainCarViewer . CarPosition && trainCarWebpage . Connections > 0 )
587+ if ( CarPositionChanged || ( trainCarWebpage != null && CarPosition != trainCarViewer . CarPosition && trainCarWebpage . Connections > 0 ) )
584588 {
585589 // Required to scroll the main window from the web version
586590 UpdateTrainCarOperation = true ;
587591 CarPosition = trainCarViewer . CarPosition ;
592+ SelectedCarPosition = CarPositionChanged ? CarPosition : SelectedCarPosition ;
588593 LabelTop = LabelPositionTop [ SelectedCarPosition ] ;
589594 Layout ( ) ;
590595 localScrollLayout ( SelectedCarPosition ) ;
596+ CarPositionChanged = false ;
591597 }
592598 //Resize this window after the font has been changed externally
593599 else if ( MultiPlayerWindow . FontChanged )
0 commit comments