Skip to content

Commit 8c8c938

Browse files
added webpage with Train Car Operations
1 parent d8a1c4d commit 8c8c938

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1403
-5
lines changed

Source/RunActivity/Viewer3D/Cameras.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,18 +1066,18 @@ protected override void OnActivate(bool sameCamera)
10661066
var carPosition = !(TrainCarViewer.CarPosition < trainCars.Count()) ? TrainCarViewer.CarPosition - 1 : TrainCarViewer.CarPosition;
10671067
var isDownCameraOutsideFront = UserInput.IsDown(UserCommand.CameraOutsideFront);
10681068
var isDownCameraOutsideRear = UserInput.IsDown(UserCommand.CameraOutsideRear);
1069-
var isVisibleTrainCarViewer = Viewer.TrainCarOperationsViewerWindow.Visible;
1069+
var isVisibleTrainCarViewerOrWebpage = Viewer.TrainCarOperationsViewerWindow.Visible || (Viewer.TrainCarOperationsWebpage.TrainCarSelected);
10701070

10711071
if (attachedCar == null || attachedCar.Train != Viewer.SelectedTrain || carPosition != oldCarPosition || isDownCameraOutsideFront || isDownCameraOutsideRear)
10721072
{
10731073
if (Front)
10741074
{
1075-
if (!isVisibleTrainCarViewer && isDownCameraOutsideFront)
1075+
if (!isVisibleTrainCarViewerOrWebpage && isDownCameraOutsideFront)
10761076
{
10771077
SetCameraCar(GetCameraCars().First());
10781078
oldCarPosition = 0;
10791079
}
1080-
else if (isVisibleTrainCarViewer && carPosition >= 0)
1080+
else if (isVisibleTrainCarViewerOrWebpage && carPosition >= 0)
10811081
{
10821082
SetCameraCar(trainCars[carPosition]);
10831083
oldCarPosition = carPosition;
@@ -1092,12 +1092,12 @@ protected override void OnActivate(bool sameCamera)
10921092
}
10931093
else
10941094
{
1095-
if (!isVisibleTrainCarViewer && isDownCameraOutsideRear)
1095+
if (!isVisibleTrainCarViewerOrWebpage && isDownCameraOutsideRear)
10961096
{
10971097
SetCameraCar(GetCameraCars().Last());
10981098
oldCarPosition = 0;
10991099
}
1100-
else if (isVisibleTrainCarViewer && carPosition >= 0)
1100+
else if (isVisibleTrainCarViewerOrWebpage && carPosition >= 0)
11011101
{
11021102
SetCameraCar(trainCars[carPosition]);
11031103
oldCarPosition = carPosition;

Source/RunActivity/Viewer3D/Viewer.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
using Orts.Viewer3D.Processes;
4141
using Orts.Viewer3D.RollingStock;
4242
using Orts.Viewer3D.WebServices.SwitchPanel;
43+
using Orts.Viewer3D.WebServices;
4344
using ORTS.Common;
4445
using ORTS.Common.Input;
4546
using ORTS.Scripting.Api;
@@ -95,6 +96,7 @@ public class Viewer
9596
public TrainOperationsWindow TrainOperationsWindow { get; private set; } // F9 window
9697
public TrainCarOperationsWindow TrainCarOperationsWindow { get; private set; } // Alt-F9 window
9798
public TrainCarOperationsViewerWindow TrainCarOperationsViewerWindow { get; private set; } // From TrainCarOperationWindow
99+
public TrainCarOperationsWebpage TrainCarOperationsWebpage { get; set; }
98100
public CarOperationsWindow CarOperationsWindow { get; private set; } // F9 sub-window for car operations
99101
public TrainDpuWindow TrainDpuWindow { get; private set; } // Shift + F9 train distributed power window
100102
public NextStationWindow NextStationWindow { get; private set; } // F10 window
@@ -870,6 +872,20 @@ public void Update(RenderFrame frame, float elapsedRealTime)
870872
WindowManager.PrepareFrame(frame, elapsedTime);
871873

872874
SwitchPanelModule.SendSwitchPanelIfChanged();
875+
876+
try
877+
{
878+
if ((PlayerTrain != null) && (TrainCarOperationsWebpage != null))
879+
{
880+
TrainCarOperationsWebpage.handleReceiveAndSend();
881+
}
882+
}
883+
catch (Exception error)
884+
{
885+
// some timing error causes an exception sometimes
886+
// just silently ignore but log the exception
887+
Trace.TraceWarning(error.ToString());
888+
}
873889
}
874890

875891
private void LoadDefectCarSound(TrainCar car, string filename)

0 commit comments

Comments
 (0)