Skip to content

Commit eecf94b

Browse files
committed
Automatic merge of T1.5.1-684-gc6e0de1c4 and 10 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 43f6ee9: Implement Polach Adhesion - Pull request #882 at e458797: Blueprint/train car operations UI window - Pull request #883 at edcc2dd: SwitchPanel disconnect/connect handling - Pull request #885 at c81447b: feat: Add notifications to Menu
12 parents 2cecf8c + c6e0de1 + c59c788 + d00beb9 + 67014b7 + f8dbeab + 43bf33e + f92de76 + 43f6ee9 + e458797 + edcc2dd + c81447b commit eecf94b

File tree

4 files changed

+64
-44
lines changed

4 files changed

+64
-44
lines changed

Source/RunActivity/Viewer3D/Cameras.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,12 +1085,12 @@ public override void Reset()
10851085
protected override void OnActivate(bool sameCamera)
10861086
{
10871087
BrowseMode = BrowseForwards = BrowseBackwards = false;
1088-
1089-
var carPosition = Viewer.TrainCarOperationsViewerWindow.CarPosition;
1088+
var trainCars = GetCameraCars();
1089+
var TrainCarViewer = Viewer.TrainCarOperationsViewerWindow;
1090+
var carPosition = !(TrainCarViewer.CarPosition < trainCars.Count()) ? TrainCarViewer.CarPosition - 1 : TrainCarViewer.CarPosition;
10901091
var isDownCameraOutsideFront = UserInput.IsDown(UserCommand.CameraOutsideFront);
10911092
var isDownCameraOutsideRear = UserInput.IsDown(UserCommand.CameraOutsideRear);
1092-
var isVisibleTrainCarViewer = Viewer.TrainCarOperationsViewerWindow.Visible;
1093-
var trainCars = GetCameraCars();
1093+
var isVisibleTrainCarViewer = Viewer.TrainCarOperationsViewerWindow.Visible;
10941094

10951095
if (attachedCar == null || attachedCar.Train != Viewer.SelectedTrain || carPosition != oldCarPosition || isDownCameraOutsideFront || isDownCameraOutsideRear)
10961096
{
@@ -1101,8 +1101,8 @@ protected override void OnActivate(bool sameCamera)
11011101
SetCameraCar(GetCameraCars().First());
11021102
oldCarPosition = 0;
11031103
}
1104-
else if (isVisibleTrainCarViewer && carPosition >= 0 && carPosition < trainCars.Count())
1105-
{
1104+
else if (isVisibleTrainCarViewer && carPosition >= 0)
1105+
{
11061106
SetCameraCar(trainCars[carPosition]);
11071107
oldCarPosition = carPosition;
11081108
}
@@ -1121,7 +1121,7 @@ protected override void OnActivate(bool sameCamera)
11211121
SetCameraCar(GetCameraCars().Last());
11221122
oldCarPosition = 0;
11231123
}
1124-
else if (isVisibleTrainCarViewer && carPosition >= 0 && carPosition < trainCars.Count())
1124+
else if (isVisibleTrainCarViewer && carPosition >= 0)
11251125
{
11261126
SetCameraCar(trainCars[carPosition]);
11271127
oldCarPosition = carPosition;

Source/RunActivity/Viewer3D/Popups/TrainCarOperationsViewerWindow.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,16 @@ public class TrainCarOperationsViewerWindow : Window
8383
public int locoRowCount;
8484
public int rowsCount;
8585
const int SymbolWidth = 32;
86-
8786
public static bool FontChanged;
8887
public static bool FontToBold;
8988
public int windowHeight { get; set; } //required by TrainCarWindow
90-
89+
9190
public int CarPosition
9291
{
9392
set;
9493
get;
9594
}
96-
public int YPosition
95+
public int NewCarPosition
9796
{
9897
set;
9998
get;
@@ -113,6 +112,11 @@ public bool RearBrakeHoseChanged
113112
set;
114113
get;
115114
}
115+
public bool CouplerChanged
116+
{
117+
set;
118+
get;
119+
} = false;
116120
public struct ListLabel
117121
{
118122
public string CarID;
@@ -124,7 +128,7 @@ public struct ListLabel
124128
int LastPlayerTrainCars;
125129
bool LastPlayerLocomotiveFlippedState;
126130
int carPosition;
127-
bool couplerFront = false;
131+
128132
public TrainCarOperationsViewerWindow(WindowManager owner)
129133
: 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"))
130134
{
@@ -365,13 +369,13 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
365369
var carOperations = Owner.Viewer.CarOperationsWindow;
366370
var trainCarOperations = Owner.Viewer.TrainCarOperationsWindow;
367371

368-
if (couplerFront || PlayerTrain != Owner.Viewer.PlayerTrain || Owner.Viewer.PlayerTrain.Cars.Count != LastPlayerTrainCars || (Owner.Viewer.PlayerLocomotive != null &&
372+
if (CouplerChanged || PlayerTrain != Owner.Viewer.PlayerTrain || Owner.Viewer.PlayerTrain.Cars.Count != LastPlayerTrainCars || (Owner.Viewer.PlayerLocomotive != null &&
369373
LastPlayerLocomotiveFlippedState != Owner.Viewer.PlayerLocomotive.Flipped))
370374
{
371-
couplerFront = false;
375+
CouplerChanged = false;
372376
PlayerTrain = Owner.Viewer.PlayerTrain;
373377

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

376380
LastPlayerTrainCars = Owner.Viewer.PlayerTrain.Cars.Count;
377381
CarPosition = CarPosition >= LastPlayerTrainCars? LastPlayerTrainCars - 1: CarPosition;
@@ -385,9 +389,12 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
385389
bool isElectricDieselLocomotive = (trainCar is MSTSElectricLocomotive) || (trainCar is MSTSDieselLocomotive);
386390

387391
if (carPosition != CarPosition || TrainCarOperationsChanged || carOperations.CarOperationChanged
388-
|| trainCarOperations.modifiedSetting || carOperations.RearBrakeHoseChanged || carOperations.FrontBrakeHoseChanged)
392+
|| trainCarOperations.carIdClicked || carOperations.RearBrakeHoseChanged || carOperations.FrontBrakeHoseChanged)
389393
{
390-
if (carPosition != CarPosition)
394+
// Updates CarPosition
395+
CarPosition = CouplerChanged ? NewCarPosition : CarPosition;
396+
397+
if (carPosition != CarPosition || (trainCarOperations.carIdClicked && CarPosition == 0))
391398
{
392399
Owner.Viewer.FrontCamera.Activate();
393400
}
@@ -459,7 +466,8 @@ void TrainCarOperationsCouplerFront_Click(Control arg1, Point arg2)
459466
else
460467
{
461468
new UncoupleCommand(Viewer.Log, CarPosition - 1);
462-
TrainCarViewer.couplerFront = true;
469+
TrainCarViewer.CouplerChanged = true;
470+
TrainCarViewer.NewCarPosition = CarPosition - 1;
463471
if (Viewer.CarOperationsWindow.CarPosition > CarPosition - 1)
464472
Viewer.CarOperationsWindow.Visible = false;
465473
}

Source/RunActivity/Viewer3D/Popups/TrainCarOperationsWindow.cs

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public class TrainCarOperationsWindow : Window
117117
public bool updatingPowerSupply = false;
118118

119119
public bool warningEnabled = false;
120-
120+
public bool carIdClicked = false;
121121
public bool modifiedSetting
122122
{
123123
set;
@@ -440,29 +440,21 @@ public void topCarPositionVisible()
440440
{ // Allows to find the last carposition, visible at the window bottom.
441441
if ((!lastRowVisible && labelTop >= 0) || labelTop > DisplaySizeY)
442442
{
443-
if (DisplaySizeY > desiredHeight)
444-
{
445-
lastRowVisible = true;
446-
carPositionVisible = rowsCount;
447-
oldPositionHeight = vbox.Position.Height;
448-
}
449-
else
443+
for (int carPosition = 0; carPosition < rowsCount; carPosition++)
450444
{
451-
for (int carPosition = 0; carPosition < rowsCount; carPosition++)
445+
var labelTop = carPosition * rowHeight;
446+
if (labelTop > vbox.Position.Height - Owner.TextFontDefault.Height)
452447
{
453-
var labelTop = carPosition * rowHeight;
454-
if (labelTop > vbox.Position.Height - Owner.TextFontDefault.Height)
448+
if (!lastRowVisible && labelTop > 0)
455449
{
456-
if (!lastRowVisible && labelTop > 0)
457-
{
458-
lastRowVisible = true;
459-
carPositionVisible = carPosition - 1;
460-
oldPositionHeight = vbox.Position.Height;
461-
break;
462-
}
450+
lastRowVisible = true;
451+
carPositionVisible = carPosition - 1;
452+
oldPositionHeight = vbox.Position.Height;
453+
var carid = PlayerTrain.Cars[carPositionVisible].CarID;
454+
break;
463455
}
464456
}
465-
}
457+
}
466458
}
467459
}
468460
public void localScrollLayout(int selectedCarPosition)
@@ -512,7 +504,7 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
512504
trainCarViewer.TrainCarOperationsChanged = !trainCarViewer.Visible && trainCarViewer.TrainCarOperationsChanged ? false : trainCarViewer.TrainCarOperationsChanged;
513505

514506
currentDisplaySizeY = DisplaySizeY;
515-
if (Owner.Viewer.DisplaySize.Y != DisplaySizeY || modifiedSetting)
507+
if (Owner.Viewer.DisplaySize.Y != DisplaySizeY || modifiedSetting || trainCarViewer.CouplerChanged)
516508
{
517509
lastRowVisible = false;
518510
supplyStatusChanged = false;
@@ -568,13 +560,14 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
568560
}
569561
}
570562
}
571-
if (trainCarViewer.TrainCarOperationsChanged || trainCarViewer.RearBrakeHoseChanged
572-
|| trainCarViewer.FrontBrakeHoseChanged || modifiedSetting || carOperations.CarOperationChanged)
563+
if (trainCarViewer.TrainCarOperationsChanged || trainCarViewer.TrainCarOperationsChanged || trainCarViewer.RearBrakeHoseChanged
564+
|| trainCarViewer.FrontBrakeHoseChanged || modifiedSetting || carIdClicked || carOperations.CarOperationChanged)
573565
{
574566
Layout();
575567
localScrollLayout(selectedCarPosition);
576568
updateLayoutSize();
577569
modifiedSetting = false;
570+
carIdClicked = false;
578571
// Avoids bug
579572
trainCarViewer.TrainCarOperationsChanged = warningEnabled;
580573
carOperations.CarOperationChanged = carOperations.Visible && carOperations.CarOperationChanged;
@@ -613,7 +606,17 @@ public buttonArrowRight(int x, int y, int size, Viewer viewer, int carPosition)
613606
TrainCarViewer = Viewer.TrainCarOperationsViewerWindow;
614607
CarPosition = carPosition;
615608

616-
Texture = TrainCarViewer.Visible && TrainCarViewer.CarPosition == CarPosition ? Viewer.TrainCarOperationsWindow.allSymbolsMode ? ArrowRight : ArrowLeft : Empty;
609+
// Coupler changed requires to modify the arrow position
610+
var trainCarViewerCarPosition = TrainCarViewer.CouplerChanged ? TrainCarViewer.NewCarPosition : TrainCarViewer.CarPosition;
611+
if (TrainCarViewer.CouplerChanged && trainCarViewerCarPosition == CarPosition)
612+
{
613+
Texture = TrainCarViewer.Visible ? Viewer.TrainCarOperationsWindow.allSymbolsMode ? ArrowRight : ArrowLeft : Empty;
614+
Viewer.TrainCarOperationsWindow.carIdClicked = true;
615+
TrainCarViewer.CarPosition = trainCarViewerCarPosition;
616+
}
617+
else
618+
Texture = TrainCarViewer.Visible && trainCarViewerCarPosition == CarPosition? Viewer.TrainCarOperationsWindow.allSymbolsMode ? ArrowRight : ArrowLeft : Empty;
619+
617620
Source = new Rectangle(0, 0, size, size);
618621
Click += new Action<Control, Point>(buttonArrowRight_Click);
619622
}
@@ -639,7 +642,17 @@ public buttonArrowLeft(int x, int y, int size, Viewer viewer, int carPosition)
639642
TrainCarViewer = Viewer.TrainCarOperationsViewerWindow;
640643
CarPosition = carPosition;
641644
Texture = Empty;
642-
Texture = TrainCarViewer.CarPosition == CarPosition ? ArrowLeft : Empty;
645+
// Coupler changed requires to modify arrow position
646+
var trainCarViewerCarPosition = TrainCarViewer.CouplerChanged ? TrainCarViewer.NewCarPosition : TrainCarViewer.CarPosition;
647+
if (TrainCarViewer.CouplerChanged && trainCarViewerCarPosition == CarPosition)
648+
{
649+
Texture = trainCarViewerCarPosition == CarPosition ? ArrowLeft : Empty;
650+
Viewer.TrainCarOperationsWindow.carIdClicked = true;
651+
TrainCarViewer.CarPosition = trainCarViewerCarPosition;
652+
}
653+
else
654+
Texture = trainCarViewerCarPosition == CarPosition ? ArrowLeft : Empty;
655+
643656
Source = new Rectangle(0, 0, size, size);
644657
Click += new Action<Control, Point>(buttonArrowLeft_Click);
645658
}
@@ -700,10 +713,9 @@ public void buttonLabel_Click(Control arg1, Point arg2)
700713
Control control = arg1;
701714

702715
TrainCar.carLabelText = Text;
703-
TrainCarViewer.YPosition = control.Position.Y;
704716
TrainCarViewer.CarPosition = CarPosition;
705717
TrainCarViewer.Visible = true;
706-
TrainCar.modifiedSetting = true;
718+
TrainCar.carIdClicked = true;
707719

708720
// required by localScrollLayout()
709721
TrainCar.selectedCarPosition = CarPosition;

Source/RunActivity/Viewer3D/Viewer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ internal void Initialize()
494494
SwitchWindow = new SwitchWindow(WindowManager);
495495
TrainOperationsWindow = new TrainOperationsWindow(WindowManager);
496496
TrainCarOperationsWindow = new TrainCarOperationsWindow(WindowManager);
497-
TrainCarOperationsViewerWindow = new TrainCarOperationsViewerWindow(WindowManager); MultiPlayerWindow = new MultiPlayerWindow(WindowManager);
497+
TrainCarOperationsViewerWindow = new TrainCarOperationsViewerWindow(WindowManager);
498498
MultiPlayerWindow = new MultiPlayerWindow(WindowManager);
499499
CarOperationsWindow = new CarOperationsWindow(WindowManager);
500500
TrainDpuWindow = new TrainDpuWindow(WindowManager);

0 commit comments

Comments
 (0)