Skip to content

Commit 9355637

Browse files
committed
Change: Add pantograph to train.xml
1 parent fe0a9f9 commit 9355637

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

source/OpenBVE/Parsers/Train/XML/TrainXmlParser.CarNode.cs

+34-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Xml;
1+
using System.Xml;
22
using OpenBveApi.Math;
33
using System.Linq;
44
using System;
@@ -11,6 +11,7 @@
1111
using OpenBveApi.Graphics;
1212
using OpenBveApi.Objects;
1313
using OpenBveApi.Interface;
14+
using OpenBveApi.Trains;
1415

1516
namespace OpenBve.Parsers.Train
1617
{
@@ -193,6 +194,38 @@ private static void ParseCarNode(XmlNode Node, string fileName, int Car, ref Tra
193194
Train.Cars[Car].EnableLoadingSway = false;
194195
}
195196
break;
197+
case "pantograph":
198+
bool collectsPower = true;
199+
double location = 0;
200+
if (c.ChildNodes.OfType<XmlElement>().Any())
201+
{
202+
foreach (XmlNode cc in c.ChildNodes)
203+
{
204+
switch (cc.Name.ToLowerInvariant())
205+
{
206+
case "fitted":
207+
int cp;
208+
NumberFormats.TryParseIntVb6(c.InnerText, out cp);
209+
if (cp == 1 || c.InnerText.ToLowerInvariant() == "true")
210+
{
211+
collectsPower = true;
212+
}
213+
else
214+
{
215+
collectsPower = false;
216+
}
217+
break;
218+
case "location":
219+
if (!NumberFormats.TryParseDoubleVb6(cc.InnerText, out location))
220+
{
221+
Interface.AddMessage(MessageType.Warning, false, "Invalid pantograph location defined for Car " + Car + " in XML file " + fileName);
222+
}
223+
break;
224+
}
225+
}
226+
}
227+
Train.Cars[Car].Pantograph = new Pantograph(Program.CurrentHost, location, collectsPower);
228+
break;
196229
case "frontbogie":
197230
if (c.ChildNodes.OfType<XmlElement>().Any())
198231
{

0 commit comments

Comments
 (0)