Skip to content

Commit f325048

Browse files
committed
Merge branch 'master' into gltf2
2 parents 3539862 + 934fd3a commit f325048

File tree

385 files changed

+53908
-29074
lines changed

Some content is hidden

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

385 files changed

+53908
-29074
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,4 +365,5 @@ ASALocalRun/
365365
healthchecksdb
366366

367367
# Backup folder for Package Reference Convert tool in Visual Studio 2017
368-
MigrationBackup/
368+
MigrationBackup/
369+
/Source/RunActivity/Properties/launchSettings.json

.readthedocs.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Read the Docs configuration file for Sphinx projects
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
version: 2
5+
6+
build:
7+
os: ubuntu-22.04
8+
tools:
9+
python: "3.12"
10+
11+
python:
12+
install:
13+
- requirements: Source/Documentation/Manual/requirements.txt
14+
15+
sphinx:
16+
configuration: Source/Documentation/Manual/conf.py
17+
18+
formats:
19+
- htmlzip
20+
- pdf
21+
- epub

Docs/Architecture.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
# Open Rails Architecture
22

3-
This document will describe the overall structure of Open Rails and how we expect different areas of the program to work together.
3+
This document describes the overall structure of Open Rails and how we expect different areas of the program to work together.
4+
5+
## Player application model
6+
7+
The player application model describes the desired components and their relationships which make up Open Rails. Each of these will be formed from one or more libraries, as needed, and each library may contain distinct but critically linked subfunctions.
8+
9+
```mermaid
10+
flowchart TB
11+
Formats["Orts.Formats"]
12+
Game["Orts.Game"]
13+
Input["Orts.Input"]
14+
Multiplayer["Orts.Multiplayer"]
15+
Parsers["Orts.Parsers"]
16+
Player["Player"]
17+
Simulation["Orts.Simulation"]
18+
Sound["Orts.Sound"]
19+
UI["Orts.UI"]
20+
Viewer["Orts.Viewer"]
21+
Web["Orts.Web"]
22+
Player --- Game --- UI --- Viewer --- Simulation & Formats
23+
Player --- Input --- UI & Simulation
24+
Sound --- Simulation --- Formats & Multiplayer & Web
25+
Formats --- Parsers
26+
```
427

528
## Threading model
629

Docs/Contributing.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If you've got a feature suggestion for Open Rails, please report it in [our road
1818

1919
You are free to make any modifications to the Open Rails code that you like; that's how open source works. However, if you'd like your feature to be included in the official version, there is a process to ensure that the community agrees and to review the code for potential issues prior to inclusion.
2020

21-
In most cases, you can get started immediately with making the changes and creating a pull request. We do ask for some additional steps to be taken for some bugs and all new features, but they can come before or after the pull request. Please feel free to share ideas and proposals as pull requests!
21+
In most cases, you can get started immediately with making the changes and creating a pull request. We have _additional requirements_ for some bugs and all new features, but they can come before or after the pull request is created. Please feel free to share ideas and proposals as pull requests!
2222

2323
**Note:** You must fork the Open Rails repository before you start working on it. We do not allow you to push branches to the official repository.
2424

@@ -28,19 +28,25 @@ In most cases, you can get started immediately with making the changes and creat
2828

2929
If you'd like to improve the [documentation](./), [manual](../Source/Documentation/Manual), or [translations](../Source/Locales) you can get started immediately.
3030

31-
There are no requirements for the pull request.
31+
There are no additional requirements for the pull request.
3232

3333
### Contributed projects
3434

3535
If you'd like to improve the [contributed projects](../Source/Contrib) you can get started immediately.
3636

37-
There are no requirements for the pull request.
37+
There are no additional requirements for the pull request.
38+
39+
### Refactoring process
40+
41+
If you'd like to refactor the existing code you can get started immediately, but please have a look at our [architecture requirements](#architecture-requirements). We welcome architectural discussions on our [forum](http://www.elvastower.com/forums/index.php?/forum/256-developing-features/).
42+
43+
There are no additional requirements for the pull request.
3844

3945
### Bug process
4046

4147
If you'd like to fix a bug, you can get started immediately. If the fix turns out to be very small, you do not even need a bug report. Otherwise, you will need to make sure it has been reported on [our bug tracker on Launchpad](https://bugs.launchpad.net/or). If it has not, you can report the bug *and* fix it!
4248

43-
There are no requirements for creating the pull request.
49+
There are no additional requirements for _creating_ the pull request.
4450

4551
These things must be done in the required order:
4652

Source/ContentChecker/ContentChecker.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net472</TargetFramework>
3+
<TargetFramework Condition="'$(BuildDotNet)' == 'true'">net6-windows</TargetFramework>
4+
<TargetFramework Condition="'$(TargetFramework)' == ''">net472</TargetFramework>
45
<OutputType>Exe</OutputType>
5-
<UseWindowsForms>true</UseWindowsForms>
6-
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
76
<IsPublishable>False</IsPublishable>
87
<AssemblyTitle>Open Rails Content Checker</AssemblyTitle>
98
<Description>Open Rails Transport Simulator</Description>
@@ -13,7 +12,7 @@
1312
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
1413
</PropertyGroup>
1514
<ItemGroup>
16-
<ProjectReference Include="..\ORTS.Content\ORTS.Content.csproj" />
15+
<ProjectReference Include="..\Orts.Content\Orts.Content.csproj" />
1716
<ProjectReference Include="..\Orts.Formats.Msts\Orts.Formats.Msts.csproj" />
1817
<ProjectReference Include="..\Orts.Formats.OR\Orts.Formats.OR.csproj" />
1918
<ProjectReference Include="..\Orts.Parsers.Msts\Orts.Parsers.Msts.csproj" />

Source/ContentChecker/Loader.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
using System.Linq;
4444
using System.Text;
4545
using Microsoft.Xna.Framework.Graphics;
46-
using System.Windows.Forms;
4746

4847
namespace ContentChecker
4948
{
@@ -70,7 +69,7 @@ abstract class Loader
7069
/// <summary> The number of files that were actually loaded </summary>
7170
public int FilesLoaded { get; protected set; }
7271
/// <summary> The number of files that were not loaded but skipped </summary>
73-
public int FilesSkipped {get; protected set;}
72+
public int FilesSkipped { get; protected set; }
7473

7574
/// <summary> The action to take when an additonal file has been identified. This is intended to be set externally </summary>
7675
protected Action<string, Loader> AddAdditionalFileAction { get; set; }
@@ -158,17 +157,13 @@ protected static GraphicsDevice GetGraphicsDevice()
158157
{
159158
if (_graphicsDevice == null)
160159
{
161-
// We use a Windows.Forms Control instead of an xna GAME because it is much easier to use.
162-
var _c = new Control();
163-
164160
// Details probably do not matter too much
165161
PresentationParameters parameters = new PresentationParameters()
166162
{
167163
BackBufferWidth = 100,
168164
BackBufferHeight = 100,
169165
BackBufferFormat = SurfaceFormat.Color,
170166
//DepthStencilFormat = DepthFormat.Depth24,
171-
DeviceWindowHandle = _c.Handle,
172167
PresentationInterval = PresentInterval.Immediate,
173168
IsFullScreen = false,
174169
};

Source/ContentChecker/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,10 @@ static bool OptionsContain(string[] args, IEnumerable<string> optionNames) {
7777
/// </summary>
7878
static void ShowHelp()
7979
{
80-
var version = FileVersionInfo.GetVersionInfo(typeof(Program).Assembly.Location);
81-
Console.WriteLine("{0} {1}", version.FileDescription, VersionInfo.VersionOrBuild);
80+
Console.WriteLine("{0} {1}", ApplicationInfo.ApplicationName, VersionInfo.VersionOrBuild);
8281
Console.WriteLine();
8382
Console.WriteLine("Usage:");
84-
Console.WriteLine(" {0} [options] <FILE> [...]", Path.GetFileNameWithoutExtension(version.FileName));
83+
Console.WriteLine(" {0} [options] <FILE> [...]", Path.GetFileNameWithoutExtension(ApplicationInfo.ProcessFile));
8584
Console.WriteLine();
8685
Console.WriteLine("Arguments:");
8786
Console.WriteLine(" <FILE> Data files to check; may contain wildcards");

Source/Contrib/ActivityEditor/ActivityEditor/ActivityEditor.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net472</TargetFramework>
3+
<TargetFramework Condition="'$(BuildDotNet)' == 'true'">net6-windows</TargetFramework>
4+
<TargetFramework Condition="'$(TargetFramework)' == ''">net472</TargetFramework>
45
<OutputType>WinExe</OutputType>
56
<AssemblyName>Contrib.ActivityEditor</AssemblyName>
67
<ApplicationIcon>..\..\..\ORTS.ico</ApplicationIcon>
@@ -77,8 +78,8 @@
7778
<ProjectReference Include="..\..\..\Orts.Formats.Msts\Orts.Formats.Msts.csproj" />
7879
<ProjectReference Include="..\..\..\Orts.Formats.OR\Orts.Formats.OR.csproj" />
7980
<ProjectReference Include="..\..\..\Orts.Parsers.Msts\Orts.Parsers.Msts.csproj" />
80-
<ProjectReference Include="..\..\..\ORTS.Common\ORTS.Common.csproj" />
81-
<ProjectReference Include="..\..\..\ORTS.Settings\ORTS.Settings.csproj" />
81+
<ProjectReference Include="..\..\..\Orts.Common\Orts.Common.csproj" />
82+
<ProjectReference Include="..\..\..\Orts.Settings\Orts.Settings.csproj" />
8283
<ProjectReference Include="..\LibAE\LibAE.csproj" />
8384
</ItemGroup>
8485
<ItemGroup>

Source/Contrib/ActivityEditor/LibAE/LibAE.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net472</TargetFramework>
3+
<TargetFramework Condition="'$(BuildDotNet)' == 'true'">net6-windows</TargetFramework>
4+
<TargetFramework Condition="'$(TargetFramework)' == ''">net472</TargetFramework>
45
<OutputType>Library</OutputType>
56
<AssemblyName>Contrib.LibAE</AssemblyName>
67
<IsPublishable>False</IsPublishable>
@@ -25,9 +26,9 @@
2526
<ProjectReference Include="..\..\..\Orts.Formats.Msts\Orts.Formats.Msts.csproj" />
2627
<ProjectReference Include="..\..\..\Orts.Formats.OR\Orts.Formats.OR.csproj" />
2728
<ProjectReference Include="..\..\..\Orts.Parsers.Msts\Orts.Parsers.Msts.csproj" />
28-
<ProjectReference Include="..\..\..\ORTS.Common\ORTS.Common.csproj" />
29-
<ProjectReference Include="..\..\..\ORTS.Content\ORTS.Content.csproj" />
30-
<ProjectReference Include="..\..\..\ORTS.Settings\ORTS.Settings.csproj" />
29+
<ProjectReference Include="..\..\..\Orts.Common\Orts.Common.csproj" />
30+
<ProjectReference Include="..\..\..\Orts.Content\Orts.Content.csproj" />
31+
<ProjectReference Include="..\..\..\Orts.Settings\Orts.Settings.csproj" />
3132
</ItemGroup>
3233
<ItemGroup>
3334
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.355802">

Source/Contrib/ContentManager/ContentInfo.cs

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@
2727
using System.Runtime.Serialization.Formatters.Binary;
2828
using System.Text;
2929
using Path = ORTS.ContentManager.Models.Path;
30+
using ORTS.Common;
3031

3132
namespace ORTS.ContentManager
3233
{
3334
public static class ContentInfo
3435
{
36+
// will be set from ConntentManagerGUI constructor
37+
public static bool IsMetric = false;
38+
public static bool IsUK = false;
39+
public static bool IsImperialBHP = false; // using default; seems only used for steam locos
40+
public static bool IsImperialBTUpS = false; // using default; seems only be used for steam locos
41+
3542
public static string GetText(Content content)
3643
{
3744
var details = new StringBuilder();
@@ -179,16 +186,39 @@ public static string GetText(Content content)
179186
{
180187
var data = new Consist(content);
181188
details.AppendFormat("Name:\t{1}{0}", Environment.NewLine, data.Name);
182-
details.AppendFormat("Car ID:\tDirection:\tName:\t{0}", Environment.NewLine);
189+
details.AppendFormat("NumEngines:\t{1}{0}", Environment.NewLine, data.NumEngines);
190+
details.AppendFormat("NumCars:\t{1}{0}", Environment.NewLine, data.NumCars);
191+
details.AppendFormat("MaxSpeed:\t{1}{0}", Environment.NewLine, FormatStrings.FormatSpeedLimit(data.MaxSpeedMps, IsMetric));
192+
details.AppendFormat("Weight:\t{1}{0}", Environment.NewLine, FormatStrings.FormatLargeMass(data.MassKG, IsMetric, IsUK));
193+
details.AppendFormat("Length:\t{1}{0}", Environment.NewLine, FormatStrings.FormatShortDistanceDisplay(data.LengthM, IsMetric));
194+
details.AppendFormat("Power:\t{1}{0}", Environment.NewLine, FormatStrings.FormatPower(data.MaxPowerW, IsMetric, IsImperialBHP, IsImperialBTUpS));
195+
details.AppendFormat("MaxTE:\t{1}{0}", Environment.NewLine, FormatStrings.FormatForce(data.MaxTractiveForceN, IsMetric));
196+
details.AppendFormat("MinCouplerStrength:\t{1}{0}", Environment.NewLine, FormatStrings.FormatForce(data.MinCouplerStrengthN, IsMetric));
197+
if (!IsMetric && !IsUK) { details.AppendFormat("HPT:\t{1}{0}", Environment.NewLine, FormatHPT(data.MaxPowerW, data.MassKG)); }
198+
if (!IsMetric && !IsUK) { details.AppendFormat("TPOB:\t{1}{0}", Environment.NewLine, FormatTPOB(data.MassKG, data.NumOperativeBrakes)); }
199+
details.AppendLine();
200+
details.AppendFormat("Car ID:\tDirection:\tWeight:\tName:\t{0}", Environment.NewLine);
183201
foreach (var car in data.Cars)
184-
details.AppendFormat("{1}\t{2}\t\u0001{3}\u0002Car\u0001{0}", Environment.NewLine, car.ID, car.Direction, car.Name);
202+
details.AppendFormat("{1}\t{2}\t{3}\t\u0001{4}\u0002Car\u0001{0}", Environment.NewLine, car.ID, car.Direction, car.IsEngine ? "Engine" : FormatMassBar(car.MassKG), car.Name);
185203
details.AppendFormat("{0}", Environment.NewLine);
186204
}
187205
else if (content.Type == ContentType.Car)
188206
{
189207
var data = new Car(content);
190208
details.AppendFormat("Type:\t{1}{0}", Environment.NewLine, data.Type);
209+
details.AppendFormat("SubType:\t{1}{0}", Environment.NewLine, data.SubType);
191210
details.AppendFormat("Name:\t{1}{0}", Environment.NewLine, data.Name);
211+
details.AppendFormat("Weight:\t{1} ({2}){0}", Environment.NewLine, FormatStrings.FormatMass(data.MassKG, IsMetric), FormatStrings.FormatLargeMass(data.MassKG, IsMetric, IsUK));
212+
details.AppendFormat("Length:\t{1}{0}", Environment.NewLine, FormatStrings.FormatShortDistanceDisplay(data.LengthM, IsMetric));
213+
if (data.Type == CarType.Engine)
214+
{
215+
details.AppendFormat("MaxPowerW:\t{1}{0}", Environment.NewLine, FormatStrings.FormatPower(data.MaxPowerW, IsMetric, IsImperialBHP, IsImperialBTUpS));
216+
details.AppendFormat("MaxForce:\t{1}{0}", Environment.NewLine, FormatStrings.FormatForce(data.MaxForceN, IsMetric));
217+
details.AppendFormat("MaxSpeed:\t{1}{0}", Environment.NewLine, FormatStrings.FormatSpeedLimit(data.MaxSpeedMps, IsMetric));
218+
}
219+
details.AppendFormat("MaxBrakeF:\t{1}{0}", Environment.NewLine, FormatStrings.FormatForce(data.MaxBarkeForceN, IsMetric));
220+
details.AppendFormat("MinCouplerStrength:\t{1}{0}", Environment.NewLine, FormatStrings.FormatForce(data.MinCouplerStrengthN, IsMetric));
221+
details.AppendLine();
192222
details.AppendFormat("Description:\t{0}{0}{1}{0}{0}", Environment.NewLine, data.Description);
193223
}
194224
else if (content is ContentMSTSCab)
@@ -215,5 +245,46 @@ static string FormatDateTime(DateTime dateTime)
215245
{
216246
return String.Format("{0} {1}", dateTime.Day - 1, dateTime.ToLongTimeString());
217247
}
248+
249+
/// <summary>
250+
/// Create a simple bar graph (string of asterisk) for the car mass.
251+
/// </summary>
252+
/// <param name="massKg"></param>
253+
/// <returns>String of asterisk representing the mass.</returns>
254+
static string FormatMassBar(float massKg)
255+
{
256+
string massBar;
257+
var range = (int)Math.Ceiling(massKg / 20000);
258+
if (massKg < 1.0) { massBar = "?"; }
259+
else if (range > 8) { massBar = new string('*', 8) + '>'; }
260+
else { massBar = new string('*', range); }
261+
return massBar;
262+
}
263+
264+
/// <summary>
265+
/// Calculate and format horsepower per ton for consist, rounded to one decimal.
266+
/// </summary>
267+
/// <param name="consistPowerW"></param>
268+
/// <param name="consistMassKG"></param>
269+
/// <returns>horsepower-per-ton formated to one decimal.</returns>
270+
//TODO: implement UK and metric version
271+
static string FormatHPT(float consistPowerW, float consistMassKG)
272+
{
273+
var hpt = consistMassKG > 0 ? W.ToHp(consistPowerW) / Kg.ToTUS(consistMassKG) : 0;
274+
return string.Format("{0:0.0}", hpt);
275+
}
276+
277+
/// <summary>
278+
/// Calculate and format tons per operative brake for consist, rounded to an integer.
279+
/// </summary>
280+
/// <param name="consistMassKG"></param>
281+
/// <param name="consistNumOpBrakes"></param>
282+
/// <returns>tons-per-operative-brake formated to an integer.</returns>
283+
//TODO: implement UK and metric version
284+
static string FormatTPOB(float consistMassKG, float consistNumOpBrakes)
285+
{
286+
var tpob = consistNumOpBrakes > 0 ? Kg.ToTUS(consistMassKG) / consistNumOpBrakes : 0;
287+
return string.Format("{0:0}", tpob);
288+
}
218289
}
219290
}

0 commit comments

Comments
 (0)