@@ -52,10 +52,6 @@ internal class DadUiController : KerbalMonoBehaviour
5252 private VisualElement _rotationMarker ;
5353 private VisualElement _rotationMarkerSprite ;
5454
55-
56- // Flight Controls Mode
57- //Label CtrlLabel;
58-
5955 // Main display
6056 private VisualElement _screen ;
6157 private float _screenHeight ;
@@ -65,6 +61,10 @@ internal class DadUiController : KerbalMonoBehaviour
6561 private VisualElement _tangentCrosshairHori ;
6662 private VisualElement _tangentCrosshairVert ;
6763
64+ // Tangent scale
65+ private Label _tangentScale ;
66+ private Label [ ] _tangentTicks ;
67+
6868 // Tangent Offset
6969 private Label _tofsLabel ;
7070
@@ -102,12 +102,19 @@ private void Update()
102102 // Update target data
103103 _target . Update ( ) ;
104104
105- // Update flight controls mode indicator
106- //if (Game?.ViewController?.GetActiveSimVessel(true) != null)
107- //{
108- // Vehicle.ActiveVesselVehicle.OnFlightControlsModeChange -= OnFlightControlsModeChanged;
109- // Vehicle.ActiveVesselVehicle.OnFlightControlsModeChange += OnFlightControlsModeChanged;
110- //}
105+ // Update tangent scale
106+ if ( DockingAlignmentDisplayPlugin . Instance . DockingTangentOffsetScale . Value == "Linear" )
107+ {
108+ _tangentScale . text = "m" ;
109+ for ( var i = 0 ; i < 4 ; i ++ )
110+ _tangentTicks [ i ] . text = ( 10 * ( 1 + i ) ) . ToString ( ) ;
111+ }
112+ else
113+ {
114+ _tangentScale . text = "10^x m" ;
115+ for ( var i = 0 ; i < 4 ; i ++ )
116+ _tangentTicks [ i ] . text = i . ToString ( ) ;
117+ }
111118
112119 if ( _target . IsValid )
113120 {
@@ -185,6 +192,12 @@ private void InitElements()
185192 _angleHori = _container . Q < VisualElement > ( "angle-hori" ) ;
186193 _angleVert = _container . Q < VisualElement > ( "angle-vert" ) ;
187194
195+ // Tangent scale
196+ _tangentScale = _container . Q < Label > ( "tangent-scale" ) ;
197+ _tangentTicks = new Label [ 4 ] ;
198+ for ( var i = 0 ; i < 4 ; i ++ )
199+ _tangentTicks [ i ] = _container . Q < Label > ( $ "tangent{ i } ") ;
200+
188201 // Rotate Angle crosshair
189202 _angleCrosshair . transform . rotation = Quaternion . AngleAxis ( 45 , Vector3 . forward ) ;
190203
@@ -233,7 +246,6 @@ private static string ToDisplay(double value)
233246 /// Set the crosshair's color to red if positionError.z < 0 (the craft is behind the target docking port).
234247 /// </summary>
235248 /// <param name="relativePos">Relative position in the target parallel frame</param>
236- /// <param name="validTarget">Is the target valid</param>
237249 private void UpdateTangentCrosshair ( Vector3 relativePos )
238250 {
239251 // Display crosshair
@@ -246,11 +258,20 @@ private void UpdateTangentCrosshair(Vector3 relativePos)
246258 _tangentCrosshairHori . EnableInClassList ( Red , relativePos . z <= 0 ) ;
247259 _tangentCrosshairVert . EnableInClassList ( Red , relativePos . z <= 0 ) ;
248260
261+ float screenX , screenY ;
249262 // Convert xy error to screen coordinates with log scale
250- var screenX = Mathf . Sign ( relativePos . x ) * _screenWidth *
251- ( Mathf . Log10 ( Mathf . Clamp ( Mathf . Abs ( relativePos . x ) , 0.1f , 990f ) ) + 1 ) / 8 ;
252- var screenY = Mathf . Sign ( relativePos . y ) * _screenHeight *
253- ( Mathf . Log10 ( Mathf . Clamp ( Mathf . Abs ( relativePos . y ) , 0.1f , 990f ) ) + 1 ) / 8 ;
263+ if ( DockingAlignmentDisplayPlugin . Instance . DockingTangentOffsetScale . Value == "Linear" )
264+ {
265+ screenX = Mathf . Clamp ( relativePos . x , - 39f , 39f ) / 40f * ( _screenWidth / 2 ) ;
266+ screenY = Mathf . Clamp ( relativePos . y , - 39f , 39f ) / 40f * ( _screenHeight / 2 ) ;
267+ }
268+ else
269+ {
270+ screenX = Mathf . Sign ( relativePos . x ) *
271+ ( Mathf . Log10 ( Mathf . Clamp ( Mathf . Abs ( relativePos . x ) , 0.1f , 990f ) ) + 1 ) / 4 * ( _screenWidth / 2 ) ;
272+ screenY = Mathf . Sign ( relativePos . y ) *
273+ ( Mathf . Log10 ( Mathf . Clamp ( Mathf . Abs ( relativePos . y ) , 0.1f , 990f ) ) + 1 ) / 4 * ( _screenHeight / 2 ) ;
274+ }
254275
255276 // Move crosshair to desired position
256277 _tangentCrosshairHori . transform . position = new Vector3 ( 0 , - screenY ) ;
@@ -263,7 +284,6 @@ private void UpdateTangentCrosshair(Vector3 relativePos)
263284 /// Set the crosshair's color to red if the docking port is pointed away from the target.
264285 /// </summary>
265286 /// <param name="relativeOrientation">Relative orientation (docking port's "up" in the parallel frame)</param>
266- /// <param name="validTarget"></param>
267287 private void UpdateAngleCrosshair ( Vector3 relativeOrientation )
268288 {
269289 // Display crosshair
@@ -292,7 +312,6 @@ private void UpdateAngleCrosshair(Vector3 relativeOrientation)
292312 /// and the target docking port. The arrow is green is the angle is less that 5° and red otherwise.
293313 /// </summary>
294314 /// <param name="relativeRoll">Relative roll between the two docking ports</param>
295- /// <param name="validTarget"></param>
296315 private void UpdateRollIndicator ( float relativeRoll )
297316 {
298317 // Display indicator
@@ -319,7 +338,6 @@ private void UpdateRollIndicator(float relativeRoll)
319338 /// docking port parallel frame.
320339 /// </summary>
321340 /// <param name="relativeVel">Relative velocity in the target parallel frame</param>
322- /// <param name="validTarget"></param>
323341 private void UpdateTvelIndicator ( Vector3 relativeVel )
324342 {
325343 // Display indicator
@@ -342,7 +360,13 @@ private void UpdateTvelIndicator(Vector3 relativeVel)
342360 _tvelMarker . transform . rotation = Quaternion . AngleAxis ( angle , Vector3 . forward ) ;
343361
344362 // Arrow length
345- var screenMag = ( Mathf . Log10 ( Mathf . Clamp ( mag , 0.1f , 990f ) ) + 1 ) / 8 * ( _screenHeight / 2 ) ;
363+ float screenMag ;
364+ // Convert xy error to screen coordinates with log scale
365+ if ( DockingAlignmentDisplayPlugin . Instance . DockingTangentOffsetScale . Value == "Linear" )
366+ screenMag = Mathf . Clamp ( mag , - 39f , 39f ) / 40f * ( _screenHeight / 2 ) ;
367+ else
368+ screenMag = ( Mathf . Log10 ( Mathf . Clamp ( mag , 0.1f , 990f ) ) + 1 ) / 4 * ( _screenHeight / 2 ) ;
369+
346370 _tvelLine . style . height = screenMag ;
347371 _tvelArrow . style . bottom = screenMag - 5 ;
348372 }
0 commit comments