Skip to content

Commit 7815b89

Browse files
committed
Create separate enum and update manual.
1 parent 6bc94a9 commit 7815b89

File tree

3 files changed

+30
-15
lines changed

3 files changed

+30
-15
lines changed

Source/Documentation/Manual/cabs.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,3 +752,13 @@ Here below is an example of an entry for a 3D cab::
752752
ScaleRange ( 0 5000 )
753753
Units ( LBS )
754754
)
755+
756+
Alignment for digital controls
757+
------------------------------
758+
759+
For backwards compatibility reasons, ``Justification ( 1 )``, ``Justification ( 2 )`` and
760+
``Justification ( 3 )`` all lead to a left alignment of the digital in 3Dcabs.
761+
762+
``Justification ( 5 )`` must be used for center alignment, and ``Justification ( 6 )``
763+
must be used for right alignment. ``Justification ( 4 )`` leads to left alignment.
764+

Source/RunActivity/Viewer3D/Popups/WindowControls.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ public enum LabelAlignment
115115
Left,
116116
Center,
117117
Right,
118-
Cab3DLeft,
119-
Cab3DCenter,
120-
Cab3DRight,
121118
}
122119

123120
public class Label : Control

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,18 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
24312431
/// </summary>
24322432
public class CabViewDigitalRenderer : CabViewControlRenderer
24332433
{
2434-
readonly LabelAlignment Alignment;
2434+
public enum CVDigitalAlignment
2435+
{
2436+
Left,
2437+
Center,
2438+
Right,
2439+
// Next ones are used for 3D cabs; digitals of old 3D cab will continue to be displayed left aligned for compatibility
2440+
Cab3DLeft,
2441+
Cab3DCenter,
2442+
Cab3DRight
2443+
}
2444+
2445+
public readonly CVDigitalAlignment Alignment;
24352446
string Format = "{0}";
24362447
readonly string Format1 = "{0}";
24372448
readonly string Format2 = "{0}";
@@ -2452,10 +2463,10 @@ public CabViewDigitalRenderer(Viewer viewer, MSTSLocomotive car, CVCDigital digi
24522463

24532464
// Clock defaults to centered.
24542465
if (Control.ControlType == CABViewControlTypes.CLOCK)
2455-
Alignment = LabelAlignment.Center;
2456-
Alignment = digital.Justification == 1 ? LabelAlignment.Center : digital.Justification == 2 ? LabelAlignment.Left : digital.Justification == 3 ? LabelAlignment.Right : Alignment;
2466+
Alignment = CVDigitalAlignment.Center;
2467+
Alignment = digital.Justification == 1 ? CVDigitalAlignment.Center : digital.Justification == 2 ? CVDigitalAlignment.Left : digital.Justification == 3 ? CVDigitalAlignment.Right : Alignment;
24572468
// Used for 3D cabs
2458-
Alignment = digital.Justification == 4 ? LabelAlignment.Cab3DCenter : digital.Justification == 5 ? LabelAlignment.Cab3DLeft : digital.Justification == 6 ? LabelAlignment.Cab3DRight : Alignment;
2469+
Alignment = digital.Justification == 4 ? CVDigitalAlignment.Cab3DCenter : digital.Justification == 5 ? CVDigitalAlignment.Cab3DLeft : digital.Justification == 6 ? CVDigitalAlignment.Cab3DRight : Alignment;
24592470
Format1 = "{0:0" + new String('0', digital.LeadingZeros) + (digital.Accuracy > 0 ? "." + new String('0', (int)digital.Accuracy) : "") + "}";
24602471
Format2 = "{0:0" + new String('0', digital.LeadingZeros) + (digital.AccuracySwitch > 0 ? "." + new String('0', (int)(digital.Accuracy + 1)) : "") + "}";
24612472
}
@@ -2535,7 +2546,8 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
25352546

25362547
public override void Draw(GraphicsDevice graphicsDevice)
25372548
{
2538-
DrawFont.Draw(ControlView.SpriteBatch, DrawPosition, Point.Zero, DrawRotation, DrawText, Alignment, DrawColor, Color.Black);
2549+
var alignment = (LabelAlignment)Alignment;
2550+
DrawFont.Draw(ControlView.SpriteBatch, DrawPosition, Point.Zero, DrawRotation, DrawText, alignment, DrawColor, Color.Black);
25392551
}
25402552

25412553
public string GetDigits(out Color DrawColor)
@@ -2680,10 +2692,6 @@ public string GetDigits(out Color DrawColor)
26802692
return "";
26812693
}
26822694

2683-
public LabelAlignment GetAlignment() //used in 3D cab, to get alignment
2684-
{
2685-
return Alignment;
2686-
}
26872695
}
26882696

26892697
/// <summary>
@@ -3067,12 +3075,12 @@ public void UpdateDigit()
30673075
// add leading blanks to consider alignment
30683076
// for backwards compatibiliy with preceding OR releases all Justification values defined by MSTS are considered as left justified
30693077
var leadingBlankCount = 0;
3070-
switch (CVFR.GetAlignment())
3078+
switch (CVFR.Alignment)
30713079
{
3072-
case LabelAlignment.Cab3DRight:
3080+
case CabViewDigitalRenderer.CVDigitalAlignment.Cab3DRight:
30733081
leadingBlankCount = MaxDigits - speed.Length;
30743082
break;
3075-
case LabelAlignment.Cab3DCenter:
3083+
case CabViewDigitalRenderer.CVDigitalAlignment.Cab3DCenter:
30763084
leadingBlankCount = (MaxDigits - speed.Length + 1) / 2;
30773085
break;
30783086
default:

0 commit comments

Comments
 (0)