Skip to content

Commit 046b292

Browse files
committed
Automatic merge of T1.5.1-684-gc6e0de1c4 and 9 pull requests
- Pull request #570 at c59c788: Experimental glTF 2.0 support with PBR lighting - Pull request #839 at d00beb9: First phase of https://blueprints.launchpad.net/or/+spec/additional-cruise-control-parameters - Pull request #865 at 67014b7: Dispatcher window improvements - Pull request #874 at f8dbeab: Dynamic brake controller refactoring - Pull request #875 at 43bf33e: Bug fix for https://bugs.launchpad.net/or/+bug/2036346 Player train switching doesn't work with 3D cabs - Pull request #876 at f92de76: docs: add source for documents previously on website to source Documentation folder - Pull request #878 at 2df2ab4: Implement Polach Adhesion - Pull request #882 at e92be5a: Blueprint/train car operations UI window - Pull request #883 at aac4d3f: SwitchPanel disconnect/connect handling
11 parents eda5a23 + c6e0de1 + c59c788 + d00beb9 + 67014b7 + f8dbeab + 43bf33e + f92de76 + 2df2ab4 + e92be5a + aac4d3f commit 046b292

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

Source/RunActivity/Viewer3D/Cameras.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,7 @@ protected override void OnActivate(bool sameCamera)
10901090
var isDownCameraOutsideFront = UserInput.IsDown(UserCommand.CameraOutsideFront);
10911091
var isDownCameraOutsideRear = UserInput.IsDown(UserCommand.CameraOutsideRear);
10921092
var isVisibleTrainCarViewer = Viewer.TrainCarOperationsViewerWindow.Visible;
1093+
var trainCars = GetCameraCars();
10931094

10941095
if (attachedCar == null || attachedCar.Train != Viewer.SelectedTrain || carPosition != oldCarPosition || isDownCameraOutsideFront || isDownCameraOutsideRear)
10951096
{
@@ -1100,9 +1101,8 @@ protected override void OnActivate(bool sameCamera)
11001101
SetCameraCar(GetCameraCars().First());
11011102
oldCarPosition = 0;
11021103
}
1103-
else if (isVisibleTrainCarViewer && carPosition >= 0)
1104-
{
1105-
var trainCars = GetCameraCars();
1104+
else if (isVisibleTrainCarViewer && carPosition >= 0 && carPosition < trainCars.Count())
1105+
{
11061106
SetCameraCar(trainCars[carPosition]);
11071107
oldCarPosition = carPosition;
11081108
}
@@ -1116,13 +1116,12 @@ protected override void OnActivate(bool sameCamera)
11161116
}
11171117
else
11181118
{
1119-
var trainCars = GetCameraCars();
11201119
if (!isVisibleTrainCarViewer && isDownCameraOutsideRear)
11211120
{
11221121
SetCameraCar(GetCameraCars().Last());
11231122
oldCarPosition = 0;
11241123
}
1125-
else if (isVisibleTrainCarViewer && carPosition >= 0)
1124+
else if (isVisibleTrainCarViewer && carPosition >= 0 && carPosition < trainCars.Count())
11261125
{
11271126
SetCameraCar(trainCars[carPosition]);
11281127
oldCarPosition = carPosition;

Source/RunActivity/Viewer3D/Popups/TrainCarOperationsViewerWindow.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using Orts.Simulation.RollingStocks.SubSystems.Brakes;
2626
using Orts.Simulation.RollingStocks.SubSystems.Brakes.MSTS;
2727
using Orts.Simulation.RollingStocks.SubSystems.PowerSupplies;
28+
using Orts.Viewer3D.RollingStock;
2829
using ORTS.Common;
2930
using ORTS.Common.Input;
3031
using ORTS.Scripting.Api;
@@ -123,6 +124,7 @@ public struct ListLabel
123124
int LastPlayerTrainCars;
124125
bool LastPlayerLocomotiveFlippedState;
125126
int carPosition;
127+
bool couplerFront = false;
126128
public TrainCarOperationsViewerWindow(WindowManager owner)
127129
: 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"))
128130
{
@@ -335,7 +337,7 @@ void AddSpace(bool full)
335337
AddSpace(false);
336338
if ((wagon != null) && (wagon.PowerSupply is IPowerSupply))
337339
{
338-
line.Add(new ToggleBatterySwitch(0, 0, textHeight, Owner.Viewer, carPosition));
340+
line.Add(new ToggleBatterySwitch(0, 0, textHeight, Owner.Viewer, CarPosition));
339341
AddSpace(false);
340342
}
341343
}
@@ -361,24 +363,27 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
361363
if (updateFull)
362364
{
363365
var carOperations = Owner.Viewer.CarOperationsWindow;
364-
var trainCarOperations = Owner.Viewer.TrainCarOperationsWindow;
365-
TrainCar trainCar = Owner.Viewer.PlayerTrain.Cars[CarPosition];
366-
bool isElectricDieselLocomotive = (trainCar is MSTSElectricLocomotive) || (trainCar is MSTSDieselLocomotive);
366+
var trainCarOperations = Owner.Viewer.TrainCarOperationsWindow;
367367

368-
if (PlayerTrain != Owner.Viewer.PlayerTrain || Owner.Viewer.PlayerTrain.Cars.Count != LastPlayerTrainCars || (Owner.Viewer.PlayerLocomotive != null &&
368+
if (couplerFront || PlayerTrain != Owner.Viewer.PlayerTrain || Owner.Viewer.PlayerTrain.Cars.Count != LastPlayerTrainCars || (Owner.Viewer.PlayerLocomotive != null &&
369369
LastPlayerLocomotiveFlippedState != Owner.Viewer.PlayerLocomotive.Flipped))
370370
{
371+
couplerFront = false;
371372
PlayerTrain = Owner.Viewer.PlayerTrain;
372373

373-
if (LastPlayerTrainCars != Owner.Viewer.PlayerTrain.Cars.Count) { Visible = false; }
374+
if (LastPlayerTrainCars != Owner.Viewer.PlayerTrain.Cars.Count){ Visible = false; }
374375

375376
LastPlayerTrainCars = Owner.Viewer.PlayerTrain.Cars.Count;
377+
CarPosition = CarPosition >= LastPlayerTrainCars? LastPlayerTrainCars - 1: CarPosition;
376378
if (Owner.Viewer.PlayerLocomotive != null) LastPlayerLocomotiveFlippedState = Owner.Viewer.PlayerLocomotive.Flipped;
377379

378380
Layout();
379381
UpdateWindowSize();
380382
}
381383

384+
TrainCar trainCar = Owner.Viewer.PlayerTrain.Cars[CarPosition];
385+
bool isElectricDieselLocomotive = (trainCar is MSTSElectricLocomotive) || (trainCar is MSTSDieselLocomotive);
386+
382387
if (carPosition != CarPosition || TrainCarOperationsChanged || carOperations.CarOperationChanged
383388
|| trainCarOperations.modifiedSetting || carOperations.RearBrakeHoseChanged || carOperations.FrontBrakeHoseChanged)
384389
{
@@ -453,8 +458,9 @@ void TrainCarOperationsCouplerFront_Click(Control arg1, Point arg2)
453458
}
454459
else
455460
{
456-
new UncoupleCommand(Viewer.Log, CarPosition);
457-
if (Viewer.CarOperationsWindow.CarPosition > CarPosition)
461+
new UncoupleCommand(Viewer.Log, CarPosition - 1);
462+
TrainCarViewer.couplerFront = true;
463+
if (Viewer.CarOperationsWindow.CarPosition > CarPosition - 1)
458464
Viewer.CarOperationsWindow.Visible = false;
459465
}
460466
}

Source/RunActivity/Viewer3D/Popups/TrainCarOperationsWindow.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
526526
localScrollLayout(selectedCarPosition);
527527
}
528528

529-
UserCommand? controlDiesel = GetPressedKey(UserCommand.ControlDieselHelper, UserCommand.ControlDieselPlayer);
530-
if (controlDiesel == UserCommand.ControlDieselHelper || controlDiesel == UserCommand.ControlDieselPlayer)
529+
UserCommand ? controlDiesel = GetPressedKey(UserCommand.ControlDieselHelper, UserCommand.ControlDieselPlayer, UserCommand.ControlInitializeBrakes);
530+
if (controlDiesel == UserCommand.ControlDieselHelper || controlDiesel == UserCommand.ControlDieselPlayer || controlDiesel == UserCommand.ControlInitializeBrakes)
531531
{
532532
Layout();
533533
powerSupplyStatus = Owner.Viewer.PlayerTrain.Cars[CarPosition].GetStatus();

0 commit comments

Comments
 (0)