Skip to content

Commit a64cd0e

Browse files
committed
tooltip disable added, cutoff fixed
1 parent 0e2c41f commit a64cd0e

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

Source/MapResourceOverlay/MapOverlay.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class MapOverlay : ScenarioModule
4040
public bool useScansat;
4141
[KSPField(isPersistant = true)]
4242
public bool show = true;
43-
43+
[KSPField(isPersistant = true)] public bool showTooltip = true;
4444
private GlobalSettings _globalSettings;
4545

4646

@@ -200,6 +200,12 @@ public ResourceConfig SelectedResourceName
200200
}
201201
}
202202

203+
public bool ShowTooltip
204+
{
205+
get { return showTooltip; }
206+
set { showTooltip = value; }
207+
}
208+
203209
private int GetScansatId(string resourceName)
204210
{
205211
if (_scansatEnum != null)
@@ -312,7 +318,7 @@ public void OnGUI()
312318
// ignore the error and assume the pause menu is not open
313319
}
314320
}
315-
if (_targetBody != FlightGlobals.ActiveVessel.mainBody || paused) //dont show tooltips on different bodys or ORS lags
321+
if (_targetBody != FlightGlobals.ActiveVessel.mainBody || paused || !showTooltip) //dont show tooltips on different bodys or ORS lags
316322
{
317323
return;
318324
}
@@ -342,15 +348,8 @@ public void OnGUI()
342348
var abundance = ORSPlanetaryResourceMapData.getResourceAvailabilityByRealResourceName(
343349
_targetBody.flightGlobalsIndex, _selectedResourceName.Resource.ResourceName, _mouseCoords.Latitude, _mouseCoords.Longitude)
344350
.getAmount();
345-
string abundanceString;
346-
if (abundance > 0.001)
347-
{
348-
abundanceString = (abundance * 100.0).ToString("0.00") + "%";
349-
}
350-
else
351-
{
352-
abundanceString = (abundance * 1000000.0).ToString("0.0") + "ppm";
353-
}
351+
string abundanceString = (abundance * 1000000.0).ToString("0.0") + "ppm";
352+
354353
GUI.Window(_toolTipId, new Rect(_mouse.x + 10, _mouse.y + 10, 200f, 55f), i =>
355354
{
356355
GUI.Label(new Rect(5, 10, 190, 20), "Long: " + _mouseCoords.Longitude.ToString("###.##") + " Lat: " + _mouseCoords.Latitude.ToString("####.##"));
@@ -521,20 +520,18 @@ private Color32 CalculateColor32At(CelestialBody body, ResourceConfig resource,
521520
}
522521
var avail = ORSPlanetaryResourceMapData.getResourceAvailabilityByRealResourceName(body.flightGlobalsIndex, resource.Resource.ResourceName, latitude, longitude);
523522
var amount = avail.getAmount();
524-
amount = Mathf.Clamp((float)amount * 1000000f, 0f, 255f);
525-
if (!bright)
523+
amount = amount * 1000000;
524+
if (amount > cutoff)
526525
{
527-
if (amount > cutoff)
526+
amount = Mathf.Clamp((float)amount, 0f, 255f);
527+
if (!bright)
528528
{
529529
var r = amount * (resource.HighColor.r / 255.0);
530530
var g = amount * (resource.HighColor.g / 255.0);
531531
var b = amount * (resource.HighColor.b / 255.0);
532532
return new Color32(Convert.ToByte(r), Convert.ToByte(g), Convert.ToByte(b), resource.HighColor.a);
533533
}
534-
}
535-
else
536-
{
537-
if (amount > cutoff)
534+
else
538535
{
539536
return new Color32(255, Convert.ToByte(amount), Convert.ToByte(amount), 150);
540537
}

Source/MapResourceOverlay/MapOverlayGui.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ protected override void DrawWindowContents(int windowId)
4545
Model.UseScansat = true;
4646
}
4747
}
48+
if (Model.ShowTooltip)
49+
{
50+
if (GUILayout.Button("Disable Tooltip"))
51+
{
52+
Model.ShowTooltip = false;
53+
}
54+
}
55+
else
56+
{
57+
if (GUILayout.Button("Enable Tooltip"))
58+
{
59+
Model.ShowTooltip = true;
60+
}
61+
}
4862

4963
Model.Bright = GUILayout.Toggle(Model.Bright, "bright");
5064

0 commit comments

Comments
 (0)