Skip to content

Commit 85192ec

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents a675233 + 4830217 commit 85192ec

File tree

5 files changed

+53
-9
lines changed

5 files changed

+53
-9
lines changed

Source/Documentation/Manual/cabs.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,3 +808,13 @@ Here below is an example of an entry for a 3D cab::
808808
ScaleRange ( 0 5000 )
809809
Units ( LBS )
810810
)
811+
812+
Alignment for digital controls
813+
------------------------------
814+
815+
For backwards compatibility reasons, ``Justification ( 1 )``, ``Justification ( 2 )`` and
816+
``Justification ( 3 )`` all lead to a left alignment of the digital in 3Dcabs.
817+
818+
``Justification ( 5 )`` must be used for center alignment, and ``Justification ( 6 )``
819+
must be used for right alignment. ``Justification ( 4 )`` leads to left alignment.
820+

Source/Orts.Simulation/Simulation/AIs/AITrain.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4114,6 +4114,8 @@ public virtual bool[] ProcessEndOfPath(int presentTime, bool checkLoop = true)
41144114

41154115
int directionNow = ValidRoute[0][PresentPosition[0].RouteListIndex].Direction;
41164116
int positionNow = ValidRoute[0][PresentPosition[0].RouteListIndex].TCSectionIndex;
4117+
int directionNowBack = PresentPosition[1].TCDirection;
4118+
int positionNowBack = PresentPosition[1].TCSectionIndex;
41174119

41184120
bool[] nextPart = UpdateRouteActions(0, checkLoop);
41194121

@@ -4132,7 +4134,7 @@ public virtual bool[] ProcessEndOfPath(int presentTime, bool checkLoop = true)
41324134
Number.ToString() + " continued, part : " + TCRoute.activeSubpath.ToString() + "\n");
41334135
}
41344136

4135-
if (positionNow == PresentPosition[0].TCSectionIndex && directionNow != PresentPosition[0].TCDirection)
4137+
if (positionNowBack == PresentPosition[0].TCSectionIndex && directionNowBack != PresentPosition[0].TCDirection)
41364138
{
41374139
ReverseFormation(false);
41384140
// active subpath must be incremented in parallel in incorporated train if present

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,6 +2788,7 @@ public virtual void UpdateWaterTroughRefill(float elapsedClockSeconds, float abs
27882788
/// Dry track = 0.33
27892789
///
27902790
/// The following values are indicatitive values only (sourced from Principles and Applications of Tribology).
2791+
/// https://books.google.com.au/books?id=LtYgBQAAQBAJ&pg=PA312&lpg=PA312&dq=Principles+and+Applications+of+Tribology+table+14.1&source=bl&ots=2hfz1WpEsM&sig=ACfU3U3U9y9Lwov9GORLaKCO10SCFHvjhA&hl=en&sa=X&ved=2ahUKEwi82NCF_Yr0AhWNTX0KHcGfB3QQ6AF6BAgMEAM#v=onepage&q=Principles%20and%20Applications%20of%20Tribology%20table%2014.1&f=false
27912792
/// Wet track (clean) = 0.18 <=> 0.2
27922793
/// Wet track (sand) = 0.22 <=> 0.25
27932794
/// Dew or fog = 0.09 <=> 0.15

Source/Orts.Simulation/Simulation/RollingStocks/MSTSSteamLocomotive.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4652,8 +4652,8 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
46524652
// Typically tangential force will be greater at starting then when the locomotive is at speed, as interia and reduce steam pressure will decrease the value.
46534653
// By default this model uses information based upon a "NYC 4-4-2 locomotive", for smaller locomotives this data is changed in the OR initialisation phase.
46544654

4655-
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics && this == Simulator.PlayerLocomotive && this.Train.TrainType != Train.TRAINTYPE.AI_PLAYERHOSTING)
4656-
// only set advanced wheel slip when advanced adhesion, and simplecontrols/physics is not set and is the player locomotive, AI locomotive will not work to this model.
4655+
if (Simulator.UseAdvancedAdhesion && !Simulator.Settings.SimpleControlPhysics && IsPlayerTrain && this.Train.TrainType != Train.TRAINTYPE.AI_PLAYERHOSTING)
4656+
// only set advanced wheel slip when advanced adhesion, and simplecontrols/physics is not set and is in the the player train, AI locomotive will not work to this model.
46574657
// Don't use slip model when train is in auto pilot
46584658
{
46594659
float SlipCutoffPressureAtmPSI;

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,18 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
24372437
/// </summary>
24382438
public class CabViewDigitalRenderer : CabViewControlRenderer
24392439
{
2440-
readonly LabelAlignment Alignment;
2440+
public enum CVDigitalAlignment
2441+
{
2442+
Left,
2443+
Center,
2444+
Right,
2445+
// Next ones are used for 3D cabs; digitals of old 3D cab will continue to be displayed left aligned for compatibility
2446+
Cab3DLeft,
2447+
Cab3DCenter,
2448+
Cab3DRight
2449+
}
2450+
2451+
public readonly CVDigitalAlignment Alignment;
24412452
string Format = "{0}";
24422453
readonly string Format1 = "{0}";
24432454
readonly string Format2 = "{0}";
@@ -2458,9 +2469,10 @@ public CabViewDigitalRenderer(Viewer viewer, MSTSLocomotive car, CVCDigital digi
24582469

24592470
// Clock defaults to centered.
24602471
if (Control.ControlType == CABViewControlTypes.CLOCK)
2461-
Alignment = LabelAlignment.Center;
2462-
Alignment = digital.Justification == 1 ? LabelAlignment.Center : digital.Justification == 2 ? LabelAlignment.Left : digital.Justification == 3 ? LabelAlignment.Right : Alignment;
2463-
2472+
Alignment = CVDigitalAlignment.Center;
2473+
Alignment = digital.Justification == 1 ? CVDigitalAlignment.Center : digital.Justification == 2 ? CVDigitalAlignment.Left : digital.Justification == 3 ? CVDigitalAlignment.Right : Alignment;
2474+
// Used for 3D cabs
2475+
Alignment = digital.Justification == 4 ? CVDigitalAlignment.Cab3DCenter : digital.Justification == 5 ? CVDigitalAlignment.Cab3DLeft : digital.Justification == 6 ? CVDigitalAlignment.Cab3DRight : Alignment;
24642476
Format1 = "{0:0" + new String('0', digital.LeadingZeros) + (digital.Accuracy > 0 ? "." + new String('0', (int)digital.Accuracy) : "") + "}";
24652477
Format2 = "{0:0" + new String('0', digital.LeadingZeros) + (digital.AccuracySwitch > 0 ? "." + new String('0', (int)(digital.Accuracy + 1)) : "") + "}";
24662478
}
@@ -2540,7 +2552,8 @@ public override void PrepareFrame(RenderFrame frame, ElapsedTime elapsedTime)
25402552

25412553
public override void Draw(GraphicsDevice graphicsDevice)
25422554
{
2543-
DrawFont.Draw(ControlView.SpriteBatch, DrawPosition, Point.Zero, DrawRotation, DrawText, Alignment, DrawColor, Color.Black);
2555+
var alignment = (LabelAlignment)Alignment;
2556+
DrawFont.Draw(ControlView.SpriteBatch, DrawPosition, Point.Zero, DrawRotation, DrawText, alignment, DrawColor, Color.Black);
25442557
}
25452558

25462559
public string GetDigits(out Color DrawColor)
@@ -3057,14 +3070,32 @@ Material FindMaterial(bool Alert)
30573070
//update the digits with current speed or time
30583071
public void UpdateDigit()
30593072
{
3060-
NumVertices = NumIndices = 0;
30613073

30623074
Material UsedMaterial = Material; //use default material
30633075

30643076
//update text string
30653077
bool Alert;
30663078
string speed = CVFR.Get3DDigits(out Alert);
30673079

3080+
NumVertices = NumIndices = 0;
3081+
3082+
// add leading blanks to consider alignment
3083+
// for backwards compatibiliy with preceding OR releases all Justification values defined by MSTS are considered as left justified
3084+
var leadingBlankCount = 0;
3085+
switch (CVFR.Alignment)
3086+
{
3087+
case CabViewDigitalRenderer.CVDigitalAlignment.Cab3DRight:
3088+
leadingBlankCount = MaxDigits - speed.Length;
3089+
break;
3090+
case CabViewDigitalRenderer.CVDigitalAlignment.Cab3DCenter:
3091+
leadingBlankCount = (MaxDigits - speed.Length + 1) / 2;
3092+
break;
3093+
default:
3094+
break;
3095+
}
3096+
for (int i = leadingBlankCount; i > 0; i--)
3097+
speed = speed.Insert(0, " ");
3098+
30683099
if (Alert)//alert use alert meterial
30693100
{
30703101
if (AlertMaterial == null) AlertMaterial = FindMaterial(true);

0 commit comments

Comments
 (0)