@@ -2454,7 +2454,8 @@ public CabViewDigitalRenderer(Viewer viewer, MSTSLocomotive car, CVCDigital digi
24542454 if ( Control . ControlType == CABViewControlTypes . CLOCK )
24552455 Alignment = LabelAlignment . Center ;
24562456 Alignment = digital . Justification == 1 ? LabelAlignment . Center : digital . Justification == 2 ? LabelAlignment . Left : digital . Justification == 3 ? LabelAlignment . Right : Alignment ;
2457-
2457+ // Used for 3D cabs
2458+ Alignment = digital . Justification == 4 ? LabelAlignment . Cab3DCenter : digital . Justification == 5 ? LabelAlignment . Cab3DLeft : digital . Justification == 6 ? LabelAlignment . Cab3DRight : Alignment ;
24582459 Format1 = "{0:0" + new String ( '0' , digital . LeadingZeros ) + ( digital . Accuracy > 0 ? "." + new String ( '0' , ( int ) digital . Accuracy ) : "" ) + "}" ;
24592460 Format2 = "{0:0" + new String ( '0' , digital . LeadingZeros ) + ( digital . AccuracySwitch > 0 ? "." + new String ( '0' , ( int ) ( digital . Accuracy + 1 ) ) : "" ) + "}" ;
24602461 }
@@ -2679,6 +2680,10 @@ public string GetDigits(out Color DrawColor)
26792680 return "" ;
26802681 }
26812682
2683+ public LabelAlignment GetAlignment ( ) //used in 3D cab, to get alignment
2684+ {
2685+ return Alignment ;
2686+ }
26822687 }
26832688
26842689 /// <summary>
@@ -3050,14 +3055,32 @@ Material FindMaterial(bool Alert)
30503055 //update the digits with current speed or time
30513056 public void UpdateDigit ( )
30523057 {
3053- NumVertices = NumIndices = 0 ;
30543058
30553059 Material UsedMaterial = Material ; //use default material
30563060
30573061 //update text string
30583062 bool Alert ;
30593063 string speed = CVFR . Get3DDigits ( out Alert ) ;
30603064
3065+ NumVertices = NumIndices = 0 ;
3066+
3067+ // add leading blanks to consider alignment
3068+ // for backwards compatibiliy with preceding OR releases all Justification values defined by MSTS are considered as left justified
3069+ var leadingBlankCount = 0 ;
3070+ switch ( CVFR . GetAlignment ( ) )
3071+ {
3072+ case LabelAlignment . Cab3DRight :
3073+ leadingBlankCount = MaxDigits - speed . Length ;
3074+ break ;
3075+ case LabelAlignment . Cab3DCenter :
3076+ leadingBlankCount = ( MaxDigits - speed . Length + 1 ) / 2 ;
3077+ break ;
3078+ default :
3079+ break ;
3080+ }
3081+ for ( int i = leadingBlankCount ; i > 0 ; i -- )
3082+ speed = speed . Insert ( 0 , " " ) ;
3083+
30613084 if ( Alert ) //alert use alert meterial
30623085 {
30633086 if ( AlertMaterial == null ) AlertMaterial = FindMaterial ( true ) ;
0 commit comments