Skip to content

Commit 46a143d

Browse files
committed
1 parent e198ab3 commit 46a143d

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

Source/Documentation/Manual/cabs.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,15 @@ if e.g. the wiper moves from left to right and back, only the frames related
466466
to the motion from left to right have to be included. For the reverse
467467
motion the same frames are used from last to first. SwitchVal can vary from 0 to 1.
468468

469+
Control Labels
470+
--------------
471+
472+
The string appearing on the screen when the mouse browses over a command control
473+
can be customized with following line, to be added within the control block in the
474+
.cvf file::
475+
476+
Label ( "string" )
477+
469478
Multiple screen pages on displays
470479
---------------------------------
471480

Source/Orts.Formats.Msts/CabViewFile.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ public class CabViewControl
397397

398398
public double OldValue;
399399
public string ACEFile = "";
400+
public string Label = "";
400401

401402
public int Display;
402403
public List<string> Screens;
@@ -598,6 +599,11 @@ public CVCDial(STFReader stf, string basepath)
598599
ToDegree = stf.ReadFloat(STFReader.UNITS.None, null);
599600
stf.SkipRestOfBlock();
600601
}),
602+
new STFReader.TokenProcessor("label", ()=>{
603+
stf.MustMatch("(");
604+
Label = stf.ReadString();
605+
stf.SkipRestOfBlock();
606+
}),
601607
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
602608
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
603609
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
@@ -687,6 +693,11 @@ public CVCGauge(STFReader stf, string basepath)
687693
}
688694
}),
689695
new STFReader.TokenProcessor("ortsangle", () =>{ Rotation = ParseRotation(stf); }),
696+
new STFReader.TokenProcessor("label", ()=>{
697+
stf.MustMatch("(");
698+
Label = stf.ReadString();
699+
stf.SkipRestOfBlock();
700+
}),
690701
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
691702
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
692703
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
@@ -813,6 +824,11 @@ public CVCDigital(STFReader stf, string basepath)
813824
}),
814825
new STFReader.TokenProcessor("ortsfont", ()=>{ParseFont(stf); }),
815826
new STFReader.TokenProcessor("ortsangle", () => {Rotation = ParseRotation(stf); }),
827+
new STFReader.TokenProcessor("label", ()=>{
828+
stf.MustMatch("(");
829+
Label = stf.ReadString();
830+
stf.SkipRestOfBlock();
831+
}),
816832
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
817833
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
818834
new STFReader.TokenProcessor("ortscabviewpoint", ()=>{ParseCabViewpoint(stf); }),
@@ -1057,6 +1073,11 @@ public CVCDiscrete(STFReader stf, string basepath, DiscreteStates discreteState)
10571073
_ValuesRead++;
10581074
}
10591075
}),
1076+
new STFReader.TokenProcessor("label", ()=>{
1077+
stf.MustMatch("(");
1078+
Label = stf.ReadString();
1079+
stf.SkipRestOfBlock();
1080+
}),
10601081
new STFReader.TokenProcessor("ortsdisplay", ()=>{ParseDisplay(stf); }),
10611082
new STFReader.TokenProcessor("ortsscreenpage", () => {ParseScreen(stf); }),
10621083
new STFReader.TokenProcessor("ortsnewscreenpage", () => {ParseNewScreen(stf); }),

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,6 +1560,7 @@ public interface ICabViewMouseControlRenderer
15601560
bool IsMouseWithin();
15611561
void HandleUserInput();
15621562
string GetControlName();
1563+
string GetControlLabel();
15631564

15641565
}
15651566

@@ -2189,6 +2190,11 @@ public string GetControlName()
21892190
return (Locomotive as MSTSLocomotive).TrainControlSystem.GetDisplayString(GetControlType().ToString());
21902191
}
21912192

2193+
public string GetControlLabel()
2194+
{
2195+
return Control.Label;
2196+
}
2197+
21922198
/// <summary>
21932199
/// Handles cabview mouse events, and changes the corresponding locomotive control values.
21942200
/// </summary>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,10 @@ public string GetControlName()
856856
}
857857
return "";
858858
}
859-
859+
public string GetControlLabel()
860+
{
861+
return GetControlName();
862+
}
860863
public override void Draw(GraphicsDevice graphicsDevice)
861864
{
862865
DMI.Draw(ControlView.SpriteBatch, new Point(DrawPosition.X, DrawPosition.Y));

Source/RunActivity/Viewer3D/Viewer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ void HandleUserInput(ElapsedTime elapsedTime)
14781478
if (MousePickedControl != null & MousePickedControl != OldMousePickedControl)
14791479
{
14801480
// say what control you have here
1481-
Simulator.Confirmer.Message(ConfirmLevel.None, MousePickedControl.GetControlName());
1481+
Simulator.Confirmer.Message(ConfirmLevel.None, String.IsNullOrEmpty(MousePickedControl.GetControlLabel()) ? MousePickedControl.GetControlName() : MousePickedControl.GetControlLabel());
14821482
}
14831483
if (MousePickedControl != null) ActualCursor = Cursors.Hand;
14841484
else if (ActualCursor == Cursors.Hand) ActualCursor = Cursors.Default;
@@ -1637,7 +1637,7 @@ void HandleUserInput(ElapsedTime elapsedTime)
16371637
if (MousePickedControl != null & MousePickedControl != OldMousePickedControl)
16381638
{
16391639
// say what control you have here
1640-
Simulator.Confirmer.Message(ConfirmLevel.None, MousePickedControl.GetControlName());
1640+
Simulator.Confirmer.Message(ConfirmLevel.None, String.IsNullOrEmpty(MousePickedControl.GetControlLabel()) ? MousePickedControl.GetControlName() : MousePickedControl.GetControlLabel());
16411641
}
16421642
if (MousePickedControl != null)
16431643
{

0 commit comments

Comments
 (0)