Skip to content

Commit 82ab6ce

Browse files
Changed Brake Hose menu entry into Front and Rear Brake Hose entry
1 parent 6a3f86f commit 82ab6ce

File tree

1 file changed

+37
-9
lines changed

1 file changed

+37
-9
lines changed

Source/RunActivity/Viewer3D/Popups/CarOperationsWindow.cs

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,25 @@ public int CarPosition
3939
}
4040

4141
public CarOperationsWindow(WindowManager owner)
42-
: base(owner, Window.DecorationSize.X + owner.TextFontDefault.Height * 19, Window.DecorationSize.Y + owner.TextFontDefault.Height * 11 + ControlLayout.SeparatorSize * 10, Viewer.Catalog.GetString("Car Operation Menu"))
42+
: base(owner, Window.DecorationSize.X + owner.TextFontDefault.Height * 20, Window.DecorationSize.Y + owner.TextFontDefault.Height * 12 + ControlLayout.SeparatorSize * 11, Viewer.Catalog.GetString("Car Operation Menu"))
4343
{
4444
Viewer = owner.Viewer;
4545
}
4646

4747
protected override ControlLayout Layout(ControlLayout layout)
4848
{
49-
Label ID, buttonHandbrake, buttonTogglePower, buttonToggleMU, buttonToggleBatterySwitch, buttonToggleElectricTrainSupplyCable, buttonToggleBrakeHose, buttonToggleAngleCockA, buttonToggleAngleCockB, buttonToggleBleedOffValve, buttonClose;
49+
Label ID, buttonHandbrake, buttonTogglePower, buttonToggleMU, buttonToggleBatterySwitch, buttonToggleElectricTrainSupplyCable, buttonToggleFrontBrakeHose, buttonToggleRearBrakeHose, buttonToggleAngleCockA, buttonToggleAngleCockB, buttonToggleBleedOffValve, buttonClose;
5050

5151
TrainCar trainCar = Viewer.PlayerTrain.Cars[CarPosition];
5252
BrakeSystem brakeSystem = (trainCar as MSTSWagon).BrakeSystem;
5353

54+
BrakeSystem rearBrakeSystem = null;
55+
if (CarPosition + 1 < Viewer.PlayerTrain.Cars.Count)
56+
{
57+
TrainCar rearTrainCar = Viewer.PlayerTrain.Cars[CarPosition + 1];
58+
rearBrakeSystem = (rearTrainCar as MSTSWagon).BrakeSystem;
59+
}
60+
5461
var vbox = base.Layout(layout).AddLayoutVertical();
5562
vbox.Add(ID = new Label(vbox.RemainingWidth, Owner.TextFontDefault.Height, Viewer.Catalog.GetString("Car ID") + " " + (CarPosition >= Viewer.PlayerTrain.Cars.Count? " " :Viewer.PlayerTrain.Cars[CarPosition].CarID), LabelAlignment.Center));
5663
ID.Color = Color.Red;
@@ -73,12 +80,20 @@ protected override ControlLayout Layout(ControlLayout layout)
7380
vbox.Add(buttonToggleElectricTrainSupplyCable = new Label(vbox.RemainingWidth, Owner.TextFontDefault.Height, Viewer.Catalog.GetString("Toggle Electric Train Supply Connection"), LabelAlignment.Center));
7481
vbox.AddHorizontalSeparator();
7582

76-
string buttonToggleBrakeHoseText = "";
83+
string buttonToggleFronBrakeHoseText = "";
7784
if (brakeSystem.FrontBrakeHoseConnected)
78-
buttonToggleBrakeHoseText = Viewer.Catalog.GetString("Disconnect Brake Hose");
85+
buttonToggleFronBrakeHoseText = Viewer.Catalog.GetString("Disconnect Front Brake Hose");
86+
else
87+
buttonToggleFronBrakeHoseText = Viewer.Catalog.GetString("Connect Front Brake Hose");
88+
vbox.Add(buttonToggleFrontBrakeHose = new Label(vbox.RemainingWidth, Owner.TextFontDefault.Height, buttonToggleFronBrakeHoseText, LabelAlignment.Center));
89+
vbox.AddHorizontalSeparator();
90+
91+
string buttonToggleRearBrakeHoseText = "";
92+
if (((CarPosition + 1) < Viewer.PlayerTrain.Cars.Count) && (rearBrakeSystem.FrontBrakeHoseConnected))
93+
buttonToggleRearBrakeHoseText = Viewer.Catalog.GetString("Disconnect Rear Brake Hose");
7994
else
80-
buttonToggleBrakeHoseText = Viewer.Catalog.GetString("Connect Brake Hose");
81-
vbox.Add(buttonToggleBrakeHose = new Label(vbox.RemainingWidth, Owner.TextFontDefault.Height, buttonToggleBrakeHoseText, LabelAlignment.Center));
95+
buttonToggleRearBrakeHoseText = Viewer.Catalog.GetString("Connect Rear Brake Hose");
96+
vbox.Add(buttonToggleRearBrakeHose = new Label(vbox.RemainingWidth, Owner.TextFontDefault.Height, buttonToggleRearBrakeHoseText, LabelAlignment.Center));
8297
vbox.AddHorizontalSeparator();
8398

8499
string buttonToggleAngleCockAText = "";
@@ -117,9 +132,13 @@ protected override ControlLayout Layout(ControlLayout layout)
117132
buttonToggleElectricTrainSupplyCable.Click += new Action<Control, Point>(buttonToggleElectricTrainSupplyCable_Click);
118133

119134
if (CarPosition > 0)
120-
buttonToggleBrakeHose.Click += new Action<Control, Point>(buttonToggleBrakeHose_Click);
135+
buttonToggleFrontBrakeHose.Click += new Action<Control, Point>(buttonToggleFrontBrakeHose_Click);
121136
else
122-
buttonToggleBrakeHose.Color = Color.Gray;
137+
buttonToggleFrontBrakeHose.Color = Color.Gray;
138+
if (CarPosition < (Viewer.PlayerTrain.Cars.Count - 1))
139+
buttonToggleRearBrakeHose.Click += new Action<Control, Point>(buttonToggleRearBrakeHose_Click);
140+
else
141+
buttonToggleRearBrakeHose.Color = Color.Gray;
123142

124143
buttonToggleAngleCockA.Click += new Action<Control, Point>(buttonToggleAngleCockA_Click);
125144
buttonToggleAngleCockB.Click += new Action<Control, Point>(buttonToggleAngleCockB_Click);
@@ -218,7 +237,7 @@ void buttonToggleElectricTrainSupplyCable_Click(Control arg1, Point arg2)
218237
}
219238
}
220239

221-
void buttonToggleBrakeHose_Click(Control arg1, Point arg2)
240+
void buttonToggleFrontBrakeHose_Click(Control arg1, Point arg2)
222241
{
223242
new WagonBrakeHoseConnectCommand(Viewer.Log, (Viewer.PlayerTrain.Cars[CarPosition] as MSTSWagon), !(Viewer.PlayerTrain.Cars[CarPosition] as MSTSWagon).BrakeSystem.FrontBrakeHoseConnected);
224243
if ((Viewer.PlayerTrain.Cars[CarPosition] as MSTSWagon).BrakeSystem.FrontBrakeHoseConnected)
@@ -227,6 +246,15 @@ void buttonToggleBrakeHose_Click(Control arg1, Point arg2)
227246
Viewer.Simulator.Confirmer.Information(Viewer.Catalog.GetString("Front brake hose disconnected"));
228247
}
229248

249+
void buttonToggleRearBrakeHose_Click(Control arg1, Point arg2)
250+
{
251+
new WagonBrakeHoseConnectCommand(Viewer.Log, (Viewer.PlayerTrain.Cars[CarPosition + 1] as MSTSWagon), !(Viewer.PlayerTrain.Cars[CarPosition + 1] as MSTSWagon).BrakeSystem.FrontBrakeHoseConnected);
252+
if ((Viewer.PlayerTrain.Cars[CarPosition + 1] as MSTSWagon).BrakeSystem.FrontBrakeHoseConnected)
253+
Viewer.Simulator.Confirmer.Information(Viewer.Catalog.GetString("Rear brake hose connected"));
254+
else
255+
Viewer.Simulator.Confirmer.Information(Viewer.Catalog.GetString("Rear brake hose disconnected"));
256+
}
257+
230258
void buttonToggleAngleCockA_Click(Control arg1, Point arg2)
231259
{
232260
new ToggleAngleCockACommand(Viewer.Log, (Viewer.PlayerTrain.Cars[CarPosition] as MSTSWagon), !(Viewer.PlayerTrain.Cars[CarPosition] as MSTSWagon).BrakeSystem.AngleCockAOpen);

0 commit comments

Comments
 (0)