Skip to content

Commit

Permalink
tooltip disable added, cutoff fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrik committed Aug 30, 2014
1 parent 0e2c41f commit a64cd0e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
33 changes: 15 additions & 18 deletions Source/MapResourceOverlay/MapOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class MapOverlay : ScenarioModule
public bool useScansat;
[KSPField(isPersistant = true)]
public bool show = true;

[KSPField(isPersistant = true)] public bool showTooltip = true;
private GlobalSettings _globalSettings;


Expand Down Expand Up @@ -200,6 +200,12 @@ public ResourceConfig SelectedResourceName
}
}

public bool ShowTooltip
{
get { return showTooltip; }
set { showTooltip = value; }
}

private int GetScansatId(string resourceName)
{
if (_scansatEnum != null)
Expand Down Expand Up @@ -312,7 +318,7 @@ public void OnGUI()
// ignore the error and assume the pause menu is not open
}
}
if (_targetBody != FlightGlobals.ActiveVessel.mainBody || paused) //dont show tooltips on different bodys or ORS lags
if (_targetBody != FlightGlobals.ActiveVessel.mainBody || paused || !showTooltip) //dont show tooltips on different bodys or ORS lags
{
return;
}
Expand Down Expand Up @@ -342,15 +348,8 @@ public void OnGUI()
var abundance = ORSPlanetaryResourceMapData.getResourceAvailabilityByRealResourceName(
_targetBody.flightGlobalsIndex, _selectedResourceName.Resource.ResourceName, _mouseCoords.Latitude, _mouseCoords.Longitude)
.getAmount();
string abundanceString;
if (abundance > 0.001)
{
abundanceString = (abundance * 100.0).ToString("0.00") + "%";
}
else
{
abundanceString = (abundance * 1000000.0).ToString("0.0") + "ppm";
}
string abundanceString = (abundance * 1000000.0).ToString("0.0") + "ppm";

GUI.Window(_toolTipId, new Rect(_mouse.x + 10, _mouse.y + 10, 200f, 55f), i =>
{
GUI.Label(new Rect(5, 10, 190, 20), "Long: " + _mouseCoords.Longitude.ToString("###.##") + " Lat: " + _mouseCoords.Latitude.ToString("####.##"));
Expand Down Expand Up @@ -521,20 +520,18 @@ private Color32 CalculateColor32At(CelestialBody body, ResourceConfig resource,
}
var avail = ORSPlanetaryResourceMapData.getResourceAvailabilityByRealResourceName(body.flightGlobalsIndex, resource.Resource.ResourceName, latitude, longitude);
var amount = avail.getAmount();
amount = Mathf.Clamp((float)amount * 1000000f, 0f, 255f);
if (!bright)
amount = amount * 1000000;
if (amount > cutoff)
{
if (amount > cutoff)
amount = Mathf.Clamp((float)amount, 0f, 255f);
if (!bright)
{
var r = amount * (resource.HighColor.r / 255.0);
var g = amount * (resource.HighColor.g / 255.0);
var b = amount * (resource.HighColor.b / 255.0);
return new Color32(Convert.ToByte(r), Convert.ToByte(g), Convert.ToByte(b), resource.HighColor.a);
}
}
else
{
if (amount > cutoff)
else
{
return new Color32(255, Convert.ToByte(amount), Convert.ToByte(amount), 150);
}
Expand Down
14 changes: 14 additions & 0 deletions Source/MapResourceOverlay/MapOverlayGui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ protected override void DrawWindowContents(int windowId)
Model.UseScansat = true;
}
}
if (Model.ShowTooltip)
{
if (GUILayout.Button("Disable Tooltip"))
{
Model.ShowTooltip = false;
}
}
else
{
if (GUILayout.Button("Enable Tooltip"))
{
Model.ShowTooltip = true;
}
}

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

Expand Down

0 comments on commit a64cd0e

Please sign in to comment.