Skip to content

Commit

Permalink
display belt radiation levels in body info window
Browse files Browse the repository at this point in the history
  • Loading branch information
SirMortimer committed Jun 18, 2019
1 parent ab5c802 commit d68fd7b
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions src/Kerbalism/UI/BodyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,20 @@ public static void Body_info(this Panel p)
}
}

// rendering panel
// radiation panel
if (Features.Radiation)
{
p.AddSection("RENDERING");
p.AddContent("inner belt", Radiation.show_inner ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_inner));
p.AddContent("outer belt", Radiation.show_outer ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_outer));
p.AddContent("magnetopause", Radiation.show_pause ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_pause));
p.AddSection("RADIATION");

string inner, outer, pause;
RadiationLevels(body, out inner, out outer, out pause);

p.AddContent(Lib.BuildString("inner belt: ", Lib.Color("#cccccc", inner)),
Radiation.show_inner ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_inner));
p.AddContent(Lib.BuildString("outer belt: ", Lib.Color("#cccccc", outer)),
Radiation.show_outer ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_outer));
p.AddContent(Lib.BuildString("magnetopause: ", Lib.Color("#cccccc", pause)),
Radiation.show_pause ? "<color=green>show</color>" : "<color=red>hide</color>", string.Empty, () => p.Toggle(ref Radiation.show_pause));
}

// explain the user how to toggle the BodyInfo window
Expand All @@ -77,6 +84,32 @@ public static void Body_info(this Panel p)
// set metadata
p.Title(Lib.BuildString(Lib.Ellipsis(body.bodyName, Styles.ScaleStringLength(24)), " <color=#cccccc>BODY INFO</color>"));
}

private static void RadiationLevels(CelestialBody body, out string inner, out string outer, out string pause)
{
// TODO cache this information in RadiationBody

double rad = PreferencesStorm.Instance.externRadiation;
var rbSun = Radiation.Info(FlightGlobals.Bodies[0]);
rad += rbSun.radiation_pause;

var rb = Radiation.Info(body);

if (rb.inner_visible)
inner = rb.model.has_inner ? "~" + Lib.HumanReadableRadiation(Math.Max(0, rad + rb.radiation_inner) / 3600.0) : "n/a";
else
inner = "unknown";

if (rb.outer_visible)
outer = rb.model.has_outer ? "~" + Lib.HumanReadableRadiation(Math.Max(0, rad + rb.radiation_outer) / 3600.0) : "n/a";
else
outer = "unknown";

if (rb.pause_visible)
pause = rb.model.has_pause ? "~" + Lib.HumanReadableRadiation(Math.Max(0, rad + rb.radiation_pause) / 3600.0) : "n/a";
else
pause = "unknown";
}
}


Expand Down

0 comments on commit d68fd7b

Please sign in to comment.