Skip to content

Commit 3b18c48

Browse files
committed
Train Forces popup Window.
New window that shows the coupler force, derail force, and brake force for each car in a bar graph. Minor changes in existing code to add conversions and access to member variables. This is a squash-merge from the prototype branch, train-forces-popup-v1.
1 parent 273f2ef commit 3b18c48

File tree

9 files changed

+450
-0
lines changed

9 files changed

+450
-0
lines changed

Source/Orts.Common/Conversions.cs

+7
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,13 @@ public static string FormatForce(float forceN, bool isMetric)
767767
return String.Format(CultureInfo.CurrentCulture, kilo ? "{0:F1} {1}" : "{0:F0} {1}", force, unit);
768768
}
769769

770+
public static string FormatLargeForce(float forceN, bool isMetric)
771+
{
772+
var force = isMetric ? forceN : N.ToLbf(forceN);
773+
var unit = isMetric ? kN : klbf;
774+
return String.Format(CultureInfo.CurrentCulture, "{0:F1} {1}", force * 1e-3f, unit);
775+
}
776+
770777
public static string FormatTemperature(float temperatureC, bool isMetric, bool isDelta)
771778
{
772779
var temperature = isMetric ? temperatureC : isDelta ? C.ToDeltaF(temperatureC) : C.ToF(temperatureC);

Source/Orts.Common/Input/UserCommand.cs

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public enum UserCommand
6464
[GetString("Display Train Car Operations Window")] DisplayTrainCarOperationsWindow,
6565
[GetString("Display Train Dpu Window")] DisplayTrainDpuWindow,
6666
[GetString("Display Next Station Window")] DisplayNextStationWindow,
67+
[GetString("Display Train Forces Window")] DisplayTrainForcesWindow,
6768
[GetString("Display Compass Window")] DisplayCompassWindow,
6869
[GetString("Display Train List Window")] DisplayTrainListWindow,
6970
[GetString("Display EOT List Window")] DisplayEOTListWindow,

Source/Orts.Settings/InputSettings.cs

+1
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ static void InitializeCommands(UserCommandInput[] Commands)
516516
Commands[(int)UserCommand.DisplayTrainOperationsWindow] = new UserCommandKeyInput(0x43, KeyModifiers.Control | KeyModifiers.Alt);
517517
Commands[(int)UserCommand.DisplayTrainDpuWindow] = new UserCommandKeyInput(0x43, KeyModifiers.Shift);
518518
Commands[(int)UserCommand.DisplayEOTListWindow] = new UserCommandKeyInput(0x43, KeyModifiers.Control);
519+
Commands[(int)UserCommand.DisplayTrainForcesWindow] = new UserCommandKeyInput(0x41, KeyModifiers.Alt);
519520
Commands[(int)UserCommand.DisplayControlRectangle] = new UserCommandKeyInput(0x3F, KeyModifiers.Control);
520521

521522
Commands[(int)UserCommand.GameAutopilotMode] = new UserCommandKeyInput(0x1E, KeyModifiers.Alt);

Source/Orts.Settings/UserSettings.cs

+2
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ public string DirectXFeatureLevel
396396
public int[] WindowPosition_ComposeMessage { get; set; }
397397
[Default(new[] { 100, 0 })]
398398
public int[] WindowPosition_TrainList { get; set; }
399+
[Default(new[] { 50, 50 })]
400+
public int[] WindowPosition_TrainForces { get; set; }
399401
[Default("")]
400402
public string LastViewNotificationDate { get; set; }
401403

Source/Orts.Simulation/Simulation/RollingStocks/TrainCar.cs

+4
Original file line numberDiff line numberDiff line change
@@ -3457,6 +3457,10 @@ public LatLonDirection GetLatLonDirection()
34573457

34583458
return new LatLonDirection(latLon, directionDeg); ;
34593459
}
3460+
3461+
public int GetWagonNumAxles() { return WagonNumAxles; }
3462+
3463+
public float GetGravitationalAccelerationMpS2() { return GravitationalAccelerationMpS2; }
34603464
}
34613465

34623466
public class WheelAxle : IComparer<WheelAxle>
700 Bytes
Loading

Source/RunActivity/RunActivity.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<Link>Native\X64\OpenAL32.dll</Link>
4343
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4444
</Content>
45+
<Content Include="Content\TrainForcesSprites.png">
46+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
47+
</Content>
4548
<Content Include="Content\blank.bmp">
4649
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4750
</Content>

Source/RunActivity/Viewer3D/Popups/TrainForcesWindow.cs

+429
Large diffs are not rendered by default.

Source/RunActivity/Viewer3D/Viewer.cs

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public class Viewer
102102
public CarOperationsWindow CarOperationsWindow { get; private set; } // F9 sub-window for car operations
103103
public TrainDpuWindow TrainDpuWindow { get; private set; } // Shift + F9 train distributed power window
104104
public NextStationWindow NextStationWindow { get; private set; } // F10 window
105+
public TrainForcesWindow TrainForcesWindow { get; private set; } // Alt-F7 window
105106
public CompassWindow CompassWindow { get; private set; } // 0 window
106107
public TracksDebugWindow TracksDebugWindow { get; private set; } // Control-Alt-F6
107108
public SignallingDebugWindow SignallingDebugWindow { get; private set; } // Control-Alt-F11 window
@@ -510,6 +511,7 @@ internal void Initialize()
510511
CarOperationsWindow = new CarOperationsWindow(WindowManager);
511512
TrainDpuWindow = new TrainDpuWindow(WindowManager);
512513
NextStationWindow = new NextStationWindow(WindowManager);
514+
TrainForcesWindow = new TrainForcesWindow(WindowManager);
513515
CompassWindow = new CompassWindow(WindowManager);
514516
TracksDebugWindow = new TracksDebugWindow(WindowManager);
515517
SignallingDebugWindow = new SignallingDebugWindow(WindowManager);
@@ -1057,6 +1059,7 @@ void HandleUserInput(ElapsedTime elapsedTime)
10571059

10581060
if (UserInput.IsPressed(UserCommand.DisplayNextStationWindow)) if (UserInput.IsDown(UserCommand.DisplayNextWindowTab)) NextStationWindow.TabAction(); else NextStationWindow.Visible = !NextStationWindow.Visible;
10591061
if (UserInput.IsPressed(UserCommand.DisplayCompassWindow)) if (UserInput.IsDown(UserCommand.DisplayNextWindowTab)) CompassWindow.TabAction(); else CompassWindow.Visible = !CompassWindow.Visible;
1062+
if (UserInput.IsPressed(UserCommand.DisplayTrainForcesWindow)) if (UserInput.IsDown(UserCommand.DisplayNextWindowTab)) TrainForcesWindow.TabAction(); else TrainForcesWindow.Visible = !TrainForcesWindow.Visible;
10601063
if (UserInput.IsPressed(UserCommand.DebugTracks)) if (UserInput.IsDown(UserCommand.DisplayNextWindowTab)) TracksDebugWindow.TabAction(); else TracksDebugWindow.Visible = !TracksDebugWindow.Visible;
10611064
if (UserInput.IsPressed(UserCommand.DebugSignalling)) if (UserInput.IsDown(UserCommand.DisplayNextWindowTab)) SignallingDebugWindow.TabAction(); else SignallingDebugWindow.Visible = !SignallingDebugWindow.Visible;
10621065
if (UserInput.IsPressed(UserCommand.DisplayTrainListWindow)) TrainListWindow.Visible = !TrainListWindow.Visible;

0 commit comments

Comments
 (0)