Skip to content

Commit 92b426e

Browse files
committed
Add Engine and Car counts to the consist info.
1 parent 1c55709 commit 92b426e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Source/Contrib/ContentManager/ContentInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ public static string GetText(Content content)
179179
{
180180
var data = new Consist(content);
181181
details.AppendFormat("Name:\t{1}{0}", Environment.NewLine, data.Name);
182+
details.AppendFormat("NumEngines:\t{1}{0}", Environment.NewLine, data.NumEngines);
183+
details.AppendFormat("NumCars:\t{1}{0}", Environment.NewLine, data.NumCars);
182184
details.AppendFormat("Car ID:\tDirection:\tName:\t{0}", Environment.NewLine);
183185
foreach (var car in data.Cars)
184186
details.AppendFormat("{1}\t{2}\t\u0001{3}\u0002Car\u0001{0}", Environment.NewLine, car.ID, car.Direction, car.Name);

Source/Contrib/ContentManager/Models/Consist.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ namespace ORTS.ContentManager.Models
2727
public class Consist
2828
{
2929
public readonly string Name;
30+
public readonly string NumEngines; // using "+" between DPU sets
31+
public readonly string NumCars;
3032

3133
public readonly IEnumerable<Car> Cars;
3234

@@ -38,8 +40,31 @@ public Consist(Content content)
3840
var file = new ConsistFile(content.PathName);
3941
Name = file.Name;
4042

43+
var EngCount = 0;
44+
var WagCount = 0;
45+
var Separator = ""; // when set, indicates that subsequent engines are in a separate block
46+
4147
Cars = from car in file.Train.TrainCfg.WagonList
4248
select new Car(car);
49+
50+
foreach (Wagon wag in file.Train.TrainCfg.WagonList)
51+
{
52+
if (wag.IsEngine)
53+
{
54+
EngCount++;
55+
} else
56+
{
57+
if (EngCount > 0)
58+
{
59+
NumEngines = NumEngines + Separator + EngCount.ToString();
60+
EngCount = 0; Separator = "+";
61+
}
62+
WagCount++;
63+
}
64+
}
65+
if (EngCount > 0) { NumEngines = NumEngines + Separator + EngCount.ToString(); }
66+
if (NumEngines == null) { NumEngines = "0"; }
67+
NumCars = WagCount.ToString();
4368
}
4469
}
4570

0 commit comments

Comments
 (0)