@@ -75,11 +75,11 @@ public override Color32 CalculateColor32(double latitude, double longitude, Cele
7575 var avail = _getResourceAvailabilityByRealResourceName ( body . flightGlobalsIndex ,
7676 ActiveResource . Resource . ResourceName , latitude , longitude ) ;
7777 var amount = ( double ) _getAmount ( avail ) * 1000000 ;
78- if ( amount > cutoff )
78+ if ( amount > ActiveResource . Cutoff )
7979 {
8080 if ( Exponential )
8181 {
82- amount = ( ( Math . Pow ( amount , 2 ) - ( Math . Pow ( cutoff , 2 ) ) ) * 255 ) / ( ( Math . Pow ( _displayMax , 2 ) - ( Math . Pow ( cutoff , 2 ) ) ) ) ;
82+ amount = ( ( Math . Pow ( amount , 2 ) - ( Math . Pow ( ActiveResource . Cutoff , 2 ) ) ) * 255 ) / ( ( Math . Pow ( _displayMax , 2 ) - ( Math . Pow ( ActiveResource . Cutoff , 2 ) ) ) ) ;
8383 if ( ColoredScale )
8484 {
8585 var color = ScanSatWrapper . heightToColor ( ( float ) amount , 0 , 255 ) ;
@@ -89,11 +89,11 @@ public override Color32 CalculateColor32(double latitude, double longitude, Cele
8989 }
9090 else if ( Logaritmic )
9191 {
92- if ( cutoff < 1 )
92+ if ( ActiveResource . Cutoff < 1 )
9393 {
94- cutoff = 1 ;
94+ ActiveResource . Cutoff = 1 ;
9595 }
96- amount = ( ( Math . Log ( amount , 2 ) - ( Math . Log ( cutoff , 2 ) ) ) * 255 ) / ( ( Math . Log ( _displayMax , 2 ) - ( Math . Log ( cutoff , 2 ) ) ) ) ;
96+ amount = ( ( Math . Log ( amount , 2 ) - ( Math . Log ( ActiveResource . Cutoff , 2 ) ) ) * 255 ) / ( ( Math . Log ( _displayMax , 2 ) - ( Math . Log ( ActiveResource . Cutoff , 2 ) ) ) ) ;
9797 if ( ColoredScale )
9898 {
9999 var color = ScanSatWrapper . heightToColor ( ( float ) amount * 255 , 0 , 255f ) ;
@@ -105,11 +105,11 @@ public override Color32 CalculateColor32(double latitude, double longitude, Cele
105105 {
106106 if ( ColoredScale )
107107 {
108- var color = ScanSatWrapper . heightToColor ( ( float ) amount , cutoff , ( float ) _displayMax ) ;
108+ var color = ScanSatWrapper . heightToColor ( ( float ) amount , ActiveResource . Cutoff , ( float ) _displayMax ) ;
109109 color . a = ActiveResource . HighColor . a ;
110110 return color ;
111111 }
112- amount = ( ( amount - cutoff ) * 255 ) / ( _displayMax - cutoff ) ;
112+ amount = ( ( amount - ActiveResource . Cutoff ) * 255 ) / ( _displayMax - ActiveResource . Cutoff ) ;
113113 }
114114 amount = Mathf . Clamp ( ( float ) amount , 0f , 255f ) ;
115115 if ( ! bright )
@@ -289,24 +289,11 @@ static Func<object, object> GenerateFunc(MethodInfo method)
289289 public override void DrawGui ( MapOverlayGui gui )
290290 {
291291 base . DrawGui ( gui ) ;
292- GUILayout . BeginVertical ( ) ;
293- Logaritmic = GUILayout . Toggle ( Logaritmic , "Logarithmic Scale" ) ;
294- Exponential = GUILayout . Toggle ( Exponential , "Exponential Scale" ) ;
295- ColoredScale = GUILayout . Toggle ( ColoredScale , "Colored Scale" ) ;
296- GUILayout . Space ( 15 ) ;
297- foreach ( var res in ColorConfigs )
292+ if ( GUILayout . Button ( "Resource Options" ) )
298293 {
299- var style = new GUIStyle ( GUI . skin . button ) ;
300- if ( res == ActiveResource )
301- {
302- style . normal . textColor = Color . yellow ;
303- }
304- if ( GUILayout . Button ( res . Resource . ResourceName , style ) )
305- {
306- ActiveResource = res ;
307- }
294+ new ResourceOverlayView ( this ) ;
308295 }
309- GUILayout . EndVertical ( ) ;
296+
310297 }
311298
312299 public bool Exponential
@@ -343,4 +330,56 @@ public bool ColoredScale
343330 }
344331 }
345332 }
333+
334+ public class ResourceOverlayView : Window < ResourceOverlay >
335+ {
336+ private readonly ResourceOverlayProvider _model ;
337+
338+ public ResourceOverlayView ( ResourceOverlayProvider model ) : base ( "Resource Overlay Options" , 300 , 400 )
339+ {
340+ _model = model ;
341+ SetVisible ( true ) ;
342+ }
343+
344+ protected override void DrawWindowContents ( int windowId )
345+ {
346+ GUILayout . BeginVertical ( ) ;
347+ _model . Logaritmic = GUILayout . Toggle ( _model . Logaritmic , "Logarithmic Scale" ) ;
348+ _model . Exponential = GUILayout . Toggle ( _model . Exponential , "Exponential Scale" ) ;
349+ _model . ColoredScale = GUILayout . Toggle ( _model . ColoredScale , "Colored Scale" ) ;
350+
351+ GUILayout . Space ( 15 ) ;
352+ foreach ( var res in _model . ColorConfigs )
353+ {
354+ var style = new GUIStyle ( GUI . skin . button ) ;
355+ if ( res == _model . ActiveResource )
356+ {
357+ style . normal . textColor = Color . yellow ;
358+ }
359+ if ( GUILayout . Button ( res . Resource . ResourceName , style ) )
360+ {
361+ _model . ActiveResource = res ;
362+ }
363+ GUILayout . BeginHorizontal ( ) ;
364+ GUILayout . Label ( "low Cuttoff ppm: " ) ;
365+ int temp ;
366+ var cutoff = GUILayout . TextField ( res . Cutoff . ToString ( ) ) ;
367+ GUILayout . EndHorizontal ( ) ;
368+ bool changed = cutoff != res . Cutoff . ToString ( ) && res == _model . ActiveResource ;
369+ if ( Int32 . TryParse ( cutoff , out temp ) )
370+ {
371+ res . Cutoff = temp ;
372+ }
373+ else if ( cutoff == "" )
374+ {
375+ res . Cutoff = 0 ;
376+ }
377+ if ( changed )
378+ {
379+ _model . ActiveResource = res ;
380+ }
381+ }
382+ GUILayout . EndVertical ( ) ;
383+ }
384+ }
346385}
0 commit comments