Skip to content

Commit abad603

Browse files
committed
add lat/lon (closes #6)
1 parent 036a43e commit abad603

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

MicroEngineerProject/MicroEngineer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<LangVersion>latest</LangVersion>
77
<ImplicitUsings>true</ImplicitUsings>
8-
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
8+
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
99
</PropertyGroup>
1010
<ItemGroup>
1111
<PackageReference Include="BepInEx.BaseLib" Version="5.4.21" Publicize="true" />

MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
using KSP.Sim;
1414
using KSP.UI.Flight;
1515
using static KSP.Rendering.Planets.PQSData;
16-
using static VehiclePhysics.EnergyProvider;
17-
using KSP.Modding;
1816

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

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

690+
private string DegreesToDMS(double degreeD)
691+
{
692+
var ts = TimeSpan.FromHours(Math.Abs(degreeD));
693+
int degrees = (int)Math.Floor(ts.TotalHours);
694+
int minutes = ts.Minutes;
695+
int seconds = ts.Seconds;
696+
697+
string result = $"{degrees:N0}<color={unitColorHex}>°</color> {minutes:00}<color={unitColorHex}>'</color> {seconds:00}<color={unitColorHex}>\"</color>";
698+
699+
return result;
700+
}
701+
690702
private void CloseWindow()
691703
{
692704
GameObject.Find("BTN-MicroEngineerBtn")?.GetComponent<UIValue_WriteBool_Toggle>()?.SetValue(false);

0 commit comments

Comments
 (0)