@@ -52,6 +52,7 @@ public class TrainCarOperationsViewerWindow : Window
5252 internal static Texture2D Coupler ;
5353 internal static Texture2D CouplerFront ;
5454 internal static Texture2D CouplerRear ;
55+ internal static Texture2D CouplerNotAvailable ;
5556 internal static Texture2D Empty ;
5657 internal static Texture2D ETSconnected32 ;
5758 internal static Texture2D ETSdisconnected32 ;
@@ -70,6 +71,8 @@ public class TrainCarOperationsViewerWindow : Window
7071 internal static Texture2D PowerChanging ;
7172 internal static Texture2D RearAngleCockOpened ;
7273 internal static Texture2D RearAngleCockClosed ;
74+ internal static Texture2D ResetBrakesOff ;
75+ internal static Texture2D ResetBrakesOn ;
7376
7477 public int WindowHeightMin ;
7578 public int WindowHeightMax ;
@@ -132,7 +135,7 @@ public struct ListLabel
132135 int LastPlayerTrainCars ;
133136 bool LastPlayerLocomotiveFlippedState ;
134137 int OldCarPosition ;
135-
138+ bool ResetAllSymbols = false ;
136139 public TrainCarOperationsViewerWindow ( WindowManager owner )
137140 : base ( owner , Window . DecorationSize . X + CarListPadding + ( ( owner . TextFontDefault . Height + 12 ) * 20 ) , Window . DecorationSize . Y + ( ( owner . TextFontDefault . Height + 12 ) * 2 ) , Viewer . Catalog . GetString ( "Train Operations Viewer" ) )
138141 {
@@ -151,6 +154,7 @@ protected internal override void Save(BinaryWriter outf)
151154 outf . Write ( Location . Height ) ;
152155
153156 outf . Write ( CarPosition ) ;
157+ outf . Write ( ResetAllSymbols ) ;
154158 }
155159 protected internal override void Restore ( BinaryReader inf )
156160 {
@@ -162,6 +166,7 @@ protected internal override void Restore(BinaryReader inf)
162166 LocationRestore . Height = inf . ReadInt32 ( ) ;
163167
164168 CarPosition = inf . ReadInt32 ( ) ;
169+ ResetAllSymbols = inf . ReadBoolean ( ) ;
165170
166171 // Display window
167172 SizeTo ( LocationRestore . Width , LocationRestore . Height ) ;
@@ -192,6 +197,7 @@ protected internal override void Initialize()
192197 Coupler = SharedTextureManager . Get ( Owner . Viewer . RenderProcess . GraphicsDevice , System . IO . Path . Combine ( Owner . Viewer . ContentPath , "TrainOperationsCoupler32.png" ) ) ;
193198 CouplerFront = SharedTextureManager . Get ( Owner . Viewer . RenderProcess . GraphicsDevice , System . IO . Path . Combine ( Owner . Viewer . ContentPath , "TrainOperationsCouplerFront32.png" ) ) ;
194199 CouplerRear = SharedTextureManager . Get ( Owner . Viewer . RenderProcess . GraphicsDevice , System . IO . Path . Combine ( Owner . Viewer . ContentPath , "TrainOperationsCouplerRear32.png" ) ) ;
200+ CouplerNotAvailable = SharedTextureManager . Get ( Owner . Viewer . RenderProcess . GraphicsDevice , System . IO . Path . Combine ( Owner . Viewer . ContentPath , "TrainOperationsCouplerNotAvailable32.png" ) ) ;
195201
196202 Empty = SharedTextureManager . Get ( Owner . Viewer . RenderProcess . GraphicsDevice , System . IO . Path . Combine ( Owner . Viewer . ContentPath , "TrainOperationsEmpty32.png" ) ) ;
197203
@@ -218,6 +224,9 @@ protected internal override void Initialize()
218224
219225 RearAngleCockClosed = SharedTextureManager . Get ( Owner . Viewer . RenderProcess . GraphicsDevice , System . IO . Path . Combine ( Owner . Viewer . ContentPath , "TrainOperationsRearAngleCockClosed32.png" ) ) ;
220226 RearAngleCockOpened = SharedTextureManager . Get ( Owner . Viewer . RenderProcess . GraphicsDevice , System . IO . Path . Combine ( Owner . Viewer . ContentPath , "TrainOperationsRearAngleCockOpened32.png" ) ) ;
227+
228+ ResetBrakesOff = SharedTextureManager . Get ( Owner . Viewer . RenderProcess . GraphicsDevice , System . IO . Path . Combine ( Owner . Viewer . ContentPath , "TrainOperationsResetBrakesOff32.png" ) ) ;
229+ ResetBrakesOn = SharedTextureManager . Get ( Owner . Viewer . RenderProcess . GraphicsDevice , System . IO . Path . Combine ( Owner . Viewer . ContentPath , "TrainOperationsResetBrakesOn32.png" ) ) ;
221230 }
222231
223232 UpdateWindowSize ( ) ;
@@ -271,8 +280,8 @@ protected override ControlLayout Layout(ControlLayout layout)
271280 var isElectric = trainCar is MSTSElectricLocomotive ;
272281 var isSteam = trainCar is MSTSSteamLocomotive ;
273282 var isEngine = isDiesel || isElectric || isSteam ;
274- var wagonType = isEngine ? $ " { Viewer . Catalog . GetString ( locomotive . WagonType . ToString ( ) ) } " + $ ":{ Viewer . Catalog . GetString ( locomotive . EngineType . ToString ( ) ) } "
275- : $ " { Viewer . Catalog . GetString ( wagon . WagonType . ToString ( ) ) } ";
283+ var wagonType = isEngine ? $ " { Viewer . Catalog . GetString ( locomotive . WagonType . ToString ( ) ) } " + $ ": { Viewer . Catalog . GetString ( locomotive . EngineType . ToString ( ) ) } "
284+ : $ " { Viewer . Catalog . GetString ( wagon . WagonType . ToString ( ) ) } : { wagon . MainShapeFileName . Replace ( ".s" , "" ) . ToLower ( ) } ";
276285
277286 Vbox . Add ( buttonClose = new Label ( Vbox . RemainingWidth , Owner . TextFontDefault . Height , $ "{ Viewer . Catalog . GetString ( "Car ID" ) } { ( CarPosition >= PlayerTrain . Cars . Count ? " " : PlayerTrain . Cars [ CarPosition ] . CarID + wagonType ) } ", LabelAlignment . Center ) ) ;
278287 CurrentCarID = CarPosition >= PlayerTrain . Cars . Count ? " " : PlayerTrain . Cars [ CarPosition ] . CarID ;
@@ -293,6 +302,10 @@ void AddSpace(bool full)
293302
294303 {
295304 var car = PlayerTrain . Cars [ CarPosition ] ;
305+ //Reset brakes
306+ var warningCarPos = Owner . Viewer . TrainCarOperationsWindow . WarningCarPosition . Where ( x => x == true ) . Count ( ) ;
307+ line . Add ( new buttonInitializeBrakes ( 0 , 0 , textHeight , Owner . Viewer , CarPosition , warningCarPos ) ) ;
308+
296309 if ( car != PlayerTrain . Cars . First ( ) )
297310 AddSpace ( false ) ;
298311
@@ -425,7 +438,7 @@ public buttonLoco(int x, int y, int size, Viewer viewer, TrainCar car)
425438 : base ( x , y , size * 2 , size )
426439 {
427440 Viewer = viewer ;
428- Texture = ( car == Viewer . PlayerTrain . LeadLocomotive || car is MSTSLocomotive ) ? LocoSymbolGreen
441+ Texture = ( car == Viewer . PlayerTrain . LeadLocomotive || car is MSTSLocomotive || car . WagonType == TrainCar . WagonTypes . Tender ) ? LocoSymbolGreen
429442 : car . BrakesStuck || ( ( car is MSTSLocomotive ) && ( car as MSTSLocomotive ) . PowerReduction > 0 ) ? LocoSymbolRed
430443 : LocoSymbol ;
431444 Source = new Rectangle ( 0 , 0 , size * 2 , size ) ;
@@ -437,22 +450,23 @@ class buttonCouplerFront : Image
437450 readonly TrainCarOperationsViewerWindow TrainCarViewer ;
438451 readonly int CarPosition ;
439452 readonly bool First ;
440-
453+ readonly TrainCar Car ;
441454 public buttonCouplerFront ( int x , int y , int size , Viewer viewer , TrainCar car , int carPosition )
442455 : base ( x , y , size , size )
443456 {
444457 Viewer = viewer ;
445458 TrainCarViewer = Viewer . TrainCarOperationsViewerWindow ;
446459 CarPosition = carPosition ;
460+ Car = car ;
447461 First = car == Viewer . PlayerTrain . Cars . First ( ) ;
448- Texture = First ? CouplerFront : Coupler ;
462+ Texture = First ? CouplerFront : Car . WagonType == MSTSWagon . WagonTypes . Tender ? CouplerNotAvailable : Coupler ;
449463 Source = new Rectangle ( 0 , 0 , size , size ) ;
450464 Click += new Action < Control , Point > ( TrainCarOperationsCouplerFront_Click ) ;
451465 }
452466
453467 void TrainCarOperationsCouplerFront_Click ( Control arg1 , Point arg2 )
454468 {
455- if ( First ) return ;
469+ if ( First || Car . WagonType == MSTSWagon . WagonTypes . Tender ) return ;
456470
457471 if ( Viewer . Simulator . TimetableMode )
458472 {
@@ -519,6 +533,48 @@ void TrainCarOperationsLabel_Click(Control arg1, Point arg2)
519533 TrainCarViewer . Visible = false ;
520534 }
521535 }
536+
537+ class buttonInitializeBrakes : Image
538+ {
539+ readonly Viewer Viewer ;
540+ readonly TrainCarOperationsViewerWindow TrainCarViewer ;
541+ readonly int WarningCars ;
542+ public buttonInitializeBrakes ( int x , int y , int size , Viewer viewer , int carPosition , int warningCars )
543+ : base ( x , y , size , size )
544+ {
545+ Viewer = viewer ;
546+ TrainCarViewer = Viewer . TrainCarOperationsViewerWindow ;
547+ WarningCars = warningCars ;
548+ Texture = WarningCars > 2 ? ResetBrakesOn : ResetBrakesOff ;
549+ Source = new Rectangle ( 0 , 0 , size , size ) ;
550+ Click += new Action < Control , Point > ( buttonInitializeBrakes_Click ) ;
551+ }
552+
553+ void buttonInitializeBrakes_Click ( Control arg1 , Point arg2 )
554+ {
555+
556+ if ( WarningCars <= 2 ) return ;
557+
558+ if ( Texture == ResetBrakesOn )
559+ {
560+ TrainCarViewer . PlayerTrain . ConnectBrakeHoses ( ) ;
561+
562+ // Reset Handbrakes
563+ foreach ( var car in Viewer . PlayerTrain . Cars )
564+ {
565+ if ( ( car as MSTSWagon ) . HandBrakePresent && ( car as MSTSWagon ) . GetTrainHandbrakeStatus ( ) )
566+ {
567+ new WagonHandbrakeCommand ( Viewer . Log , ( car as MSTSWagon ) , ! ( car as MSTSWagon ) . GetTrainHandbrakeStatus ( ) ) ;
568+ Texture = HandBrakeNotSet ;
569+ }
570+ }
571+ //Refresh all symbols
572+ TrainCarViewer . TrainCarOperationsChanged = true ;
573+ }
574+ TrainCarViewer . ResetAllSymbols = ! TrainCarViewer . ResetAllSymbols ;
575+ Texture = TrainCarViewer . ResetAllSymbols ? ResetBrakesOn : ResetBrakesOff ;
576+ }
577+ }
522578 class buttonHandBrake : Image
523579 {
524580 readonly Viewer Viewer ;
0 commit comments