Skip to content

Commit 69a70cb

Browse files
committed
Adjust Train Driver Window to line up with HuD operation of derailment window.
1 parent 562fe42 commit 69a70cb

File tree

1 file changed

+32
-21
lines changed

1 file changed

+32
-21
lines changed

Source/RunActivity/Viewer3D/Popups/TrainDrivingWindow.cs

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,47 +1178,58 @@ void AddSeparator() => AddLabel(new ListLabel
11781178
}
11791179

11801180
//Derailment Coefficient. Changed the float value output by a text label.
1181-
var maxDerailCoeff = 0.0f;
11821181
var carIDerailCoeff = "";
1182+
var carDerailPossible = false;
1183+
var carDerailExpected = false;
1184+
11831185
for (var i = 0; i < train.Cars.Count; i++)
11841186
{
11851187
var carDerailCoeff = train.Cars[i].DerailmentCoefficient;
11861188
carDerailCoeff = float.IsInfinity(carDerailCoeff) || float.IsNaN(carDerailCoeff) ? 0 : carDerailCoeff;
1187-
if (carDerailCoeff > maxDerailCoeff)
1189+
1190+
carIDerailCoeff = train.Cars[i].CarID;
1191+
1192+
// Only record the first car that has derailed, stop looking for other derailed cars
1193+
carDerailExpected = train.Cars[i].DerailExpected;
1194+
if (carDerailExpected)
1195+
{
1196+
break;
1197+
}
1198+
1199+
// Only record first instance of a possible car derailment (warning)
1200+
if (train.Cars[i].DerailPossible && !carDerailPossible)
11881201
{
1189-
maxDerailCoeff = carDerailCoeff;
1190-
carIDerailCoeff = train.Cars[i].CarID;
1202+
carDerailPossible = train.Cars[i].DerailPossible;
11911203
}
11921204
}
11931205

1194-
if (maxDerailCoeff > 0.66)
1206+
if (carDerailPossible || carDerailExpected)
11951207
{
11961208
derailLabelVisible = true;
11971209
clockDerailTime = Owner.Viewer.Simulator.ClockTime;
11981210
}
11991211

1200-
if (maxDerailCoeff > 0.66)
1212+
// The most extreme instance of the derail coefficient will only be displayed in the TDW
1213+
if (carDerailExpected)
12011214
{
1202-
if (maxDerailCoeff > 1)
1215+
AddLabel(new ListLabel
12031216
{
1204-
AddLabel(new ListLabel
1205-
{
1206-
FirstCol = Viewer.Catalog.GetString("DerailCoeff"),
1207-
LastCol = $"{Viewer.Catalog.GetString("Derailed")} {carIDerailCoeff}" + ColorCode[Color.OrangeRed],
1208-
});
1209-
}
1210-
else if (maxDerailCoeff < 1 && maxDerailCoeff > 0.66)
1217+
FirstCol = Viewer.Catalog.GetString("DerailCoeff"),
1218+
LastCol = $"{Viewer.Catalog.GetString("Derailed")} {carIDerailCoeff}" + ColorCode[Color.OrangeRed],
1219+
});
1220+
}
1221+
else if (carDerailPossible)
1222+
{
1223+
AddLabel(new ListLabel
12111224
{
1212-
AddLabel(new ListLabel
1213-
{
1214-
FirstCol = Viewer.Catalog.GetString("DerailCoeff"),
1215-
LastCol = $"{Viewer.Catalog.GetString("Warning")} {carIDerailCoeff}" + ColorCode[Color.Yellow],
1216-
});
1217-
}
1225+
FirstCol = Viewer.Catalog.GetString("DerailCoeff"),
1226+
LastCol = $"{Viewer.Catalog.GetString("Warning")} {carIDerailCoeff}" + ColorCode[Color.Yellow],
1227+
});
12181228
}
1229+
12191230
else
12201231
{
1221-
// delay to hide the derailcoeff label
1232+
// delay to hide the derailcoeff label if normal
12221233
if (derailLabelVisible && clockDerailTime + 3 < Owner.Viewer.Simulator.ClockTime)
12231234
derailLabelVisible = false;
12241235

0 commit comments

Comments
 (0)