Skip to content

Commit c5f1627

Browse files
committed
Fix incorrectly disabled options in train operations window
1 parent a5be129 commit c5f1627

File tree

3 files changed

+40
-25
lines changed

3 files changed

+40
-25
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5073,6 +5073,33 @@ public override string GetDPDynamicBrakeStatus()
50735073
return string.Format("{0:F0}% {1}", DynamicBrakePercent, dpStatus);
50745074
return string.Format("{0} {1}", DynamicBrakeController.GetStatus(), dpStatus);
50755075
}
5076+
5077+
public override string GetMultipleUnitsConfiguration()
5078+
{
5079+
if (Train == null)
5080+
return base.GetMultipleUnitsConfiguration();
5081+
var numberOfLocomotives = 0;
5082+
var group = 0;
5083+
var configuration = "";
5084+
5085+
var remoteControlGroup = 0;
5086+
for (var i = 0; i < Train.Cars.Count; i++)
5087+
{
5088+
if (Train.Cars[i] is MSTSLocomotive)
5089+
{
5090+
if (remoteControlGroup != (remoteControlGroup = Train.Cars[i].RemoteControlGroup) && i != 0)
5091+
{
5092+
configuration += string.Format("{0} | ", group);
5093+
group = 0;
5094+
}
5095+
group++;
5096+
numberOfLocomotives++;
5097+
}
5098+
}
5099+
if (group > 0)
5100+
configuration += string.Format("{0}", group);
5101+
return numberOfLocomotives > 0 ? configuration : null;
5102+
}
50765103
#endregion
50775104

50785105
public override void SignalEvent(TCSEvent evt)

Source/RunActivity/Viewer3D/Popups/TrainCarOperationsViewerWindow.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ void AddSpace(bool full)
442442
line.Add(new buttonToggleMU(0, 0, textHeight, Owner.Viewer, CarPosition));
443443
AddSpace(false);
444444
}
445+
445446
line.Add(new buttonTogglePower(0, 0, textHeight, Owner.Viewer, CarPosition));
446447
AddSpace(false);
447448
if ((wagon != null) && (wagon.PowerSupply is IPowerSupply))
@@ -894,7 +895,6 @@ public buttonFrontAngleCock(int x, int y, int size, Viewer viewer, TrainCar car,
894895
Viewer = viewer;
895896
TrainCarViewer = Viewer.TrainCarOperationsViewerWindow;
896897
CurrentCar = Viewer.PlayerTrain.Cars[carPosition];
897-
var first = car == Viewer.PlayerTrain.Cars.First();
898898

899899
if (CurrentCar.BrakeSystem is VacuumSinglePipe)
900900
{
@@ -904,15 +904,11 @@ public buttonFrontAngleCock(int x, int y, int size, Viewer viewer, TrainCar car,
904904
{
905905
var carAngleCockAOpenAmount = CurrentCar.BrakeSystem.AngleCockAOpenAmount;
906906
var carAngleCockAOpen = (CurrentCar as MSTSWagon).BrakeSystem.AngleCockAOpen;
907-
Texture = !TrainCarViewer.TrainCarOperationsChanged && first ? FrontAngleCockClosed
908-
: carAngleCockAOpenAmount > 0 && carAngleCockAOpenAmount < 1 ? FrontAngleCockPartial
907+
Texture = carAngleCockAOpenAmount > 0 && carAngleCockAOpenAmount < 1 ? FrontAngleCockPartial
909908
: carAngleCockAOpen ? FrontAngleCockOpened
910909
: FrontAngleCockClosed;
911910

912-
if (!first)
913-
{
914-
Click += new Action<Control, Point>(buttonFrontAngleCock_Click);
915-
}
911+
Click += new Action<Control, Point>(buttonFrontAngleCock_Click);
916912
}
917913
Source = new Rectangle(0, 0, size, size);
918914
}
@@ -945,7 +941,6 @@ public buttonRearAngleCock(int x, int y, int size, Viewer viewer, TrainCar car,
945941
Viewer = viewer;
946942
TrainCarViewer = Viewer.TrainCarOperationsViewerWindow;
947943
CurrentCar = Viewer.PlayerTrain.Cars[carPosition];
948-
var last = car == Viewer.PlayerTrain.Cars.Last();
949944

950945
if (CurrentCar.BrakeSystem is VacuumSinglePipe)
951946
{
@@ -955,15 +950,11 @@ public buttonRearAngleCock(int x, int y, int size, Viewer viewer, TrainCar car,
955950
{
956951
var carAngleCockBOpenAmount = (CurrentCar as MSTSWagon).BrakeSystem.AngleCockBOpenAmount;
957952
var carAngleCockBOpen = (CurrentCar as MSTSWagon).BrakeSystem.AngleCockBOpen;
958-
Texture = last ? RearAngleCockClosed
959-
: carAngleCockBOpenAmount > 0 && carAngleCockBOpenAmount < 1 ? RearAngleCockPartial
953+
Texture = carAngleCockBOpenAmount > 0 && carAngleCockBOpenAmount < 1 ? RearAngleCockPartial
960954
: carAngleCockBOpen ? RearAngleCockOpened
961955
: RearAngleCockClosed;
962956

963-
if (!last)
964-
{
965-
Click += new Action<Control, Point>(buttonRearAngleCock_Click);
966-
}
957+
Click += new Action<Control, Point>(buttonRearAngleCock_Click);
967958
}
968959
Source = new Rectangle(0, 0, size, size);
969960
}
@@ -1099,7 +1090,7 @@ public buttonToggleMU(int x, int y, int size, Viewer viewer, int carPosition)
10991090
CurrentCar = Viewer.PlayerTrain.Cars[carPosition];
11001091

11011092
MultipleUnitsConfiguration = Viewer.PlayerLocomotive.GetMultipleUnitsConfiguration();
1102-
if (CurrentCar is MSTSDieselLocomotive && MultipleUnitsConfiguration != null)
1093+
if (CurrentCar is MSTSLocomotive && MultipleUnitsConfiguration != null)
11031094
{
11041095
Texture = Viewer.TrainCarOperationsWindow.ModifiedSetting || ((CurrentCar as MSTSLocomotive).RemoteControlGroup == 0 && MultipleUnitsConfiguration != "1") ? MUconnected : MUdisconnected;
11051096
}
@@ -1112,7 +1103,7 @@ public buttonToggleMU(int x, int y, int size, Viewer viewer, int carPosition)
11121103
}
11131104
void buttonToggleMU_Click(Control arg1, Point arg2)
11141105
{
1115-
if (CurrentCar is MSTSDieselLocomotive)
1106+
if (CurrentCar is MSTSLocomotive)
11161107
{
11171108
MSTSLocomotive locomotive = CurrentCar as MSTSLocomotive;
11181109

Source/RunActivity/Viewer3D/Popups/TrainCarOperationsWindow.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ void AddSpace()
490490
line.Add(new buttonToggleMU(0, 0, SymbolSize, Owner.Viewer, carPosition));
491491
AddSpace();
492492
}
493+
493494
line.Add(new buttonTogglePower(0, 0, SymbolSize, Owner.Viewer, carPosition));
494495
AddSpace();
495496

@@ -1097,7 +1098,6 @@ public buttonFrontAngleCock(int x, int y, int size, Viewer viewer, TrainCar car,
10971098
{
10981099
Viewer = viewer;
10991100
TrainCarViewer = Viewer.TrainCarOperationsViewerWindow;
1100-
var First = car == viewer.PlayerTrain.Cars.First();
11011101
var CurrentCar = Viewer.PlayerTrain.Cars[carPosition];
11021102

11031103
if (CurrentCar.BrakeSystem is VacuumSinglePipe)
@@ -1108,15 +1108,14 @@ public buttonFrontAngleCock(int x, int y, int size, Viewer viewer, TrainCar car,
11081108
{
11091109
var carAngleCockAOpenAmount = (CurrentCar as MSTSWagon).BrakeSystem.AngleCockAOpenAmount;
11101110
var carAngleCockAOpen = (CurrentCar as MSTSWagon).BrakeSystem.AngleCockAOpen;
1111-
Texture = !TrainCarViewer.TrainCarOperationsChanged && First ? FrontAngleCockClosed
1112-
: carAngleCockAOpenAmount > 0 && carAngleCockAOpenAmount < 1 ? FrontAngleCockPartial
1111+
Texture = carAngleCockAOpenAmount > 0 && carAngleCockAOpenAmount < 1 ? FrontAngleCockPartial
11131112
: carAngleCockAOpen ? FrontAngleCockOpened
11141113
: FrontAngleCockClosed;
11151114
}
11161115
Source = new Rectangle(0, 0, size, size);
11171116

11181117
var trainCarOperations = Viewer.TrainCarOperationsWindow;
1119-
if (!First && !trainCarOperations.WarningCarPosition[carPosition])
1118+
if (!trainCarOperations.WarningCarPosition[carPosition])
11201119
{
11211120
trainCarOperations.updateWarningCarPosition(carPosition, Texture, FrontAngleCockClosed);
11221121
trainCarOperations.updateWarningCarPosition(carPosition, Texture, FrontAngleCockPartial);
@@ -1130,7 +1129,6 @@ public buttonRearAngleCock(int x, int y, int size, Viewer viewer, TrainCar car,
11301129
: base(x, y, size, size)
11311130
{
11321131
Viewer = viewer;
1133-
var Last = car == viewer.PlayerTrain.Cars.Last();
11341132
var CurrentCar = Viewer.PlayerTrain.Cars[carPosition];
11351133

11361134
if (CurrentCar.BrakeSystem is VacuumSinglePipe)
@@ -1141,15 +1139,14 @@ public buttonRearAngleCock(int x, int y, int size, Viewer viewer, TrainCar car,
11411139
{
11421140
var carAngleCockBOpenAmount = (CurrentCar as MSTSWagon).BrakeSystem.AngleCockBOpenAmount;
11431141
var carAngleCockBOpen = (CurrentCar as MSTSWagon).BrakeSystem.AngleCockBOpen;
1144-
Texture = Last ? RearAngleCockClosed
1145-
: carAngleCockBOpenAmount > 0 && carAngleCockBOpenAmount < 1 ? RearAngleCockPartial
1142+
Texture = carAngleCockBOpenAmount > 0 && carAngleCockBOpenAmount < 1 ? RearAngleCockPartial
11461143
: carAngleCockBOpen ? RearAngleCockOpened
11471144
: RearAngleCockClosed;
11481145
}
11491146
Source = new Rectangle(0, 0, size, size);
11501147

11511148
var trainCarOperations = Viewer.TrainCarOperationsWindow;
1152-
if (!Last && !trainCarOperations.WarningCarPosition[carPosition])
1149+
if (!trainCarOperations.WarningCarPosition[carPosition])
11531150
{
11541151
trainCarOperations.updateWarningCarPosition(carPosition, Texture, RearAngleCockClosed);
11551152
trainCarOperations.updateWarningCarPosition(carPosition, Texture, RearAngleCockPartial);
@@ -1266,7 +1263,7 @@ public buttonToggleMU(int x, int y, int size, Viewer viewer, int carPosition)
12661263
CarPosition = carPosition;
12671264

12681265
var multipleUnitsConfiguration = Viewer.PlayerLocomotive.GetMultipleUnitsConfiguration();
1269-
if ((Viewer.PlayerTrain.Cars[CarPosition] is MSTSDieselLocomotive) && multipleUnitsConfiguration != null)
1266+
if ((Viewer.PlayerTrain.Cars[CarPosition] is MSTSLocomotive) && multipleUnitsConfiguration != null)
12701267
{
12711268
Texture = (Viewer.PlayerTrain.Cars[CarPosition] as MSTSLocomotive).RemoteControlGroup == 0 && multipleUnitsConfiguration != "1" ? MUconnected : MUdisconnected;
12721269
}

0 commit comments

Comments
 (0)