Skip to content

Commit

Permalink
add lat/lon (closes #6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Micrologist committed Mar 5, 2023
1 parent 036a43e commit abad603
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion MicroEngineerProject/MicroEngineer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>true</ImplicitUsings>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BepInEx.BaseLib" Version="5.4.21" Publicize="true" />
Expand Down
16 changes: 14 additions & 2 deletions MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
using KSP.Sim;
using KSP.UI.Flight;
using static KSP.Rendering.Planets.PQSData;
using static VehiclePhysics.EnergyProvider;
using KSP.Modding;

namespace MicroMod
{
Expand Down Expand Up @@ -436,6 +434,8 @@ private void FillSurface(int _ = 0)
DrawSectionHeader("Surface", ref popoutSur, activeVessel.mainBody.bodyName);

DrawEntry("Situation", SituationToString(activeVessel.Situation));
DrawEntry("Latitude", $"{DegreesToDMS(activeVessel.Latitude)}", activeVessel.Latitude < 0 ? "S" : "N");
DrawEntry("Longitude", $"{DegreesToDMS(activeVessel.Longitude)}", activeVessel.Longitude < 0 ? "W" : "E");
DrawEntry("Biome", BiomeToString(activeVessel.SimulationObject.Telemetry.SurfaceBiome));
DrawEntry("Alt. MSL", MetersToDistanceString(activeVessel.AltitudeFromSeaLevel), "m");
DrawEntry("Alt. AGL", MetersToDistanceString(activeVessel.AltitudeFromScenery), "m");
Expand Down Expand Up @@ -687,6 +687,18 @@ private string BiomeToString(BiomeSurfaceData biome)
return result.Substring(0, 1).ToUpper() + result.Substring(1);
}

private string DegreesToDMS(double degreeD)
{
var ts = TimeSpan.FromHours(Math.Abs(degreeD));
int degrees = (int)Math.Floor(ts.TotalHours);
int minutes = ts.Minutes;
int seconds = ts.Seconds;

string result = $"{degrees:N0}<color={unitColorHex}>°</color> {minutes:00}<color={unitColorHex}>'</color> {seconds:00}<color={unitColorHex}>\"</color>";

return result;
}

private void CloseWindow()
{
GameObject.Find("BTN-MicroEngineerBtn")?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(false);
Expand Down

0 comments on commit abad603

Please sign in to comment.