Skip to content

Commit b3f26c8

Browse files
committed
Added DisabledIfCabPowerSupplyOff and DisabledIfLowVoltagePowerSupplyOff parameters to ETCS DMI
1 parent abee23d commit b3f26c8

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with Open Rails. If not, see <http://www.gnu.org/licenses/>.
1717

18+
using Microsoft.Xna.Framework;
19+
using Orts.Parsers.Msts;
1820
using System;
19-
using System.Collections;
2021
using System.Collections.Generic;
2122
using System.Diagnostics;
2223
using System.IO;
2324
using System.Linq;
24-
using Microsoft.Xna.Framework;
25-
using Orts.Parsers.Msts;
2625

2726
namespace Orts.Formats.Msts
2827
{
2928

30-
// TODO - this is an incomplete parse of the cvf file.
31-
public class CabViewFile
32-
{
29+
// TODO - this is an incomplete parse of the cvf file.
30+
public class CabViewFile
31+
{
3332
public List<Vector3> Locations = new List<Vector3>(); // Head locations for front, left and right views
3433
public List<Vector3> Directions = new List<Vector3>(); // Head directions for each view
3534
public List<string> TwoDViews = new List<string>(); // 2D CAB Views - by GeorgeS
@@ -38,7 +37,7 @@ public class CabViewFile
3837
public CabViewControls CabViewControls; // Controls in CAB - by GeorgeS
3938

4039
public CabViewFile(string filePath, string basePath)
41-
{
40+
{
4241
using (STFReader stf = new STFReader(filePath, false))
4342
stf.ParseFile(new STFReader.TokenProcessor[] {
4443
new STFReader.TokenProcessor("tr_cabviewfile", ()=>{ stf.MustMatch("("); stf.ParseBlock(new STFReader.TokenProcessor[] {
@@ -1276,6 +1275,8 @@ public CVCScreen(STFReader stf, string basepath)
12761275
new STFReader.TokenProcessor("graphic", ()=>{ ParseGraphic(stf, basepath); }),
12771276
new STFReader.TokenProcessor("units", ()=>{ ParseUnits(stf); }),
12781277
new STFReader.TokenProcessor("parameters", ()=>{ ParseCustomParameters(stf); }),
1278+
new STFReader.TokenProcessor("disablediflowvoltagepowersupplyoff", ()=>{ ParseDisabledIfLowVoltagePowerSupplyOff(stf); }),
1279+
new STFReader.TokenProcessor("disabledifcabpowersupplyoff", ()=>{ ParseDisabledIfCabPowerSupplyOff(stf); }),
12791280
});
12801281
}
12811282
protected void ParseCustomParameters(STFReader stf)

Source/RunActivity/Viewer3D/RollingStock/SubSystems/ETCS/DriverMachineInterface.cs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -765,28 +765,32 @@ public DriverMachineInterfaceRenderer(Viewer viewer, MSTSLocomotive locomotive,
765765

766766
public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
767767
{
768-
base.PrepareFrame(frame, elapsedTime);
769-
var xScale = Viewer.CabWidthPixels / 640f;
770-
var yScale = Viewer.CabHeightPixels / 480f;
771-
DrawPosition.X = (int)(Position.X * xScale) - Viewer.CabXOffsetPixels + Viewer.CabXLetterboxPixels;
772-
DrawPosition.Y = (int)(Position.Y * yScale) + Viewer.CabYOffsetPixels + Viewer.CabYLetterboxPixels;
773-
DrawPosition.Width = (int)(Control.Width * xScale);
774-
DrawPosition.Height = (int)(Control.Height * yScale);
775-
if (Zoomed)
776-
{
777-
DrawPosition.Width = 640;
778-
DrawPosition.Height = 480;
779-
DMI.SizeTo(DrawPosition.Width, DrawPosition.Height);
780-
DrawPosition.X -= 320;
781-
DrawPosition.Y -= 240;
782-
DMI.ETCSDefaultWindow.BackgroundColor = ColorBackground;
783-
}
784-
else
785-
{
786-
DMI.SizeTo(DrawPosition.Width, DrawPosition.Height);
787-
DMI.ETCSDefaultWindow.BackgroundColor = Color.Transparent;
768+
if ((!Control.DisabledIfLowVoltagePowerSupplyOff || Locomotive.LocomotivePowerSupply.LowVoltagePowerSupplyOn) &&
769+
(!Control.DisabledIfCabPowerSupplyOff || Locomotive.LocomotivePowerSupply.CabPowerSupplyOn))
770+
{
771+
base.PrepareFrame(frame, elapsedTime);
772+
var xScale = Viewer.CabWidthPixels / 640f;
773+
var yScale = Viewer.CabHeightPixels / 480f;
774+
DrawPosition.X = (int)(Position.X * xScale) - Viewer.CabXOffsetPixels + Viewer.CabXLetterboxPixels;
775+
DrawPosition.Y = (int)(Position.Y * yScale) + Viewer.CabYOffsetPixels + Viewer.CabYLetterboxPixels;
776+
DrawPosition.Width = (int)(Control.Width * xScale);
777+
DrawPosition.Height = (int)(Control.Height * yScale);
778+
if (Zoomed)
779+
{
780+
DrawPosition.Width = 640;
781+
DrawPosition.Height = 480;
782+
DMI.SizeTo(DrawPosition.Width, DrawPosition.Height);
783+
DrawPosition.X -= 320;
784+
DrawPosition.Y -= 240;
785+
DMI.ETCSDefaultWindow.BackgroundColor = ColorBackground;
786+
}
787+
else
788+
{
789+
DMI.SizeTo(DrawPosition.Width, DrawPosition.Height);
790+
DMI.ETCSDefaultWindow.BackgroundColor = Color.Transparent;
791+
}
792+
DMI.PrepareFrame(elapsedTime.ClockSeconds);
788793
}
789-
DMI.PrepareFrame(elapsedTime.ClockSeconds);
790794
}
791795

792796
public bool IsMouseWithin()

0 commit comments

Comments
 (0)