Skip to content

Commit

Permalink
Automatic merge of T1.5.1-684-gc6e0de1c4 and 10 pull requests
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
openrails-bot committed Oct 30, 2023
12 parents 2cecf8c + c6e0de1 + c59c788 + d00beb9 + 67014b7 + f8dbeab + 43bf33e + f92de76 + 43f6ee9 + e458797 + edcc2dd + c81447b commit eecf94b
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 44 deletions.
14 changes: 7 additions & 7 deletions Source/RunActivity/Viewer3D/Cameras.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,12 +1085,12 @@ public override void Reset()
protected override void OnActivate(bool sameCamera)
{
BrowseMode = BrowseForwards = BrowseBackwards = false;

var carPosition = Viewer.TrainCarOperationsViewerWindow.CarPosition;
var trainCars = GetCameraCars();
var TrainCarViewer = Viewer.TrainCarOperationsViewerWindow;
var carPosition = !(TrainCarViewer.CarPosition < trainCars.Count()) ? TrainCarViewer.CarPosition - 1 : TrainCarViewer.CarPosition;
var isDownCameraOutsideFront = UserInput.IsDown(UserCommand.CameraOutsideFront);
var isDownCameraOutsideRear = UserInput.IsDown(UserCommand.CameraOutsideRear);
var isVisibleTrainCarViewer = Viewer.TrainCarOperationsViewerWindow.Visible;
var trainCars = GetCameraCars();
var isVisibleTrainCarViewer = Viewer.TrainCarOperationsViewerWindow.Visible;

if (attachedCar == null || attachedCar.Train != Viewer.SelectedTrain || carPosition != oldCarPosition || isDownCameraOutsideFront || isDownCameraOutsideRear)
{
Expand All @@ -1101,8 +1101,8 @@ protected override void OnActivate(bool sameCamera)
SetCameraCar(GetCameraCars().First());
oldCarPosition = 0;
}
else if (isVisibleTrainCarViewer && carPosition >= 0 && carPosition < trainCars.Count())
{
else if (isVisibleTrainCarViewer && carPosition >= 0)
{
SetCameraCar(trainCars[carPosition]);
oldCarPosition = carPosition;
}
Expand All @@ -1121,7 +1121,7 @@ protected override void OnActivate(bool sameCamera)
SetCameraCar(GetCameraCars().Last());
oldCarPosition = 0;
}
else if (isVisibleTrainCarViewer && carPosition >= 0 && carPosition < trainCars.Count())
else if (isVisibleTrainCarViewer && carPosition >= 0)
{
SetCameraCar(trainCars[carPosition]);
oldCarPosition = carPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,16 @@ public class TrainCarOperationsViewerWindow : Window
public int locoRowCount;
public int rowsCount;
const int SymbolWidth = 32;

public static bool FontChanged;
public static bool FontToBold;
public int windowHeight { get; set; } //required by TrainCarWindow

public int CarPosition
{
set;
get;
}
public int YPosition
public int NewCarPosition
{
set;
get;
Expand All @@ -113,6 +112,11 @@ public bool RearBrakeHoseChanged
set;
get;
}
public bool CouplerChanged
{
set;
get;
} = false;
public struct ListLabel
{
public string CarID;
Expand All @@ -124,7 +128,7 @@ public struct ListLabel
int LastPlayerTrainCars;
bool LastPlayerLocomotiveFlippedState;
int carPosition;
bool couplerFront = false;

public TrainCarOperationsViewerWindow(WindowManager owner)
: 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"))
{
Expand Down Expand Up @@ -365,13 +369,13 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
var carOperations = Owner.Viewer.CarOperationsWindow;
var trainCarOperations = Owner.Viewer.TrainCarOperationsWindow;

if (couplerFront || PlayerTrain != Owner.Viewer.PlayerTrain || Owner.Viewer.PlayerTrain.Cars.Count != LastPlayerTrainCars || (Owner.Viewer.PlayerLocomotive != null &&
if (CouplerChanged || PlayerTrain != Owner.Viewer.PlayerTrain || Owner.Viewer.PlayerTrain.Cars.Count != LastPlayerTrainCars || (Owner.Viewer.PlayerLocomotive != null &&
LastPlayerLocomotiveFlippedState != Owner.Viewer.PlayerLocomotive.Flipped))
{
couplerFront = false;
CouplerChanged = false;
PlayerTrain = Owner.Viewer.PlayerTrain;

if (LastPlayerTrainCars != Owner.Viewer.PlayerTrain.Cars.Count){ Visible = false; }
//if (LastPlayerTrainCars != Owner.Viewer.PlayerTrain.Cars.Count){ Visible = false; }

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

if (carPosition != CarPosition || TrainCarOperationsChanged || carOperations.CarOperationChanged
|| trainCarOperations.modifiedSetting || carOperations.RearBrakeHoseChanged || carOperations.FrontBrakeHoseChanged)
|| trainCarOperations.carIdClicked || carOperations.RearBrakeHoseChanged || carOperations.FrontBrakeHoseChanged)
{
if (carPosition != CarPosition)
// Updates CarPosition
CarPosition = CouplerChanged ? NewCarPosition : CarPosition;

if (carPosition != CarPosition || (trainCarOperations.carIdClicked && CarPosition == 0))
{
Owner.Viewer.FrontCamera.Activate();
}
Expand Down Expand Up @@ -459,7 +466,8 @@ void TrainCarOperationsCouplerFront_Click(Control arg1, Point arg2)
else
{
new UncoupleCommand(Viewer.Log, CarPosition - 1);
TrainCarViewer.couplerFront = true;
TrainCarViewer.CouplerChanged = true;
TrainCarViewer.NewCarPosition = CarPosition - 1;
if (Viewer.CarOperationsWindow.CarPosition > CarPosition - 1)
Viewer.CarOperationsWindow.Visible = false;
}
Expand Down
64 changes: 38 additions & 26 deletions Source/RunActivity/Viewer3D/Popups/TrainCarOperationsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class TrainCarOperationsWindow : Window
public bool updatingPowerSupply = false;

public bool warningEnabled = false;

public bool carIdClicked = false;
public bool modifiedSetting
{
set;
Expand Down Expand Up @@ -440,29 +440,21 @@ public void topCarPositionVisible()
{ // Allows to find the last carposition, visible at the window bottom.
if ((!lastRowVisible && labelTop >= 0) || labelTop > DisplaySizeY)
{
if (DisplaySizeY > desiredHeight)
{
lastRowVisible = true;
carPositionVisible = rowsCount;
oldPositionHeight = vbox.Position.Height;
}
else
for (int carPosition = 0; carPosition < rowsCount; carPosition++)
{
for (int carPosition = 0; carPosition < rowsCount; carPosition++)
var labelTop = carPosition * rowHeight;
if (labelTop > vbox.Position.Height - Owner.TextFontDefault.Height)
{
var labelTop = carPosition * rowHeight;
if (labelTop > vbox.Position.Height - Owner.TextFontDefault.Height)
if (!lastRowVisible && labelTop > 0)
{
if (!lastRowVisible && labelTop > 0)
{
lastRowVisible = true;
carPositionVisible = carPosition - 1;
oldPositionHeight = vbox.Position.Height;
break;
}
lastRowVisible = true;
carPositionVisible = carPosition - 1;
oldPositionHeight = vbox.Position.Height;
var carid = PlayerTrain.Cars[carPositionVisible].CarID;
break;
}
}
}
}
}
}
public void localScrollLayout(int selectedCarPosition)
Expand Down Expand Up @@ -512,7 +504,7 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
trainCarViewer.TrainCarOperationsChanged = !trainCarViewer.Visible && trainCarViewer.TrainCarOperationsChanged ? false : trainCarViewer.TrainCarOperationsChanged;

currentDisplaySizeY = DisplaySizeY;
if (Owner.Viewer.DisplaySize.Y != DisplaySizeY || modifiedSetting)
if (Owner.Viewer.DisplaySize.Y != DisplaySizeY || modifiedSetting || trainCarViewer.CouplerChanged)
{
lastRowVisible = false;
supplyStatusChanged = false;
Expand Down Expand Up @@ -568,13 +560,14 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull)
}
}
}
if (trainCarViewer.TrainCarOperationsChanged || trainCarViewer.RearBrakeHoseChanged
|| trainCarViewer.FrontBrakeHoseChanged || modifiedSetting || carOperations.CarOperationChanged)
if (trainCarViewer.TrainCarOperationsChanged || trainCarViewer.TrainCarOperationsChanged || trainCarViewer.RearBrakeHoseChanged
|| trainCarViewer.FrontBrakeHoseChanged || modifiedSetting || carIdClicked || carOperations.CarOperationChanged)
{
Layout();
localScrollLayout(selectedCarPosition);
updateLayoutSize();
modifiedSetting = false;
carIdClicked = false;
// Avoids bug
trainCarViewer.TrainCarOperationsChanged = warningEnabled;
carOperations.CarOperationChanged = carOperations.Visible && carOperations.CarOperationChanged;
Expand Down Expand Up @@ -613,7 +606,17 @@ public buttonArrowRight(int x, int y, int size, Viewer viewer, int carPosition)
TrainCarViewer = Viewer.TrainCarOperationsViewerWindow;
CarPosition = carPosition;

Texture = TrainCarViewer.Visible && TrainCarViewer.CarPosition == CarPosition ? Viewer.TrainCarOperationsWindow.allSymbolsMode ? ArrowRight : ArrowLeft : Empty;
// Coupler changed requires to modify the arrow position
var trainCarViewerCarPosition = TrainCarViewer.CouplerChanged ? TrainCarViewer.NewCarPosition : TrainCarViewer.CarPosition;
if (TrainCarViewer.CouplerChanged && trainCarViewerCarPosition == CarPosition)
{
Texture = TrainCarViewer.Visible ? Viewer.TrainCarOperationsWindow.allSymbolsMode ? ArrowRight : ArrowLeft : Empty;
Viewer.TrainCarOperationsWindow.carIdClicked = true;
TrainCarViewer.CarPosition = trainCarViewerCarPosition;
}
else
Texture = TrainCarViewer.Visible && trainCarViewerCarPosition == CarPosition? Viewer.TrainCarOperationsWindow.allSymbolsMode ? ArrowRight : ArrowLeft : Empty;

Source = new Rectangle(0, 0, size, size);
Click += new Action<Control, Point>(buttonArrowRight_Click);
}
Expand All @@ -639,7 +642,17 @@ public buttonArrowLeft(int x, int y, int size, Viewer viewer, int carPosition)
TrainCarViewer = Viewer.TrainCarOperationsViewerWindow;
CarPosition = carPosition;
Texture = Empty;
Texture = TrainCarViewer.CarPosition == CarPosition ? ArrowLeft : Empty;
// Coupler changed requires to modify arrow position
var trainCarViewerCarPosition = TrainCarViewer.CouplerChanged ? TrainCarViewer.NewCarPosition : TrainCarViewer.CarPosition;
if (TrainCarViewer.CouplerChanged && trainCarViewerCarPosition == CarPosition)
{
Texture = trainCarViewerCarPosition == CarPosition ? ArrowLeft : Empty;
Viewer.TrainCarOperationsWindow.carIdClicked = true;
TrainCarViewer.CarPosition = trainCarViewerCarPosition;
}
else
Texture = trainCarViewerCarPosition == CarPosition ? ArrowLeft : Empty;

Source = new Rectangle(0, 0, size, size);
Click += new Action<Control, Point>(buttonArrowLeft_Click);
}
Expand Down Expand Up @@ -700,10 +713,9 @@ public void buttonLabel_Click(Control arg1, Point arg2)
Control control = arg1;

TrainCar.carLabelText = Text;
TrainCarViewer.YPosition = control.Position.Y;
TrainCarViewer.CarPosition = CarPosition;
TrainCarViewer.Visible = true;
TrainCar.modifiedSetting = true;
TrainCar.carIdClicked = true;

// required by localScrollLayout()
TrainCar.selectedCarPosition = CarPosition;
Expand Down
2 changes: 1 addition & 1 deletion Source/RunActivity/Viewer3D/Viewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ internal void Initialize()
SwitchWindow = new SwitchWindow(WindowManager);
TrainOperationsWindow = new TrainOperationsWindow(WindowManager);
TrainCarOperationsWindow = new TrainCarOperationsWindow(WindowManager);
TrainCarOperationsViewerWindow = new TrainCarOperationsViewerWindow(WindowManager); MultiPlayerWindow = new MultiPlayerWindow(WindowManager);
TrainCarOperationsViewerWindow = new TrainCarOperationsViewerWindow(WindowManager);
MultiPlayerWindow = new MultiPlayerWindow(WindowManager);
CarOperationsWindow = new CarOperationsWindow(WindowManager);
TrainDpuWindow = new TrainDpuWindow(WindowManager);
Expand Down

0 comments on commit eecf94b

Please sign in to comment.