Skip to content

Commit

Permalink
Automatic merge of T1.4-28-g98f46f681 and 4 pull requests
Browse files Browse the repository at this point in the history
- Pull request #480 at 7815b89: Blueprint https://blueprints.launchpad.net/or/+spec/digital-alignment-in-3dcabs
- Pull request #503 at 918960c: Update derailment functionality
- Pull request #510 at d4d3256: Add performance monitoring for diesel mechanic locomotives and new parameters
- Pull request #519 at 619ce90: Website changes for Release v1.4
  • Loading branch information
openrails-bot committed Oct 20, 2021
6 parents ac18228 + 98f46f6 + 7815b89 + 918960c + d4d3256 + 619ce90 commit e060ef3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
10 changes: 10 additions & 0 deletions Source/Documentation/Manual/cabs.rst
Expand Up @@ -808,3 +808,13 @@ Here below is an example of an entry for a 3D cab::
ScaleRange ( 0 5000 )
Units ( LBS )
)

Alignment for digital controls
------------------------------

For backwards compatibility reasons, ``Justification ( 1 )``, ``Justification ( 2 )`` and
``Justification ( 3 )`` all lead to a left alignment of the digital in 3Dcabs.

``Justification ( 5 )`` must be used for center alignment, and ``Justification ( 6 )``
must be used for right alignment. ``Justification ( 4 )`` leads to left alignment.

3 changes: 0 additions & 3 deletions Source/RunActivity/Viewer3D/Popups/WindowControls.cs
Expand Up @@ -115,9 +115,6 @@ public enum LabelAlignment
Left,
Center,
Right,
Cab3DLeft,
Cab3DCenter,
Cab3DRight,
}

public class Label : Control
Expand Down
32 changes: 20 additions & 12 deletions Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs
Expand Up @@ -2437,7 +2437,18 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
/// </summary>
public class CabViewDigitalRenderer : CabViewControlRenderer
{
readonly LabelAlignment Alignment;
public enum CVDigitalAlignment
{
Left,
Center,
Right,
// Next ones are used for 3D cabs; digitals of old 3D cab will continue to be displayed left aligned for compatibility
Cab3DLeft,
Cab3DCenter,
Cab3DRight
}

public readonly CVDigitalAlignment Alignment;
string Format = "{0}";
readonly string Format1 = "{0}";
readonly string Format2 = "{0}";
Expand All @@ -2458,10 +2469,10 @@ public CabViewDigitalRenderer(Viewer viewer, MSTSLocomotive car, CVCDigital digi

// Clock defaults to centered.
if (Control.ControlType == CABViewControlTypes.CLOCK)
Alignment = LabelAlignment.Center;
Alignment = digital.Justification == 1 ? LabelAlignment.Center : digital.Justification == 2 ? LabelAlignment.Left : digital.Justification == 3 ? LabelAlignment.Right : Alignment;
Alignment = CVDigitalAlignment.Center;
Alignment = digital.Justification == 1 ? CVDigitalAlignment.Center : digital.Justification == 2 ? CVDigitalAlignment.Left : digital.Justification == 3 ? CVDigitalAlignment.Right : Alignment;
// Used for 3D cabs
Alignment = digital.Justification == 4 ? LabelAlignment.Cab3DCenter : digital.Justification == 5 ? LabelAlignment.Cab3DLeft : digital.Justification == 6 ? LabelAlignment.Cab3DRight : Alignment;
Alignment = digital.Justification == 4 ? CVDigitalAlignment.Cab3DCenter : digital.Justification == 5 ? CVDigitalAlignment.Cab3DLeft : digital.Justification == 6 ? CVDigitalAlignment.Cab3DRight : Alignment;
Format1 = "{0:0" + new String('0', digital.LeadingZeros) + (digital.Accuracy > 0 ? "." + new String('0', (int)digital.Accuracy) : "") + "}";
Format2 = "{0:0" + new String('0', digital.LeadingZeros) + (digital.AccuracySwitch > 0 ? "." + new String('0', (int)(digital.Accuracy + 1)) : "") + "}";
}
Expand Down Expand Up @@ -2541,7 +2552,8 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)

public override void Draw(GraphicsDevice graphicsDevice)
{
DrawFont.Draw(ControlView.SpriteBatch, DrawPosition, Point.Zero, DrawRotation, DrawText, Alignment, DrawColor, Color.Black);
var alignment = (LabelAlignment)Alignment;
DrawFont.Draw(ControlView.SpriteBatch, DrawPosition, Point.Zero, DrawRotation, DrawText, alignment, DrawColor, Color.Black);
}

public string GetDigits(out Color DrawColor)
Expand Down Expand Up @@ -2687,10 +2699,6 @@ public string GetDigits(out Color DrawColor)
return "";
}

public LabelAlignment GetAlignment() //used in 3D cab, to get alignment
{
return Alignment;
}
}

/// <summary>
Expand Down Expand Up @@ -3074,12 +3082,12 @@ public void UpdateDigit()
// add leading blanks to consider alignment
// for backwards compatibiliy with preceding OR releases all Justification values defined by MSTS are considered as left justified
var leadingBlankCount = 0;
switch (CVFR.GetAlignment())
switch (CVFR.Alignment)
{
case LabelAlignment.Cab3DRight:
case CabViewDigitalRenderer.CVDigitalAlignment.Cab3DRight:
leadingBlankCount = MaxDigits - speed.Length;
break;
case LabelAlignment.Cab3DCenter:
case CabViewDigitalRenderer.CVDigitalAlignment.Cab3DCenter:
leadingBlankCount = (MaxDigits - speed.Length + 1) / 2;
break;
default:
Expand Down

0 comments on commit e060ef3

Please sign in to comment.