From 90255fba24519da2ce5909085869491797796cbe Mon Sep 17 00:00:00 2001 From: mbm-OR Date: Mon, 4 Dec 2023 11:03:57 +0100 Subject: [PATCH] Duplicates statements removed. --- Source/RunActivity/Viewer3D/Cameras.cs | 2 +- .../Popups/TrainCarOperationsViewerWindow.cs | 52 +++++++---------- .../Popups/TrainCarOperationsWindow.cs | 58 ++++++++----------- 3 files changed, 46 insertions(+), 66 deletions(-) diff --git a/Source/RunActivity/Viewer3D/Cameras.cs b/Source/RunActivity/Viewer3D/Cameras.cs index 9b9d0e04b7..ccabb95b6e 100644 --- a/Source/RunActivity/Viewer3D/Cameras.cs +++ b/Source/RunActivity/Viewer3D/Cameras.cs @@ -1066,7 +1066,7 @@ protected override void OnActivate(bool sameCamera) var carPosition = !(TrainCarViewer.CarPosition < trainCars.Count()) ? TrainCarViewer.CarPosition - 1 : TrainCarViewer.CarPosition; var isDownCameraOutsideFront = UserInput.IsDown(UserCommand.CameraOutsideFront); var isDownCameraOutsideRear = UserInput.IsDown(UserCommand.CameraOutsideRear); - var isVisibleTrainCarViewerOrWebpage = Viewer.TrainCarOperationsViewerWindow.Visible || (Viewer.TrainCarOperationsWebpage.TrainCarSelected); + var isVisibleTrainCarViewerOrWebpage = Viewer.TrainCarOperationsViewerWindow.Visible || (Viewer.TrainCarOperationsWebpage.TrainCarSelected); if (attachedCar == null || attachedCar.Train != Viewer.SelectedTrain || carPosition != oldCarPosition || isDownCameraOutsideFront || isDownCameraOutsideRear) { diff --git a/Source/RunActivity/Viewer3D/Popups/TrainCarOperationsViewerWindow.cs b/Source/RunActivity/Viewer3D/Popups/TrainCarOperationsViewerWindow.cs index 7c7ad15bf1..394ac56484 100644 --- a/Source/RunActivity/Viewer3D/Popups/TrainCarOperationsViewerWindow.cs +++ b/Source/RunActivity/Viewer3D/Popups/TrainCarOperationsViewerWindow.cs @@ -283,43 +283,33 @@ void AddSpace(bool full) { var car = PlayerTrain.Cars[CarPosition]; - //Front brake hose if (car != PlayerTrain.Cars.First()) - { - AddSpace(false); - line.Add(new buttonFrontBrakeHose(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - line.Add(new buttonFrontAngleCock(0, 0, textHeight, Owner.Viewer, car, CarPosition)); AddSpace(false); - line.Add(new buttonCouplerFront(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - } - else - { - line.Add(new buttonFrontBrakeHose(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - line.Add(new buttonFrontAngleCock(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - line.Add(new buttonCouplerFront(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - } - line.Add(new buttonLoco(0, 0, textHeight, Owner.Viewer, car)); + //Front brake hose + line.Add(new buttonFrontBrakeHose(0, 0, textHeight, Owner.Viewer, car, CarPosition)); + // Front angle cock + line.Add(new buttonFrontAngleCock(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - if (car != PlayerTrain.Cars.Last()) - { - line.Add(new buttonCouplerRear(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - AddSpace(false); - line.Add(new buttonRearAngleCock(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - line.Add(new buttonRearBrakeHose(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - AddSpace(false); - line.Add(new buttonHandBrake(0, 0, textHeight, Owner.Viewer, CarPosition)); - } - else - { - line.Add(new buttonCouplerRear(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - AddSpace(false); - line.Add(new buttonRearAngleCock(0, 0, textHeight, Owner.Viewer, car, CarPosition)); - line.Add(new buttonRearBrakeHose(0, 0, textHeight, Owner.Viewer, car, CarPosition)); + if (car != PlayerTrain.Cars.First()) AddSpace(false); - line.Add(new buttonHandBrake(0, 0, textHeight, Owner.Viewer, CarPosition)); - } + + // Front coupler + line.Add(new buttonCouplerFront(0, 0, textHeight, Owner.Viewer, car, CarPosition)); + // Loco label + line.Add(new buttonLoco(0, 0, textHeight, Owner.Viewer, car)); + // Rear coupler + line.Add(new buttonCouplerRear(0, 0, textHeight, Owner.Viewer, car, CarPosition)); + AddSpace(false); + // Rear angle cock + line.Add(new buttonRearAngleCock(0, 0, textHeight, Owner.Viewer, car, CarPosition)); + // Rear brake hose + line.Add(new buttonRearBrakeHose(0, 0, textHeight, Owner.Viewer, car, CarPosition)); + AddSpace(false); + // Handbrake + line.Add(new buttonHandBrake(0, 0, textHeight, Owner.Viewer, CarPosition)); AddSpace(false); + // Bleed off valve line.Add(new buttonBleedOffValve(0, 0, textHeight, Owner.Viewer, CarPosition)); AddSpace(false); diff --git a/Source/RunActivity/Viewer3D/Popups/TrainCarOperationsWindow.cs b/Source/RunActivity/Viewer3D/Popups/TrainCarOperationsWindow.cs index 67163d7d79..f49c48d1c7 100644 --- a/Source/RunActivity/Viewer3D/Popups/TrainCarOperationsWindow.cs +++ b/Source/RunActivity/Viewer3D/Popups/TrainCarOperationsWindow.cs @@ -337,7 +337,7 @@ void AddSpace() if (RefreshRestoredData) { // Restores brake hose RefreshRestoredData = false; - for (int i = 0; i < PlayerTrain.Cars.Count; i++) + for (var i = 0; i < PlayerTrain.Cars.Count; i++) { (PlayerTrain.Cars[i] as MSTSWagon).BrakeSystem.RearBrakeHoseConnected = RearBrakes[i]; } @@ -378,51 +378,41 @@ void AddSpace() if (car.BrakesStuck || ((car is MSTSLocomotive) && (car as MSTSLocomotive).PowerReduction > 0)) carLabel.Color = Color.Red; + // Left arrow line.Add(new buttonArrowLeft(0, 0, SymbolSize, Owner.Viewer, carPosition)); AddSpace(); - if (car != PlayerTrain.Cars.First()) - { - line.Add(new buttonFrontBrakeHose(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); - line.Add(new buttonFrontAngleCock(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); - AddSpace(); - line.Add(new buttonCouplerFront(0, 0, SymbolSize, Owner.Viewer, car)); - } - else - { - line.Add(new buttonFrontBrakeHose(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); - line.Add(new buttonFrontAngleCock(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); - AddSpace(); - line.Add(new buttonCouplerFront(0, 0, SymbolSize, Owner.Viewer, car)); - } + + // Front brake hose + line.Add(new buttonFrontBrakeHose(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); + // Front angle cock + line.Add(new buttonFrontAngleCock(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); + AddSpace(); + + // Front coupler + line.Add(new buttonCouplerFront(0, 0, SymbolSize, Owner.Viewer, car)); + // Car label line.Add(carLabel); - if (car != PlayerTrain.Cars.Last()) - { - line.Add(new buttonCouplerRear(0, 0, SymbolSize, Owner.Viewer, car)); - AddSpace(); - line.Add(new buttonRearAngleCock(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); - line.Add(new buttonRearBrakeHose(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); - } - else - { - line.Add(new buttonCouplerRear(0, 0, SymbolSize, Owner.Viewer, car)); - AddSpace(); - line.Add(new buttonRearAngleCock(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); - line.Add(new buttonRearBrakeHose(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); - } + // Rear coupler + line.Add(new buttonCouplerRear(0, 0, SymbolSize, Owner.Viewer, car)); + AddSpace(); + // Rear angle cock + line.Add(new buttonRearAngleCock(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); + // Rear brake hose + line.Add(new buttonRearBrakeHose(0, 0, SymbolSize, Owner.Viewer, car, carPosition)); AddSpace(); // Handbrake line.Add(new buttonHandBrake(0, 0, SymbolSize, Owner.Viewer, carPosition)); AddSpace(); - // Bleed Off Valve + // Bleed off valve line.Add(new buttonBleedOffValve(0, 0, SymbolSize, Owner.Viewer, carPosition)); AddSpace(); if (AllSymbolsMode)//Allows to display all symbols { - // Electric Train Supply Connection (ETS) + // Electric train supply connection (ETS) if (PlayerTrain.Cars.Count() > 1 && wagon.PowerSupply != null) { line.Add(new buttonToggleElectricTrainSupplyCable(0, 0, SymbolSize, Owner.Viewer, carPosition)); @@ -445,7 +435,7 @@ void AddSpace() } } } - + // Right arrow line.Add(new buttonArrowRight(0, 0, textHeight, Owner.Viewer, carPosition)); AddSpace(); AddSpace(); @@ -505,7 +495,7 @@ public void localScrollLayout(int selectedCarPosition) LocalScrollPosition = 0; - if (CarPositionVisible > 0 && selectedCarPosition >= CarPositionVisible)// && selectedCarPosition != currentCarPosition)// Not related with CarID + if (CarPositionVisible > 0 && selectedCarPosition >= CarPositionVisible)// Not related with CarID { Client = ControlLayoutScrollboxVertical.NewClient; var xcarPosition = CarPositionVisible; @@ -615,7 +605,7 @@ public override void PrepareFrame(ElapsedTime elapsedTime, bool updateFull) carOperations.CarOperationChanged = carOperations.Visible && carOperations.CarOperationChanged; } - if (CarPosition != trainCarViewer.CarPosition) + if (CarPosition != trainCarViewer.CarPosition && Owner.Viewer.TrainCarOperationsWebpage.Connections > 0) { // Required to scroll the main window from the web version UpdateTrainCarOperation = true;