From 7d31a95c1bdf57df750d5aae0965079d494b5a8e Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sat, 15 Apr 2023 12:52:15 +0200 Subject: [PATCH 01/38] Initial commit - add lots of new entries - add initial maneuver manipulation --- .../MicroEngineer/MicroEngineerMod.cs | 125 +- .../MicroEngineer/MicroEntries.cs | 1266 ++++++++++++++++- .../MicroEngineer/MicroUtility.cs | 5 + .../MicroEngineer/MicroWindow.cs | 4 +- 4 files changed, 1393 insertions(+), 7 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 3831268..f8bf272 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -9,6 +9,7 @@ using KSP.Sim.DeltaV; using KSP.Messages; using KSP.Sim.impl; +using KSP.Sim.Maneuver; namespace MicroMod { @@ -197,7 +198,6 @@ public void Update() { MicroUtility.RefreshGameManager(); - // Perform OAB updates only if we're in OAB if (MicroUtility.GameState != null && MicroUtility.GameState.IsObjectAssembly) { @@ -416,7 +416,7 @@ private void FillMainGUI(int windowID) Logger.LogError(ex); } } - + private int _selectedNode = 0; /// /// Draws all windows that are toggled and popped out /// @@ -430,10 +430,74 @@ private void DrawPopoutWindow(int windowIndex) foreach (MicroEntry entry in windowToDraw.Entries) DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); + // TEMP - MOVE SOMEWHERE ELSE WHEN DONE + + GUILayout.BeginHorizontal(); + if(GUILayout.Button("<")) + { + _selectedNode--; + } + GUILayout.Label($"{_selectedNode}"); + if (GUILayout.Button(">")) + { + _selectedNode++; + } + GUILayout.EndHorizontal(); + + if (windowToDraw.Name == "Maneuver") + { + if (GUILayout.Button("Delete")) + { + /* OLD - DOESN'T WORK + var activeVesselPlan2 = GameManager.Instance.Game.SpaceSimulation.Maneuvers.GetNodesForVessel(MicroUtility.ActiveVessel.GlobalId); + if (activeVesselPlan2 != null) + { + var node = activeVesselPlan2.FirstOrDefault(); + if (node != null) + { + + GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, new List { node }); + } + } + */ + + /* THIS WORKS! + var _activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); + List nodeData = new List(); + nodeData.Add(_activeVesselPlan.ActiveNode); + + foreach (ManeuverNodeData node in _activeVesselPlan.GetNodes()) + { + if (!nodeData.Contains(node) && (!_activeVesselPlan.ActiveNode.IsOnManeuverTrajectory || _activeVesselPlan.ActiveNode.Time < node.Time)) + nodeData.Add(node); + } + GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodeData); + */ + + var _activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); + List nodeData = new List(); + + var nodeToDelete = _activeVesselPlan.GetNodes()[_selectedNode]; + nodeData.Add(nodeToDelete); + + foreach (ManeuverNodeData node in _activeVesselPlan.GetNodes()) + { + if (!nodeData.Contains(node) && (!nodeToDelete.IsOnManeuverTrajectory || nodeToDelete.Time < node.Time)) + nodeData.Add(node); + } + GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodeData); + + + + //this.RemoveNodesFromVessel(this._activeVesselPlan.ActiveNode.RelatedSimID, nodeData); + //this.NormalizedManeuverTime = ManeuverProvider.NORMALIZED_MANEUVER_BOUND; + } + } + + // END TEMP DrawSectionEnd(windowToDraw); } - - private void DrawSettingsWindow(int windowIndex) + private void DrawSettingsWindow(int windowIndex) { MicroWindow windowToDraw = MicroWindows[windowIndex]; @@ -1072,6 +1136,59 @@ private void InitializeEntries() MicroEntries.Add(new TotalDeltaVVac_OAB()); MicroEntries.Add(new Torque()); MicroEntries.Add(new StageInfo_OAB()); + #endregion + + #region New entries + MicroEntries.Add(new AltitudeFromScenery()); + MicroEntries.Add(new AtmosphericTemperature()); + MicroEntries.Add(new DynamicPressure_kPa()); + MicroEntries.Add(new ExposedArea()); + MicroEntries.Add(new ExternalTemperature()); + MicroEntries.Add(new FuelPercentage()); + MicroEntries.Add(new Heading()); + MicroEntries.Add(new Pitch_HorizonRelative()); + MicroEntries.Add(new Roll_HorizonRelative()); + MicroEntries.Add(new Yaw_HorizonRelative()); + MicroEntries.Add(new DragCoefficient()); + MicroEntries.Add(new OrbitalSpeed()); + MicroEntries.Add(new SoundSpeed()); + MicroEntries.Add(new StageFuelPercentage()); + MicroEntries.Add(new StaticPressure_kPa()); + MicroEntries.Add(new TimeSinceLaunch()); + MicroEntries.Add(new TotalCommandCrewCapacity()); + MicroEntries.Add(new Zenith()); + MicroEntries.Add(new altimeterMode()); + MicroEntries.Add(new geeForce()); + MicroEntries.Add(new gravityForPos()); + MicroEntries.Add(new launchTime()); + MicroEntries.Add(new speedMode()); + MicroEntries.Add(new AutopilotStatus_IsEnabled()); + MicroEntries.Add(new AutopilotStatus_Mode()); + MicroEntries.Add(new EccentricAnomaly()); + MicroEntries.Add(new EndUT()); + MicroEntries.Add(new MeanAnomaly()); + MicroEntries.Add(new ObT()); + MicroEntries.Add(new ArgumentOfPeriapsis()); + MicroEntries.Add(new LongitudeOfAscendingNode()); + MicroEntries.Add(new SemiMajorAxis()); + MicroEntries.Add(new SemiMinorAxis()); + MicroEntries.Add(new OrbitalEnergy()); + MicroEntries.Add(new ReferenceBodyConstants_Radius()); + MicroEntries.Add(new ReferenceBodyConstants_StandardGravitationParameter()); + MicroEntries.Add(new SemiLatusRectum()); + MicroEntries.Add(new StartUT()); + MicroEntries.Add(new TrueAnomaly()); + MicroEntries.Add(new UniversalTimeAtClosestApproach()); + MicroEntries.Add(new UniversalTimeAtSoiEncounter()); + MicroEntries.Add(new orbitPercent()); + MicroEntries.Add(new radius()); + MicroEntries.Add(new ManeuverPrograde()); + MicroEntries.Add(new ManeuverNormal()); + MicroEntries.Add(new ManeuverRadial()); + + + + #endregion } diff --git a/MicroEngineerProject/MicroEngineer/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/MicroEntries.cs index d6c25a6..66c29be 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEntries.cs @@ -542,7 +542,7 @@ public class AltitudeAsl : MicroEntry { public AltitudeAsl() { - Name = "Altitude (ASL)"; + Name = "Altitude (Sea Level)"; Description = "Shows the vessel's altitude Above Sea Level"; Category = MicroEntryCategory.Surface; Unit = "m"; @@ -570,7 +570,7 @@ public class AltitudeAgl : MicroEntry { public AltitudeAgl() { - Name = "Altitude (AGL)"; + Name = "Altitude (Ground)"; Description = "Shows the vessel's altitude Above Ground Level"; Category = MicroEntryCategory.Surface; Unit = "m"; @@ -1535,4 +1535,1266 @@ private double GetISPAtAltitude(double altitude, CelestialBodyComponent cel) internal double GetDeltaVelAtSeaLevel(CelestialBodyComponent cel) => GetDeltaVelAlt(0, cel); } #endregion + + + #region New entries + + public class AltitudeFromScenery : MicroEntry + { + public AltitudeFromScenery() + { + Name = "Altitude (Scenery)"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AltitudeFromScenery; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class AtmosphericTemperature : MicroEntry + { + public AtmosphericTemperature() + { + Name = "AtmosphericTemperature"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = "K"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AtmosphericTemperature; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class ExternalTemperature : MicroEntry + { + public ExternalTemperature() + { + Name = "ExternalTemperature"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "K"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.ExternalTemperature; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class DynamicPressure_kPa : MicroEntry + { + public DynamicPressure_kPa() + { + Name = "DynamicPressure_kPa"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "kPa"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.DynamicPressure_kPa; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class ExposedArea : MicroEntry + { + public ExposedArea() + { + Name = "ExposedArea"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.ExposedArea; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + + + public class FuelPercentage : MicroEntry + { + public FuelPercentage() + { + Name = "FuelPercentage"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "%"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.FuelPercentage; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Heading : MicroEntry + { + public Heading() + { + Name = "Heading"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Heading; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Pitch_HorizonRelative : MicroEntry + { + public Pitch_HorizonRelative() + { + Name = "Pitch_HorizonRelative"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Pitch_HorizonRelative; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Roll_HorizonRelative : MicroEntry + { + public Roll_HorizonRelative() + { + Name = "Roll_HorizonRelative"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Roll_HorizonRelative; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Yaw_HorizonRelative : MicroEntry + { + public Yaw_HorizonRelative() + { + Name = "Yaw_HorizonRelative"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Yaw_HorizonRelative; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class DragCoefficient : MicroEntry + { + public DragCoefficient() + { + Name = "DragCoefficient"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N5}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.DragCoefficient; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class OrbitalSpeed : MicroEntry + { + public OrbitalSpeed() + { + Name = "OrbitalSpeed"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.OrbitalSpeed; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class SoundSpeed : MicroEntry + { + public SoundSpeed() + { + Name = "SoundSpeed"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.SoundSpeed; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class StageFuelPercentage : MicroEntry + { + public StageFuelPercentage() + { + Name = "StageFuelPercentage"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.StageFuelPercentage; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class StaticPressure_kPa : MicroEntry + { + public StaticPressure_kPa() + { + Name = "StaticPressure_kPa"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.StaticPressure_kPa; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class TimeSinceLaunch : MicroEntry + { + public TimeSinceLaunch() + { + Name = "TimeSinceLaunch"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TimeSinceLaunch; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class TotalCommandCrewCapacity : MicroEntry + { + public TotalCommandCrewCapacity() + { + Name = "TotalCommandCrewCapacity"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TotalCommandCrewCapacity; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Zenith : MicroEntry + { + public Zenith() + { + Name = "Zenith"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Zenith; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class altimeterMode : MicroEntry + { + public altimeterMode() + { + Name = "altimeterMode"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.altimeterMode; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class geeForce : MicroEntry + { + public geeForce() + { + Name = "geeForce"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.geeForce; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class gravityForPos : MicroEntry + { + public gravityForPos() + { + Name = "gravityForPos"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.gravityForPos.magnitude; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + + public class launchTime : MicroEntry + { + public launchTime() + { + Name = "launchTime"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.launchTime; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class speedMode : MicroEntry + { + public speedMode() + { + Name = "speedMode"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.speedMode; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class AutopilotStatus_IsEnabled : MicroEntry + { + public AutopilotStatus_IsEnabled() + { + Name = "AutopilotStatus_IsEnabled"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.IsEnabled; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class AutopilotStatus_Mode : MicroEntry + { + public AutopilotStatus_Mode() + { + Name = "AutopilotStatus_Mode"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.Mode; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + + + + public class EccentricAnomaly : MicroEntry + { + public EccentricAnomaly() + { + Name = "EccentricAnomaly"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.EccentricAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue) + "(" + String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg) + ")"; + } + } + } + + public class EndUT : MicroEntry + { + public EndUT() + { + Name = "EndUT"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.EndUT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class MeanAnomaly : MicroEntry + { + public MeanAnomaly() + { + Name = "MeanAnomaly"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.MeanAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue) + "(" + String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg) + ")"; + } + } + } + + public class ObT : MicroEntry + { + public ObT() + { + Name = "Orbit Time"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ObT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class ArgumentOfPeriapsis : MicroEntry + { + public ArgumentOfPeriapsis() + { + Name = "ArgumentOfPeriapsis"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.ArgumentOfPeriapsis; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class LongitudeOfAscendingNode : MicroEntry + { + public LongitudeOfAscendingNode() + { + Name = "LongitudeOfAscendingNode"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.LongitudeOfAscendingNode; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class SemiMajorAxis : MicroEntry + { + public SemiMajorAxis() + { + Name = "SemiMajorAxis"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.SemiMajorAxis; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class SemiMinorAxis : MicroEntry + { + public SemiMinorAxis() + { + Name = "SemiMinorAxis"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.SemiMinorAxis; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class OrbitalEnergy : MicroEntry + { + public OrbitalEnergy() + { + Name = "OrbitalEnergy"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalEnergy; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class ReferenceBodyConstants_Radius : MicroEntry + { + public ReferenceBodyConstants_Radius() + { + Name = "Ref.Bod.Con.Radius"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.Radius; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class ReferenceBodyConstants_StandardGravitationParameter : MicroEntry + { + public ReferenceBodyConstants_StandardGravitationParameter() + { + Name = "Ref.Bod.Con.GPar"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.StandardGravitationParameter; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class SemiLatusRectum : MicroEntry + { + public SemiLatusRectum() + { + Name = "SemiLatusRectum"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.SemiLatusRectum; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class StartUT : MicroEntry + { + public StartUT() + { + Name = "StartUT"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.StartUT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class TrueAnomaly : MicroEntry + { + public TrueAnomaly() + { + Name = "T.Anomaly"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.TrueAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.RadiansToDegrees((double)EntryValue)); + } + } + } + + public class UniversalTimeAtClosestApproach : MicroEntry + { + public UniversalTimeAtClosestApproach() + { + Name = "UT Closest Appr."; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtClosestApproach; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class UniversalTimeAtSoiEncounter : MicroEntry + { + public UniversalTimeAtSoiEncounter() + { + Name = "UT SOI Enc"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class orbitPercent : MicroEntry + { + public orbitPercent() + { + Name = "orbitPercent"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "%"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.orbitPercent * 100; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class radius : MicroEntry + { + public radius() + { + Name = "Orbit Radius"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.radius; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ManeuverPrograde : MicroEntry + { + public ManeuverPrograde() + { + Name = "∆v Prograde"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.CurrentManeuver?.BurnVector.z; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ManeuverNormal : MicroEntry + { + public ManeuverNormal() + { + Name = "∆v Normal"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.CurrentManeuver?.BurnVector.y; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ManeuverRadial : MicroEntry + { + public ManeuverRadial() + { + Name = "∆v Radial"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.CurrentManeuver?.BurnVector.x; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + + + + + + + + #endregion + } diff --git a/MicroEngineerProject/MicroEngineer/MicroUtility.cs b/MicroEngineerProject/MicroEngineer/MicroUtility.cs index 2835c99..5187455 100644 --- a/MicroEngineerProject/MicroEngineer/MicroUtility.cs +++ b/MicroEngineerProject/MicroEngineer/MicroUtility.cs @@ -152,6 +152,11 @@ public static string BiomeToString(BiomeSurfaceData biome) return result.Substring(0, 1).ToUpper() + result.Substring(1); } + public static double RadiansToDegrees(double radians) + { + return radians * PatchedConicsOrbit.Rad2Deg; + } + /// /// Validates if user entered a 3 character string /// diff --git a/MicroEngineerProject/MicroEngineer/MicroWindow.cs b/MicroEngineerProject/MicroEngineer/MicroWindow.cs index 91a479d..bca8901 100644 --- a/MicroEngineerProject/MicroEngineer/MicroWindow.cs +++ b/MicroEngineerProject/MicroEngineer/MicroWindow.cs @@ -126,7 +126,9 @@ public enum MicroEntryCategory Maneuver, Stage, Misc, - OAB + OAB, + New, + Accepted } /// From 634b8749692cdb54ea2cc06aa197d6d42e1187a7 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sun, 16 Apr 2023 00:13:21 +0200 Subject: [PATCH 02/38] Add ManeuverWindow - Rename MicroWindow to BaseWindow - Add new ManeuverWindow that inherits from BaseWindow - Move data refresh from MicroEngineerMod to BaseWindow/ManeuverWindow - Rename MicroStyles to Styles - Move BaseWindow and ManeuverWindow to Windows folder - Add manipulation of multiple active nodes, nodes can be deleted, node info can switch to other nodes --- .../MicroEngineer/MicroEngineerMod.cs | 336 +++++++++--------- .../MicroEngineer/MicroEntries.cs | 105 +++++- .../MicroEngineer/MicroUtility.cs | 20 +- .../{MicroStyles.cs => Styles.cs} | 17 +- .../{MicroWindow.cs => Windows/BaseWindow.cs} | 60 ++-- .../MicroEngineer/Windows/ManeuverWindow.cs | 88 +++++ 6 files changed, 409 insertions(+), 217 deletions(-) rename MicroEngineerProject/MicroEngineer/{MicroStyles.cs => Styles.cs} (93%) rename MicroEngineerProject/MicroEngineer/{MicroWindow.cs => Windows/BaseWindow.cs} (67%) create mode 100644 MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index f8bf272..28c325d 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -9,11 +9,10 @@ using KSP.Sim.DeltaV; using KSP.Messages; using KSP.Sim.impl; -using KSP.Sim.Maneuver; namespace MicroMod { - [BepInPlugin("com.micrologist.microengineer", "MicroEngineer", "0.8.0")] + [BepInPlugin("com.micrologist.microengineer", "MicroEngineer", "1.0.0")] [BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)] public class MicroEngineerMod : BaseSpaceWarpPlugin { @@ -36,7 +35,7 @@ public class MicroEngineerMod : BaseSpaceWarpPlugin /// /// All windows that can be rendered /// - private List MicroWindows; + private List MicroWindows; /// /// Holds data on all bodies for calculating TWR (currently) @@ -53,7 +52,7 @@ public class MicroEngineerMod : BaseSpaceWarpPlugin public override void OnInitialized() { - MicroStyles.InitializeStyles(); + Styles.InitializeStyles(); InitializeEntries(); InitializeWindows(); SubscribeToMessages(); @@ -97,14 +96,14 @@ private void BackwardCompatibilityInitializations() // Preserve backward compatibility with SpaceWarp 1.0.1 if (MicroUtility.IsModOlderThan("SpaceWarp", 1, 1, 0)) { - Logger.LogInfo("Space Warp older version detected. Loading old MicroStyles."); - MicroStyles.SetStylesForOldSpaceWarpSkin(); + Logger.LogInfo("Space Warp older version detected. Loading old Styles."); + Styles.SetStylesForOldSpaceWarpSkin(); } else - Logger.LogInfo("Space Warp new version detected. Loading new MicroStyles."); + Logger.LogInfo("Space Warp new version detected. Loading new Styles."); // Preserve backward compatibility with 0.7.2. If user previously saved the layout and then upgraded without deleting the original folder, then the Torque entry won't be in the loaded StageOAB window. So, we add it manually now. - MicroWindow stageOabWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + BaseWindow stageOabWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); if (stageOabWindow.Entries.Find(e => e.Name == "Torque") == null) { stageOabWindow.Entries.Add(this.MicroEntries.Find(e => e.Name == "Torque")); @@ -182,7 +181,7 @@ private void RefreshStagingDataOAB(MessageCenterMessage obj) MicroUtility.RefreshStagesOAB(); - MicroWindow stageWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + BaseWindow stageWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); if (MicroUtility.VesselDeltaVComponentOAB?.StageInfo == null) { @@ -220,18 +219,16 @@ public void Update() if (MicroUtility.ActiveVessel == null) return; - // Grab all Flight entries from all active windows and refresh their data - foreach (MicroEntry entry in MicroWindows - .Where(w => w.IsFlightActive) - .SelectMany(w => w.Entries ?? Enumerable.Empty()).ToList()) - entry.RefreshData(); + // Refresh all active windows' entries + foreach (BaseWindow window in MicroWindows.Where(w => w.IsFlightActive)) + window.RefreshData(); } } #endregion private void OnGUI() { - GUI.skin = MicroStyles.SpaceWarpUISkin; + GUI.skin = Styles.SpaceWarpUISkin; MicroUtility.RefreshGameManager(); if (MicroUtility.GameState?.GameState == GameState.VehicleAssemblyBuilder) @@ -247,7 +244,7 @@ private void OnGUI_Flight() if (!_showGuiFlight || MicroUtility.ActiveVessel == null) return; - MicroWindow mainGui = MicroWindows.Find(window => window.MainWindow == MainWindow.MainGui); + BaseWindow mainGui = MicroWindows.Find(window => window.MainWindow == MainWindow.MainGui); // Draw main GUI that contains docked windows mainGui.FlightRect = GUILayout.Window( @@ -255,7 +252,7 @@ private void OnGUI_Flight() mainGui.FlightRect, FillMainGUI, "// MICRO ENGINEER", - MicroStyles.MainWindowStyle, + Styles.MainWindowStyle, GUILayout.Height(0) ); mainGui.FlightRect.position = MicroUtility.ClampToScreen(mainGui.FlightRect.position, mainGui.FlightRect.size); @@ -283,9 +280,9 @@ private void OnGUI_Flight() window.FlightRect, DrawPopoutWindow, "", - MicroStyles.PopoutWindowStyle, + Styles.PopoutWindowStyle, GUILayout.Height(0), - GUILayout.Width(MicroStyles.WindowWidth + GUILayout.Width(Styles.WindowWidth )); // Set alpha back to 100% @@ -304,9 +301,9 @@ private void OnGUI_Flight() MicroWindows[settingsIndex].FlightRect, DrawSettingsWindow, "", - MicroStyles.PopoutWindowStyle, + Styles.PopoutWindowStyle, GUILayout.Height(0), - GUILayout.Width(MicroStyles.WindowWidth) + GUILayout.Width(Styles.WindowWidth) ); MicroWindows[settingsIndex].FlightRect.position = MicroUtility.ClampToScreen(MicroWindows[settingsIndex].FlightRect.position, MicroWindows[settingsIndex].FlightRect.size); @@ -321,9 +318,9 @@ private void OnGUI_Flight() MicroWindows[stageIndex].FlightRect, DrawStages, "", - MicroStyles.PopoutWindowStyle, + Styles.PopoutWindowStyle, GUILayout.Height(0), - GUILayout.Width(MicroStyles.WindowWidth) + GUILayout.Width(Styles.WindowWidth) ); MicroWindows[stageIndex].FlightRect.position = MicroUtility.ClampToScreen(MicroWindows[stageIndex].FlightRect.position, MicroWindows[stageIndex].FlightRect.size); @@ -332,12 +329,12 @@ private void OnGUI_Flight() // Draw Edit Window if (showEditWindow) { - MicroStyles.EditWindowRect = GUILayout.Window( + Styles.EditWindowRect = GUILayout.Window( GUIUtility.GetControlID(FocusType.Passive), - MicroStyles.EditWindowRect, + Styles.EditWindowRect, DrawEditWindow, "", - MicroStyles.EditWindowStyle, + Styles.EditWindowStyle, GUILayout.Height(0) ); } @@ -351,7 +348,7 @@ private void FillMainGUI(int windowID) { try { - if (CloseButton(MicroStyles.CloseBtnRect)) + if (CloseButton(Styles.CloseBtnRect)) { CloseWindow(); } @@ -362,7 +359,7 @@ private void FillMainGUI(int windowID) int toggleIndex = -1; // Draw toggles for all windows except MainGui and StageInfoOAB - foreach (MicroWindow window in MicroWindows.Where(x => x.MainWindow != MainWindow.MainGui && x.MainWindow != MainWindow.StageInfoOAB)) + foreach (BaseWindow window in MicroWindows.Where(x => x.MainWindow != MainWindow.MainGui && x.MainWindow != MainWindow.StageInfoOAB)) { // layout can fit 6 toggles, so if all 6 slots are filled then go to a new line. Index == 0 is the MainGUI which isn't rendered if (++toggleIndex % 6 == 0 && toggleIndex > 0) @@ -370,7 +367,7 @@ private void FillMainGUI(int windowID) GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); } - window.IsFlightActive = GUILayout.Toggle(window.IsFlightActive, window.Abbreviation, MicroStyles.SectionToggleStyle); + window.IsFlightActive = GUILayout.Toggle(window.IsFlightActive, window.Abbreviation, Styles.SectionToggleStyle); } GUILayout.EndHorizontal(); GUILayout.Space(5); @@ -408,7 +405,7 @@ private void FillMainGUI(int windowID) DrawSectionEnd(window); } - GUI.DragWindow(new Rect(0, 0, MicroStyles.WindowWidth, MicroStyles.WindowHeight)); + GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); } catch (Exception ex) @@ -423,32 +420,24 @@ private void FillMainGUI(int windowID) /// private void DrawPopoutWindow(int windowIndex) { - MicroWindow windowToDraw = MicroWindows[windowIndex]; + BaseWindow windowToDraw = MicroWindows[windowIndex]; DrawSectionHeader(windowToDraw.Name, ref windowToDraw.IsFlightPoppedOut, windowToDraw.IsLocked, ""); + windowToDraw.DrawWindowHeader(); + foreach (MicroEntry entry in windowToDraw.Entries) - DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); + DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); - // TEMP - MOVE SOMEWHERE ELSE WHEN DONE - - GUILayout.BeginHorizontal(); - if(GUILayout.Button("<")) - { - _selectedNode--; - } - GUILayout.Label($"{_selectedNode}"); - if (GUILayout.Button(">")) - { - _selectedNode++; - } - GUILayout.EndHorizontal(); + windowToDraw.DrawWindowFooter(); + // TEMP - MOVE SOMEWHERE ELSE WHEN DONE + /* if (windowToDraw.Name == "Maneuver") { if (GUILayout.Button("Delete")) { - /* OLD - DOESN'T WORK + // OLD - DOESN'T WORK var activeVesselPlan2 = GameManager.Instance.Game.SpaceSimulation.Maneuvers.GetNodesForVessel(MicroUtility.ActiveVessel.GlobalId); if (activeVesselPlan2 != null) { @@ -459,9 +448,8 @@ private void DrawPopoutWindow(int windowIndex) GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, new List { node }); } } - */ - /* THIS WORKS! + // THIS WORKS! var _activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); List nodeData = new List(); nodeData.Add(_activeVesselPlan.ActiveNode); @@ -472,7 +460,8 @@ private void DrawPopoutWindow(int windowIndex) nodeData.Add(node); } GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodeData); - */ + + var _activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); List nodeData = new List(); @@ -492,31 +481,31 @@ private void DrawPopoutWindow(int windowIndex) //this.RemoveNodesFromVessel(this._activeVesselPlan.ActiveNode.RelatedSimID, nodeData); //this.NormalizedManeuverTime = ManeuverProvider.NORMALIZED_MANEUVER_BOUND; } - } + }*/ // END TEMP DrawSectionEnd(windowToDraw); } private void DrawSettingsWindow(int windowIndex) { - MicroWindow windowToDraw = MicroWindows[windowIndex]; + BaseWindow windowToDraw = MicroWindows[windowIndex]; DrawSectionHeader(windowToDraw.Name, ref windowToDraw.IsFlightPoppedOut, windowToDraw.IsLocked, ""); GUILayout.Space(10); GUILayout.BeginHorizontal(); - if (GUILayout.Button("SAVE LAYOUT", MicroStyles.NormalBtnStyle)) + if (GUILayout.Button("SAVE LAYOUT", Styles.NormalBtnStyle)) MicroUtility.SaveLayout(MicroWindows); GUILayout.Space(5); - if (GUILayout.Button("LOAD LAYOUT", MicroStyles.NormalBtnStyle)) + if (GUILayout.Button("LOAD LAYOUT", Styles.NormalBtnStyle)) MicroUtility.LoadLayout(MicroWindows); GUILayout.Space(5); - if (GUILayout.Button("RESET", MicroStyles.NormalBtnStyle)) + if (GUILayout.Button("RESET", Styles.NormalBtnStyle)) ResetLayout(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - if (GUILayout.Button("Edit Windows", MicroStyles.NormalBtnStyle)) + if (GUILayout.Button("Edit Windows", Styles.NormalBtnStyle)) { showEditWindow = !showEditWindow; } @@ -527,7 +516,7 @@ private void DrawSettingsWindow(int windowIndex) private void DrawStages(int windowIndex) { - MicroWindow windowToDraw = MicroWindows[windowIndex]; + BaseWindow windowToDraw = MicroWindows[windowIndex]; DrawStagesHeader(windowToDraw); @@ -569,60 +558,60 @@ private void DrawSectionHeader(string sectionName, ref bool isPopout, bool isLoc GUILayout.BeginHorizontal(); // If window is popped out and it's not locked => show the close button. If it's not popped out => show to popup arrow - isPopout = isPopout && !isLocked ? !CloseButton(MicroStyles.CloseBtnRect) : !isPopout ? GUILayout.Button("⇖", MicroStyles.PopoutBtnStyle) : isPopout; + isPopout = isPopout && !isLocked ? !CloseButton(Styles.CloseBtnRect) : !isPopout ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : isPopout; GUILayout.Label($"{sectionName}"); GUILayout.FlexibleSpace(); - GUILayout.Label(value, MicroStyles.ValueLabelStyle); + GUILayout.Label(value, Styles.ValueLabelStyle); GUILayout.Space(5); - GUILayout.Label("", MicroStyles.UnitLabelStyle); + GUILayout.Label("", Styles.UnitLabelStyle); GUILayout.EndHorizontal(); - GUILayout.Space(MicroStyles.SpacingAfterHeader); + GUILayout.Space(Styles.SpacingAfterHeader); } - private void DrawStagesHeader(MicroWindow stageWindow) + private void DrawStagesHeader(BaseWindow stageWindow) { GUILayout.BeginHorizontal(); - stageWindow.IsFlightPoppedOut = stageWindow.IsFlightPoppedOut ? !CloseButton(MicroStyles.CloseBtnRect) : GUILayout.Button("⇖", MicroStyles.PopoutBtnStyle); + stageWindow.IsFlightPoppedOut = stageWindow.IsFlightPoppedOut ? !CloseButton(Styles.CloseBtnRect) : GUILayout.Button("⇖", Styles.PopoutBtnStyle); GUILayout.Label($"{stageWindow.Name}"); GUILayout.FlexibleSpace(); - GUILayout.Label("∆v", MicroStyles.TableHeaderLabelStyle); + GUILayout.Label("∆v", Styles.TableHeaderLabelStyle); GUILayout.Space(16); - GUILayout.Label($"TWR", MicroStyles.TableHeaderLabelStyle, GUILayout.Width(40)); + GUILayout.Label($"TWR", Styles.TableHeaderLabelStyle, GUILayout.Width(40)); GUILayout.Space(16); if (stageWindow.IsFlightPoppedOut) { - GUILayout.Label($"Burn", GUILayout.Width(56)); + GUILayout.Label($"Burn", GUILayout.Width(56)); } else { - GUILayout.Label($"Burn", MicroStyles.TableHeaderLabelStyle, GUILayout.Width(56)); + GUILayout.Label($"Burn", Styles.TableHeaderLabelStyle, GUILayout.Width(56)); } GUILayout.EndHorizontal(); - GUILayout.Space(MicroStyles.SpacingAfterHeader); + GUILayout.Space(Styles.SpacingAfterHeader); } private void DrawEntry(string entryName, string value, string unit = "") { GUILayout.BeginHorizontal(); - GUILayout.Label(entryName, MicroStyles.NameLabelStyle); + GUILayout.Label(entryName, Styles.NameLabelStyle); GUILayout.FlexibleSpace(); - GUILayout.Label(value, MicroStyles.ValueLabelStyle); + GUILayout.Label(value, Styles.ValueLabelStyle); GUILayout.Space(5); - GUILayout.Label(unit, MicroStyles.UnitLabelStyle); + GUILayout.Label(unit, Styles.UnitLabelStyle); GUILayout.EndHorizontal(); - GUILayout.Space(MicroStyles.SpacingAfterEntry); + GUILayout.Space(Styles.SpacingAfterEntry); } private void DrawStageEntry(int stageID, DeltaVStageInfo stageInfo, string twrFormatString) { GUILayout.BeginHorizontal(); - GUILayout.Label($"{stageID:00.}", MicroStyles.NameLabelStyle, GUILayout.Width(24)); + GUILayout.Label($"{stageID:00.}", Styles.NameLabelStyle, GUILayout.Width(24)); GUILayout.FlexibleSpace(); - GUILayout.Label($"{stageInfo.DeltaVActual:N0} m/s", MicroStyles.ValueLabelStyle); + GUILayout.Label($"{stageInfo.DeltaVActual:N0} m/s", Styles.ValueLabelStyle); GUILayout.Space(16); - GUILayout.Label($"{stageInfo.TWRActual.ToString(twrFormatString)}", MicroStyles.ValueLabelStyle, GUILayout.Width(40)); + GUILayout.Label($"{stageInfo.TWRActual.ToString(twrFormatString)}", Styles.ValueLabelStyle, GUILayout.Width(40)); GUILayout.Space(16); string burnTime = MicroUtility.SecondsToTimeString(stageInfo.StageBurnTime, false); string lastUnit = "s"; @@ -637,23 +626,23 @@ private void DrawStageEntry(int stageID, DeltaVStageInfo stageInfo, string twrFo lastUnit = "h"; } - GUILayout.Label($"{burnTime}{lastUnit}", MicroStyles.ValueLabelStyle, GUILayout.Width(56)); + GUILayout.Label($"{burnTime}{lastUnit}", Styles.ValueLabelStyle, GUILayout.Width(56)); GUILayout.EndHorizontal(); - GUILayout.Space(MicroStyles.SpacingAfterEntry); + GUILayout.Space(Styles.SpacingAfterEntry); } - private void DrawSectionEnd(MicroWindow window) + private void DrawSectionEnd(BaseWindow window) { if (window.IsFlightPoppedOut) { if (!window.IsLocked) - GUI.DragWindow(new Rect(0, 0, MicroStyles.WindowWidth, MicroStyles.WindowHeight)); + GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); - GUILayout.Space(MicroStyles.SpacingBelowPopout); + GUILayout.Space(Styles.SpacingBelowPopout); } else { - GUILayout.Space(MicroStyles.SpacingAfterSection); + GUILayout.Space(Styles.SpacingAfterSection); } } @@ -663,25 +652,25 @@ private void DrawSectionEnd(MicroWindow window) /// private void DrawEditWindow(int windowIndex) { - List editableWindows = MicroWindows.FindAll(w => w.IsEditable); // Editable windows are all except MainGUI, Settings, Stage and StageInfoOAB + List editableWindows = MicroWindows.FindAll(w => w.IsEditable); // Editable windows are all except MainGUI, Settings, Stage and StageInfoOAB List entriesByCategory = MicroEntries.FindAll(e => e.Category == selectedCategory); // All window stageInfoOabEntries belong to a category, but they can still be placed in any window - showEditWindow = !CloseButton(MicroStyles.CloseBtnRect); + showEditWindow = !CloseButton(Styles.CloseBtnRect); #region Selection of window to be edited GUILayout.BeginHorizontal(); - GUILayout.Label("EDITING WINDOW", MicroStyles.TitleLabelStyle); + GUILayout.Label("EDITING WINDOW", Styles.TitleLabelStyle); GUILayout.FlexibleSpace(); - if (GUILayout.Button("<", MicroStyles.OneCharacterBtnStyle)) + if (GUILayout.Button("<", Styles.OneCharacterBtnStyle)) { selectedWindowId = selectedWindowId > 0 ? selectedWindowId - 1 : editableWindows.Count - 1; } GUI.SetNextControlName(MicroUtility.InputDisableWindowAbbreviation); - editableWindows[selectedWindowId].Abbreviation = GUILayout.TextField(editableWindows[selectedWindowId].Abbreviation, MicroStyles.WindowSelectionAbbrevitionTextFieldStyle); + editableWindows[selectedWindowId].Abbreviation = GUILayout.TextField(editableWindows[selectedWindowId].Abbreviation, Styles.WindowSelectionAbbrevitionTextFieldStyle); editableWindows[selectedWindowId].Abbreviation = MicroUtility.ValidateAbbreviation(editableWindows[selectedWindowId].Abbreviation); GUI.SetNextControlName(MicroUtility.InputDisableWindowName); - editableWindows[selectedWindowId].Name = GUILayout.TextField(editableWindows[selectedWindowId].Name, MicroStyles.WindowSelectionTextFieldStyle); - if (GUILayout.Button(">", MicroStyles.OneCharacterBtnStyle)) + editableWindows[selectedWindowId].Name = GUILayout.TextField(editableWindows[selectedWindowId].Name, Styles.WindowSelectionTextFieldStyle); + if (GUILayout.Button(">", Styles.OneCharacterBtnStyle)) { selectedWindowId = selectedWindowId < editableWindows.Count - 1 ? selectedWindowId + 1 : 0; } @@ -697,66 +686,66 @@ private void DrawEditWindow(int windowIndex) GUILayout.FlexibleSpace(); if (editableWindows[selectedWindowId].IsDeletable) { - if (GUILayout.Button("DEL WINDOW", MicroStyles.NormalBtnStyle)) + if (GUILayout.Button("DEL WINDOW", Styles.NormalBtnStyle)) { MicroWindows.Remove(editableWindows[selectedWindowId]); editableWindows.Remove(editableWindows[selectedWindowId]); selectedWindowId--; } } - if (GUILayout.Button("NEW WINDOW", MicroStyles.NormalBtnStyle)) + if (GUILayout.Button("NEW WINDOW", Styles.NormalBtnStyle)) CreateCustomWindow(editableWindows); GUILayout.EndHorizontal(); GUILayout.Space(10); - MicroStyles.DrawHorizontalLine(); + Styles.DrawHorizontalLine(); GUILayout.Space(10); #region Installed entries in the selected window GUILayout.BeginHorizontal(); - GUILayout.Label("Installed", MicroStyles.NormalLabelStyle); + GUILayout.Label("Installed", Styles.NormalLabelStyle); GUILayout.EndHorizontal(); var entries = editableWindows[selectedWindowId].Entries.ToList(); foreach (var (entry, index) in entries.Select((entry, index) => (entry, index))) { GUILayout.BeginHorizontal(); - GUILayout.Label(entry.Name, MicroStyles.NameLabelStyle); - if (GUILayout.Button("↑", MicroStyles.OneCharacterBtnStyle)) + GUILayout.Label(entry.Name, Styles.NameLabelStyle); + if (GUILayout.Button("↑", Styles.OneCharacterBtnStyle)) { if (index > 0) editableWindows[selectedWindowId].MoveEntryUp(index); } - if (GUILayout.Button("↓", MicroStyles.OneCharacterBtnStyle)) + if (GUILayout.Button("↓", Styles.OneCharacterBtnStyle)) { if (index < editableWindows[selectedWindowId].Entries.Count - 1) editableWindows[selectedWindowId].MoveEntryDown(index); } - if (GUILayout.Button("X", MicroStyles.OneCharacterBtnStyle)) + if (GUILayout.Button("X", Styles.OneCharacterBtnStyle)) editableWindows[selectedWindowId].RemoveEntry(index); GUILayout.EndHorizontal(); } #endregion GUILayout.Space(10); - MicroStyles.DrawHorizontalLine(); + Styles.DrawHorizontalLine(); GUILayout.Space(10); #region All entries that can be added to any IsEditable window GUILayout.BeginHorizontal(); - GUILayout.Label("Add", MicroStyles.NormalLabelStyle); + GUILayout.Label("Add", Styles.NormalLabelStyle); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - GUILayout.Label("Category", MicroStyles.NormalLabelStyle); + GUILayout.Label("Category", Styles.NormalLabelStyle); GUILayout.FlexibleSpace(); - if (GUILayout.Button("<", MicroStyles.OneCharacterBtnStyle)) + if (GUILayout.Button("<", Styles.OneCharacterBtnStyle)) { selectedCategory = (int)selectedCategory > 0 ? selectedCategory - 1 : Enum.GetValues(typeof(MicroEntryCategory)).Cast().Last(); } - GUILayout.Label(selectedCategory.ToString(), MicroStyles.NormalCenteredLabelStyle); - if (GUILayout.Button(">", MicroStyles.OneCharacterBtnStyle)) + GUILayout.Label(selectedCategory.ToString(), Styles.NormalCenteredLabelStyle); + if (GUILayout.Button(">", Styles.OneCharacterBtnStyle)) { selectedCategory = (int)selectedCategory < (int)Enum.GetValues(typeof(MicroEntryCategory)).Cast().Last() ? selectedCategory + 1 : Enum.GetValues(typeof(MicroEntryCategory)).Cast().First(); } @@ -765,8 +754,8 @@ private void DrawEditWindow(int windowIndex) foreach (var (entry, index) in entriesByCategory.Select((entry, index) => (entry, index))) { GUILayout.BeginHorizontal(); - GUILayout.Label(entry.Name, MicroStyles.NameLabelStyle); - if (GUILayout.Button("?", MicroStyles.OneCharacterBtnStyle)) + GUILayout.Label(entry.Name, Styles.NameLabelStyle); + if (GUILayout.Button("?", Styles.OneCharacterBtnStyle)) { if (!showTooltip.condition) showTooltip = (true, index); @@ -778,7 +767,7 @@ private void DrawEditWindow(int windowIndex) showTooltip = (false, index); } } - if (GUILayout.Button("+", MicroStyles.OneCharacterBtnStyle)) + if (GUILayout.Button("+", Styles.OneCharacterBtnStyle)) { editableWindows[selectedWindowId].AddEntry(entry); } @@ -787,30 +776,30 @@ private void DrawEditWindow(int windowIndex) if (showTooltip.condition && showTooltip.index == index) { GUILayout.BeginHorizontal(); - GUILayout.Label(entry.Description, MicroStyles.BlueLabelStyle); + GUILayout.Label(entry.Description, Styles.BlueLabelStyle); GUILayout.EndHorizontal(); } } #endregion - GUI.DragWindow(new Rect(0, 0, MicroStyles.WindowWidth, MicroStyles.WindowHeight)); + GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); } /// /// Creates a new custom window user can fill with any entry /// /// - private void CreateCustomWindow(List editableWindows) + private void CreateCustomWindow(List editableWindows) { // Default window's name will be CustomX where X represents the first not used integer int nameID = 1; - foreach (MicroWindow window in editableWindows) + foreach (BaseWindow window in editableWindows) { if (window.Name == "Custom" + nameID) nameID++; } - MicroWindow newWindow = new MicroWindow() + BaseWindow newWindow = new BaseWindow() { Name = "Custom" + nameID, Abbreviation = nameID.ToString().Length == 1 ? "Cu" + nameID : nameID.ToString().Length == 2 ? "C" + nameID : nameID.ToString(), @@ -824,7 +813,7 @@ private void CreateCustomWindow(List editableWindows) IsLocked = false, MainWindow = MainWindow.None, //EditorRect = null, - FlightRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), Entries = new List() }; @@ -852,7 +841,7 @@ private void OnGUI_OAB() { if (!_showGuiOAB) return; - MicroWindow stageInfoOAB = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + BaseWindow stageInfoOAB = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); if (stageInfoOAB.Entries.Find(e => e.Name == "Stage Info (OAB)").EntryValue == null) return; stageInfoOAB.EditorRect = GUILayout.Window( @@ -860,7 +849,7 @@ private void OnGUI_OAB() stageInfoOAB.EditorRect, DrawStageInfoOAB, "", - MicroStyles.StageOABWindowStyle, + Styles.StageOABWindowStyle, GUILayout.Height(0) ); stageInfoOAB.EditorRect.position = MicroUtility.ClampToScreen(stageInfoOAB.EditorRect.position, stageInfoOAB.EditorRect.size); @@ -878,7 +867,7 @@ private void OnGUI_OAB() celestialBodyRect, DrawCelestialBodySelection, "", - MicroStyles.CelestialSelectionStyle, + Styles.CelestialSelectionStyle, GUILayout.Height(0) ); } @@ -894,7 +883,7 @@ private void OnGUI_OAB() settingsRect, DrawSettingsOabWindow, "", - MicroStyles.SettingsOabStyle, + Styles.SettingsOabStyle, GUILayout.Height(0) ); } @@ -902,14 +891,14 @@ private void OnGUI_OAB() private void DrawStageInfoOAB(int windowID) { - MicroWindow stageInfoOabWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + BaseWindow stageInfoOabWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); List stageInfoOabEntries = stageInfoOabWindow.Entries; GUILayout.BeginHorizontal(); - if (SettingsButton(MicroStyles.SettingsOABRect)) + if (SettingsButton(Styles.SettingsOABRect)) _showGuiSettingsOAB = !_showGuiSettingsOAB; - if (CloseButton(MicroStyles.CloseBtnStagesOABRect)) + if (CloseButton(Styles.CloseBtnStagesOABRect)) { stageInfoOabWindow.IsEditorActive = false; _showGuiOAB = false; @@ -919,42 +908,42 @@ private void DrawStageInfoOAB(int windowID) // Draw StageInfo header - Delta V fields GUILayout.BeginHorizontal(); - GUILayout.Label("Total ∆v (ASL, vacuum)", MicroStyles.NameLabelStyle); + GUILayout.Label("Total ∆v (ASL, vacuum)", Styles.NameLabelStyle); GUILayout.FlexibleSpace(); - GUILayout.Label($"{stageInfoOabEntries.Find(e => e.Name == "Total ∆v Actual (OAB)").ValueDisplay}, {stageInfoOabEntries.Find(e => e.Name == "Total ∆v Vac (OAB)").ValueDisplay}", MicroStyles.ValueLabelStyle); + GUILayout.Label($"{stageInfoOabEntries.Find(e => e.Name == "Total ∆v Actual (OAB)").ValueDisplay}, {stageInfoOabEntries.Find(e => e.Name == "Total ∆v Vac (OAB)").ValueDisplay}", Styles.ValueLabelStyle); GUILayout.Space(5); - GUILayout.Label("m/s", MicroStyles.UnitLabelStyle); + GUILayout.Label("m/s", Styles.UnitLabelStyle); GUILayout.EndHorizontal(); // Draw Torque Torque torque = (Torque)stageInfoOabEntries.Find(e => e.Name == "Torque"); if (torque.IsActive) { - GUILayout.Space(MicroStyles.SpacingAfterEntry); + GUILayout.Space(Styles.SpacingAfterEntry); GUILayout.BeginHorizontal(); - GUILayout.Label("Torque", MicroStyles.NameLabelStyle); + GUILayout.Label("Torque", Styles.NameLabelStyle); GUILayout.FlexibleSpace(); - GUILayout.Label(torque.ValueDisplay, MicroStyles.ValueLabelStyle); + GUILayout.Label(torque.ValueDisplay, Styles.ValueLabelStyle); GUILayout.Space(5); - GUILayout.Label(torque.Unit, MicroStyles.UnitLabelStyle); + GUILayout.Label(torque.Unit, Styles.UnitLabelStyle); GUILayout.EndHorizontal(); } // Draw Stage table header GUILayout.BeginHorizontal(); - GUILayout.Label("Stage", MicroStyles.NameLabelStyle, GUILayout.Width(40)); + GUILayout.Label("Stage", Styles.NameLabelStyle, GUILayout.Width(40)); GUILayout.FlexibleSpace(); - GUILayout.Label("TWR", MicroStyles.TableHeaderLabelStyle, GUILayout.Width(65)); - GUILayout.Label("SLT", MicroStyles.TableHeaderLabelStyle, GUILayout.Width(75)); - GUILayout.Label("", MicroStyles.TableHeaderLabelStyle, GUILayout.Width(30)); - GUILayout.Label("ASL ∆v", MicroStyles.TableHeaderLabelStyle, GUILayout.Width(75)); - GUILayout.Label("", MicroStyles.TableHeaderLabelStyle, GUILayout.Width(30)); - GUILayout.Label("Vac ∆v", MicroStyles.TableHeaderLabelStyle, GUILayout.Width(75)); - GUILayout.Label("Burn Time", MicroStyles.TableHeaderLabelStyle, GUILayout.Width(110)); + GUILayout.Label("TWR", Styles.TableHeaderLabelStyle, GUILayout.Width(65)); + GUILayout.Label("SLT", Styles.TableHeaderLabelStyle, GUILayout.Width(75)); + GUILayout.Label("", Styles.TableHeaderLabelStyle, GUILayout.Width(30)); + GUILayout.Label("ASL ∆v", Styles.TableHeaderLabelStyle, GUILayout.Width(75)); + GUILayout.Label("", Styles.TableHeaderLabelStyle, GUILayout.Width(30)); + GUILayout.Label("Vac ∆v", Styles.TableHeaderLabelStyle, GUILayout.Width(75)); + GUILayout.Label("Burn Time", Styles.TableHeaderLabelStyle, GUILayout.Width(110)); GUILayout.Space(20); - GUILayout.Label("Body", MicroStyles.TableHeaderCenteredLabelStyle, GUILayout.Width(80)); + GUILayout.Label("Body", Styles.TableHeaderCenteredLabelStyle, GUILayout.Width(80)); GUILayout.EndHorizontal(); - GUILayout.Space(MicroStyles.SpacingAfterEntry); + GUILayout.Space(Styles.SpacingAfterEntry); StageInfo_OAB stageInfoOab = (StageInfo_OAB)stageInfoOabWindow.Entries .Find(e => e.Name == "Stage Info (OAB)"); @@ -971,35 +960,35 @@ private void DrawStageInfoOAB(int windowID) stageInfoOab.AddNewCelestialBody(_celestialBodies); GUILayout.BeginHorizontal(); - GUILayout.Label(String.Format("{0:00}", ((List)stageInfoOab.EntryValue).Count - stages[stageIndex].Stage), MicroStyles.NameLabelStyle, GUILayout.Width(40)); + GUILayout.Label(String.Format("{0:00}", ((List)stageInfoOab.EntryValue).Count - stages[stageIndex].Stage), Styles.NameLabelStyle, GUILayout.Width(40)); GUILayout.FlexibleSpace(); // We calculate what factor needs to be applied to TWR in order to compensate for different gravity of the selected celestial body double twrFactor = _celestialBodies.GetTwrFactor(stageInfoOab.CelestialBodyForStage[celestialIndex]); - GUILayout.Label(String.Format("{0:N2}", stages[stageIndex].TWRVac * twrFactor), MicroStyles.ValueLabelStyle, GUILayout.Width(65)); + GUILayout.Label(String.Format("{0:N2}", stages[stageIndex].TWRVac * twrFactor), Styles.ValueLabelStyle, GUILayout.Width(65)); // Calculate Sea Level TWR and DeltaV CelestialBodyComponent cel = _celestialBodies.Bodies.Find(b => b.Name == stageInfoOab.CelestialBodyForStage[celestialIndex]).CelestialBodyComponent; - GUILayout.Label(String.Format("{0:N2}", stages[stageIndex].GetTWRAtSeaLevel(cel) * twrFactor), MicroStyles.ValueLabelStyle, GUILayout.Width(75)); - GUILayout.Label(String.Format("{0:N0}", stages[stageIndex].GetDeltaVelAtSeaLevel(cel)), MicroStyles.ValueLabelStyle, GUILayout.Width(75)); - GUILayout.Label("m/s", MicroStyles.UnitLabelStyleStageOAB, GUILayout.Width(30)); + GUILayout.Label(String.Format("{0:N2}", stages[stageIndex].GetTWRAtSeaLevel(cel) * twrFactor), Styles.ValueLabelStyle, GUILayout.Width(75)); + GUILayout.Label(String.Format("{0:N0}", stages[stageIndex].GetDeltaVelAtSeaLevel(cel)), Styles.ValueLabelStyle, GUILayout.Width(75)); + GUILayout.Label("m/s", Styles.UnitLabelStyleStageOAB, GUILayout.Width(30)); - GUILayout.Label(String.Format("{0:N0}", stages[stageIndex].DeltaVVac), MicroStyles.ValueLabelStyle, GUILayout.Width(75)); - GUILayout.Label("m/s", MicroStyles.UnitLabelStyleStageOAB, GUILayout.Width(30)); - GUILayout.Label(MicroUtility.SecondsToTimeString(stages[stageIndex].StageBurnTime, true, true), MicroStyles.ValueLabelStyle, GUILayout.Width(110)); + GUILayout.Label(String.Format("{0:N0}", stages[stageIndex].DeltaVVac), Styles.ValueLabelStyle, GUILayout.Width(75)); + GUILayout.Label("m/s", Styles.UnitLabelStyleStageOAB, GUILayout.Width(30)); + GUILayout.Label(MicroUtility.SecondsToTimeString(stages[stageIndex].StageBurnTime, true, true), Styles.ValueLabelStyle, GUILayout.Width(110)); GUILayout.Space(20); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); - if (GUILayout.Button(stageInfoOab.CelestialBodyForStage[celestialIndex], MicroStyles.CelestialBodyBtnStyle)) + if (GUILayout.Button(stageInfoOab.CelestialBodyForStage[celestialIndex], Styles.CelestialBodyBtnStyle)) { _celestialBodySelectionStageIndex = celestialIndex; } GUILayout.EndVertical(); GUILayout.EndHorizontal(); - GUILayout.Space(MicroStyles.SpacingAfterEntry); + GUILayout.Space(Styles.SpacingAfterEntry); } - GUILayout.Space(MicroStyles.SpacingBelowPopout); + GUILayout.Space(Styles.SpacingBelowPopout); GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height)); } @@ -1013,7 +1002,7 @@ private void DrawCelestialBodySelection(int id) foreach (var body in _celestialBodies.Bodies) { - if (GUILayout.Button(body.DisplayName, MicroStyles.CelestialSelectionBtnStyle)) + if (GUILayout.Button(body.DisplayName, Styles.CelestialSelectionBtnStyle)) { StageInfo_OAB stageInfoOab = (StageInfo_OAB)MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Stage Info (OAB)"); stageInfoOab.CelestialBodyForStage[_celestialBodySelectionStageIndex] = body.Name; @@ -1031,14 +1020,14 @@ private void DrawCelestialBodySelection(int id) /// private void DrawSettingsOabWindow(int id) { - if (CloseButton(MicroStyles.CloseBtnSettingsOABRect)) + if (CloseButton(Styles.CloseBtnSettingsOABRect)) _showGuiSettingsOAB = false; - MicroWindow stageInfoOabWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + BaseWindow stageInfoOabWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); List stageInfoOabEntries = stageInfoOabWindow.Entries; Torque torqueEntry = (Torque)stageInfoOabEntries.Find(e => e.Name == "Torque"); - torqueEntry.IsActive = GUILayout.Toggle(torqueEntry.IsActive, "Display Torque (experimental)\nTurn on CoT & CoM for this", MicroStyles.SectionToggleStyle); + torqueEntry.IsActive = GUILayout.Toggle(torqueEntry.IsActive, "Display Torque (experimental)\nTurn on CoT & CoM for this", Styles.SectionToggleStyle); } #endregion @@ -1049,7 +1038,7 @@ private void DrawSettingsOabWindow(int id) /// private bool CloseButton(Rect rect) { - return GUI.Button(rect, "X", MicroStyles.CloseBtnStyle); + return GUI.Button(rect, "X", Styles.CloseBtnStyle); } /// @@ -1059,7 +1048,7 @@ private bool CloseButton(Rect rect) /// private bool SettingsButton(Rect rect) { - return GUI.Button(rect, "≡", MicroStyles.SettingsBtnStyle); + return GUI.Button(rect, "≡", Styles.SettingsBtnStyle); } #region Window and data initialization @@ -1197,11 +1186,11 @@ private void InitializeEntries() /// private void InitializeWindows() { - MicroWindows = new List(); + MicroWindows = new List(); try { - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new BaseWindow { Name = "MainGui", Abbreviation = null, @@ -1215,11 +1204,11 @@ private void InitializeWindows() IsLocked = false, MainWindow = MainWindow.MainGui, //EditorRect = null, - FlightRect = new Rect(MicroStyles.MainGuiX, MicroStyles.MainGuiY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.MainGuiX, Styles.MainGuiY, Styles.WindowWidth, Styles.WindowHeight), Entries = null }); - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new BaseWindow { Name = "Settings", Abbreviation = "SET", @@ -1233,11 +1222,11 @@ private void InitializeWindows() IsLocked = false, MainWindow = MainWindow.Settings, //EditorRect = null, - FlightRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), Entries = null }); - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new BaseWindow { Name = "Vessel", Abbreviation = "VES", @@ -1251,11 +1240,11 @@ private void InitializeWindows() IsLocked = false, MainWindow = MainWindow.Vessel, //EditorRect = null, - FlightRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Vessel).ToList() }); - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new BaseWindow { Name = "Orbital", Abbreviation = "ORB", @@ -1269,11 +1258,11 @@ private void InitializeWindows() IsLocked = false, MainWindow = MainWindow.Orbital, //EditorRect = null, - FlightRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Orbital).ToList() }); - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new BaseWindow { Name = "Surface", Abbreviation = "SUR", @@ -1287,11 +1276,11 @@ private void InitializeWindows() IsLocked = false, MainWindow = MainWindow.Surface, //EditorRect = null, - FlightRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Surface).ToList() }); - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new BaseWindow { Name = "Flight", Abbreviation = "FLT", @@ -1305,11 +1294,11 @@ private void InitializeWindows() IsLocked = false, MainWindow = MainWindow.Flight, //EditorRect = null, - FlightRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Flight).ToList() }); - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new BaseWindow { Name = "Target", Abbreviation = "TGT", @@ -1323,15 +1312,16 @@ private void InitializeWindows() IsLocked = false, MainWindow = MainWindow.Target, //EditorRect = null, - FlightRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Target).ToList() }); - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new ManeuverWindow { Name = "Maneuver", Abbreviation = "MAN", Description = "Maneuver entries", + WindowType = typeof(ManeuverWindow), IsEditorActive = false, IsFlightActive = true, IsMapActive = false, @@ -1341,11 +1331,11 @@ private void InitializeWindows() IsLocked = false, MainWindow = MainWindow.Maneuver, //EditorRect = null, - FlightRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Maneuver).ToList() }); - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new BaseWindow { Name = "Stage", Abbreviation = "STG", @@ -1359,7 +1349,7 @@ private void InitializeWindows() IsLocked = false, MainWindow = MainWindow.Stage, //EditorRect = null, - FlightRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, MicroStyles.WindowWidth, MicroStyles.WindowHeight), + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Stage).ToList() }); @@ -1367,13 +1357,13 @@ private void InitializeWindows() } catch (Exception ex) { - Logger.LogError("Error creating a MicroWindow. Full exception: " + ex); + Logger.LogError("Error creating a BaseWindow. Full exception: " + ex); } } private void InitializeStageInfoOABWindow() { - MicroWindows.Add(new MicroWindow + MicroWindows.Add(new BaseWindow { Name = "Stage (OAB)", Abbreviation = "SOAB", @@ -1386,7 +1376,7 @@ private void InitializeStageInfoOABWindow() IsMapPoppedOut = false, // Not used IsLocked = false, // Not used MainWindow = MainWindow.StageInfoOAB, - EditorRect = new Rect(MicroStyles.PoppedOutX, MicroStyles.PoppedOutY, 0, 0), + EditorRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, 0, 0), Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.OAB).ToList() }); } diff --git a/MicroEngineerProject/MicroEngineer/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/MicroEntries.cs index 66c29be..f695510 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEntries.cs @@ -973,6 +973,8 @@ public override string ValueDisplay public class ProjectedAp : MicroEntry { + internal int SelectedNodeIndex = 0; + public ProjectedAp() { Name = "Projected Ap."; @@ -984,7 +986,18 @@ public ProjectedAp() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList.FirstOrDefault().ApoapsisArl; + List patchedConicsList = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList?.Where(p => p.ActivePatch == true).ToList(); + + if (patchedConicsList == null || patchedConicsList.Count() == 0) + { + EntryValue = null; + return; + } + + if (patchedConicsList.Count >= SelectedNodeIndex + 1) + { + EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[SelectedNodeIndex].ApoapsisArl; + } } public override string ValueDisplay @@ -1001,6 +1014,8 @@ public override string ValueDisplay public class ProjectedPe : MicroEntry { + internal int SelectedNodeIndex = 0; + public ProjectedPe() { Name = "Projected Pe."; @@ -1012,7 +1027,18 @@ public ProjectedPe() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList.FirstOrDefault().PeriapsisArl; + List patchedConicsList = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList?.Where(p => p.ActivePatch == true).ToList(); + + if (patchedConicsList == null || patchedConicsList.Count() == 0) + { + EntryValue = null; + return; + } + + if (patchedConicsList.Count >= SelectedNodeIndex + 1) + { + EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[SelectedNodeIndex].PeriapsisArl; + } } public override string ValueDisplay @@ -1029,6 +1055,8 @@ public override string ValueDisplay public class DeltaVRequired : MicroEntry { + internal int SelectedNodeIndex = 0; + public DeltaVRequired() { Name = "∆v required"; @@ -1040,7 +1068,28 @@ public DeltaVRequired() public override void RefreshData() { - EntryValue = (MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut)).magnitude; + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count == 1) + { + EntryValue = (MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut)).magnitude; + } + else if (nodes.Count >= SelectedNodeIndex + 1) + { + EntryValue = nodes[SelectedNodeIndex].BurnRequiredDV; + } + else + { + EntryValue = null; + return; + } } public override string ValueDisplay @@ -1057,6 +1106,8 @@ public override string ValueDisplay public class TimeToNode : MicroEntry { + internal int SelectedNodeIndex = 0; + public TimeToNode() { Name = "Time to Node"; @@ -1068,7 +1119,28 @@ public TimeToNode() public override void RefreshData() { - EntryValue = MicroUtility.CurrentManeuver != null ? MicroUtility.CurrentManeuver.Time - GameManager.Instance.Game.UniverseModel.UniversalTime : null; + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count == 1) + { + EntryValue = MicroUtility.CurrentManeuver.Time - GameManager.Instance.Game.UniverseModel.UniversalTime; + } + else if (nodes.Count >= SelectedNodeIndex + 1) + { + EntryValue = nodes[SelectedNodeIndex].Time - GameManager.Instance.Game.UniverseModel.UniversalTime; + } + else + { + EntryValue = null; + return; + } } public override string ValueDisplay @@ -1085,6 +1157,8 @@ public override string ValueDisplay public class BurnTime : MicroEntry { + internal int SelectedNodeIndex = 0; + public BurnTime() { Name = "Burn Time"; @@ -1096,7 +1170,28 @@ public BurnTime() public override void RefreshData() { - EntryValue = MicroUtility.CurrentManeuver?.BurnDuration; + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count == 1) + { + EntryValue = MicroUtility.CurrentManeuver?.BurnDuration; + } + else if (nodes.Count >= SelectedNodeIndex + 1) + { + EntryValue = nodes[SelectedNodeIndex].BurnDuration; + } + else + { + EntryValue = null; + return; + } } public override string ValueDisplay diff --git a/MicroEngineerProject/MicroEngineer/MicroUtility.cs b/MicroEngineerProject/MicroEngineer/MicroUtility.cs index 5187455..5594f65 100644 --- a/MicroEngineerProject/MicroEngineer/MicroUtility.cs +++ b/MicroEngineerProject/MicroEngineer/MicroUtility.cs @@ -54,7 +54,7 @@ public static string DegreesToDMS(double degreeD) int minutes = ts.Minutes; int seconds = ts.Seconds; - string result = $"{degrees:N0}° {minutes:00}' {seconds:00}\""; + string result = $"{degrees:N0}° {minutes:00}' {seconds:00}\""; return result; } @@ -97,13 +97,13 @@ public static string SecondsToTimeString(double seconds, bool addSpacing = true, if (days > 0) { - result += $"{days}{spacing}d "; + result += $"{days}{spacing}d "; } if (hours > 0 || days > 0) { { - result += $"{hours}{spacing}h "; + result += $"{hours}{spacing}h "; } } @@ -111,21 +111,21 @@ public static string SecondsToTimeString(double seconds, bool addSpacing = true, { if (hours > 0 || days > 0) { - result += $"{minutes:00.}{spacing}m "; + result += $"{minutes:00.}{spacing}m "; } else { - result += $"{minutes}{spacing}m "; + result += $"{minutes}{spacing}m "; } } if (minutes > 0 || hours > 0 || days > 0) { - result += returnLastUnit ? $"{secs:00.}{spacing}s" : $"{secs:00.}"; + result += returnLastUnit ? $"{secs:00.}{spacing}s" : $"{secs:00.}"; } else { - result += returnLastUnit ? $"{secs}{spacing}s" : $"{secs}"; + result += returnLastUnit ? $"{secs}{spacing}s" : $"{secs}"; } return result; @@ -170,7 +170,7 @@ public static string ValidateAbbreviation(string abbreviation) return abbreviation.Substring(0, Math.Min(abbreviation.Length, 3)).ToUpperInvariant(); } - public static void SaveLayout(List windows) + internal static void SaveLayout(List windows) { try { @@ -186,11 +186,11 @@ public static void SaveLayout(List windows) } } - public static void LoadLayout(List windows) + internal static void LoadLayout(List windows) { try { - List deserializedWindows = JsonConvert.DeserializeObject>(File.ReadAllText(LayoutPath)); + List deserializedWindows = JsonConvert.DeserializeObject>(File.ReadAllText(LayoutPath)); windows.Clear(); windows.AddRange(deserializedWindows); diff --git a/MicroEngineerProject/MicroEngineer/MicroStyles.cs b/MicroEngineerProject/MicroEngineer/Styles.cs similarity index 93% rename from MicroEngineerProject/MicroEngineer/MicroStyles.cs rename to MicroEngineerProject/MicroEngineer/Styles.cs index 443ea23..0914658 100644 --- a/MicroEngineerProject/MicroEngineer/MicroStyles.cs +++ b/MicroEngineerProject/MicroEngineer/Styles.cs @@ -3,7 +3,7 @@ namespace MicroMod { - public static class MicroStyles + public static class Styles { public static int WindowWidth = 290; public static int WindowHeight = 1440; @@ -15,6 +15,7 @@ public static class MicroStyles public static GUIStyle PopoutWindowStyle; public static GUIStyle EditWindowStyle; public static GUIStyle StageOABWindowStyle; + public static GUIStyle CelestialSelectionStyle; public static GUIStyle SettingsOabStyle; public static GUIStyle PopoutBtnStyle; @@ -29,6 +30,7 @@ public static class MicroStyles public static GUIStyle NormalCenteredLabelStyle; public static GUIStyle WindowSelectionTextFieldStyle; public static GUIStyle WindowSelectionAbbrevitionTextFieldStyle; + public static GUIStyle CloseBtnStyle; public static GUIStyle SettingsBtnStyle; public static GUIStyle CloseBtnStageOABStyle; @@ -36,6 +38,7 @@ public static class MicroStyles public static GUIStyle CelestialBodyBtnStyle; public static GUIStyle CelestialSelectionBtnStyle; public static GUIStyle OneCharacterBtnStyle; + public static GUIStyle TableHeaderLabelStyle; public static GUIStyle TableHeaderCenteredLabelStyle; @@ -51,11 +54,11 @@ public static class MicroStyles public static float MainGuiX = Screen.width * 0.8f; public static float MainGuiY = Screen.height * 0.2f; - public static Rect CloseBtnRect = new Rect(MicroStyles.WindowWidth - 23, 6, 16, 16); - public static Rect CloseBtnStagesOABRect = new Rect(MicroStyles.WindowWidthStageOAB - 23, 6, 16, 16); - public static Rect CloseBtnSettingsOABRect = new Rect(MicroStyles.WindowWidthSettingsOAB - 23, 6, 16, 16); - public static Rect SettingsOABRect = new Rect(MicroStyles.WindowWidthStageOAB - 50, 6, 16, 16); - public static Rect EditWindowRect = new Rect(Screen.width * 0.5f - MicroStyles.WindowWidth / 2, Screen.height * 0.2f, MicroStyles.WindowWidth, 0); + public static Rect CloseBtnRect = new Rect(Styles.WindowWidth - 23, 6, 16, 16); + public static Rect CloseBtnStagesOABRect = new Rect(Styles.WindowWidthStageOAB - 23, 6, 16, 16); + public static Rect CloseBtnSettingsOABRect = new Rect(Styles.WindowWidthSettingsOAB - 23, 6, 16, 16); + public static Rect SettingsOABRect = new Rect(Styles.WindowWidthStageOAB - 50, 6, 16, 16); + public static Rect EditWindowRect = new Rect(Screen.width * 0.5f - Styles.WindowWidth / 2, Screen.height * 0.2f, Styles.WindowWidth, 0); public static void InitializeStyles() { @@ -235,7 +238,7 @@ public static void DrawHorizontalLine(float height) /// /// Draws a white horizontal line accross the container it's put in with height of 1 px /// - public static void DrawHorizontalLine() { MicroStyles.DrawHorizontalLine(1); } + public static void DrawHorizontalLine() { Styles.DrawHorizontalLine(1); } internal static void SetStylesForOldSpaceWarpSkin() { diff --git a/MicroEngineerProject/MicroEngineer/MicroWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs similarity index 67% rename from MicroEngineerProject/MicroEngineer/MicroWindow.cs rename to MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs index bca8901..dc24b44 100644 --- a/MicroEngineerProject/MicroEngineer/MicroWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs @@ -1,5 +1,6 @@ using UnityEngine; using Newtonsoft.Json; +using System.Runtime.CompilerServices; namespace MicroMod { @@ -7,61 +8,63 @@ namespace MicroMod /// Window that can hold a list of Entries /// [JsonObject(MemberSerialization.OptIn)] - public class MicroWindow + internal class BaseWindow { [JsonProperty] - public string Name; + internal string Name; [JsonProperty] - public string Abbreviation; + internal string Abbreviation; [JsonProperty] - public string Description; // not used + internal string Description; // not used + [JsonProperty] + internal Type WindowType = typeof(BaseWindow); [JsonProperty] - public bool IsEditorActive; + internal bool IsEditorActive; [JsonProperty] - public bool IsFlightActive; + internal bool IsFlightActive; [JsonProperty] - public bool IsMapActive; // TODO: implement + internal bool IsMapActive; // TODO: implement [JsonProperty] - public bool IsEditorPoppedOut; + internal bool IsEditorPoppedOut; [JsonProperty] - public bool IsFlightPoppedOut; + internal bool IsFlightPoppedOut; [JsonProperty] - public bool IsMapPoppedOut; + internal bool IsMapPoppedOut; /// /// Can the window be dragged or closed /// [JsonProperty] - public bool IsLocked; + internal bool IsLocked; /// /// Window can be deleted if it's not one of main windows /// [JsonProperty] - public bool IsDeletable { get => MainWindow == MainWindow.None; } + internal bool IsDeletable { get => MainWindow == MainWindow.None; } /// /// Can the window be edited (add, remove & arrange entries) /// [JsonProperty] - public bool IsEditable { get => MainWindow != MainWindow.MainGui && MainWindow != MainWindow.Settings && MainWindow != MainWindow.Stage && MainWindow != MainWindow.StageInfoOAB; } + internal bool IsEditable { get => MainWindow != MainWindow.MainGui && MainWindow != MainWindow.Settings && MainWindow != MainWindow.Stage && MainWindow != MainWindow.StageInfoOAB; } [JsonProperty] - public MainWindow MainWindow; + internal MainWindow MainWindow; [JsonProperty] - public Rect EditorRect; + internal Rect EditorRect; [JsonProperty] - public Rect FlightRect; + internal Rect FlightRect; [JsonProperty] - public List Entries; + internal List Entries; /// /// Moves entry upwards in the window. Does nothing if it's already first. /// /// Entry's current index - public void MoveEntryUp(int entryIndex) + internal void MoveEntryUp(int entryIndex) { // check if entry exists and it's not first if (entryIndex < Entries.Count && entryIndex > 0) @@ -76,7 +79,7 @@ public void MoveEntryUp(int entryIndex) /// Moves entry downwards in the window. Does nothing if it's already last. /// /// Entry's current index - public void MoveEntryDown(int entryIndex) + internal void MoveEntryDown(int entryIndex) { // check if entry is not last if (entryIndex < Entries.Count - 1) @@ -91,7 +94,7 @@ public void MoveEntryDown(int entryIndex) /// Removes entry from the window /// /// Entry's index - public void RemoveEntry(int entryIndex) + internal void RemoveEntry(int entryIndex) { if (entryIndex < Entries.Count) Entries.RemoveAt(entryIndex); @@ -101,16 +104,29 @@ public void RemoveEntry(int entryIndex) /// Adds an entry to the window to the last position /// /// - public void AddEntry(MicroEntry entry) => Entries.Add(entry); + internal void AddEntry(MicroEntry entry) => Entries.Add(entry); /// /// Grabs new data for each entry in the window /// - public void RefreshEntryData() + internal void RefreshEntryData() { foreach (MicroEntry entry in Entries) entry.RefreshData(); } + + internal virtual void DrawWindowHeader() { } + + internal virtual void DrawWindowFooter() { } + + internal virtual void RefreshData() + { + if (Entries == null || Entries.Count == 0) + return; + + foreach (MicroEntry entry in Entries) + entry.RefreshData(); + } } /// diff --git a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs new file mode 100644 index 0000000..8f4967e --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs @@ -0,0 +1,88 @@ +using KSP.Game; +using KSP.Sim.impl; +using KSP.Sim.Maneuver; +using UnityEngine; + +namespace MicroMod +{ + internal class ManeuverWindow : BaseWindow + { + internal int SelectedNodeIndex = 0; + internal List Nodes = new(); + + override internal void DrawWindowHeader() + { + if (Nodes == null || Nodes.Count <= 1) + return; + + GUILayout.Space(10); + + GUILayout.BeginHorizontal(); + + if (GUILayout.Button("<", Styles.NormalBtnStyle) && SelectedNodeIndex > 0) + SelectedNodeIndex--; + + GUILayout.Label($"Node #{SelectedNodeIndex + 1}", Styles.TableHeaderCenteredLabelStyle); + + if (GUILayout.Button(">", Styles.NormalBtnStyle) && SelectedNodeIndex + 1 < Nodes.Count) + SelectedNodeIndex++; + + GUILayout.EndHorizontal(); + } + + override internal void DrawWindowFooter() + { + if (Nodes == null || Nodes.Count == 0) + return; + + GUILayout.Space(10); + + GUILayout.BeginHorizontal(); + if (GUILayout.Button("Delete", Styles.NormalBtnStyle)) + DeleteNodes(); + + GUILayout.EndHorizontal(); + } + + private void DeleteNodes() + { + var activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); + List nodeData = new List(); + + var nodeToDelete = activeVesselPlan.GetNodes()[SelectedNodeIndex]; + nodeData.Add(nodeToDelete); + + foreach (ManeuverNodeData node in activeVesselPlan.GetNodes()) + { + if (!nodeData.Contains(node) && (!nodeToDelete.IsOnManeuverTrajectory || nodeToDelete.Time < node.Time)) + nodeData.Add(node); + } + GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodeData); + SelectedNodeIndex = 0; + } + + internal override void RefreshData() + { + base.RefreshData(); + RefreshManeuverNodes(); + + // Add SelectedNodeIndex to base entries as well. They will show the correct node's info. + (Entries.Find(e => e.GetType() == typeof(ProjectedAp)) as ProjectedAp).SelectedNodeIndex = SelectedNodeIndex; + (Entries.Find(e => e.GetType() == typeof(ProjectedPe)) as ProjectedPe).SelectedNodeIndex = SelectedNodeIndex; + (Entries.Find(e => e.GetType() == typeof(DeltaVRequired)) as DeltaVRequired).SelectedNodeIndex = SelectedNodeIndex; + (Entries.Find(e => e.GetType() == typeof(TimeToNode)) as TimeToNode).SelectedNodeIndex = SelectedNodeIndex; + (Entries.Find(e => e.GetType() == typeof(BurnTime)) as BurnTime).SelectedNodeIndex = SelectedNodeIndex; + } + + internal void RefreshManeuverNodes() + { + //MicroUtility.RefreshActiveVesselAndCurrentManeuver(); -> check if we need this here + + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); + if (activeVesselPlan != null) + { + Nodes = activeVesselPlan.GetNodes(); + } + } + } +} From 1cb14cd1486ce4a7ba39e6e25e9216e30b9615aa Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sun, 16 Apr 2023 02:07:10 +0200 Subject: [PATCH 03/38] Update maneuver window - subscribe to ManeuverCreatedMessage: sets the selected node index to the newly created node - draw new maneuver controls on docked window as well --- .../MicroEngineer/MicroEngineerMod.cs | 13 +++++++++++++ .../MicroEngineer/Windows/ManeuverWindow.cs | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 28c325d..4fba2e1 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -126,6 +126,15 @@ private void SubscribeToMessages() // We are saving layout state when exiting from Flight or OAB game state MicroUtility.MessageCenter.Subscribe(new Action(this.GameStateLeft)); + + // Sets the selected node index to the newly created node + MicroUtility.MessageCenter.Subscribe(new Action(this.OnManeuverCreatedMessage)); + } + + private void OnManeuverCreatedMessage(MessageCenterMessage message) + { + var maneuverWindow = MicroWindows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; + maneuverWindow.OnManeuverCreatedMessage(message); } private void GameStateEntered(MessageCenterMessage obj) @@ -399,9 +408,13 @@ private void FillMainGUI(int windowID) DrawSectionHeader(window.Name, ref window.IsFlightPoppedOut, window.IsLocked, ""); + window.DrawWindowHeader(); + foreach (MicroEntry entry in window.Entries) DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); + window.DrawWindowFooter(); + DrawSectionEnd(window); } diff --git a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs index 8f4967e..2ec589a 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs @@ -1,4 +1,5 @@ using KSP.Game; +using KSP.Messages; using KSP.Sim.impl; using KSP.Sim.Maneuver; using UnityEngine; @@ -84,5 +85,11 @@ internal void RefreshManeuverNodes() Nodes = activeVesselPlan.GetNodes(); } } + + internal void OnManeuverCreatedMessage(MessageCenterMessage message) + { + var nodeData = MicroUtility.ActiveVessel.SimulationObject?.FindComponent()?.GetNodes(); + SelectedNodeIndex = nodeData != null ? nodeData.Count > 0 ? nodeData.Count - 1 : 0 : 0; + } } } From 815373fbb89b36f6dbb013decf4da8a519b79c86 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sun, 16 Apr 2023 02:17:37 +0200 Subject: [PATCH 04/38] Make maneuver fields private --- .../MicroEngineer/Windows/ManeuverWindow.cs | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs index 2ec589a..b78a568 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs @@ -8,32 +8,32 @@ namespace MicroMod { internal class ManeuverWindow : BaseWindow { - internal int SelectedNodeIndex = 0; - internal List Nodes = new(); + private int _selectedNodeIndex = 0; + private List _nodes = new(); override internal void DrawWindowHeader() { - if (Nodes == null || Nodes.Count <= 1) + if (_nodes == null || _nodes.Count <= 1) return; GUILayout.Space(10); GUILayout.BeginHorizontal(); - if (GUILayout.Button("<", Styles.NormalBtnStyle) && SelectedNodeIndex > 0) - SelectedNodeIndex--; + if (GUILayout.Button("<", Styles.NormalBtnStyle) && _selectedNodeIndex > 0) + _selectedNodeIndex--; - GUILayout.Label($"Node #{SelectedNodeIndex + 1}", Styles.TableHeaderCenteredLabelStyle); + GUILayout.Label($"Node #{_selectedNodeIndex + 1}", Styles.TableHeaderCenteredLabelStyle); - if (GUILayout.Button(">", Styles.NormalBtnStyle) && SelectedNodeIndex + 1 < Nodes.Count) - SelectedNodeIndex++; + if (GUILayout.Button(">", Styles.NormalBtnStyle) && _selectedNodeIndex + 1 < _nodes.Count) + _selectedNodeIndex++; GUILayout.EndHorizontal(); } override internal void DrawWindowFooter() { - if (Nodes == null || Nodes.Count == 0) + if (_nodes == null || _nodes.Count == 0) return; GUILayout.Space(10); @@ -50,7 +50,7 @@ private void DeleteNodes() var activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); List nodeData = new List(); - var nodeToDelete = activeVesselPlan.GetNodes()[SelectedNodeIndex]; + var nodeToDelete = activeVesselPlan.GetNodes()[_selectedNodeIndex]; nodeData.Add(nodeToDelete); foreach (ManeuverNodeData node in activeVesselPlan.GetNodes()) @@ -59,7 +59,7 @@ private void DeleteNodes() nodeData.Add(node); } GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodeData); - SelectedNodeIndex = 0; + _selectedNodeIndex = 0; } internal override void RefreshData() @@ -67,29 +67,29 @@ internal override void RefreshData() base.RefreshData(); RefreshManeuverNodes(); - // Add SelectedNodeIndex to base entries as well. They will show the correct node's info. - (Entries.Find(e => e.GetType() == typeof(ProjectedAp)) as ProjectedAp).SelectedNodeIndex = SelectedNodeIndex; - (Entries.Find(e => e.GetType() == typeof(ProjectedPe)) as ProjectedPe).SelectedNodeIndex = SelectedNodeIndex; - (Entries.Find(e => e.GetType() == typeof(DeltaVRequired)) as DeltaVRequired).SelectedNodeIndex = SelectedNodeIndex; - (Entries.Find(e => e.GetType() == typeof(TimeToNode)) as TimeToNode).SelectedNodeIndex = SelectedNodeIndex; - (Entries.Find(e => e.GetType() == typeof(BurnTime)) as BurnTime).SelectedNodeIndex = SelectedNodeIndex; + // Add _selectedNodeIndex to base entries as well. They will show the correct node's info. + (Entries.Find(e => e.GetType() == typeof(ProjectedAp)) as ProjectedAp).SelectedNodeIndex = _selectedNodeIndex; + (Entries.Find(e => e.GetType() == typeof(ProjectedPe)) as ProjectedPe).SelectedNodeIndex = _selectedNodeIndex; + (Entries.Find(e => e.GetType() == typeof(DeltaVRequired)) as DeltaVRequired).SelectedNodeIndex = _selectedNodeIndex; + (Entries.Find(e => e.GetType() == typeof(TimeToNode)) as TimeToNode).SelectedNodeIndex = _selectedNodeIndex; + (Entries.Find(e => e.GetType() == typeof(BurnTime)) as BurnTime).SelectedNodeIndex = _selectedNodeIndex; } - internal void RefreshManeuverNodes() + private void RefreshManeuverNodes() { //MicroUtility.RefreshActiveVesselAndCurrentManeuver(); -> check if we need this here ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); if (activeVesselPlan != null) { - Nodes = activeVesselPlan.GetNodes(); + _nodes = activeVesselPlan.GetNodes(); } } internal void OnManeuverCreatedMessage(MessageCenterMessage message) { var nodeData = MicroUtility.ActiveVessel.SimulationObject?.FindComponent()?.GetNodes(); - SelectedNodeIndex = nodeData != null ? nodeData.Count > 0 ? nodeData.Count - 1 : 0 : 0; + _selectedNodeIndex = nodeData != null ? nodeData.Count > 0 ? nodeData.Count - 1 : 0 : 0; } } } From 799d767ef42c97135bde12fe429815cc962859d9 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sun, 16 Apr 2023 15:36:31 +0200 Subject: [PATCH 05/38] More maneuver updates - Create new ManeuverEntry class, inherits from MicroEntry - Change ManeuverPrograde, ManeuverNormal, ManeuverRadial category to maneuver - Fix data refresh from generating NREs if entries are not added to the Maneuver window --- .../MicroEngineer/MicroEntries.cs | 226 +++++++++++------- .../MicroEngineer/Windows/ManeuverWindow.cs | 11 +- 2 files changed, 151 insertions(+), 86 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/MicroEntries.cs index f695510..abed71c 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEntries.cs @@ -42,6 +42,12 @@ public virtual string ValueDisplay public virtual void RefreshData() { } } + public class ManeuverEntry : MicroEntry + { + internal int SelectedNodeIndex = 0; + } + + #region Flight scene entries public class Vessel : MicroEntry { @@ -971,10 +977,8 @@ public override string ValueDisplay } } - public class ProjectedAp : MicroEntry + public class ProjectedAp : ManeuverEntry { - internal int SelectedNodeIndex = 0; - public ProjectedAp() { Name = "Projected Ap."; @@ -994,9 +998,9 @@ public override void RefreshData() return; } - if (patchedConicsList.Count >= SelectedNodeIndex + 1) + if (patchedConicsList.Count >= base.SelectedNodeIndex + 1) { - EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[SelectedNodeIndex].ApoapsisArl; + EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[base.SelectedNodeIndex].ApoapsisArl; } } @@ -1012,10 +1016,8 @@ public override string ValueDisplay } } - public class ProjectedPe : MicroEntry + public class ProjectedPe : ManeuverEntry { - internal int SelectedNodeIndex = 0; - public ProjectedPe() { Name = "Projected Pe."; @@ -1035,9 +1037,9 @@ public override void RefreshData() return; } - if (patchedConicsList.Count >= SelectedNodeIndex + 1) + if (patchedConicsList.Count >= base.SelectedNodeIndex + 1) { - EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[SelectedNodeIndex].PeriapsisArl; + EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[base.SelectedNodeIndex].PeriapsisArl; } } @@ -1053,10 +1055,8 @@ public override string ValueDisplay } } - public class DeltaVRequired : MicroEntry + public class DeltaVRequired : ManeuverEntry { - internal int SelectedNodeIndex = 0; - public DeltaVRequired() { Name = "∆v required"; @@ -1081,9 +1081,9 @@ public override void RefreshData() { EntryValue = (MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut)).magnitude; } - else if (nodes.Count >= SelectedNodeIndex + 1) + else if (nodes.Count >= base.SelectedNodeIndex + 1) { - EntryValue = nodes[SelectedNodeIndex].BurnRequiredDV; + EntryValue = nodes[base.SelectedNodeIndex].BurnRequiredDV; } else { @@ -1104,10 +1104,133 @@ public override string ValueDisplay } } - public class TimeToNode : MicroEntry + public class ManeuverPrograde : ManeuverEntry { - internal int SelectedNodeIndex = 0; + public ManeuverPrograde() + { + Name = "∆v Prograde"; + Description = ""; + Category = MicroEntryCategory.Maneuver; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = nodes[base.SelectedNodeIndex].BurnVector.z; + } + else + { + EntryValue = null; + return; + } + + // DOESN'T WORK + //EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.z - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).z; + + //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.z; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ManeuverNormal : ManeuverEntry + { + public ManeuverNormal() + { + Name = "∆v Normal"; + Description = ""; + Category = MicroEntryCategory.Maneuver; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = nodes[base.SelectedNodeIndex].BurnVector.y; + } + else + { + EntryValue = null; + return; + } + + // DOESN'T WORK + // EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.y - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).y; + + //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.y; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ManeuverRadial : ManeuverEntry + { + public ManeuverRadial() + { + Name = "∆v Radial"; + Description = ""; + Category = MicroEntryCategory.Maneuver; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = nodes[base.SelectedNodeIndex].BurnVector.x; + } + else + { + EntryValue = null; + return; + } + + // DOESN'T WORK + // EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.x - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).x; + + //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.x; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + + + public class TimeToNode : ManeuverEntry + { public TimeToNode() { Name = "Time to Node"; @@ -1132,9 +1255,9 @@ public override void RefreshData() { EntryValue = MicroUtility.CurrentManeuver.Time - GameManager.Instance.Game.UniverseModel.UniversalTime; } - else if (nodes.Count >= SelectedNodeIndex + 1) + else if (nodes.Count >= base.SelectedNodeIndex + 1) { - EntryValue = nodes[SelectedNodeIndex].Time - GameManager.Instance.Game.UniverseModel.UniversalTime; + EntryValue = nodes[base.SelectedNodeIndex].Time - GameManager.Instance.Game.UniverseModel.UniversalTime; } else { @@ -1155,10 +1278,8 @@ public override string ValueDisplay } } - public class BurnTime : MicroEntry + public class BurnTime : ManeuverEntry { - internal int SelectedNodeIndex = 0; - public BurnTime() { Name = "Burn Time"; @@ -1183,9 +1304,9 @@ public override void RefreshData() { EntryValue = MicroUtility.CurrentManeuver?.BurnDuration; } - else if (nodes.Count >= SelectedNodeIndex + 1) + else if (nodes.Count >= base.SelectedNodeIndex + 1) { - EntryValue = nodes[SelectedNodeIndex].BurnDuration; + EntryValue = nodes[base.SelectedNodeIndex].BurnDuration; } else { @@ -2826,62 +2947,7 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class ManeuverPrograde : MicroEntry - { - public ManeuverPrograde() - { - Name = "∆v Prograde"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.CurrentManeuver?.BurnVector.z; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ManeuverNormal : MicroEntry - { - public ManeuverNormal() - { - Name = "∆v Normal"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.CurrentManeuver?.BurnVector.y; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ManeuverRadial : MicroEntry - { - public ManeuverRadial() - { - Name = "∆v Radial"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.CurrentManeuver?.BurnVector.x; - } - - public override string ValueDisplay => base.ValueDisplay; - } + diff --git a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs index b78a568..5602ab4 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs @@ -67,12 +67,11 @@ internal override void RefreshData() base.RefreshData(); RefreshManeuverNodes(); - // Add _selectedNodeIndex to base entries as well. They will show the correct node's info. - (Entries.Find(e => e.GetType() == typeof(ProjectedAp)) as ProjectedAp).SelectedNodeIndex = _selectedNodeIndex; - (Entries.Find(e => e.GetType() == typeof(ProjectedPe)) as ProjectedPe).SelectedNodeIndex = _selectedNodeIndex; - (Entries.Find(e => e.GetType() == typeof(DeltaVRequired)) as DeltaVRequired).SelectedNodeIndex = _selectedNodeIndex; - (Entries.Find(e => e.GetType() == typeof(TimeToNode)) as TimeToNode).SelectedNodeIndex = _selectedNodeIndex; - (Entries.Find(e => e.GetType() == typeof(BurnTime)) as BurnTime).SelectedNodeIndex = _selectedNodeIndex; + // Add _selectedNodeIndex to entries as well. They will show the correct node's info. + List entries = Entries.OfType().ToList(); + + foreach (var entry in entries) + entry.SelectedNodeIndex = _selectedNodeIndex; } private void RefreshManeuverNodes() From 5d1df8e2427cf0f6a98ce4b42fc6d3bf3e91ae3c Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sun, 16 Apr 2023 22:19:46 +0200 Subject: [PATCH 06/38] New Target entries - Add new folder Entries - Move target entries to new file Entries\TargetEntries.cs - Add new class TargetEntry that inherits from MicroEntry - All target entries are now TargetEntry - Move maneuver entries to new file Entries\ManeuverEntries.cs - Add static UniversalTime to MicroUtility --- .../MicroEngineer/Entries/ManeuverEntries.cs | 360 +++++++++ .../MicroEngineer/Entries/TargetEntries.cs | 580 +++++++++++++++ .../MicroEngineer/MicroEngineerMod.cs | 25 + .../MicroEngineer/MicroEntries.cs | 699 +++++------------- .../MicroEngineer/MicroUtility.cs | 1 + 5 files changed, 1155 insertions(+), 510 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs create mode 100644 MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs new file mode 100644 index 0000000..5a71d48 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -0,0 +1,360 @@ +using KSP.Game; +using KSP.Sim.impl; + +namespace MicroMod +{ + public class ManeuverEntry : MicroEntry + { + internal int SelectedNodeIndex = 0; + } + + public class ProjectedAp : ManeuverEntry + { + public ProjectedAp() + { + Name = "Projected Ap."; + Description = "Shows the projected apoapsis vessel will have after completing the maneuver."; + Category = MicroEntryCategory.Maneuver; + Unit = "m"; + Formatting = null; + } + + public override void RefreshData() + { + List patchedConicsList = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList?.Where(p => p.ActivePatch == true).ToList(); + + if (patchedConicsList == null || patchedConicsList.Count() == 0) + { + EntryValue = null; + return; + } + + if (patchedConicsList.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[base.SelectedNodeIndex].ApoapsisArl; + } + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.MetersToDistanceString((double)EntryValue); + } + } + } + + public class ProjectedPe : ManeuverEntry + { + public ProjectedPe() + { + Name = "Projected Pe."; + Description = "Shows the projected periapsis vessel will have after completing the maneuver."; + Category = MicroEntryCategory.Maneuver; + Unit = "m"; + Formatting = null; + } + + public override void RefreshData() + { + List patchedConicsList = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList?.Where(p => p.ActivePatch == true).ToList(); + + if (patchedConicsList == null || patchedConicsList.Count() == 0) + { + EntryValue = null; + return; + } + + if (patchedConicsList.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[base.SelectedNodeIndex].PeriapsisArl; + } + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.MetersToDistanceString((double)EntryValue); + } + } + } + + public class DeltaVRequired : ManeuverEntry + { + public DeltaVRequired() + { + Name = "∆v required"; + Description = "Shows the delta velocity needed to complete the maneuver."; + Category = MicroEntryCategory.Maneuver; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count == 1) + { + EntryValue = (MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut)).magnitude; + } + else if (nodes.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = nodes[base.SelectedNodeIndex].BurnRequiredDV; + } + else + { + EntryValue = null; + return; + } + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); + } + } + } + + public class ManeuverPrograde : ManeuverEntry + { + public ManeuverPrograde() + { + Name = "∆v Prograde"; + Description = ""; + Category = MicroEntryCategory.Maneuver; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = nodes[base.SelectedNodeIndex].BurnVector.z; + } + else + { + EntryValue = null; + return; + } + + // DOESN'T WORK + //EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.z - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).z; + + //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.z; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ManeuverNormal : ManeuverEntry + { + public ManeuverNormal() + { + Name = "∆v Normal"; + Description = ""; + Category = MicroEntryCategory.Maneuver; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = nodes[base.SelectedNodeIndex].BurnVector.y; + } + else + { + EntryValue = null; + return; + } + + // DOESN'T WORK + // EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.y - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).y; + + //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.y; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ManeuverRadial : ManeuverEntry + { + public ManeuverRadial() + { + Name = "∆v Radial"; + Description = ""; + Category = MicroEntryCategory.Maneuver; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = nodes[base.SelectedNodeIndex].BurnVector.x; + } + else + { + EntryValue = null; + return; + } + + // DOESN'T WORK + // EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.x - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).x; + + //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.x; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + + + public class TimeToNode : ManeuverEntry + { + public TimeToNode() + { + Name = "Time to Node"; + Description = "Shows the time until vessel reaches the maneuver node."; + Category = MicroEntryCategory.Maneuver; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count == 1) + { + EntryValue = MicroUtility.CurrentManeuver.Time - GameManager.Instance.Game.UniverseModel.UniversalTime; + } + else if (nodes.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = nodes[base.SelectedNodeIndex].Time - GameManager.Instance.Game.UniverseModel.UniversalTime; + } + else + { + EntryValue = null; + return; + } + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } + + public class BurnTime : ManeuverEntry + { + public BurnTime() + { + Name = "Burn Time"; + Description = "Shows the length of time needed to complete the maneuver node."; + Category = MicroEntryCategory.Maneuver; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); + var nodes = activeVesselPlan?.GetNodes(); + + if (nodes == null || nodes.Count == 0) + { + EntryValue = null; + return; + } + + if (nodes.Count == 1) + { + EntryValue = MicroUtility.CurrentManeuver?.BurnDuration; + } + else if (nodes.Count >= base.SelectedNodeIndex + 1) + { + EntryValue = nodes[base.SelectedNodeIndex].BurnDuration; + } + else + { + EntryValue = null; + return; + } + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } +} diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs new file mode 100644 index 0000000..ad4c5d6 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -0,0 +1,580 @@ +using KSP.Sim.impl; + +namespace MicroMod +{ + public class TargetEntry : MicroEntry + { } + + public class TargetApoapsis : TargetEntry + { + public TargetApoapsis() + { + Name = "Target Ap."; + Description = "Shows the target's apoapsis height relative to the sea level."; + Category = MicroEntryCategory.Target; + Unit = "m"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.ApoapsisArl; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.MetersToDistanceString((double)EntryValue); + } + } + } + + public class TargetPeriapsis : TargetEntry + { + public TargetPeriapsis() + { + Name = "Target Pe."; + Description = "Shows the target's periapsis height relative to the sea level."; + Category = MicroEntryCategory.Target; + Unit = "m"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.PeriapsisArl; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.MetersToDistanceString((double)EntryValue); + } + } + } + + public class DistanceToTarget : TargetEntry + { + public DistanceToTarget() + { + Name = "Distance to Target"; + Description = "Shows the current distance between the vessel and the target."; + Category = MicroEntryCategory.Target; + Unit = "m"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit != null ? (MicroUtility.ActiveVessel.Orbit.Position - MicroUtility.ActiveVessel.TargetObject.Orbit.Position).magnitude : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + // return value only if vessel and target are in the same SOI + return MicroUtility.ActiveVessel.Orbit.referenceBody == MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody ? + MicroUtility.MetersToDistanceString((double)EntryValue) : "-"; + } + } + } + + public class RelativeSpeed : TargetEntry + { + public RelativeSpeed() + { + Name = "Rel. Speed"; + Description = "Shows the relative velocity between the vessel and the target."; + Category = MicroEntryCategory.Target; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit != null ? (MicroUtility.ActiveVessel.Orbit.relativeVelocity - MicroUtility.ActiveVessel.TargetObject.Orbit.relativeVelocity).magnitude : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + // return value only if vessel and target are in the same SOI + if (MicroUtility.ActiveVessel.Orbit.referenceBody != MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); + } + } + } + + public class RelativeInclination : TargetEntry + { + public RelativeInclination() + { + Name = "Rel. Inclination"; + Description = "Shows the relative inclination between the vessel and the target."; + Category = MicroEntryCategory.Target; + Unit = "°"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.AscendingNodeTarget.Inclination; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + // return value only if vessel and target are in the same SOI + if (MicroUtility.ActiveVessel.Orbit.referenceBody != MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); + } + } + } + + + + + + //////////////////////// NEW ENTRIES //////////////////////// + + public class Target_EccentricAnomaly : TargetEntry + { + public Target_EccentricAnomaly() + { + Name = "[T] Eccentric Anomaly"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.EccentricAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } + } + + public class Target_MeanAnomaly : TargetEntry + { + public Target_MeanAnomaly() + { + Name = "[T] Mean Anomaly"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.MeanAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } + } + + public class Target_ObT : TargetEntry + { + public Target_ObT() + { + Name = "[T] Orbit Time"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.ObT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class Target_ArgumentOfPeriapsis : TargetEntry + { + public Target_ArgumentOfPeriapsis() + { + Name = "[T] Arg. of Pe."; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.argumentOfPeriapsis; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Target_Eccentricity : TargetEntry + { + public Target_Eccentricity() + { + Name = "[T] Eccentricity"; + Description = "Shows the target's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.eccentricity; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Target_Inclination : TargetEntry + { + public Target_Inclination() + { + Name = "[T] Inclination"; + Description = "Shows the target's orbital inclination relative to the equator."; + Category = MicroEntryCategory.Accepted; + Unit = "°"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.inclination; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Target_LongitudeOfAscendingNode : TargetEntry + { + public Target_LongitudeOfAscendingNode() + { + Name = "[T] LAN"; + Description = "Shows the target's Longitude Of Ascending Node"; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.longitudeOfAscendingNode; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Target_SemiMajorAxis : TargetEntry + { + public Target_SemiMajorAxis() + { + Name = "[T] Semi Major Axis"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.semiMajorAxis; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Target_ReferenceBodyConstants_Radius : TargetEntry + { + public Target_ReferenceBodyConstants_Radius() + { + Name = "[T] Ref.Bod.Con.Radius"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.radius; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Target_ReferenceBodyConstants_StandardGravitationParameter : TargetEntry + { + public Target_ReferenceBodyConstants_StandardGravitationParameter() + { + Name = "[T] Ref.Bod.Con.GPar"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody.gravParameter; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Target_SemiLatusRectum : TargetEntry + { + public Target_SemiLatusRectum() + { + Name = "[T] Semi Latus Rectum"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.SemiLatusRectum; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Target_SemiMinorAxis : TargetEntry + { + public Target_SemiMinorAxis() + { + Name = "[T] Semi Minor Axis"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.SemiMinorAxis; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class Target_TrueAnomaly : TargetEntry + { + public Target_TrueAnomaly() + { + Name = "[T] True Anomaly"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.TrueAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.RadiansToDegrees((double)EntryValue)); + } + } + } + + public class Target_Period : TargetEntry + { + public Target_Period() + { + Name = "[T] Period"; + Description = "Shows the amount of time it will take to complete a full orbit."; + Category = MicroEntryCategory.Accepted; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.period; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } + + public class Target_radius : TargetEntry + { + public Target_radius() + { + Name = "[T] Orbit Radius"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit.radius; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + + + + + +} diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 4fba2e1..f69936d 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -9,6 +9,7 @@ using KSP.Sim.DeltaV; using KSP.Messages; using KSP.Sim.impl; +using KSP.Iteration.UI.Binding; namespace MicroMod { @@ -1187,6 +1188,30 @@ private void InitializeEntries() MicroEntries.Add(new ManeuverPrograde()); MicroEntries.Add(new ManeuverNormal()); MicroEntries.Add(new ManeuverRadial()); + MicroEntries.Add(new DistanceAtCloseApproach1()); + MicroEntries.Add(new TimeToCloseApproach1()); + MicroEntries.Add(new RelativeSpeedAtCloseApproach1()); + MicroEntries.Add(new DistanceAtCloseApproach2()); + MicroEntries.Add(new TimeToCloseApproach2()); + MicroEntries.Add(new RelativeSpeedAtCloseApproach2()); + + MicroEntries.Add(new Target_EccentricAnomaly()); + MicroEntries.Add(new Target_MeanAnomaly()); + MicroEntries.Add(new Target_ObT()); + MicroEntries.Add(new Target_ArgumentOfPeriapsis()); + MicroEntries.Add(new Target_Eccentricity()); + MicroEntries.Add(new Target_Inclination()); + MicroEntries.Add(new Target_LongitudeOfAscendingNode()); + MicroEntries.Add(new Target_SemiMajorAxis()); + MicroEntries.Add(new Target_ReferenceBodyConstants_Radius()); + MicroEntries.Add(new Target_ReferenceBodyConstants_StandardGravitationParameter()); + MicroEntries.Add(new Target_SemiLatusRectum()); + MicroEntries.Add(new Target_SemiMinorAxis()); + MicroEntries.Add(new Target_TrueAnomaly()); + MicroEntries.Add(new Target_Period()); + MicroEntries.Add(new Target_radius()); + + diff --git a/MicroEngineerProject/MicroEngineer/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/MicroEntries.cs index abed71c..c157be0 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEntries.cs @@ -41,12 +41,7 @@ public virtual string ValueDisplay public virtual void RefreshData() { } } - - public class ManeuverEntry : MicroEntry - { - internal int SelectedNodeIndex = 0; - } - + #region Flight scene entries public class Vessel : MicroEntry @@ -827,505 +822,9 @@ public override string ValueDisplay } } - public class TargetApoapsis : MicroEntry - { - public TargetApoapsis() - { - Name = "Target Ap."; - Description = "Shows the target's apoapsis height relative to the sea level."; - Category = MicroEntryCategory.Target; - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.ApoapsisArl; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } - } - - public class TargetPeriapsis : MicroEntry - { - public TargetPeriapsis() - { - Name = "Target Pe."; - Description = "Shows the target's periapsis height relative to the sea level."; - Category = MicroEntryCategory.Target; - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.PeriapsisArl; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } - } - - public class DistanceToTarget : MicroEntry - { - public DistanceToTarget() - { - Name = "Distance to Target"; - Description = "Shows the current distance between the vessel and the target."; - Category = MicroEntryCategory.Target; - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit != null ? (MicroUtility.ActiveVessel.Orbit.Position - MicroUtility.ActiveVessel.TargetObject.Orbit.Position).magnitude : null; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - // return value only if vessel and target are in the same SOI - return MicroUtility.ActiveVessel.Orbit.referenceBody == MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody ? - MicroUtility.MetersToDistanceString((double)EntryValue) : "-"; - } - } - } - - public class RelativeSpeed : MicroEntry - { - public RelativeSpeed() - { - Name = "Rel. Speed"; - Description = "Shows the relative velocity between the vessel and the target."; - Category = MicroEntryCategory.Target; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit != null ? (MicroUtility.ActiveVessel.Orbit.relativeVelocity - MicroUtility.ActiveVessel.TargetObject.Orbit.relativeVelocity).magnitude : null; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - // return value only if vessel and target are in the same SOI - if (MicroUtility.ActiveVessel.Orbit.referenceBody != MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } - } - - public class RelativeInclination : MicroEntry - { - public RelativeInclination() - { - Name = "Rel. Inclination"; - Description = "Shows the relative inclination between the vessel and the target."; - Category = MicroEntryCategory.Target; - Unit = "°"; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.AscendingNodeTarget.Inclination; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - // return value only if vessel and target are in the same SOI - if (MicroUtility.ActiveVessel.Orbit.referenceBody != MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } - } - - public class ProjectedAp : ManeuverEntry - { - public ProjectedAp() - { - Name = "Projected Ap."; - Description = "Shows the projected apoapsis vessel will have after completing the maneuver."; - Category = MicroEntryCategory.Maneuver; - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - List patchedConicsList = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList?.Where(p => p.ActivePatch == true).ToList(); - - if (patchedConicsList == null || patchedConicsList.Count() == 0) - { - EntryValue = null; - return; - } - - if (patchedConicsList.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[base.SelectedNodeIndex].ApoapsisArl; - } - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } - } - public class ProjectedPe : ManeuverEntry - { - public ProjectedPe() - { - Name = "Projected Pe."; - Description = "Shows the projected periapsis vessel will have after completing the maneuver."; - Category = MicroEntryCategory.Maneuver; - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - List patchedConicsList = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList?.Where(p => p.ActivePatch == true).ToList(); - - if (patchedConicsList == null || patchedConicsList.Count() == 0) - { - EntryValue = null; - return; - } - - if (patchedConicsList.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[base.SelectedNodeIndex].PeriapsisArl; - } - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } - } - - public class DeltaVRequired : ManeuverEntry - { - public DeltaVRequired() - { - Name = "∆v required"; - Description = "Shows the delta velocity needed to complete the maneuver."; - Category = MicroEntryCategory.Maneuver; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count == 1) - { - EntryValue = (MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut)).magnitude; - } - else if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnRequiredDV; - } - else - { - EntryValue = null; - return; - } - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } - } - - public class ManeuverPrograde : ManeuverEntry - { - public ManeuverPrograde() - { - Name = "∆v Prograde"; - Description = ""; - Category = MicroEntryCategory.Maneuver; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnVector.z; - } - else - { - EntryValue = null; - return; - } - - // DOESN'T WORK - //EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.z - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).z; - - //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.z; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ManeuverNormal : ManeuverEntry - { - public ManeuverNormal() - { - Name = "∆v Normal"; - Description = ""; - Category = MicroEntryCategory.Maneuver; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnVector.y; - } - else - { - EntryValue = null; - return; - } - // DOESN'T WORK - // EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.y - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).y; - - //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.y; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ManeuverRadial : ManeuverEntry - { - public ManeuverRadial() - { - Name = "∆v Radial"; - Description = ""; - Category = MicroEntryCategory.Maneuver; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnVector.x; - } - else - { - EntryValue = null; - return; - } - - // DOESN'T WORK - // EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.x - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).x; - - //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.x; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - - - public class TimeToNode : ManeuverEntry - { - public TimeToNode() - { - Name = "Time to Node"; - Description = "Shows the time until vessel reaches the maneuver node."; - Category = MicroEntryCategory.Maneuver; - Unit = "s"; - Formatting = null; - } - - public override void RefreshData() - { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count == 1) - { - EntryValue = MicroUtility.CurrentManeuver.Time - GameManager.Instance.Game.UniverseModel.UniversalTime; - } - else if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].Time - GameManager.Instance.Game.UniverseModel.UniversalTime; - } - else - { - EntryValue = null; - return; - } - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.SecondsToTimeString((double)EntryValue); - } - } - } - - public class BurnTime : ManeuverEntry - { - public BurnTime() - { - Name = "Burn Time"; - Description = "Shows the length of time needed to complete the maneuver node."; - Category = MicroEntryCategory.Maneuver; - Unit = "s"; - Formatting = null; - } - - public override void RefreshData() - { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count == 1) - { - EntryValue = MicroUtility.CurrentManeuver?.BurnDuration; - } - else if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnDuration; - } - else - { - EntryValue = null; - return; - } - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.SecondsToTimeString((double)EntryValue); - } - } - } + public class TotalDeltaVVac : MicroEntry { @@ -2484,7 +1983,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue) + "(" + String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg) + ")"; + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); } } } @@ -2540,7 +2039,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue) + "(" + String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg) + ")"; + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); } } } @@ -2636,8 +2135,8 @@ public SemiMajorAxis() Name = "SemiMajorAxis"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Unit = "m"; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -2857,7 +2356,7 @@ public class UniversalTimeAtClosestApproach : MicroEntry { public UniversalTimeAtClosestApproach() { - Name = "UT Closest Appr."; + Name = "UniversalTime Closest Appr."; Description = ""; Category = MicroEntryCategory.Accepted; Unit = null; @@ -2885,7 +2384,7 @@ public class UniversalTimeAtSoiEncounter : MicroEntry { public UniversalTimeAtSoiEncounter() { - Name = "UT SOI Enc"; + Name = "UniversalTime SOI Enc"; Description = ""; Category = MicroEntryCategory.Accepted; Unit = null; @@ -2947,7 +2446,187 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - + public class DistanceAtCloseApproach1 : MicroEntry + { + public DistanceAtCloseApproach1() + { + Name = "CloseApp1 Dist"; + Description = ""; + Category = MicroEntryCategory.Accepted; //Target + Unit = "m"; + Formatting = null; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeDistance : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.MetersToDistanceString((double)EntryValue); + } + + } + } + + public class TimeToCloseApproach1 : MicroEntry + { + public TimeToCloseApproach1() + { + Name = "CloseApp1 Time"; + Description = ""; + Category = MicroEntryCategory.Accepted; //Target + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.UniversalTime - MicroUtility.UniversalTime : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } + + public class RelativeSpeedAtCloseApproach1 : MicroEntry + { + public RelativeSpeedAtCloseApproach1() + { + Name = "CloseApp1 Speed"; + Description = ""; + Category = MicroEntryCategory.Accepted; //Target + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeSpeed : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class DistanceAtCloseApproach2 : MicroEntry + { + public DistanceAtCloseApproach2() + { + Name = "CloseApp2 Dist"; + Description = ""; + Category = MicroEntryCategory.Accepted; //Target + Unit = "m"; + Formatting = null; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeDistance : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.MetersToDistanceString((double)EntryValue); + } + + } + } + + public class TimeToCloseApproach2 : MicroEntry + { + public TimeToCloseApproach2() + { + Name = "CloseApp2 Time"; + Description = ""; + Category = MicroEntryCategory.Accepted; //Target + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.UniversalTime - MicroUtility.UniversalTime : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } + + public class RelativeSpeedAtCloseApproach2 : MicroEntry + { + public RelativeSpeedAtCloseApproach2() + { + Name = "CloseApp2 Speed"; + Description = ""; + Category = MicroEntryCategory.Accepted; //Target + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeSpeed : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } diff --git a/MicroEngineerProject/MicroEngineer/MicroUtility.cs b/MicroEngineerProject/MicroEngineer/MicroUtility.cs index 5594f65..7a3e761 100644 --- a/MicroEngineerProject/MicroEngineer/MicroUtility.cs +++ b/MicroEngineerProject/MicroEngineer/MicroUtility.cs @@ -26,6 +26,7 @@ public static class MicroUtility public static VesselDeltaVComponent VesselDeltaVComponentOAB; public static string InputDisableWindowAbbreviation = "WindowAbbreviation"; public static string InputDisableWindowName = "WindowName"; + public static double UniversalTime => GameManager.Instance.Game.UniverseModel.UniversalTime; /// /// Refreshes the ActiveVessel and CurrentManeuver From 4f96184522b3a70acbf9460b531333515a5525c9 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sun, 16 Apr 2023 22:52:58 +0200 Subject: [PATCH 07/38] 3 new target entries --- .../MicroEngineer/Entries/TargetEntries.cs | 253 +++++++++++++++++- .../MicroEngineer/MicroEngineerMod.cs | 4 +- .../MicroEngineer/MicroEntries.cs | 188 +------------ 3 files changed, 258 insertions(+), 187 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index ad4c5d6..fb36068 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -161,6 +161,53 @@ public override string ValueDisplay //////////////////////// NEW ENTRIES //////////////////////// + public class Target_AltitudeFromSeaLevel : TargetEntry + { + public Target_AltitudeFromSeaLevel() + { + Name = "[T] Altitude (Sea)"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.AltitudeFromSeaLevel; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.MetersToDistanceString((double)EntryValue); + } + } + } + + public class Target_Name : TargetEntry + { + public Target_Name() + { + Name = "[T] Name"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.DisplayName; + } + + public override string ValueDisplay => base.ValueDisplay; + } + public class Target_EccentricAnomaly : TargetEntry { public Target_EccentricAnomaly() @@ -223,8 +270,8 @@ public Target_ObT() { Name = "[T] Orbit Time"; Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; + Category = MicroEntryCategory.New; + Unit = "s"; Formatting = "{0:N3}"; } @@ -572,6 +619,208 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } + public class Target_Obtvelocity : TargetEntry + { + public Target_Obtvelocity() + { + Name = "[T] Orbital Speed"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TargetObject?.ObtVelocity.magnitude; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + + public class DistanceAtCloseApproach1 : MicroEntry + { + public DistanceAtCloseApproach1() + { + Name = "CloseApp1 Dist"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m"; + Formatting = null; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeDistance : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.MetersToDistanceString((double)EntryValue); + } + + } + } + + public class TimeToCloseApproach1 : MicroEntry + { + public TimeToCloseApproach1() + { + Name = "CloseApp1 Time"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.UniversalTime - MicroUtility.UniversalTime : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } + + public class RelativeSpeedAtCloseApproach1 : MicroEntry + { + public RelativeSpeedAtCloseApproach1() + { + Name = "CloseApp1 Speed"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeSpeed : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class DistanceAtCloseApproach2 : MicroEntry + { + public DistanceAtCloseApproach2() + { + Name = "CloseApp2 Dist"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m"; + Formatting = null; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeDistance : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.MetersToDistanceString((double)EntryValue); + } + + } + } + + public class TimeToCloseApproach2 : MicroEntry + { + public TimeToCloseApproach2() + { + Name = "CloseApp2 Time"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.UniversalTime - MicroUtility.UniversalTime : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } + + public class RelativeSpeedAtCloseApproach2 : MicroEntry + { + public RelativeSpeedAtCloseApproach2() + { + Name = "CloseApp2 Speed"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; + + EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeSpeed : null; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index f69936d..d62650f 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1194,7 +1194,6 @@ private void InitializeEntries() MicroEntries.Add(new DistanceAtCloseApproach2()); MicroEntries.Add(new TimeToCloseApproach2()); MicroEntries.Add(new RelativeSpeedAtCloseApproach2()); - MicroEntries.Add(new Target_EccentricAnomaly()); MicroEntries.Add(new Target_MeanAnomaly()); MicroEntries.Add(new Target_ObT()); @@ -1210,6 +1209,9 @@ private void InitializeEntries() MicroEntries.Add(new Target_TrueAnomaly()); MicroEntries.Add(new Target_Period()); MicroEntries.Add(new Target_radius()); + MicroEntries.Add(new Target_AltitudeFromSeaLevel()); + MicroEntries.Add(new Target_Name()); + MicroEntries.Add(new Target_Obtvelocity()); diff --git a/MicroEngineerProject/MicroEngineer/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/MicroEntries.cs index c157be0..17410e9 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEntries.cs @@ -1568,11 +1568,11 @@ public class OrbitalSpeed : MicroEntry { public OrbitalSpeed() { - Name = "OrbitalSpeed"; + Name = "Orbital Velocity"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Unit = "m/s"; + Formatting = "{0:N1}"; } public override void RefreshData() @@ -2446,187 +2446,7 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class DistanceAtCloseApproach1 : MicroEntry - { - public DistanceAtCloseApproach1() - { - Name = "CloseApp1 Dist"; - Description = ""; - Category = MicroEntryCategory.Accepted; //Target - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; - - EntryValue = isValid != null && isValid == true ? MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeDistance : null; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - - } - } - - public class TimeToCloseApproach1 : MicroEntry - { - public TimeToCloseApproach1() - { - Name = "CloseApp1 Time"; - Description = ""; - Category = MicroEntryCategory.Accepted; //Target - Unit = "s"; - Formatting = null; - } - - public override void RefreshData() - { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; - - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.UniversalTime - MicroUtility.UniversalTime : null; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.SecondsToTimeString((double)EntryValue); - } - } - } - - public class RelativeSpeedAtCloseApproach1 : MicroEntry - { - public RelativeSpeedAtCloseApproach1() - { - Name = "CloseApp1 Speed"; - Description = ""; - Category = MicroEntryCategory.Accepted; //Target - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; - - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeSpeed : null; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class DistanceAtCloseApproach2 : MicroEntry - { - public DistanceAtCloseApproach2() - { - Name = "CloseApp2 Dist"; - Description = ""; - Category = MicroEntryCategory.Accepted; //Target - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; - - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeDistance : null; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - - } - } - - public class TimeToCloseApproach2 : MicroEntry - { - public TimeToCloseApproach2() - { - Name = "CloseApp2 Time"; - Description = ""; - Category = MicroEntryCategory.Accepted; //Target - Unit = "s"; - Formatting = null; - } - - public override void RefreshData() - { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; - - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.UniversalTime - MicroUtility.UniversalTime : null; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.SecondsToTimeString((double)EntryValue); - } - } - } - - public class RelativeSpeedAtCloseApproach2 : MicroEntry - { - public RelativeSpeedAtCloseApproach2() - { - Name = "CloseApp2 Speed"; - Description = ""; - Category = MicroEntryCategory.Accepted; //Target - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; - - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeSpeed : null; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } + From 32596c4f2641f54216c8f9c650b9fe97500ae38c Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Mon, 17 Apr 2023 00:43:55 +0200 Subject: [PATCH 08/38] Add new vessel entries - Move vessel entries to new file Entries\VesselEntries.cs - Add new class VesselEntry that inherits from MicroEntry - All vessel entries are now VesselEntry --- .../MicroEngineer/Entries/TargetEntries.cs | 2 +- .../MicroEngineer/Entries/VesselEntries.cs | 315 ++++++++++++++++++ .../MicroEngineer/MicroEngineerMod.cs | 21 +- .../MicroEngineer/MicroEntries.cs | 218 +----------- 4 files changed, 332 insertions(+), 224 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index fb36068..4bdfe1d 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -270,7 +270,7 @@ public Target_ObT() { Name = "[T] Orbit Time"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted; Unit = "s"; Formatting = "{0:N3}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs new file mode 100644 index 0000000..9d26d2b --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -0,0 +1,315 @@ + +namespace MicroMod +{ + public class VesselEntry : MicroEntry + { } + + public class Vessel : VesselEntry + { + public Vessel() + { + Name = "Vessel"; + Description = "Name of the current vessel."; + Category = MicroEntryCategory.Vessel; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.DisplayName; + } + + public override string ValueDisplay => EntryValue?.ToString(); + } + + public class Mass : VesselEntry + { + public Mass() + { + Name = "Mass"; + Description = "Shows the total mass of the vessel."; + Category = MicroEntryCategory.Vessel; + Unit = "kg"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.totalMass * 1000; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TotalDeltaVActual : VesselEntry + { + public TotalDeltaVActual() + { + Name = "Total ∆v"; + Description = "Shows the vessel's total delta velocity."; + Category = MicroEntryCategory.Vessel; + Unit = "m/s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVActual; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageThrustActual : VesselEntry + { + public StageThrustActual() + { + Name = "Thrust"; + Description = "Shows the vessel's actual thrust."; + Category = MicroEntryCategory.Vessel; + Unit = "N"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustActual * 1000; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageTWRActual : VesselEntry + { + public StageTWRActual() + { + Name = "TWR"; + Description = "Shows the vessel's StageThrustActual to Weight Ratio."; + Category = MicroEntryCategory.Vessel; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRActual; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + + // NEW ENTRIES // + + + public class PartsCount : VesselEntry + { + public PartsCount() + { + Name = "Parts"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.PartInfo?.Count; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TotalBurnTime : VesselEntry + { + public TotalBurnTime() + { + Name = "Total Burn Time"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalBurnTime; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TotalDeltaVASL : VesselEntry + { + public TotalDeltaVASL() + { + Name = "Total ∆v ASL"; + Description = "Shows the total delta velocity of the vessel At Sea Level."; + Category = MicroEntryCategory.New; + Unit = "m/s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVASL; + } + + public override string ValueDisplay => base.ValueDisplay; + + } + + public class TotalDeltaVVac : VesselEntry + { + public TotalDeltaVVac() + { + Name = "Total ∆v Vac"; + Description = "Shows the total delta velocity of the vessel in vacuum."; + Category = MicroEntryCategory.New; + Unit = "m/s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVVac; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageISPAsl : VesselEntry + { + public StageISPAsl() + { + Name = "ISP (ASL)"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.IspASL; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageISPActual : VesselEntry + { + public StageISPActual() + { + Name = "ISP (Actual)"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.IspActual; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageISPVac : VesselEntry + { + public StageISPVac() + { + Name = "ISP (Vacuum)"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.IspVac; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageTWRASL : VesselEntry + { + public StageTWRASL() + { + Name = "TWR (ASL)"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRASL; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageTWRVac : VesselEntry + { + public StageTWRVac() + { + Name = "TWR (Vacuum)"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRVac; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageThrustASL : VesselEntry + { + public StageThrustASL() + { + Name = "Thrust (ASL)"; + Description = "Shows the vessel's actual thrust."; + Category = MicroEntryCategory.New; + Unit = "N"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustASL * 1000; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageThrustVac : VesselEntry + { + public StageThrustVac() + { + Name = "Thrust (Vacuum)"; + Description = "Shows the vessel's actual thrust."; + Category = MicroEntryCategory.New; + Unit = "N"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustVac * 1000; + } + + public override string ValueDisplay => base.ValueDisplay; + } +} diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index d62650f..19eff5b 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1076,9 +1076,9 @@ private void InitializeEntries() #region Vessel entries MicroEntries.Add(new Vessel()); MicroEntries.Add(new Mass()); - MicroEntries.Add(new DeltaV()); - MicroEntries.Add(new Thrust()); - MicroEntries.Add(new TWR()); + MicroEntries.Add(new TotalDeltaVActual()); + MicroEntries.Add(new StageThrustActual()); + MicroEntries.Add(new StageTWRActual()); #endregion #region Orbital entries MicroEntries.Add(new Apoapsis()); @@ -1124,9 +1124,6 @@ private void InitializeEntries() MicroEntries.Add(new BurnTime()); #endregion #region Stage entries - MicroEntries.Add(new TotalDeltaVVac()); - MicroEntries.Add(new TotalDeltaVAsl()); - MicroEntries.Add(new TotalDeltaVActual()); MicroEntries.Add(new StageInfo()); #endregion #region Misc entries @@ -1214,6 +1211,18 @@ private void InitializeEntries() MicroEntries.Add(new Target_Obtvelocity()); + MicroEntries.Add(new PartsCount()); + MicroEntries.Add(new TotalBurnTime()); + MicroEntries.Add(new TotalDeltaVASL()); + MicroEntries.Add(new TotalDeltaVVac()); + MicroEntries.Add(new StageISPAsl()); + MicroEntries.Add(new StageISPActual()); + MicroEntries.Add(new StageISPVac()); + MicroEntries.Add(new StageTWRASL()); + MicroEntries.Add(new StageTWRVac()); + MicroEntries.Add(new StageThrustASL()); + MicroEntries.Add(new StageThrustVac()); + diff --git a/MicroEngineerProject/MicroEngineer/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/MicroEntries.cs index 17410e9..48cd46c 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEntries.cs @@ -43,137 +43,7 @@ public virtual void RefreshData() { } } - #region Flight scene entries - public class Vessel : MicroEntry - { - public Vessel() - { - Name = "Vessel"; - Description = "Name of the current vessel."; - Category = MicroEntryCategory.Vessel; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.DisplayName; - } - - public override string ValueDisplay => EntryValue?.ToString(); - } - - public class Mass : MicroEntry - { - public Mass() - { - Name = "Mass"; - Description = "Shows the total mass of the vessel."; - Category = MicroEntryCategory.Vessel; - Unit = "kg"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.totalMass * 1000; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class DeltaV : MicroEntry - { - public DeltaV() - { - Name = "∆v"; - Description = "Shows the vessel's total delta velocity."; - Category = MicroEntryCategory.Vessel; - Unit = "m/s"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVActual; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class Thrust : MicroEntry - { - public Thrust() - { - Name = "Thrust"; - Description = "Shows the vessel's actual thrust."; - Category = MicroEntryCategory.Vessel; - Unit = "N"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustActual * 1000; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class TWR : MicroEntry - { - public TWR() - { - Name = "TWR"; - Description = "Shows the vessel's Thrust to Weight Ratio."; - Category = MicroEntryCategory.Vessel; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRActual; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } + #region Flight scene entries public class Apoapsis : MicroEntry { @@ -821,95 +691,9 @@ public override string ValueDisplay } } } - - - public class TotalDeltaVVac : MicroEntry - { - public TotalDeltaVVac() - { - Name = "Total ∆v Vac"; - Description = "Shows the total delta velocity of the vessel in vacuum."; - Category = MicroEntryCategory.Stage; - Unit = "m/s"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVVac; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } - } - - public class TotalDeltaVAsl : MicroEntry - { - public TotalDeltaVAsl() - { - Name = "Total ∆v ASL"; - Description = "Shows the total delta velocity of the vessel At Sea Level."; - Category = MicroEntryCategory.Stage; - Unit = "m/s"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVASL; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } - } - - public class TotalDeltaVActual : MicroEntry - { - public TotalDeltaVActual() - { - Name = "Total ∆v Actual"; - Description = "Shows the current total delta velocity."; - Category = MicroEntryCategory.Stage; - Unit = "m/s"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVActual; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } - } - public class StageInfo : MicroEntry { public StageInfo() From debef85417d9911811d93b92909be1eb7dafc37c Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Mon, 17 Apr 2023 22:51:54 +0200 Subject: [PATCH 09/38] Simplify maneuver entry refresh --- .../MicroEngineer/Entries/ManeuverEntries.cs | 182 +++--------------- .../MicroEngineer/MicroEngineerMod.cs | 1 - 2 files changed, 24 insertions(+), 159 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 5a71d48..1e8ba22 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -1,5 +1,6 @@ using KSP.Game; using KSP.Sim.impl; +using KSP.Sim.Maneuver; namespace MicroMod { @@ -21,18 +22,10 @@ public ProjectedAp() public override void RefreshData() { - List patchedConicsList = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList?.Where(p => p.ActivePatch == true).ToList(); - - if (patchedConicsList == null || patchedConicsList.Count() == 0) - { - EntryValue = null; - return; - } - - if (patchedConicsList.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[base.SelectedNodeIndex].ApoapsisArl; - } + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .ApoapsisArl; } public override string ValueDisplay @@ -60,18 +53,10 @@ public ProjectedPe() public override void RefreshData() { - List patchedConicsList = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList?.Where(p => p.ActivePatch == true).ToList(); - - if (patchedConicsList == null || patchedConicsList.Count() == 0) - { - EntryValue = null; - return; - } - - if (patchedConicsList.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.PatchedConicsList[base.SelectedNodeIndex].PeriapsisArl; - } + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .PeriapsisArl; } public override string ValueDisplay @@ -99,28 +84,12 @@ public DeltaVRequired() public override void RefreshData() { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); + List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count == 1) - { - EntryValue = (MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut)).magnitude; - } - else if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnRequiredDV; - } - else - { - EntryValue = null; - return; - } + EntryValue = (nodes == null || nodes.Count == 0) ? null : + (nodes.Count == 1) ? (MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut)).magnitude : + (nodes.Count >= base.SelectedNodeIndex + 1) ? nodes[base.SelectedNodeIndex].BurnRequiredDV : + null; } public override string ValueDisplay @@ -148,29 +117,8 @@ public ManeuverPrograde() public override void RefreshData() { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnVector.z; - } - else - { - EntryValue = null; - return; - } - - // DOESN'T WORK - //EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.z - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).z; - - //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.z; + List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.BurnVector.z; } public override string ValueDisplay => base.ValueDisplay; @@ -189,29 +137,8 @@ public ManeuverNormal() public override void RefreshData() { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnVector.y; - } - else - { - EntryValue = null; - return; - } - - // DOESN'T WORK - // EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.y - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).y; - - //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.y; + List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.BurnVector.y; } public override string ValueDisplay => base.ValueDisplay; @@ -230,29 +157,8 @@ public ManeuverRadial() public override void RefreshData() { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnVector.x; - } - else - { - EntryValue = null; - return; - } - - // DOESN'T WORK - // EntryValue = MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector.x - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut).x; - - //EntryValue = MicroUtility.CurrentManeuver?.BurnVector.x; + List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.BurnVector.x; } public override string ValueDisplay => base.ValueDisplay; @@ -273,28 +179,8 @@ public TimeToNode() public override void RefreshData() { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count == 1) - { - EntryValue = MicroUtility.CurrentManeuver.Time - GameManager.Instance.Game.UniverseModel.UniversalTime; - } - else if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].Time - GameManager.Instance.Game.UniverseModel.UniversalTime; - } - else - { - EntryValue = null; - return; - } + List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.Time - GameManager.Instance.Game.UniverseModel.UniversalTime; } public override string ValueDisplay @@ -322,28 +208,8 @@ public BurnTime() public override void RefreshData() { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent(); - var nodes = activeVesselPlan?.GetNodes(); - - if (nodes == null || nodes.Count == 0) - { - EntryValue = null; - return; - } - - if (nodes.Count == 1) - { - EntryValue = MicroUtility.CurrentManeuver?.BurnDuration; - } - else if (nodes.Count >= base.SelectedNodeIndex + 1) - { - EntryValue = nodes[base.SelectedNodeIndex].BurnDuration; - } - else - { - EntryValue = null; - return; - } + List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.BurnDuration; } public override string ValueDisplay diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 19eff5b..cf9881f 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -9,7 +9,6 @@ using KSP.Sim.DeltaV; using KSP.Messages; using KSP.Sim.impl; -using KSP.Iteration.UI.Binding; namespace MicroMod { From 024b6d2c7f552571d7e48799055b7ae2c0f28a02 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Tue, 18 Apr 2023 01:41:58 +0200 Subject: [PATCH 10/38] Add new maneuver entries --- .../MicroEngineer/Entries/ManeuverEntries.cs | 519 +++++++++++++++++- .../MicroEngineer/Entries/VesselEntries.cs | 22 +- .../MicroEngineer/MicroEntries.cs | 10 +- .../MicroEngineer/Windows/BaseWindow.cs | 3 +- 4 files changed, 533 insertions(+), 21 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 1e8ba22..28aed8e 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -164,8 +164,6 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - - public class TimeToNode : ManeuverEntry { public TimeToNode() @@ -190,7 +188,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.SecondsToTimeString((double)EntryValue); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -219,8 +217,521 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.SecondsToTimeString((double)EntryValue); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + + // NEW ENTRIES + + public class Maneuver_EccentricAnomaly : ManeuverEntry + { + public Maneuver_EccentricAnomaly() + { + Name = "Eccentric Anomaly"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .EccentricAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } + } + + public class Maneuver_EndUT : ManeuverEntry + { + public Maneuver_EndUT() + { + Name = "EndUT"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "s"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .EndUT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class Maneuver_MeanAnomaly : ManeuverEntry + { + public Maneuver_MeanAnomaly() + { + Name = "Mean Anomaly"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "°"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .MeanAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } + } + + public class Maneuver_ObT : ManeuverEntry + { + public Maneuver_ObT() + { + Name = "Orbit Time"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .ObT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class Maneuver_ArgumentOfPeriapsis : ManeuverEntry + { + public Maneuver_ArgumentOfPeriapsis() + { + Name = "Argument of Periapsis"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .OrbitalElements.ArgumentOfPeriapsis; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_Eccentricity : ManeuverEntry + { + public Maneuver_Eccentricity() + { + Name = "Eccentricity"; + Description = "Shows the vessel's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; + Category = MicroEntryCategory.New; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .OrbitalElements.Eccentricity; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_Inclination : ManeuverEntry + { + public Maneuver_Inclination() + { + Name = "Inclination"; + Description = "Shows the vessel's orbital inclination relative to the equator."; + Category = MicroEntryCategory.New; + Unit = "°"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .OrbitalElements.Inclination; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_LongitudeOfAscendingNode : ManeuverEntry + { + public Maneuver_LongitudeOfAscendingNode() + { + Name = "LAN"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .OrbitalElements.LongitudeOfAscendingNode; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_SemiMajorAxis : ManeuverEntry + { + public Maneuver_SemiMajorAxis() + { + Name = "Semi Major Axis"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .OrbitalElements.SemiMajorAxis; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_SemiMinorAxis : ManeuverEntry + { + public Maneuver_SemiMinorAxis() + { + Name = "Semi Minor Axis"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .SemiMinorAxis; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_OrbitalEnergy : ManeuverEntry + { + public Maneuver_OrbitalEnergy() + { + Name = "Orbital Energy"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .OrbitalEnergy; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_SemiLatusRectum : ManeuverEntry + { + public Maneuver_SemiLatusRectum() + { + Name = "Semi Latus Rectum ℓ"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .SemiLatusRectum; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_TimeToAp : ManeuverEntry + { + public Maneuver_TimeToAp() + { + Name = "Time to Ap."; + Description = "Shows the time until the vessel reaches apoapsis, the highest point of the orbit."; + Category = MicroEntryCategory.New; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .TimeToAp; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class Maneuver_TimeToPe : ManeuverEntry + { + public Maneuver_TimeToPe() + { + Name = "Time to Pe."; + Description = "Shows the time until the vessel reaches periapsis, the lowest point of the orbit."; + Category = MicroEntryCategory.New; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .TimeToPe; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class Maneuver_TrueAnomaly : ManeuverEntry + { + public Maneuver_TrueAnomaly() + { + Name = "True Anomaly"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .TrueAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } + } + + public class Maneuver_UniversalTimeAtClosestApproach : ManeuverEntry + { + public Maneuver_UniversalTimeAtClosestApproach() + { + Name = "UT Closest Appr."; + Description = ""; + Category = MicroEntryCategory.New; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .UniversalTimeAtClosestApproach; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } + + public class Maneuver_UniversalTimeAtSoiEncounter : ManeuverEntry + { + public Maneuver_UniversalTimeAtSoiEncounter() + { + Name = "UT SOI Enc"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .UniversalTimeAtSoiEncounter; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class Maneuver_orbitPercent : ManeuverEntry + { + public Maneuver_orbitPercent() + { + Name = "Orbit percent"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "%"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .orbitPercent * 100; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_period : ManeuverEntry + { + public Maneuver_period() + { + Name = "Period"; + Description = "Shows the amount of time it will take to complete a full orbit."; + Category = MicroEntryCategory.New; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .period; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + } diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 9d26d2b..6b2c813 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -109,7 +109,7 @@ public PartsCount() { Name = "Parts"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = null; Formatting = null; } @@ -128,7 +128,7 @@ public TotalBurnTime() { Name = "Total Burn Time"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "s"; Formatting = "{0:N0}"; } @@ -147,7 +147,7 @@ public TotalDeltaVASL() { Name = "Total ∆v ASL"; Description = "Shows the total delta velocity of the vessel At Sea Level."; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "m/s"; Formatting = "{0:N0}"; } @@ -167,7 +167,7 @@ public TotalDeltaVVac() { Name = "Total ∆v Vac"; Description = "Shows the total delta velocity of the vessel in vacuum."; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "m/s"; Formatting = "{0:N0}"; } @@ -186,7 +186,7 @@ public StageISPAsl() { Name = "ISP (ASL)"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "s"; Formatting = "{0:N0}"; } @@ -205,7 +205,7 @@ public StageISPActual() { Name = "ISP (Actual)"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "s"; Formatting = "{0:N0}"; } @@ -224,7 +224,7 @@ public StageISPVac() { Name = "ISP (Vacuum)"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "s"; Formatting = "{0:N0}"; } @@ -243,7 +243,7 @@ public StageTWRASL() { Name = "TWR (ASL)"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = null; Formatting = "{0:N2}"; } @@ -262,7 +262,7 @@ public StageTWRVac() { Name = "TWR (Vacuum)"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = null; Formatting = "{0:N2}"; } @@ -281,7 +281,7 @@ public StageThrustASL() { Name = "Thrust (ASL)"; Description = "Shows the vessel's actual thrust."; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "N"; Formatting = "{0:N0}"; } @@ -300,7 +300,7 @@ public StageThrustVac() { Name = "Thrust (Vacuum)"; Description = "Shows the vessel's actual thrust."; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "N"; Formatting = "{0:N0}"; } diff --git a/MicroEngineerProject/MicroEngineer/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/MicroEntries.cs index 48cd46c..b77566a 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEntries.cs @@ -1748,7 +1748,7 @@ public class EccentricAnomaly : MicroEntry { public EccentricAnomaly() { - Name = "EccentricAnomaly"; + Name = "Eccentric Anomaly"; Description = ""; Category = MicroEntryCategory.Accepted; Unit = null; @@ -1808,7 +1808,7 @@ public MeanAnomaly() Description = ""; Category = MicroEntryCategory.Accepted; Unit = null; - Formatting = "{0:N3}"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -1888,7 +1888,7 @@ public class LongitudeOfAscendingNode : MicroEntry { public LongitudeOfAscendingNode() { - Name = "LongitudeOfAscendingNode"; + Name = "LAN"; Description = ""; Category = MicroEntryCategory.Accepted; Unit = null; @@ -2140,7 +2140,7 @@ public class UniversalTimeAtClosestApproach : MicroEntry { public UniversalTimeAtClosestApproach() { - Name = "UniversalTime Closest Appr."; + Name = "UT Closest Appr."; Description = ""; Category = MicroEntryCategory.Accepted; Unit = null; @@ -2168,7 +2168,7 @@ public class UniversalTimeAtSoiEncounter : MicroEntry { public UniversalTimeAtSoiEncounter() { - Name = "UniversalTime SOI Enc"; + Name = "UT SOI Enc"; Description = ""; Category = MicroEntryCategory.Accepted; Unit = null; diff --git a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs index dc24b44..119e0a6 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs @@ -144,7 +144,8 @@ public enum MicroEntryCategory Misc, OAB, New, - Accepted + Accepted, + Accepted2 } /// From a6da38ac1957236843f2a6016e6162fcc95032d6 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Tue, 18 Apr 2023 01:46:52 +0200 Subject: [PATCH 11/38] Fix index out of range if maneuver node is manually deleted --- .../MicroEngineer/MicroEngineerMod.cs | 32 +++++++++++++++++-- .../MicroEngineer/Windows/ManeuverWindow.cs | 27 ++++++++++------ 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index cf9881f..6b47925 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -129,14 +129,23 @@ private void SubscribeToMessages() // Sets the selected node index to the newly created node MicroUtility.MessageCenter.Subscribe(new Action(this.OnManeuverCreatedMessage)); - } + // Resets node index + MicroUtility.MessageCenter.Subscribe(new Action(this.OnManeuverRemovedMessage)); + } + private void OnManeuverCreatedMessage(MessageCenterMessage message) { var maneuverWindow = MicroWindows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; maneuverWindow.OnManeuverCreatedMessage(message); } + private void OnManeuverRemovedMessage(MessageCenterMessage message) + { + var maneuverWindow = MicroWindows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; + maneuverWindow.OnManeuverRemovedMessage(message); + } + private void GameStateEntered(MessageCenterMessage obj) { Logger.LogInfo("Message triggered: GameStateEnteredMessage"); @@ -1208,8 +1217,6 @@ private void InitializeEntries() MicroEntries.Add(new Target_AltitudeFromSeaLevel()); MicroEntries.Add(new Target_Name()); MicroEntries.Add(new Target_Obtvelocity()); - - MicroEntries.Add(new PartsCount()); MicroEntries.Add(new TotalBurnTime()); MicroEntries.Add(new TotalDeltaVASL()); @@ -1222,6 +1229,25 @@ private void InitializeEntries() MicroEntries.Add(new StageThrustASL()); MicroEntries.Add(new StageThrustVac()); + MicroEntries.Add(new Maneuver_EccentricAnomaly()); + MicroEntries.Add(new Maneuver_EndUT()); + MicroEntries.Add(new Maneuver_MeanAnomaly()); + MicroEntries.Add(new Maneuver_ObT()); + MicroEntries.Add(new Maneuver_ArgumentOfPeriapsis()); + MicroEntries.Add(new Maneuver_Eccentricity()); + MicroEntries.Add(new Maneuver_Inclination()); + MicroEntries.Add(new Maneuver_LongitudeOfAscendingNode()); + MicroEntries.Add(new Maneuver_SemiMajorAxis()); + MicroEntries.Add(new Maneuver_SemiMinorAxis()); + MicroEntries.Add(new Maneuver_OrbitalEnergy()); + MicroEntries.Add(new Maneuver_SemiLatusRectum()); + MicroEntries.Add(new Maneuver_TimeToAp()); + MicroEntries.Add(new Maneuver_TimeToPe()); + MicroEntries.Add(new Maneuver_TrueAnomaly()); + MicroEntries.Add(new Maneuver_UniversalTimeAtClosestApproach()); + MicroEntries.Add(new Maneuver_UniversalTimeAtSoiEncounter()); + MicroEntries.Add(new Maneuver_orbitPercent()); + MicroEntries.Add(new Maneuver_period()); diff --git a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs index 5602ab4..bc9582c 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs @@ -47,18 +47,22 @@ override internal void DrawWindowFooter() private void DeleteNodes() { - var activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); - List nodeData = new List(); + var nodes = MicroUtility.ActiveVessel.SimulationObject?.FindComponent()?.GetNodes(); + List nodesToDelete = new List(); - var nodeToDelete = activeVesselPlan.GetNodes()[_selectedNodeIndex]; - nodeData.Add(nodeToDelete); + // This should never happen, but better be safe + if (_selectedNodeIndex + 1 > nodes.Count) + _selectedNodeIndex = Math.Max(0, nodes.Count - 1); - foreach (ManeuverNodeData node in activeVesselPlan.GetNodes()) + var nodeToDelete = nodes[_selectedNodeIndex]; + nodesToDelete.Add(nodeToDelete); + + foreach (ManeuverNodeData node in nodes) { - if (!nodeData.Contains(node) && (!nodeToDelete.IsOnManeuverTrajectory || nodeToDelete.Time < node.Time)) - nodeData.Add(node); + if (!nodesToDelete.Contains(node) && (!nodeToDelete.IsOnManeuverTrajectory || nodeToDelete.Time < node.Time)) + nodesToDelete.Add(node); } - GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodeData); + GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodesToDelete); _selectedNodeIndex = 0; } @@ -76,8 +80,6 @@ internal override void RefreshData() private void RefreshManeuverNodes() { - //MicroUtility.RefreshActiveVesselAndCurrentManeuver(); -> check if we need this here - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); if (activeVesselPlan != null) { @@ -90,5 +92,10 @@ internal void OnManeuverCreatedMessage(MessageCenterMessage message) var nodeData = MicroUtility.ActiveVessel.SimulationObject?.FindComponent()?.GetNodes(); _selectedNodeIndex = nodeData != null ? nodeData.Count > 0 ? nodeData.Count - 1 : 0 : 0; } + + internal void OnManeuverRemovedMessage(MessageCenterMessage message) + { + _selectedNodeIndex = 0; + } } } From dd93fcbd43f364a68ac04be0b0b1b1d67d9817bb Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Tue, 18 Apr 2023 20:39:26 +0200 Subject: [PATCH 12/38] Mark Maneuver entries as accepted --- .../MicroEngineer/Entries/ManeuverEntries.cs | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 28aed8e..b072de5 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -231,7 +231,7 @@ public Maneuver_EccentricAnomaly() { Name = "Eccentric Anomaly"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "°"; Formatting = "{0:N2}"; } @@ -262,7 +262,7 @@ public Maneuver_EndUT() { Name = "EndUT"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "s"; Formatting = "{0:N3}"; } @@ -293,7 +293,7 @@ public Maneuver_MeanAnomaly() { Name = "Mean Anomaly"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "°"; Formatting = "{0:N3}"; } @@ -324,7 +324,7 @@ public Maneuver_ObT() { Name = "Orbit Time"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "s"; Formatting = null; } @@ -355,7 +355,7 @@ public Maneuver_ArgumentOfPeriapsis() { Name = "Argument of Periapsis"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = null; Formatting = "{0:N3}"; } @@ -377,7 +377,7 @@ public Maneuver_Eccentricity() { Name = "Eccentricity"; Description = "Shows the vessel's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = null; Formatting = "{0:N3}"; } @@ -399,7 +399,7 @@ public Maneuver_Inclination() { Name = "Inclination"; Description = "Shows the vessel's orbital inclination relative to the equator."; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "°"; Formatting = "{0:N3}"; } @@ -421,7 +421,7 @@ public Maneuver_LongitudeOfAscendingNode() { Name = "LAN"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = null; Formatting = "{0:N3}"; } @@ -443,7 +443,7 @@ public Maneuver_SemiMajorAxis() { Name = "Semi Major Axis"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "m"; Formatting = "{0:N0}"; } @@ -465,7 +465,7 @@ public Maneuver_SemiMinorAxis() { Name = "Semi Minor Axis"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "m"; Formatting = "{0:N0}"; } @@ -487,7 +487,7 @@ public Maneuver_OrbitalEnergy() { Name = "Orbital Energy"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = null; Formatting = "{0:N3}"; } @@ -509,7 +509,7 @@ public Maneuver_SemiLatusRectum() { Name = "Semi Latus Rectum ℓ"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "m"; Formatting = "{0:N0}"; } @@ -531,7 +531,7 @@ public Maneuver_TimeToAp() { Name = "Time to Ap."; Description = "Shows the time until the vessel reaches apoapsis, the highest point of the orbit."; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "s"; Formatting = null; } @@ -562,7 +562,7 @@ public Maneuver_TimeToPe() { Name = "Time to Pe."; Description = "Shows the time until the vessel reaches periapsis, the lowest point of the orbit."; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "s"; Formatting = null; } @@ -593,7 +593,7 @@ public Maneuver_TrueAnomaly() { Name = "True Anomaly"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "°"; Formatting = "{0:N2}"; } @@ -624,7 +624,7 @@ public Maneuver_UniversalTimeAtClosestApproach() { Name = "UT Closest Appr."; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = null; Formatting = null; } @@ -655,7 +655,7 @@ public Maneuver_UniversalTimeAtSoiEncounter() { Name = "UT SOI Enc"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = null; Formatting = null; } @@ -686,7 +686,7 @@ public Maneuver_orbitPercent() { Name = "Orbit percent"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "%"; Formatting = "{0:N2}"; } @@ -708,7 +708,7 @@ public Maneuver_period() { Name = "Period"; Description = "Shows the amount of time it will take to complete a full orbit."; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "s"; Formatting = null; } From c4510c8bd679e0d4b9ffa9a942fce17216e79305 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Tue, 18 Apr 2023 20:42:48 +0200 Subject: [PATCH 13/38] Flight entries update - Move flight entries to new file Entries\FlightEntries.cs - Add new class FlightEntry that inherits from MicroEntry - All flight entries are now FlightEntry - Add AngleOfAttack and SideSlip --- .../MicroEngineer/Entries/FlightEntries.cs | 215 ++++++++++ .../MicroEngineer/MicroEngineerMod.cs | 5 +- .../MicroEngineer/MicroEntries.cs | 400 ++---------------- .../MicroEngineer/MicroUtility.cs | 61 +++ 4 files changed, 318 insertions(+), 363 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs new file mode 100644 index 0000000..2d7ade8 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -0,0 +1,215 @@ + +namespace MicroMod +{ + public class FlightEntry : MicroEntry + { } + + public class Speed : FlightEntry + { + public Speed() + { + Name = "Speed"; + Description = "Shows the vessel's total velocity."; + Category = MicroEntryCategory.Flight; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.SurfaceVelocity.magnitude; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class MachNumber : FlightEntry + { + public MachNumber() + { + Name = "Mach Number"; + Description = "Shows the ratio of vessel's speed and local speed of sound."; + Category = MicroEntryCategory.Flight; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.MachNumber; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class AtmosphericDensity : FlightEntry + { + public AtmosphericDensity() + { + Name = "Atm. Density"; + Description = "Shows the atmospheric density."; + Category = MicroEntryCategory.Flight; + Unit = "g/L"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.AtmosphericDensity; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class TotalLift : FlightEntry + { + public TotalLift() + { + Name = "Total Lift"; + Description = "Shows the total lift force produced by the vessel."; + Category = MicroEntryCategory.Flight; + Unit = "N"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = AeroForces.TotalLift; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + double toReturn = (double)EntryValue * 1000; + return String.IsNullOrEmpty(base.Formatting) ? toReturn.ToString() : String.Format(base.Formatting, toReturn); + } + } + } + + public class TotalDrag : FlightEntry + { + public TotalDrag() + { + Name = "Total Drag"; + Description = "Shows the total drag force exerted on the vessel."; + Category = MicroEntryCategory.Flight; + Unit = "N"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = AeroForces.TotalDrag; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + double toReturn = (double)EntryValue * 1000; + return String.IsNullOrEmpty(base.Formatting) ? toReturn.ToString() : String.Format(base.Formatting, toReturn); + } + } + } + + public class LiftDivDrag : FlightEntry + { + public LiftDivDrag() + { + Name = "Lift / Drag"; + Description = "Shows the ratio of total lift and drag forces."; + Category = MicroEntryCategory.Flight; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = AeroForces.TotalLift / AeroForces.TotalDrag; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + double toReturn = (double)EntryValue * 1000; + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); + } + } + } + + public class AngleOfAttack : FlightEntry + { + public AngleOfAttack() + { + Name = "Angle of Attack"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "°"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = AeroForces.AngleOfAttack; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class SideSlip : FlightEntry + { + public SideSlip() + { + Name = "Sideslip"; + Description = ""; + Category = MicroEntryCategory.New; + Unit = "°"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = AeroForces.SideSlip; + } + + public override string ValueDisplay => base.ValueDisplay; + } +} diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 6b47925..4c8dfb3 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -428,7 +428,6 @@ private void FillMainGUI(int windowID) } GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); - } catch (Exception ex) { @@ -1228,7 +1227,6 @@ private void InitializeEntries() MicroEntries.Add(new StageTWRVac()); MicroEntries.Add(new StageThrustASL()); MicroEntries.Add(new StageThrustVac()); - MicroEntries.Add(new Maneuver_EccentricAnomaly()); MicroEntries.Add(new Maneuver_EndUT()); MicroEntries.Add(new Maneuver_MeanAnomaly()); @@ -1249,6 +1247,9 @@ private void InitializeEntries() MicroEntries.Add(new Maneuver_orbitPercent()); MicroEntries.Add(new Maneuver_period()); + MicroEntries.Add(new AngleOfAttack()); + MicroEntries.Add(new SideSlip()); + diff --git a/MicroEngineerProject/MicroEngineer/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/MicroEntries.cs index b77566a..745805a 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEntries.cs @@ -521,176 +521,7 @@ public override string ValueDisplay } } - public class Speed : MicroEntry - { - public Speed() - { - Name = "Speed"; - Description = "Shows the vessel's total velocity."; - Category = MicroEntryCategory.Flight; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.SurfaceVelocity.magnitude; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class MachNumber : MicroEntry - { - public MachNumber() - { - Name = "Mach Number"; - Description = "Shows the ratio of vessel's speed and local speed of sound."; - Category = MicroEntryCategory.Flight; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.MachNumber; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class AtmosphericDensity : MicroEntry - { - public AtmosphericDensity() - { - Name = "Atm. Density"; - Description = "Shows the atmospheric density."; - Category = MicroEntryCategory.Flight; - Unit = "g/L"; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.AtmosphericDensity; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class TotalLift : MicroEntry - { - public TotalLift() - { - Name = "Total Lift"; - Description = "Shows the total lift force produced by the vessel."; - Category = MicroEntryCategory.Flight; - Unit = "N"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = AeroForces.TotalLift; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - double toReturn = (double)EntryValue * 1000; - return String.IsNullOrEmpty(base.Formatting) ? toReturn.ToString() : String.Format(base.Formatting, toReturn); - } - } - } - - public class TotalDrag : MicroEntry - { - public TotalDrag() - { - Name = "Total Drag"; - Description = "Shows the total drag force exerted on the vessel."; - Category = MicroEntryCategory.Flight; - Unit = "N"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = AeroForces.TotalDrag; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - double toReturn = (double)EntryValue * 1000; - return String.IsNullOrEmpty(base.Formatting) ? toReturn.ToString() : String.Format(base.Formatting, toReturn); - } - } - } - - public class LiftDivDrag : MicroEntry - { - public LiftDivDrag() - { - Name = "Lift / Drag"; - Description = "Shows the ratio of total lift and drag forces."; - Category = MicroEntryCategory.Flight; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = AeroForces.TotalLift / AeroForces.TotalDrag; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - double toReturn = (double)EntryValue * 1000; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } - } + @@ -1045,7 +876,7 @@ public AltitudeFromScenery() Name = "Altitude (Scenery)"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; + Unit = "m"; Formatting = "{0:N2}"; } @@ -1054,25 +885,16 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.AltitudeFromScenery; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class AtmosphericTemperature : MicroEntry { public AtmosphericTemperature() { - Name = "AtmosphericTemperature"; + Name = "Static ambient temp."; Description = ""; - Category = MicroEntryCategory.Misc; + Category = MicroEntryCategory.Accepted; Unit = "K"; Formatting = "{0:N2}"; } @@ -1082,23 +904,14 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.AtmosphericTemperature; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class ExternalTemperature : MicroEntry { public ExternalTemperature() { - Name = "ExternalTemperature"; + Name = "External temperature"; Description = ""; Category = MicroEntryCategory.Accepted; Unit = "K"; @@ -1110,23 +923,14 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.ExternalTemperature; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class DynamicPressure_kPa : MicroEntry { public DynamicPressure_kPa() { - Name = "DynamicPressure_kPa"; + Name = "Dynamic Pressure"; Description = ""; Category = MicroEntryCategory.Accepted; Unit = "kPa"; @@ -1138,16 +942,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.DynamicPressure_kPa; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class ExposedArea : MicroEntry @@ -1166,16 +961,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.ExposedArea; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } @@ -1196,16 +982,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.FuelPercentage; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Heading : MicroEntry @@ -1215,7 +992,7 @@ public Heading() Name = "Heading"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; + Unit = "°"; Formatting = "{0:N2}"; } @@ -1224,26 +1001,17 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.Heading; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Pitch_HorizonRelative : MicroEntry { public Pitch_HorizonRelative() { - Name = "Pitch_HorizonRelative"; + Name = "Pitch"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; + Unit = "°"; Formatting = "{0:N2}"; } @@ -1252,26 +1020,17 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.Pitch_HorizonRelative; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Roll_HorizonRelative : MicroEntry { public Roll_HorizonRelative() { - Name = "Roll_HorizonRelative"; + Name = "Roll"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; + Unit = "°"; Formatting = "{0:N2}"; } @@ -1280,26 +1039,17 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.Roll_HorizonRelative; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Yaw_HorizonRelative : MicroEntry { public Yaw_HorizonRelative() { - Name = "Yaw_HorizonRelative"; + Name = "Yaw"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; + Unit = "°"; Formatting = "{0:N2}"; } @@ -1308,16 +1058,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.Yaw_HorizonRelative; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class DragCoefficient : MicroEntry @@ -1336,16 +1077,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.DragCoefficient; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class OrbitalSpeed : MicroEntry @@ -1364,27 +1096,18 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.OrbitalSpeed; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class SoundSpeed : MicroEntry { public SoundSpeed() { - Name = "SoundSpeed"; + Name = "Speed of sound"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Unit = "m/s"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -1392,16 +1115,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.SoundSpeed; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class StageFuelPercentage : MicroEntry @@ -1420,26 +1134,17 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.StageFuelPercentage; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class StaticPressure_kPa : MicroEntry { public StaticPressure_kPa() { - Name = "StaticPressure_kPa"; + Name = "Static Pressure"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; + Unit = "kPa"; Formatting = "{0:N3}"; } @@ -1448,16 +1153,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.StaticPressure_kPa; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class TimeSinceLaunch : MicroEntry @@ -1504,16 +1200,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TotalCommandCrewCapacity; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Zenith : MicroEntry @@ -1523,8 +1210,8 @@ public Zenith() Name = "Zenith"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -1532,16 +1219,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.Zenith; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class altimeterMode : MicroEntry @@ -1576,10 +1254,10 @@ public class geeForce : MicroEntry { public geeForce() { - Name = "geeForce"; + Name = "G-Force"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; + Unit = "g"; Formatting = "{0:N3}"; } diff --git a/MicroEngineerProject/MicroEngineer/MicroUtility.cs b/MicroEngineerProject/MicroEngineer/MicroUtility.cs index 7a3e761..6118490 100644 --- a/MicroEngineerProject/MicroEngineer/MicroUtility.cs +++ b/MicroEngineerProject/MicroEngineer/MicroUtility.cs @@ -390,5 +390,66 @@ public static double TotalDrag return toReturn; } } + + public static double AngleOfAttack + { + get + { + double aoe = 0.0; + + ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(MicroUtility.ActiveVessel.SimulationObject); + if (simulationViewIfLoaded != null) + { + Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(MicroUtility.ActiveVessel.SurfaceVelocity).normalized; + Vector up = simulationViewIfLoaded.Model.Vessel.ControlTransform.up; + Vector3 lhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(up); + Vector right = simulationViewIfLoaded.Model.Vessel.ControlTransform.right; + Vector3 rhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(right); + Vector3 lhs2 = normalized; + Vector3 normalized2 = Vector3.Cross(lhs2, rhs).normalized; + Vector3 rhs2 = Vector3.Cross(lhs2, normalized2); + aoe = Vector3.Dot(lhs, normalized2); + aoe = Math.Asin(aoe) * 57.295780181884766; + if (double.IsNaN(aoe)) + { + aoe = 0.0; + } + } + + return aoe; + } + } + + public static double SideSlip + { + get + { + double sideSlip = 0.0; + + ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(MicroUtility.ActiveVessel.SimulationObject); + if (simulationViewIfLoaded != null) + { + Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(MicroUtility.ActiveVessel.SurfaceVelocity).normalized; + Vector up = simulationViewIfLoaded.Model.Vessel.ControlTransform.up; + Vector3 lhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(up); + Vector right = simulationViewIfLoaded.Model.Vessel.ControlTransform.right; + Vector3 rhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(right); + Vector3 lhs2 = normalized; + Vector3 normalized2 = Vector3.Cross(lhs2, rhs).normalized; + Vector3 rhs2 = Vector3.Cross(lhs2, normalized2); + + sideSlip = Vector3.Dot(lhs, rhs2); + sideSlip = Math.Asin(sideSlip) * 57.295780181884766; + if (double.IsNaN(sideSlip)) + { + sideSlip = 0.0; + } + } + + return sideSlip; + } + } + + } } From 4f843f4c58a99b127afa90f02ab6fce84853e4a9 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Tue, 18 Apr 2023 21:20:14 +0200 Subject: [PATCH 14/38] Simplify Target ValueDisplay calls --- .../MicroEngineer/Entries/TargetEntries.cs | 121 ++---------------- 1 file changed, 11 insertions(+), 110 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 4bdfe1d..2802581 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -308,16 +308,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.argumentOfPeriapsis; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_Eccentricity : TargetEntry @@ -336,16 +327,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.eccentricity; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_Inclination : TargetEntry @@ -364,16 +346,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.inclination; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_LongitudeOfAscendingNode : TargetEntry @@ -392,16 +365,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.longitudeOfAscendingNode; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_SemiMajorAxis : TargetEntry @@ -420,16 +384,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.semiMajorAxis; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_ReferenceBodyConstants_Radius : TargetEntry @@ -448,16 +403,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.radius; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_ReferenceBodyConstants_StandardGravitationParameter : TargetEntry @@ -476,16 +422,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody.gravParameter; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_SemiLatusRectum : TargetEntry @@ -504,16 +441,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.SemiLatusRectum; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_SemiMinorAxis : TargetEntry @@ -532,16 +460,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.SemiMinorAxis; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_TrueAnomaly : TargetEntry @@ -718,16 +637,7 @@ public override void RefreshData() EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeSpeed : null; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class DistanceAtCloseApproach2 : MicroEntry @@ -809,16 +719,7 @@ public override void RefreshData() EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeSpeed : null; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } From e8570f106a7513982c84895234776899d9207026 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Wed, 19 Apr 2023 13:48:24 +0200 Subject: [PATCH 15/38] Add phase angle --- .../MicroEngineer/Entries/FlightEntries.cs | 4 +- .../MicroEngineer/Entries/TargetEntries.cs | 93 +++++++++++++++++-- .../MicroEngineer/MicroEngineerMod.cs | 2 +- 3 files changed, 89 insertions(+), 10 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index 2d7ade8..f18d349 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -181,7 +181,7 @@ public AngleOfAttack() { Name = "Angle of Attack"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "°"; Formatting = "{0:N3}"; } @@ -200,7 +200,7 @@ public SideSlip() { Name = "Sideslip"; Description = ""; - Category = MicroEntryCategory.New; + Category = MicroEntryCategory.Accepted2; Unit = "°"; Formatting = "{0:N3}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 2802581..9f4d2d2 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -1,4 +1,5 @@ using KSP.Sim.impl; +using UnityEngine; namespace MicroMod { @@ -558,7 +559,7 @@ public override void RefreshData() } - public class DistanceAtCloseApproach1 : MicroEntry + public class DistanceAtCloseApproach1 : TargetEntry { public DistanceAtCloseApproach1() { @@ -589,7 +590,7 @@ public override string ValueDisplay } } - public class TimeToCloseApproach1 : MicroEntry + public class TimeToCloseApproach1 : TargetEntry { public TimeToCloseApproach1() { @@ -619,7 +620,7 @@ public override string ValueDisplay } } - public class RelativeSpeedAtCloseApproach1 : MicroEntry + public class RelativeSpeedAtCloseApproach1 : TargetEntry { public RelativeSpeedAtCloseApproach1() { @@ -640,7 +641,7 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class DistanceAtCloseApproach2 : MicroEntry + public class DistanceAtCloseApproach2 : TargetEntry { public DistanceAtCloseApproach2() { @@ -671,7 +672,7 @@ public override string ValueDisplay } } - public class TimeToCloseApproach2 : MicroEntry + public class TimeToCloseApproach2 : TargetEntry { public TimeToCloseApproach2() { @@ -701,7 +702,7 @@ public override string ValueDisplay } } - public class RelativeSpeedAtCloseApproach2 : MicroEntry + public class RelativeSpeedAtCloseApproach2 : TargetEntry { public RelativeSpeedAtCloseApproach2() { @@ -720,10 +721,88 @@ public override void RefreshData() } public override string ValueDisplay => base.ValueDisplay; - } + } + + public class PhaseAngle : TargetEntry + { + public PhaseAngle() + { + Name = "Phase angle"; + Description = ""; + Category = MicroEntryCategory.Accepted2; + Unit = "°"; + Formatting = "{0:N2}"; + } + + private double? GetPhaseAngle() + { + // If Target is the body that vessel is orbiting, there is no phase angle + if (MicroUtility.ActiveVessel.Orbit.referenceBody == MicroUtility.ActiveVessel.TargetObject.CelestialBody) + return null; + + (CelestialBodyComponent referenceBody, Vector3 localPosition) from = (MicroUtility.ActiveVessel.Orbit.referenceBody, MicroUtility.ActiveVessel.Orbit.Position.localPosition); + (CelestialBodyComponent referenceBody, Vector3 localPosition) to = (MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody, MicroUtility.ActiveVessel.TargetObject.Orbit.Position.localPosition); + // We search for the common celestial body that both ActiveVessel and TargetObject are orbiting and then calculate the phase angle + bool commonReferenceBodyFound = false; + + // Set a limit for common reference body lookups. There should always be a common reference body so this shouldn't be needed, but just to be safe. + int numberOfLoopTries = 3; + // Outer loop => TargetObject (to) + for (int i = 0; i < numberOfLoopTries; i++) + { + from.referenceBody = MicroUtility.ActiveVessel.Orbit.referenceBody; + from.localPosition = MicroUtility.ActiveVessel.Orbit.Position.localPosition; + + // Inner lookp => ActiveVessel (from) + for (int j = 0; j < numberOfLoopTries; j++) + { + if (from.referenceBody == to.referenceBody) + { + commonReferenceBodyFound = true; + break; + } + + // referenceBody.Orbit is null when referenceBody is a star (i.e. Kerbol). Lookup should end here since the star isn't orbiting anything (yet!) + if (from.referenceBody.Orbit == null) + break; + + // Set the reference body one level up + from.localPosition = from.referenceBody.Position.localPosition + from.localPosition; + from.referenceBody = from.referenceBody.referenceBody; + } + + if (commonReferenceBodyFound) + break; + + if (to.referenceBody.Orbit == null) + break; + + // Set the reference body one level up + to.localPosition = to.referenceBody.Position.localPosition + to.localPosition; + to.referenceBody = to.referenceBody.referenceBody; + } + + if (commonReferenceBodyFound) + { + double phase = Vector3d.SignedAngle(to.localPosition, from.localPosition, Vector3d.up); + return Math.Round(phase, 1); + } + else + return null; + } + public override void RefreshData() + { + if (MicroUtility.TargetExists()) + { + EntryValue = this.GetPhaseAngle(); + } + } + + public override string ValueDisplay => base.ValueDisplay; + } diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 4c8dfb3..5e38ad6 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1246,9 +1246,9 @@ private void InitializeEntries() MicroEntries.Add(new Maneuver_UniversalTimeAtSoiEncounter()); MicroEntries.Add(new Maneuver_orbitPercent()); MicroEntries.Add(new Maneuver_period()); - MicroEntries.Add(new AngleOfAttack()); MicroEntries.Add(new SideSlip()); + MicroEntries.Add(new PhaseAngle()); From 831b177b85ac3a709dac6dbdcc64f40712e4cad9 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Wed, 19 Apr 2023 17:35:46 +0200 Subject: [PATCH 16/38] Add TransferAngle - Move MicroUtility to Utilities folder - Move AeroForces to a new file -> Utilities\AeroForces.cs - Add new class TransferInfo -> Utilities\TransferInfo.cs - Add TransferAngle --- .../MicroEngineer/Entries/TargetEntries.cs | 79 ++------- .../MicroEngineer/MicroEngineerMod.cs | 1 + .../MicroEngineer/Utilities/AeroForces.cs | 134 +++++++++++++++ .../{ => Utilities}/MicroUtility.cs | 162 ++---------------- .../MicroEngineer/Utilities/TransferInfo.cs | 118 +++++++++++++ .../MicroEngineer/Windows/BaseWindow.cs | 1 - 6 files changed, 285 insertions(+), 210 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs rename MicroEngineerProject/MicroEngineer/{ => Utilities}/MicroUtility.cs (64%) create mode 100644 MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 9f4d2d2..5ca92fb 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -1,5 +1,4 @@ using KSP.Sim.impl; -using UnityEngine; namespace MicroMod { @@ -727,83 +726,37 @@ public class PhaseAngle : TargetEntry { public PhaseAngle() { - Name = "Phase angle"; + Name = "Phase Angle"; Description = ""; Category = MicroEntryCategory.Accepted2; Unit = "°"; Formatting = "{0:N2}"; } - private double? GetPhaseAngle() + public override void RefreshData() { - // If Target is the body that vessel is orbiting, there is no phase angle - if (MicroUtility.ActiveVessel.Orbit.referenceBody == MicroUtility.ActiveVessel.TargetObject.CelestialBody) - return null; - - (CelestialBodyComponent referenceBody, Vector3 localPosition) from = (MicroUtility.ActiveVessel.Orbit.referenceBody, MicroUtility.ActiveVessel.Orbit.Position.localPosition); - (CelestialBodyComponent referenceBody, Vector3 localPosition) to = (MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody, MicroUtility.ActiveVessel.TargetObject.Orbit.Position.localPosition); + EntryValue = MicroUtility.TargetExists() ? TransferInfo.GetPhaseAngle() : null; + } - // We search for the common celestial body that both ActiveVessel and TargetObject are orbiting and then calculate the phase angle - bool commonReferenceBodyFound = false; - - // Set a limit for common reference body lookups. There should always be a common reference body so this shouldn't be needed, but just to be safe. - int numberOfLoopTries = 3; + public override string ValueDisplay => base.ValueDisplay; + } - // Outer loop => TargetObject (to) - for (int i = 0; i < numberOfLoopTries; i++) - { - from.referenceBody = MicroUtility.ActiveVessel.Orbit.referenceBody; - from.localPosition = MicroUtility.ActiveVessel.Orbit.Position.localPosition; - - // Inner lookp => ActiveVessel (from) - for (int j = 0; j < numberOfLoopTries; j++) - { - if (from.referenceBody == to.referenceBody) - { - commonReferenceBodyFound = true; - break; - } - - // referenceBody.Orbit is null when referenceBody is a star (i.e. Kerbol). Lookup should end here since the star isn't orbiting anything (yet!) - if (from.referenceBody.Orbit == null) - break; - - // Set the reference body one level up - from.localPosition = from.referenceBody.Position.localPosition + from.localPosition; - from.referenceBody = from.referenceBody.referenceBody; - } - - if (commonReferenceBodyFound) - break; - - if (to.referenceBody.Orbit == null) - break; - - // Set the reference body one level up - to.localPosition = to.referenceBody.Position.localPosition + to.localPosition; - to.referenceBody = to.referenceBody.referenceBody; - } - - if (commonReferenceBodyFound) - { - double phase = Vector3d.SignedAngle(to.localPosition, from.localPosition, Vector3d.up); - return Math.Round(phase, 1); - } - else - return null; + public class TransferAngle : TargetEntry + { + public TransferAngle() + { + Name = "Transfer Angle"; + Description = ""; + Category = MicroEntryCategory.Accepted2; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() { - if (MicroUtility.TargetExists()) - { - EntryValue = this.GetPhaseAngle(); - } + EntryValue = MicroUtility.TargetExists() ? TransferInfo.GetTransferAngle() : null; } public override string ValueDisplay => base.ValueDisplay; } - - - } diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 5e38ad6..582d116 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1250,6 +1250,7 @@ private void InitializeEntries() MicroEntries.Add(new SideSlip()); MicroEntries.Add(new PhaseAngle()); + MicroEntries.Add(new TransferAngle()); diff --git a/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs b/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs new file mode 100644 index 0000000..0392fd4 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs @@ -0,0 +1,134 @@ +using KSP.Game; +using KSP.Sim.impl; +using KSP.Sim; +using KSP.UI.Flight; +using UnityEngine; + +namespace MicroMod +{ + public static class AeroForces + { + private static readonly List liftForces = new() + { + PhysicsForceDisplaySystem.MODULE_DRAG_BODY_LIFT_TYPE, + PhysicsForceDisplaySystem.MODULE_LIFTINGSURFACE_LIFT_TYPE + }; + + private static readonly List dragForces = new() + { + PhysicsForceDisplaySystem.MODULE_DRAG_DRAG_TYPE, + PhysicsForceDisplaySystem.MODULE_LIFTINGSURFACE_DRAG_TYPE + }; + + public static double TotalLift + { + get + { + double toReturn = 0.0; + + IEnumerable parts = MicroUtility.ActiveVessel?.SimulationObject?.PartOwner?.Parts; + if (parts == null || !MicroUtility.ActiveVessel.IsInAtmosphere) + { + return toReturn; + } + + foreach (PartComponent part in parts) + { + foreach (IForce force in part.SimulationObject.Rigidbody.Forces) + { + if (liftForces.Contains(force.GetType())) + { + toReturn += force.RelativeForce.magnitude; + } + } + } + + return toReturn; + } + } + + public static double TotalDrag + { + get + { + double toReturn = 0.0; + + IEnumerable parts = MicroUtility.ActiveVessel?.SimulationObject?.PartOwner?.Parts; + if (parts == null || !MicroUtility.ActiveVessel.IsInAtmosphere) + return toReturn; + + foreach (PartComponent part in parts) + { + foreach (IForce force in part.SimulationObject.Rigidbody.Forces) + { + if (dragForces.Contains(force.GetType())) + { + toReturn += force.RelativeForce.magnitude; + } + } + } + + return toReturn; + } + } + + public static double AngleOfAttack + { + get + { + double aoe = 0.0; + + ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(MicroUtility.ActiveVessel.SimulationObject); + if (simulationViewIfLoaded != null) + { + Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(MicroUtility.ActiveVessel.SurfaceVelocity).normalized; + Vector up = simulationViewIfLoaded.Model.Vessel.ControlTransform.up; + Vector3 lhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(up); + Vector right = simulationViewIfLoaded.Model.Vessel.ControlTransform.right; + Vector3 rhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(right); + Vector3 lhs2 = normalized; + Vector3 normalized2 = Vector3.Cross(lhs2, rhs).normalized; + Vector3 rhs2 = Vector3.Cross(lhs2, normalized2); + aoe = Vector3.Dot(lhs, normalized2); + aoe = Math.Asin(aoe) * 57.295780181884766; + if (double.IsNaN(aoe)) + { + aoe = 0.0; + } + } + + return aoe; + } + } + + public static double SideSlip + { + get + { + double sideSlip = 0.0; + + ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(MicroUtility.ActiveVessel.SimulationObject); + if (simulationViewIfLoaded != null) + { + Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(MicroUtility.ActiveVessel.SurfaceVelocity).normalized; + Vector up = simulationViewIfLoaded.Model.Vessel.ControlTransform.up; + Vector3 lhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(up); + Vector right = simulationViewIfLoaded.Model.Vessel.ControlTransform.right; + Vector3 rhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(right); + Vector3 lhs2 = normalized; + Vector3 normalized2 = Vector3.Cross(lhs2, rhs).normalized; + Vector3 rhs2 = Vector3.Cross(lhs2, normalized2); + + sideSlip = Vector3.Dot(lhs, rhs2); + sideSlip = Math.Asin(sideSlip) * 57.295780181884766; + if (double.IsNaN(sideSlip)) + { + sideSlip = 0.0; + } + } + + return sideSlip; + } + } + } +} diff --git a/MicroEngineerProject/MicroEngineer/MicroUtility.cs b/MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs similarity index 64% rename from MicroEngineerProject/MicroEngineer/MicroUtility.cs rename to MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs index 6118490..0b3c11f 100644 --- a/MicroEngineerProject/MicroEngineer/MicroUtility.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs @@ -1,9 +1,7 @@ using System.Reflection; using KSP.Game; -using KSP.Sim; using KSP.Sim.impl; using KSP.Sim.Maneuver; -using KSP.UI.Flight; using Newtonsoft.Json; using UnityEngine; using static KSP.Rendering.Planets.PQSData; @@ -34,7 +32,7 @@ public static class MicroUtility public static void RefreshActiveVesselAndCurrentManeuver() { ActiveVessel = GameManager.Instance?.Game?.ViewController?.GetActiveVehicle(true)?.GetSimVessel(true); - CurrentManeuver = ActiveVessel != null ? GameManager.Instance?.Game?.SpaceSimulation.Maneuvers.GetNodesForVessel(ActiveVessel.GlobalId).FirstOrDefault(): null; + CurrentManeuver = ActiveVessel != null ? GameManager.Instance?.Game?.SpaceSimulation.Maneuvers.GetNodesForVessel(ActiveVessel.GlobalId).FirstOrDefault() : null; } public static void RefreshGameManager() @@ -67,11 +65,11 @@ public static string MetersToDistanceString(double heightInMeters) public static string SecondsToTimeString(double seconds, bool addSpacing = true, bool returnLastUnit = false) { - if (seconds == Double.PositiveInfinity) + if (seconds == double.PositiveInfinity) { return "∞"; } - else if (seconds == Double.NegativeInfinity) + else if (seconds == double.NegativeInfinity) { return "-∞"; } @@ -92,9 +90,9 @@ public static string SecondsToTimeString(double seconds, bool addSpacing = true, } int days = (int)(seconds / 21600); - int hours = (int)((seconds - (days * 21600)) / 3600); - int minutes = (int)((seconds - (hours * 3600) - (days * 21600)) / 60); - int secs = (int)(seconds - (days * 21600) - (hours * 3600) - (minutes * 60)); + int hours = (int)((seconds - days * 21600) / 3600); + int minutes = (int)((seconds - hours * 3600 - days * 21600) / 60); + int secs = (int)(seconds - days * 21600 - hours * 3600 - minutes * 60); if (days > 0) { @@ -165,7 +163,7 @@ public static double RadiansToDegrees(double radians) /// Uppercase string shortened to 3 characters. If abbreviation is empty returns "CUS" public static string ValidateAbbreviation(string abbreviation) { - if (String.IsNullOrEmpty(abbreviation)) + if (string.IsNullOrEmpty(abbreviation)) return "CUS"; return abbreviation.Substring(0, Math.Min(abbreviation.Length, 3)).ToUpperInvariant(); @@ -194,8 +192,8 @@ internal static void LoadLayout(List windows) List deserializedWindows = JsonConvert.DeserializeObject>(File.ReadAllText(LayoutPath)); windows.Clear(); - windows.AddRange(deserializedWindows); - + windows.AddRange(deserializedWindows); + Logger.LogInfo("LoadLayout successful"); } catch (FileNotFoundException ex) @@ -215,7 +213,7 @@ internal static void LoadLayout(List windows) /// public static bool TargetExists() { - try { return (MicroUtility.ActiveVessel.TargetObject != null); } + try { return ActiveVessel.TargetObject != null; } catch { return false; } } @@ -225,7 +223,7 @@ public static bool TargetExists() /// public static bool ManeuverExists() { - try { return (GameManager.Instance?.Game?.SpaceSimulation.Maneuvers.GetNodesForVessel(MicroUtility.ActiveVessel.GlobalId).FirstOrDefault() != null); } + try { return GameManager.Instance?.Game?.SpaceSimulation.Maneuvers.GetNodesForVessel(ActiveVessel.GlobalId).FirstOrDefault() != null; } catch { return false; } } @@ -246,7 +244,7 @@ internal static bool ToggleGameInputOnControlInFocus(bool gameInputState, bool s { if (gameInputState) { - if (MicroUtility.InputDisableWindowAbbreviation == GUI.GetNameOfFocusedControl() || MicroUtility.InputDisableWindowName == GUI.GetNameOfFocusedControl()) + if (InputDisableWindowAbbreviation == GUI.GetNameOfFocusedControl() || InputDisableWindowName == GUI.GetNameOfFocusedControl()) { GameManager.Instance.Game.Input.Disable(); return false; @@ -256,7 +254,7 @@ internal static bool ToggleGameInputOnControlInFocus(bool gameInputState, bool s } else { - if ((MicroUtility.InputDisableWindowAbbreviation != GUI.GetNameOfFocusedControl() && MicroUtility.InputDisableWindowName != GUI.GetNameOfFocusedControl()) || !showGuiFlight) + if (InputDisableWindowAbbreviation != GUI.GetNameOfFocusedControl() && InputDisableWindowName != GUI.GetNameOfFocusedControl() || !showGuiFlight) { GameManager.Instance.Game.Input.Enable(); return true; @@ -301,9 +299,9 @@ internal static (int major, int minor, int patch)? GetModVersion(string modId) /// Specified minor version (0.X.0) /// Specified patch version (0.0.X) /// True = installed mod is older. False = installed mod has the same version or it's newer or version isn't declared or version declared is gibberish that cannot be parsed - internal static bool IsModOlderThan (string modId, int major, int minor, int patch) + internal static bool IsModOlderThan(string modId, int major, int minor, int patch) { - var modVersion = MicroUtility.GetModVersion(modId); + var modVersion = GetModVersion(modId); if (!modVersion.HasValue || modVersion.Value == (0, 0, 0)) return false; @@ -323,133 +321,5 @@ internal static bool IsModOlderThan (string modId, int major, int minor, int pat else return false; } - } - - public static class AeroForces - { - private static readonly List liftForces = new() - { - PhysicsForceDisplaySystem.MODULE_DRAG_BODY_LIFT_TYPE, - PhysicsForceDisplaySystem.MODULE_LIFTINGSURFACE_LIFT_TYPE - }; - - private static readonly List dragForces = new() - { - PhysicsForceDisplaySystem.MODULE_DRAG_DRAG_TYPE, - PhysicsForceDisplaySystem.MODULE_LIFTINGSURFACE_DRAG_TYPE - }; - - public static double TotalLift - { - get - { - double toReturn = 0.0; - - IEnumerable parts = MicroUtility.ActiveVessel?.SimulationObject?.PartOwner?.Parts; - if (parts == null || !MicroUtility.ActiveVessel.IsInAtmosphere) - { - return toReturn; - } - - foreach (PartComponent part in parts) - { - foreach (IForce force in part.SimulationObject.Rigidbody.Forces) - { - if (liftForces.Contains(force.GetType())) - { - toReturn += force.RelativeForce.magnitude; - } - } - } - - return toReturn; - } - } - - public static double TotalDrag - { - get - { - double toReturn = 0.0; - - IEnumerable parts = MicroUtility.ActiveVessel?.SimulationObject?.PartOwner?.Parts; - if (parts == null || !MicroUtility.ActiveVessel.IsInAtmosphere) - return toReturn; - - foreach (PartComponent part in parts) - { - foreach (IForce force in part.SimulationObject.Rigidbody.Forces) - { - if (dragForces.Contains(force.GetType())) - { - toReturn += force.RelativeForce.magnitude; - } - } - } - - return toReturn; - } - } - - public static double AngleOfAttack - { - get - { - double aoe = 0.0; - - ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(MicroUtility.ActiveVessel.SimulationObject); - if (simulationViewIfLoaded != null) - { - Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(MicroUtility.ActiveVessel.SurfaceVelocity).normalized; - Vector up = simulationViewIfLoaded.Model.Vessel.ControlTransform.up; - Vector3 lhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(up); - Vector right = simulationViewIfLoaded.Model.Vessel.ControlTransform.right; - Vector3 rhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(right); - Vector3 lhs2 = normalized; - Vector3 normalized2 = Vector3.Cross(lhs2, rhs).normalized; - Vector3 rhs2 = Vector3.Cross(lhs2, normalized2); - aoe = Vector3.Dot(lhs, normalized2); - aoe = Math.Asin(aoe) * 57.295780181884766; - if (double.IsNaN(aoe)) - { - aoe = 0.0; - } - } - - return aoe; - } - } - - public static double SideSlip - { - get - { - double sideSlip = 0.0; - - ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(MicroUtility.ActiveVessel.SimulationObject); - if (simulationViewIfLoaded != null) - { - Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(MicroUtility.ActiveVessel.SurfaceVelocity).normalized; - Vector up = simulationViewIfLoaded.Model.Vessel.ControlTransform.up; - Vector3 lhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(up); - Vector right = simulationViewIfLoaded.Model.Vessel.ControlTransform.right; - Vector3 rhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(right); - Vector3 lhs2 = normalized; - Vector3 normalized2 = Vector3.Cross(lhs2, rhs).normalized; - Vector3 rhs2 = Vector3.Cross(lhs2, normalized2); - - sideSlip = Vector3.Dot(lhs, rhs2); - sideSlip = Math.Asin(sideSlip) * 57.295780181884766; - if (double.IsNaN(sideSlip)) - { - sideSlip = 0.0; - } - } - - return sideSlip; - } - } - - - } + } } diff --git a/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs b/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs new file mode 100644 index 0000000..8199274 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs @@ -0,0 +1,118 @@ +using KSP.Sim.impl; +using KSP.Sim; +using UnityEngine; +using static UnityEngine.GraphicsBuffer; +using System.Runtime.ConstrainedExecution; + +namespace MicroMod +{ + /// + /// Original code by: + /// https://github.com/ABritInSpace/TransferCalculator-KSP2 + /// License: https://raw.githubusercontent.com/ABritInSpace/TransferCalculator-KSP2/master/LICENSE.md + /// + public static class TransferInfo + { + private static Vector3? _fromLocalPosition; + private static IKeplerOrbit _fromOrbit; + private static Vector3? _toLocalPosition; + private static IKeplerOrbit _toOrbit; + + private static bool CalculateParameters() + { + // If Target is the body that vessel is orbiting, there is no phase angle + if (MicroUtility.ActiveVessel.Orbit.referenceBody == MicroUtility.ActiveVessel.TargetObject.CelestialBody) + { + _fromLocalPosition = null; + _toLocalPosition = null; + _fromOrbit = null; + _toOrbit = null; + return false; + } + + (CelestialBodyComponent referenceBody, Vector3 localPosition, IKeplerOrbit currentOrbit) from = (MicroUtility.ActiveVessel.Orbit.referenceBody, MicroUtility.ActiveVessel.Orbit.Position.localPosition, MicroUtility.ActiveVessel.Orbit); + (CelestialBodyComponent referenceBody, Vector3 localPosition, IKeplerOrbit currentOrbit) to = (MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody, MicroUtility.ActiveVessel.TargetObject.Orbit.Position.localPosition, MicroUtility.ActiveVessel.TargetObject.Orbit); + + // We search for the common celestial body that both ActiveVessel and TargetObject are orbiting and then calculate the phase angle + bool commonReferenceBodyFound = false; + + // Set a limit for common reference body lookups. There should always be a common reference body so this shouldn't be needed, but just to be safe. + int numberOfLoopTries = 3; + + // Outer loop => TargetObject (to) + for (int i = 0; i < numberOfLoopTries; i++) + { + from.referenceBody = MicroUtility.ActiveVessel.Orbit.referenceBody; + from.localPosition = MicroUtility.ActiveVessel.Orbit.Position.localPosition; + from.currentOrbit = MicroUtility.ActiveVessel.Orbit; + + // Inner lookp => ActiveVessel (from) + for (int j = 0; j < numberOfLoopTries; j++) + { + if (from.referenceBody == to.referenceBody) + { + commonReferenceBodyFound = true; + break; + } + + // referenceBody.Orbit is null when referenceBody is a star (i.e. Kerbol). Lookup should end here since the star isn't orbiting anything (yet!) + if (from.referenceBody.Orbit == null) + break; + + // Set the reference body one level up + from.localPosition = from.referenceBody.Position.localPosition + from.localPosition; + from.currentOrbit = from.referenceBody.Orbit; + from.referenceBody = from.referenceBody.referenceBody; + } + + if (commonReferenceBodyFound) + break; + + if (to.referenceBody.Orbit == null) + break; + + // Set the reference body one level up + to.localPosition = to.referenceBody.Position.localPosition + to.localPosition; + to.currentOrbit = to.referenceBody.Orbit; + to.referenceBody = to.referenceBody.referenceBody; + } + + if (commonReferenceBodyFound) + { + _fromLocalPosition = from.localPosition; + _fromOrbit = from.currentOrbit; + _toLocalPosition = to.localPosition; + _toOrbit = to.currentOrbit; + return true; + } + else + { + _fromLocalPosition = null; + _fromOrbit = null; + _toLocalPosition = null; + _toOrbit = null; + return false; + } + } + + public static double? GetPhaseAngle() + { + if (CalculateParameters()) + { + double phase = Vector3d.SignedAngle((Vector3d)_toLocalPosition, (Vector3d)_fromLocalPosition, Vector3d.up); + return Math.Round(phase, 1); + } + else + return null; + } + + public static double? GetTransferAngle() + { + double ellipseA = (_toOrbit.semiMajorAxis + _fromOrbit.semiMajorAxis) / 2; + double time = Mathf.PI * Mathf.Sqrt((float)((ellipseA) * (ellipseA) * (ellipseA)) / ((float)_toOrbit.referenceBody.Mass * 6.67e-11f)); + double transfer = 180 - ((time / _toOrbit.period) * 360); + while (transfer < -180) { transfer += 360; } + return Math.Round(transfer, 1); + } + } +} diff --git a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs index 119e0a6..a0f999b 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs @@ -1,6 +1,5 @@ using UnityEngine; using Newtonsoft.Json; -using System.Runtime.CompilerServices; namespace MicroMod { From 28d27b3deb653eb6bdcd9b162083a9acf1cbae11 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Wed, 19 Apr 2023 20:04:57 +0200 Subject: [PATCH 17/38] Add Throttle --- .../MicroEngineer/Entries/VesselEntries.cs | 19 +++++++++++++++++++ .../MicroEngineer/MicroEngineerMod.cs | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 6b2c813..1252070 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -312,4 +312,23 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } + + public class Throttle : VesselEntry + { + public Throttle() + { + Name = "Throttle"; + Description = ""; + Category = MicroEntryCategory.Accepted2; + Unit = "%"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.flightCtrlState.mainThrottle * 100; + } + + public override string ValueDisplay => base.ValueDisplay; + } } diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 582d116..ccd14fc 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1249,8 +1249,8 @@ private void InitializeEntries() MicroEntries.Add(new AngleOfAttack()); MicroEntries.Add(new SideSlip()); MicroEntries.Add(new PhaseAngle()); - MicroEntries.Add(new TransferAngle()); + MicroEntries.Add(new Throttle()); From bc21a0b82f01daccbcdbc2687806d5e09e95fe5a Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Wed, 19 Apr 2023 23:03:20 +0200 Subject: [PATCH 18/38] Refactor - Move Orbital, Surface, OabStage and MicroEntries to their respective Entries\.cs - Remove MetersTODistanceString (MicroUtility) to clean up more --- .../MicroEngineer/Entries/FlightEntries.cs | 33 +- .../MicroEngineer/Entries/ManeuverEntries.cs | 37 +- .../MicroEngineer/Entries/MicroEntries.cs | 992 +++++++++ .../Entries/OabStageInfoEntries.cs | 279 +++ .../MicroEngineer/Entries/OrbitalEntries.cs | 196 ++ .../MicroEngineer/Entries/SurfaceEntries.cs | 215 ++ .../MicroEngineer/Entries/TargetEntries.cs | 70 +- .../MicroEngineer/MicroEntries.cs | 1922 ----------------- .../MicroEngineer/Utilities/MicroUtility.cs | 5 - 9 files changed, 1701 insertions(+), 2048 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs create mode 100644 MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs create mode 100644 MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs create mode 100644 MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs delete mode 100644 MicroEngineerProject/MicroEngineer/MicroEntries.cs diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index f18d349..bb5b620 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -20,16 +20,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.SurfaceVelocity.magnitude; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class MachNumber : FlightEntry @@ -48,16 +39,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.MachNumber; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class AtmosphericDensity : FlightEntry @@ -76,16 +58,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.AtmosphericDensity; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class TotalLift : FlightEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index b072de5..6b92daf 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -17,7 +17,7 @@ public ProjectedAp() Description = "Shows the projected apoapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "m"; - Formatting = null; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -28,16 +28,7 @@ public override void RefreshData() .ApoapsisArl; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class ProjectedPe : ManeuverEntry @@ -48,7 +39,7 @@ public ProjectedPe() Description = "Shows the projected periapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "m"; - Formatting = null; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -59,16 +50,7 @@ public override void RefreshData() .PeriapsisArl; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class DeltaVRequired : ManeuverEntry @@ -92,16 +74,7 @@ public override void RefreshData() null; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class ManeuverPrograde : ManeuverEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs new file mode 100644 index 0000000..bd005e8 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs @@ -0,0 +1,992 @@ +using KSP.Sim.impl; +using Newtonsoft.Json; + +namespace MicroMod +{ + /// + /// Base class for all Entries (values that can be attached to windows) + /// + [JsonObject(MemberSerialization.OptIn)] + public class MicroEntry + { + [JsonProperty] + public string Name; + [JsonProperty] + public string Description; + [JsonProperty] + public MicroEntryCategory Category; + [JsonProperty] + public string Unit; + [JsonProperty] + public string Formatting; + + public virtual object EntryValue { get; set; } + + /// + /// Controls how the value should be displayed. Should be overriden in a inheritet class for a concrete implementation. + /// + public virtual string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + + public virtual void RefreshData() { } + } + + + #region Flight scene entries + + public class StageInfo : MicroEntry + { + public StageInfo() + { + Name = "Stage Info"; + Description = "Stage Info object, not implemented yet."; // TODO Stage Info display and description + Category = MicroEntryCategory.Stage; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Separator : MicroEntry + { + public Separator() + { + Name = "--------------"; + Description = "It's a separator!"; + Category = MicroEntryCategory.Misc; + Unit = "---"; + Formatting = null; + EntryValue = "---------------"; + } + } + #endregion + + #region New entries + + public class AltitudeFromScenery : MicroEntry + { + public AltitudeFromScenery() + { + Name = "Altitude (Scenery)"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AltitudeFromScenery; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class AtmosphericTemperature : MicroEntry + { + public AtmosphericTemperature() + { + Name = "Static ambient temp."; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "K"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AtmosphericTemperature; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ExternalTemperature : MicroEntry + { + public ExternalTemperature() + { + Name = "External temperature"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "K"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.ExternalTemperature; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class DynamicPressure_kPa : MicroEntry + { + public DynamicPressure_kPa() + { + Name = "Dynamic Pressure"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "kPa"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.DynamicPressure_kPa; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ExposedArea : MicroEntry + { + public ExposedArea() + { + Name = "ExposedArea"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.ExposedArea; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + + + public class FuelPercentage : MicroEntry + { + public FuelPercentage() + { + Name = "FuelPercentage"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "%"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.FuelPercentage; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Heading : MicroEntry + { + public Heading() + { + Name = "Heading"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Heading; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Pitch_HorizonRelative : MicroEntry + { + public Pitch_HorizonRelative() + { + Name = "Pitch"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Pitch_HorizonRelative; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Roll_HorizonRelative : MicroEntry + { + public Roll_HorizonRelative() + { + Name = "Roll"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Roll_HorizonRelative; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Yaw_HorizonRelative : MicroEntry + { + public Yaw_HorizonRelative() + { + Name = "Yaw"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Yaw_HorizonRelative; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class DragCoefficient : MicroEntry + { + public DragCoefficient() + { + Name = "DragCoefficient"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N5}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.DragCoefficient; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class OrbitalSpeed : MicroEntry + { + public OrbitalSpeed() + { + Name = "Orbital Velocity"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.OrbitalSpeed; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class SoundSpeed : MicroEntry + { + public SoundSpeed() + { + Name = "Speed of sound"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m/s"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.SoundSpeed; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageFuelPercentage : MicroEntry + { + public StageFuelPercentage() + { + Name = "StageFuelPercentage"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.StageFuelPercentage; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StaticPressure_kPa : MicroEntry + { + public StaticPressure_kPa() + { + Name = "Static Pressure"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "kPa"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.StaticPressure_kPa; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TimeSinceLaunch : MicroEntry + { + public TimeSinceLaunch() + { + Name = "TimeSinceLaunch"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TimeSinceLaunch; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class TotalCommandCrewCapacity : MicroEntry + { + public TotalCommandCrewCapacity() + { + Name = "TotalCommandCrewCapacity"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TotalCommandCrewCapacity; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Zenith : MicroEntry + { + public Zenith() + { + Name = "Zenith"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Zenith; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class altimeterMode : MicroEntry + { + public altimeterMode() + { + Name = "altimeterMode"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.altimeterMode; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class geeForce : MicroEntry + { + public geeForce() + { + Name = "G-Force"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "g"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.geeForce; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class gravityForPos : MicroEntry + { + public gravityForPos() + { + Name = "gravityForPos"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.gravityForPos.magnitude; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + + public class launchTime : MicroEntry + { + public launchTime() + { + Name = "launchTime"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.launchTime; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class speedMode : MicroEntry + { + public speedMode() + { + Name = "speedMode"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.speedMode; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class AutopilotStatus_IsEnabled : MicroEntry + { + public AutopilotStatus_IsEnabled() + { + Name = "AutopilotStatus_IsEnabled"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.IsEnabled; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class AutopilotStatus_Mode : MicroEntry + { + public AutopilotStatus_Mode() + { + Name = "AutopilotStatus_Mode"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.Mode; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class EccentricAnomaly : MicroEntry + { + public EccentricAnomaly() + { + Name = "Eccentric Anomaly"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.EccentricAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } + } + + public class EndUT : MicroEntry + { + public EndUT() + { + Name = "EndUT"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.EndUT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class MeanAnomaly : MicroEntry + { + public MeanAnomaly() + { + Name = "MeanAnomaly"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.MeanAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } + } + + public class ObT : MicroEntry + { + public ObT() + { + Name = "Orbit Time"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ObT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class ArgumentOfPeriapsis : MicroEntry + { + public ArgumentOfPeriapsis() + { + Name = "ArgumentOfPeriapsis"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.ArgumentOfPeriapsis; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class LongitudeOfAscendingNode : MicroEntry + { + public LongitudeOfAscendingNode() + { + Name = "LAN"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.LongitudeOfAscendingNode; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class SemiMajorAxis : MicroEntry + { + public SemiMajorAxis() + { + Name = "SemiMajorAxis"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.SemiMajorAxis; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class SemiMinorAxis : MicroEntry + { + public SemiMinorAxis() + { + Name = "SemiMinorAxis"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.SemiMinorAxis; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class OrbitalEnergy : MicroEntry + { + public OrbitalEnergy() + { + Name = "OrbitalEnergy"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalEnergy; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ReferenceBodyConstants_Radius : MicroEntry + { + public ReferenceBodyConstants_Radius() + { + Name = "Ref.Bod.Con.Radius"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.Radius; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ReferenceBodyConstants_StandardGravitationParameter : MicroEntry + { + public ReferenceBodyConstants_StandardGravitationParameter() + { + Name = "Ref.Bod.Con.GPar"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.StandardGravitationParameter; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class SemiLatusRectum : MicroEntry + { + public SemiLatusRectum() + { + Name = "SemiLatusRectum"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.SemiLatusRectum; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StartUT : MicroEntry + { + public StartUT() + { + Name = "StartUT"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.StartUT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class TrueAnomaly : MicroEntry + { + public TrueAnomaly() + { + Name = "T.Anomaly"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.TrueAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.RadiansToDegrees((double)EntryValue)); + } + } + } + + public class UniversalTimeAtClosestApproach : MicroEntry + { + public UniversalTimeAtClosestApproach() + { + Name = "UT Closest Appr."; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtClosestApproach; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class UniversalTimeAtSoiEncounter : MicroEntry + { + public UniversalTimeAtSoiEncounter() + { + Name = "UT SOI Enc"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class orbitPercent : MicroEntry + { + public orbitPercent() + { + Name = "orbitPercent"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "%"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.orbitPercent * 100; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class radius : MicroEntry + { + public radius() + { + Name = "Orbit Radius"; + Description = ""; + Category = MicroEntryCategory.Accepted; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.radius; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + #endregion + +} diff --git a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs new file mode 100644 index 0000000..99196eb --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs @@ -0,0 +1,279 @@ +using KSP.Game; +using KSP.Sim.DeltaV; +using KSP.Sim.impl; +using Newtonsoft.Json; + +namespace MicroMod +{ + public class OabStageInfoEntry : MicroEntry + { } + + public class TotalBurnTime_OAB : OabStageInfoEntry + { + public bool UseDHMSFormatting; // TODO: implement + + public TotalBurnTime_OAB() + { + Name = "Total Burn Time (OAB)"; + Description = "Shows the total length of burn the vessel can mantain."; + Category = MicroEntryCategory.OAB; + Unit = "s"; + Formatting = "{0:N1}"; + UseDHMSFormatting = true; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalBurnTime; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + if (UseDHMSFormatting) + return MicroUtility.SecondsToTimeString((double)EntryValue); + else + return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + } + } + } + + public class TotalDeltaVASL_OAB : OabStageInfoEntry + { + public TotalDeltaVASL_OAB() + { + Name = "Total ∆v ASL (OAB)"; + Description = "Shows the vessel's total delta velocity At Sea Level."; + Category = MicroEntryCategory.OAB; + Unit = "m/s"; + Formatting = "{0:N0}"; + } + public override void RefreshData() + { + EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalDeltaVASL; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TotalDeltaVActual_OAB : OabStageInfoEntry + { + public TotalDeltaVActual_OAB() + { + Name = "Total ∆v Actual (OAB)"; + Description = "Shows the vessel's actual total delta velocity (not used in OAB)."; + Category = MicroEntryCategory.OAB; + Unit = "m/s"; + Formatting = "{0:N0}"; + } + public override void RefreshData() + { + EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalDeltaVActual; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TotalDeltaVVac_OAB : OabStageInfoEntry + { + public TotalDeltaVVac_OAB() + { + Name = "Total ∆v Vac (OAB)"; + Description = "Shows the vessel's total delta velocity in Vacuum."; + Category = MicroEntryCategory.OAB; + Unit = "m/s"; + Formatting = "{0:N0}"; + } + public override void RefreshData() + { + EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalDeltaVVac; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + /// + /// Calculates torque from the Center of Thrust and Center of Mass + /// + public class Torque : OabStageInfoEntry + { + [JsonProperty] + internal bool IsActive = false; + + public Torque() + { + Name = "Torque"; + Description = "Thrust torque that is generated by not having Thrust Vector and Center of Mass aligned. Turn on the Center of Thrust and Center of Mass VAB indicators to get an accurate value."; + Category = MicroEntryCategory.OAB; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + if (!this.IsActive) + return; + + Vector3d com = GameManager.Instance?.Game?.OAB?.Current?.Stats?.MainAssembly?.CenterOfProperties?.CoM ?? Vector3d.zero; + Vector3d cot = GameManager.Instance?.Game?.OAB?.Current?.Stats?.MainAssembly?.CenterOfProperties?.CoT ?? Vector3d.zero; + + if (com == Vector3d.zero || cot == Vector3d.zero) + return; + + List engines = GameManager.Instance?.Game?.OAB?.Current?.Stats?.MainAssembly?.VesselDeltaV?.EngineInfo; + if (engines == null || engines.Count == 0) + return; + + Vector3d force = new Vector3d(); + + foreach (var engine in engines) + { + force += engine.ThrustVectorVac; + } + + var leverArm = cot - com; + + Vector3d torque = Vector3d.Cross(force, (Vector3d)leverArm); + + this.EntryValue = torque.magnitude; + this.Unit = (double)EntryValue >= 1.0 ? "kNm" : "Nm"; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null || !this.IsActive) + return "-"; + + if ((double)EntryValue >= 1.0) + return $"{String.Format("{0:F2}", EntryValue)}"; + + return Math.Abs((double)EntryValue) > double.Epsilon ? $"{String.Format("{0:F2}", (double)EntryValue * 1000.0)}" : $"{String.Format("{0:F0}", (double)EntryValue)}"; + } + } + } + + /// + /// Holds stage info parameters for each stage. Also keeps information about the celestial body user selected in the window. + /// + public class StageInfo_OAB : OabStageInfoEntry + { + public List CelestialBodyForStage = new(); + + public StageInfo_OAB() + { + Name = "Stage Info (OAB)"; + Description = "Holds a list of stage info parameters."; + Category = MicroEntryCategory.OAB; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue ??= new List(); + + ((List)EntryValue).Clear(); + + if (MicroUtility.VesselDeltaVComponentOAB?.StageInfo == null) return; + + foreach (var stage in MicroUtility.VesselDeltaVComponentOAB.StageInfo) + { + ((List)EntryValue).Add(new DeltaVStageInfo_OAB + { + DeltaVActual = stage.DeltaVActual, + DeltaVASL = stage.DeltaVatASL, + DeltaVVac = stage.DeltaVinVac, + DryMass = stage.DryMass, + EndMass = stage.EndMass, + FuelMass = stage.FuelMass, + IspASL = stage.IspASL, + IspActual = stage.IspActual, + IspVac = stage.IspVac, + SeparationIndex = stage.SeparationIndex, + Stage = stage.Stage, + StageBurnTime = stage.StageBurnTime, + StageMass = stage.StageMass, + StartMass = stage.StartMass, + TWRASL = stage.TWRASL, + TWRActual = stage.TWRActual, + TWRVac = stage.TWRVac, + ThrustASL = stage.ThrustASL, + ThrustActual = stage.ThrustActual, + ThrustVac = stage.ThrustVac, + TotalExhaustVelocityASL = stage.TotalExhaustVelocityASL, + TotalExhaustVelocityActual = stage.TotalExhaustVelocityActual, + TotalExhaustVelocityVAC = stage.TotalExhaustVelocityVAC, + DeltaVStageInfo = stage + }); + } + } + + public override string ValueDisplay + { + get + { + return "-"; + } + } + + /// + /// Adds a new string to the CelestialBodyForStage list that corresponds to the HomeWorld, i.e. Kerbin + /// + /// + internal void AddNewCelestialBody(MicroCelestialBodies celestialBodies) + { + this.CelestialBodyForStage.Add(celestialBodies.Bodies.Find(b => b.IsHomeWorld).Name); + } + } + + /// + /// Parameters for one stage + /// + internal class DeltaVStageInfo_OAB + { + internal double DeltaVActual; + internal double DeltaVASL; + internal double DeltaVVac; + internal double DryMass; + internal double EndMass; + internal double FuelMass; + internal double IspASL; + internal double IspActual; + internal double IspVac; + internal int SeparationIndex; + internal int Stage; + internal double StageBurnTime; + internal double StageMass; + internal double StartMass; + internal float TWRASL; + internal float TWRActual; + internal float TWRVac; + internal float ThrustASL; + internal float ThrustActual; + internal float ThrustVac; + internal float TotalExhaustVelocityASL; + internal float TotalExhaustVelocityActual; + internal float TotalExhaustVelocityVAC; + internal DeltaVStageInfo DeltaVStageInfo; + + private float GetThrustAtAltitude(double altitude, CelestialBodyComponent cel) => this.DeltaVStageInfo.EnginesActiveInStage?.Select(e => e.Engine.MaxThrustOutputAtm(atmPressure: cel.GetPressure(altitude) / 101.325))?.Sum() ?? 0; + private double GetISPAtAltitude(double altitude, CelestialBodyComponent cel) + { + float sum = 0; + foreach (DeltaVEngineInfo engInfo in this.DeltaVStageInfo.EnginesActiveInStage) + sum += engInfo.Engine.MaxThrustOutputAtm(atmPressure: cel.GetPressure(altitude) / 101.325) / + engInfo.Engine.currentEngineModeData.atmosphereCurve.Evaluate((float)cel.GetPressure(altitude) / 101.325f); + return GetThrustAtAltitude(altitude, cel) / sum; + } + private double GetDeltaVelAlt(double altitude, CelestialBodyComponent cel) => GetISPAtAltitude(altitude, cel) * 9.80665 * Math.Log(this.DeltaVStageInfo.StartMass / this.DeltaVStageInfo.EndMass); + private double GetTWRAtAltitude(double altitude, CelestialBodyComponent cel) => this.DeltaVStageInfo.TWRVac * (GetThrustAtAltitude(altitude, cel) / this.DeltaVStageInfo.ThrustVac); + internal double GetTWRAtSeaLevel(CelestialBodyComponent cel) => this.GetTWRAtAltitude(0, cel); + internal double GetDeltaVelAtSeaLevel(CelestialBodyComponent cel) => GetDeltaVelAlt(0, cel); + } +} diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs new file mode 100644 index 0000000..8590477 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -0,0 +1,196 @@ +using KSP.Game; +using KSP.Sim.impl; + +namespace MicroMod +{ + public class OrbitalEntry : MicroEntry + { } + + public class Apoapsis : OrbitalEntry + { + public Apoapsis() + { + Name = "Apoapsis"; + Description = "Vessel's apoapsis height relative to the sea level. Apoapsis is the highest point of an orbit."; + Category = MicroEntryCategory.Orbital; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ApoapsisArl; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TimeToApoapsis : OrbitalEntry + { + public TimeToApoapsis() + { + Name = "Time to Ap."; + Description = "Shows the time until the vessel reaches apoapsis, the highest point of the orbit."; + Category = MicroEntryCategory.Orbital; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = (MicroUtility.ActiveVessel.Situation == VesselSituations.Landed || MicroUtility.ActiveVessel.Situation == VesselSituations.PreLaunch) ? 0f : MicroUtility.ActiveVessel.Orbit.TimeToAp; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } + + public class Periapsis : OrbitalEntry + { + public Periapsis() + { + Name = "Periapsis"; + Description = "Vessel's periapsis height relative to the sea level. Periapsis is the lowest point of an orbit."; + Category = MicroEntryCategory.Orbital; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.PeriapsisArl; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TimeToPeriapsis : OrbitalEntry + { + public TimeToPeriapsis() + { + Name = "Time to Pe."; + Description = "Shows the time until the vessel reaches periapsis, the lowest point of the orbit."; + Category = MicroEntryCategory.Orbital; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.TimeToPe; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } + + public class Inclination : OrbitalEntry + { + public Inclination() + { + Name = "Inclination"; + Description = "Shows the vessel's orbital inclination relative to the equator."; + Category = MicroEntryCategory.Orbital; + Unit = "°"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.inclination; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Eccentricity : OrbitalEntry + { + public Eccentricity() + { + Name = "Eccentricity"; + Description = "Shows the vessel's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; + Category = MicroEntryCategory.Orbital; + Unit = null; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.eccentricity; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Period : OrbitalEntry + { + public Period() + { + Name = "Period"; + Description = "Shows the amount of time it will take to complete a full orbit."; + Category = MicroEntryCategory.Orbital; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.period; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SecondsToTimeString((double)EntryValue); + } + } + } + + public class SoiTransition : OrbitalEntry + { + public SoiTransition() + { + Name = "SOI Trans."; + Description = "Shows the amount of time it will take to transition to another Sphere of Influence."; + Category = MicroEntryCategory.Orbital; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter - GameManager.Instance.Game.UniverseModel.UniversalTime; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return (double)EntryValue >= 0 ? MicroUtility.SecondsToTimeString((double)EntryValue) : "-"; + } + } + } +} diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs new file mode 100644 index 0000000..d5253c1 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -0,0 +1,215 @@ +using KSP.Sim.impl; +using static KSP.Rendering.Planets.PQSData; + +namespace MicroMod +{ + public class SurfaceEntry : MicroEntry + { } + + public class Body : SurfaceEntry + { + public Body() + { + Name = "Body"; + Description = "Shows the body that vessel is currently at."; + Category = MicroEntryCategory.Surface; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.mainBody.bodyName; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Situation : SurfaceEntry + { + public Situation() + { + Name = "Situation"; + Description = "Shows the vessel's current situation: Landed, Flying, Orbiting, etc."; + Category = MicroEntryCategory.Surface; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Situation; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.SituationToString((VesselSituations)EntryValue); + } + } + } + + public class Latitude : SurfaceEntry + { + public Latitude() + { + Name = "Latitude"; + Description = "Shows the vessel's latitude position around the celestial body. Latitude is the angle from the equator towards the poles."; + Category = MicroEntryCategory.Surface; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Latitude; + Unit = MicroUtility.ActiveVessel.Latitude < 0 ? "S" : "N"; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.DegreesToDMS((double)EntryValue); + } + } + } + + public class Longitude : SurfaceEntry + { + public Longitude() + { + Name = "Longitude"; + Description = "Shows the vessel's longitude position around the celestial body. Longitude is the angle from the body's prime meridian to the current meridian."; + Category = MicroEntryCategory.Surface; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Longitude; + Unit = MicroUtility.ActiveVessel.Longitude < 0 ? "W" : "E"; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.DegreesToDMS((double)EntryValue); + } + } + } + + public class Biome : SurfaceEntry + { + public Biome() + { + Name = "Biome"; + Description = "Shows the biome currently below the vessel."; + Category = MicroEntryCategory.Surface; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.SurfaceBiome; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return MicroUtility.BiomeToString((BiomeSurfaceData)EntryValue); + } + } + } + + public class AltitudeAsl : SurfaceEntry + { + public AltitudeAsl() + { + Name = "Altitude (Sea Lvl)"; + Description = "Shows the vessel's altitude Above Sea Level"; + Category = MicroEntryCategory.Surface; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AltitudeFromSeaLevel; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class AltitudeAgl : SurfaceEntry + { + public AltitudeAgl() + { + Name = "Altitude (Ground)"; + Description = "Shows the vessel's altitude Above Ground Level"; + Category = MicroEntryCategory.Surface; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AltitudeFromTerrain; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class HorizontalVelocity : SurfaceEntry + { + public HorizontalVelocity() + { + Name = "Horizontal Vel."; + Description = "Shows the vessel's horizontal velocity across a celestial body's surface."; + Category = MicroEntryCategory.Surface; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.HorizontalSrfSpeed; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class VerticalVelocity : SurfaceEntry + { + public VerticalVelocity() + { + Name = "Vertical Vel."; + Description = "Shows the vessel's vertical velocity (up/down)."; + Category = MicroEntryCategory.Surface; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.VerticalSrfSpeed; + } + + public override string ValueDisplay => base.ValueDisplay; + } +} diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 5ca92fb..61ec6bb 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -13,7 +13,7 @@ public TargetApoapsis() Description = "Shows the target's apoapsis height relative to the sea level."; Category = MicroEntryCategory.Target; Unit = "m"; - Formatting = null; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -21,16 +21,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.ApoapsisArl; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class TargetPeriapsis : TargetEntry @@ -41,7 +32,7 @@ public TargetPeriapsis() Description = "Shows the target's periapsis height relative to the sea level."; Category = MicroEntryCategory.Target; Unit = "m"; - Formatting = null; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -49,16 +40,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.PeriapsisArl; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class DistanceToTarget : TargetEntry @@ -69,7 +51,7 @@ public DistanceToTarget() Description = "Shows the current distance between the vessel and the target."; Category = MicroEntryCategory.Target; Unit = "m"; - Formatting = null; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -86,7 +68,7 @@ public override string ValueDisplay // return value only if vessel and target are in the same SOI return MicroUtility.ActiveVessel.Orbit.referenceBody == MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody ? - MicroUtility.MetersToDistanceString((double)EntryValue) : "-"; + String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue) : "-"; } } } @@ -177,16 +159,7 @@ public override void RefreshData() EntryValue = MicroUtility.ActiveVessel.TargetObject?.AltitudeFromSeaLevel; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class Target_Name : TargetEntry @@ -557,7 +530,6 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class DistanceAtCloseApproach1 : TargetEntry { public DistanceAtCloseApproach1() @@ -566,7 +538,7 @@ public DistanceAtCloseApproach1() Description = ""; Category = MicroEntryCategory.Accepted; Unit = "m"; - Formatting = null; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -576,17 +548,7 @@ public override void RefreshData() EntryValue = isValid != null && isValid == true ? MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeDistance : null; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - - } + public override string ValueDisplay => base.ValueDisplay; } public class TimeToCloseApproach1 : TargetEntry @@ -648,7 +610,7 @@ public DistanceAtCloseApproach2() Description = ""; Category = MicroEntryCategory.Accepted; Unit = "m"; - Formatting = null; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -658,17 +620,7 @@ public override void RefreshData() EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeDistance : null; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - - } + public override string ValueDisplay => base.ValueDisplay; } public class TimeToCloseApproach2 : TargetEntry diff --git a/MicroEngineerProject/MicroEngineer/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/MicroEntries.cs deleted file mode 100644 index 745805a..0000000 --- a/MicroEngineerProject/MicroEngineer/MicroEntries.cs +++ /dev/null @@ -1,1922 +0,0 @@ -using KSP.Game; -using KSP.Sim.DeltaV; -using KSP.Sim.impl; -using Newtonsoft.Json; -using static KSP.Rendering.Planets.PQSData; - -namespace MicroMod -{ - /// - /// Base class for all Entries (values that can be attached to windows) - /// - [JsonObject(MemberSerialization.OptIn)] - public class MicroEntry - { - [JsonProperty] - public string Name; - [JsonProperty] - public string Description; - [JsonProperty] - public MicroEntryCategory Category; - [JsonProperty] - public string Unit; - [JsonProperty] - public string Formatting; - - public virtual object EntryValue { get; set; } - - /// - /// Controls how the value should be displayed. Should be overriden in a inheritet class for a concrete implementation. - /// - public virtual string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - - public virtual void RefreshData() { } - } - - - #region Flight scene entries - - public class Apoapsis : MicroEntry - { - public Apoapsis() - { - Name = "Apoapsis"; - Description = "Vessel's apoapsis height relative to the sea level. Apoapsis is the highest point of an orbit."; - Category = MicroEntryCategory.Orbital; - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.ApoapsisArl; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } - } - - public class TimeToApoapsis : MicroEntry - { - public TimeToApoapsis() - { - Name = "Time to Ap."; - Description = "Shows the time until the vessel reaches apoapsis, the highest point of the orbit."; - Category = MicroEntryCategory.Orbital; - Unit = "s"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = (MicroUtility.ActiveVessel.Situation == VesselSituations.Landed || MicroUtility.ActiveVessel.Situation == VesselSituations.PreLaunch) ? 0f : MicroUtility.ActiveVessel.Orbit.TimeToAp; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.SecondsToTimeString((double)EntryValue); - } - } - } - - public class Periapsis : MicroEntry - { - public Periapsis() - { - Name = "Periapsis"; - Description = "Vessel's periapsis height relative to the sea level. Periapsis is the lowest point of an orbit."; - Category = MicroEntryCategory.Orbital; - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.PeriapsisArl; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } - } - - public class TimeToPeriapsis : MicroEntry - { - public TimeToPeriapsis() - { - Name = "Time to Pe."; - Description = "Shows the time until the vessel reaches periapsis, the lowest point of the orbit."; - Category = MicroEntryCategory.Orbital; - Unit = "s"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = EntryValue = MicroUtility.ActiveVessel.Orbit.TimeToPe; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.SecondsToTimeString((double)EntryValue); - } - } - } - - public class Inclination : MicroEntry - { - public Inclination() - { - Name = "Inclination"; - Description = "Shows the vessel's orbital inclination relative to the equator."; - Category = MicroEntryCategory.Orbital; - Unit = "°"; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.inclination; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class Eccentricity : MicroEntry - { - public Eccentricity() - { - Name = "Eccentricity"; - Description = "Shows the vessel's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; - Category = MicroEntryCategory.Orbital; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.eccentricity; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class Period : MicroEntry - { - public Period() - { - Name = "Period"; - Description = "Shows the amount of time it will take to complete a full orbit."; - Category = MicroEntryCategory.Orbital; - Unit = "s"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.period; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.SecondsToTimeString((double)EntryValue); - } - } - } - - public class SoiTransition : MicroEntry - { - public SoiTransition() - { - Name = "SOI Trans."; - Description = "Shows the amount of time it will take to transition to another Sphere of Influence."; - Category = MicroEntryCategory.Orbital; - Unit = "s"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter - GameManager.Instance.Game.UniverseModel.UniversalTime; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return (double)EntryValue >= 0 ? MicroUtility.SecondsToTimeString((double)EntryValue) : "-"; - } - } - } - - public class Body : MicroEntry - { - public Body() - { - Name = "Body"; - Description = "Shows the body that vessel is currently at."; - Category = MicroEntryCategory.Surface; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.mainBody.bodyName; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class Situation : MicroEntry - { - public Situation() - { - Name = "Situation"; - Description = "Shows the vessel's current situation: Landed, Flying, Orbiting, etc."; - Category = MicroEntryCategory.Surface; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Situation; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.SituationToString((VesselSituations)EntryValue); - } - } - } - - public class Latitude : MicroEntry - { - public Latitude() - { - Name = "Latitude"; - Description = "Shows the vessel's latitude position around the celestial body. Latitude is the angle from the equator towards the poles."; - Category = MicroEntryCategory.Surface; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Latitude; - Unit = MicroUtility.ActiveVessel.Latitude < 0 ? "S" : "N"; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.DegreesToDMS((double)EntryValue); - } - } - } - - public class Longitude : MicroEntry - { - public Longitude() - { - Name = "Longitude"; - Description = "Shows the vessel's longitude position around the celestial body. Longitude is the angle from the body's prime meridian to the current meridian."; - Category = MicroEntryCategory.Surface; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Longitude; - Unit = MicroUtility.ActiveVessel.Longitude < 0 ? "W" : "E"; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.DegreesToDMS((double)EntryValue); - } - } - } - - public class Biome : MicroEntry - { - public Biome() - { - Name = "Biome"; - Description = "Shows the biome currently below the vessel."; - Category = MicroEntryCategory.Surface; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.SurfaceBiome; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.BiomeToString((BiomeSurfaceData)EntryValue); - } - } - } - - public class AltitudeAsl : MicroEntry - { - public AltitudeAsl() - { - Name = "Altitude (Sea Level)"; - Description = "Shows the vessel's altitude Above Sea Level"; - Category = MicroEntryCategory.Surface; - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AltitudeFromSeaLevel; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } - } - - public class AltitudeAgl : MicroEntry - { - public AltitudeAgl() - { - Name = "Altitude (Ground)"; - Description = "Shows the vessel's altitude Above Ground Level"; - Category = MicroEntryCategory.Surface; - Unit = "m"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AltitudeFromTerrain; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return MicroUtility.MetersToDistanceString((double)EntryValue); - } - } - } - - public class HorizontalVelocity : MicroEntry - { - public HorizontalVelocity() - { - Name = "Horizontal Vel."; - Description = "Shows the vessel's horizontal velocity across a celestial body's surface."; - Category = MicroEntryCategory.Surface; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.HorizontalSrfSpeed; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class VerticalVelocity : MicroEntry - { - public VerticalVelocity() - { - Name = "Vertical Vel."; - Description = "Shows the vessel's vertical velocity (up/down)."; - Category = MicroEntryCategory.Surface; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.VerticalSrfSpeed; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - - - - - public class StageInfo : MicroEntry - { - public StageInfo() - { - Name = "Stage Info"; - Description = "Stage Info object, not implemented yet."; // TODO Stage Info display and description - Category = MicroEntryCategory.Stage; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo; - } - - public override string ValueDisplay - { - get - { - //TODO: stageinfo display - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } - } - - public class Separator : MicroEntry - { - public Separator() - { - Name = "--------------"; - Description = "It's a separator!"; - Category = MicroEntryCategory.Misc; - Unit = "---"; - Formatting = null; - EntryValue = "---------------"; - } - } - #endregion - - #region OAB scene entries - public class TotalBurnTime_OAB : MicroEntry - { - public bool UseDHMSFormatting; // TODO: implement - - public TotalBurnTime_OAB() - { - Name = "Total Burn Time (OAB)"; - Description = "Shows the total length of burn the vessel can mantain."; - Category = MicroEntryCategory.OAB; - Unit = "s"; - Formatting = "{0:N1}"; - UseDHMSFormatting = true; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalBurnTime; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - if (UseDHMSFormatting) - return MicroUtility.SecondsToTimeString((double)EntryValue); - else - return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class TotalDeltaVASL_OAB : MicroEntry - { - public TotalDeltaVASL_OAB() - { - Name = "Total ∆v ASL (OAB)"; - Description = "Shows the vessel's total delta velocity At Sea Level."; - Category = MicroEntryCategory.OAB; - Unit = "m/s"; - Formatting = "{0:N0}"; - } - public override void RefreshData() - { - EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalDeltaVASL; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class TotalDeltaVActual_OAB : MicroEntry - { - public TotalDeltaVActual_OAB() - { - Name = "Total ∆v Actual (OAB)"; - Description = "Shows the vessel's actual total delta velocity (not used in OAB)."; - Category = MicroEntryCategory.OAB; - Unit = "m/s"; - Formatting = "{0:N0}"; - } - public override void RefreshData() - { - EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalDeltaVActual; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class TotalDeltaVVac_OAB : MicroEntry - { - public TotalDeltaVVac_OAB() - { - Name = "Total ∆v Vac (OAB)"; - Description = "Shows the vessel's total delta velocity in Vacuum."; - Category = MicroEntryCategory.OAB; - Unit = "m/s"; - Formatting = "{0:N0}"; - } - public override void RefreshData() - { - EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalDeltaVVac; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - /// - /// Calculates torque from the Center of Thrust and Center of Mass - /// - public class Torque : MicroEntry - { - [JsonProperty] - internal bool IsActive = false; - - public Torque() - { - Name = "Torque"; - Description = "Thrust torque that is generated by not having Thrust Vector and Center of Mass aligned. Turn on the Center of Thrust and Center of Mass VAB indicators to get an accurate value."; - Category = MicroEntryCategory.OAB; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - if (!this.IsActive) - return; - - Vector3d com = GameManager.Instance?.Game?.OAB?.Current?.Stats?.MainAssembly?.CenterOfProperties?.CoM ?? Vector3d.zero; - Vector3d cot = GameManager.Instance?.Game?.OAB?.Current?.Stats?.MainAssembly?.CenterOfProperties?.CoT ?? Vector3d.zero; - - if (com == Vector3d.zero || cot == Vector3d.zero) - return; - - List engines = GameManager.Instance?.Game?.OAB?.Current?.Stats?.MainAssembly?.VesselDeltaV?.EngineInfo; - if (engines == null || engines.Count == 0) - return; - - Vector3d force = new Vector3d(); - - foreach (var engine in engines) - { - force += engine.ThrustVectorVac; - } - - var leverArm = cot - com; - - Vector3d torque = Vector3d.Cross(force, (Vector3d)leverArm); - - this.EntryValue = torque.magnitude; - this.Unit = (double)EntryValue >= 1.0 ? "kNm" : "Nm"; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null || !this.IsActive) - return "-"; - - if ((double)EntryValue >= 1.0) - return $"{String.Format("{0:F2}", EntryValue)}"; - - return Math.Abs((double)EntryValue) > double.Epsilon ? $"{String.Format("{0:F2}", (double)EntryValue * 1000.0)}" : $"{String.Format("{0:F0}", (double)EntryValue)}"; - } - } - } - - /// - /// Holds stage info parameters for each stage. Also keeps information about the celestial body user selected in the window. - /// - public class StageInfo_OAB : MicroEntry - { - public List CelestialBodyForStage = new(); - - public StageInfo_OAB() - { - Name = "Stage Info (OAB)"; - Description = "Holds a list of stage info parameters."; - Category = MicroEntryCategory.OAB; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue ??= new List(); - - ((List)EntryValue).Clear(); - - if (MicroUtility.VesselDeltaVComponentOAB?.StageInfo == null) return; - - foreach (var stage in MicroUtility.VesselDeltaVComponentOAB.StageInfo) - { - ((List)EntryValue).Add(new DeltaVStageInfo_OAB - { - DeltaVActual = stage.DeltaVActual, - DeltaVASL = stage.DeltaVatASL, - DeltaVVac = stage.DeltaVinVac, - DryMass = stage.DryMass, - EndMass = stage.EndMass, - FuelMass = stage.FuelMass, - IspASL = stage.IspASL, - IspActual = stage.IspActual, - IspVac = stage.IspVac, - SeparationIndex = stage.SeparationIndex, - Stage = stage.Stage, - StageBurnTime = stage.StageBurnTime, - StageMass = stage.StageMass, - StartMass = stage.StartMass, - TWRASL = stage.TWRASL, - TWRActual = stage.TWRActual, - TWRVac = stage.TWRVac, - ThrustASL = stage.ThrustASL, - ThrustActual = stage.ThrustActual, - ThrustVac = stage.ThrustVac, - TotalExhaustVelocityASL = stage.TotalExhaustVelocityASL, - TotalExhaustVelocityActual = stage.TotalExhaustVelocityActual, - TotalExhaustVelocityVAC = stage.TotalExhaustVelocityVAC, - DeltaVStageInfo = stage - }); - } - } - - public override string ValueDisplay - { - get - { - return "-"; - } - } - - /// - /// Adds a new string to the CelestialBodyForStage list that corresponds to the HomeWorld, i.e. Kerbin - /// - /// - internal void AddNewCelestialBody(MicroCelestialBodies celestialBodies) - { - this.CelestialBodyForStage.Add(celestialBodies.Bodies.Find(b => b.IsHomeWorld).Name); - } - } - - /// - /// Parameters for one stage - /// - internal class DeltaVStageInfo_OAB - { - internal double DeltaVActual; - internal double DeltaVASL; - internal double DeltaVVac; - internal double DryMass; - internal double EndMass; - internal double FuelMass; - internal double IspASL; - internal double IspActual; - internal double IspVac; - internal int SeparationIndex; - internal int Stage; - internal double StageBurnTime; - internal double StageMass; - internal double StartMass; - internal float TWRASL; - internal float TWRActual; - internal float TWRVac; - internal float ThrustASL; - internal float ThrustActual; - internal float ThrustVac; - internal float TotalExhaustVelocityASL; - internal float TotalExhaustVelocityActual; - internal float TotalExhaustVelocityVAC; - internal DeltaVStageInfo DeltaVStageInfo; - - private float GetThrustAtAltitude(double altitude, CelestialBodyComponent cel) => this.DeltaVStageInfo.EnginesActiveInStage?.Select(e => e.Engine.MaxThrustOutputAtm(atmPressure: cel.GetPressure(altitude) / 101.325))?.Sum() ?? 0; - private double GetISPAtAltitude(double altitude, CelestialBodyComponent cel) - { - float sum = 0; - foreach (DeltaVEngineInfo engInfo in this.DeltaVStageInfo.EnginesActiveInStage) - sum += engInfo.Engine.MaxThrustOutputAtm(atmPressure: cel.GetPressure(altitude) / 101.325) / - engInfo.Engine.currentEngineModeData.atmosphereCurve.Evaluate((float)cel.GetPressure(altitude) / 101.325f); - return GetThrustAtAltitude(altitude, cel) / sum; - } - private double GetDeltaVelAlt(double altitude, CelestialBodyComponent cel) => GetISPAtAltitude(altitude, cel) * 9.80665 * Math.Log(this.DeltaVStageInfo.StartMass / this.DeltaVStageInfo.EndMass); - private double GetTWRAtAltitude(double altitude, CelestialBodyComponent cel) => this.DeltaVStageInfo.TWRVac * (GetThrustAtAltitude(altitude, cel) / this.DeltaVStageInfo.ThrustVac); - internal double GetTWRAtSeaLevel(CelestialBodyComponent cel) => this.GetTWRAtAltitude(0, cel); - internal double GetDeltaVelAtSeaLevel(CelestialBodyComponent cel) => GetDeltaVelAlt(0, cel); - } - #endregion - - - #region New entries - - public class AltitudeFromScenery : MicroEntry - { - public AltitudeFromScenery() - { - Name = "Altitude (Scenery)"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AltitudeFromScenery; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class AtmosphericTemperature : MicroEntry - { - public AtmosphericTemperature() - { - Name = "Static ambient temp."; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "K"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AtmosphericTemperature; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ExternalTemperature : MicroEntry - { - public ExternalTemperature() - { - Name = "External temperature"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "K"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.ExternalTemperature; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class DynamicPressure_kPa : MicroEntry - { - public DynamicPressure_kPa() - { - Name = "Dynamic Pressure"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "kPa"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.DynamicPressure_kPa; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ExposedArea : MicroEntry - { - public ExposedArea() - { - Name = "ExposedArea"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.ExposedArea; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - - - public class FuelPercentage : MicroEntry - { - public FuelPercentage() - { - Name = "FuelPercentage"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "%"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.FuelPercentage; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Heading : MicroEntry - { - public Heading() - { - Name = "Heading"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Heading; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Pitch_HorizonRelative : MicroEntry - { - public Pitch_HorizonRelative() - { - Name = "Pitch"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Pitch_HorizonRelative; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Roll_HorizonRelative : MicroEntry - { - public Roll_HorizonRelative() - { - Name = "Roll"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Roll_HorizonRelative; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Yaw_HorizonRelative : MicroEntry - { - public Yaw_HorizonRelative() - { - Name = "Yaw"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Yaw_HorizonRelative; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class DragCoefficient : MicroEntry - { - public DragCoefficient() - { - Name = "DragCoefficient"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N5}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.DragCoefficient; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class OrbitalSpeed : MicroEntry - { - public OrbitalSpeed() - { - Name = "Orbital Velocity"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.OrbitalSpeed; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class SoundSpeed : MicroEntry - { - public SoundSpeed() - { - Name = "Speed of sound"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m/s"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.SoundSpeed; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class StageFuelPercentage : MicroEntry - { - public StageFuelPercentage() - { - Name = "StageFuelPercentage"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.StageFuelPercentage; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class StaticPressure_kPa : MicroEntry - { - public StaticPressure_kPa() - { - Name = "Static Pressure"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "kPa"; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.StaticPressure_kPa; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class TimeSinceLaunch : MicroEntry - { - public TimeSinceLaunch() - { - Name = "TimeSinceLaunch"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.TimeSinceLaunch; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class TotalCommandCrewCapacity : MicroEntry - { - public TotalCommandCrewCapacity() - { - Name = "TotalCommandCrewCapacity"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.TotalCommandCrewCapacity; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Zenith : MicroEntry - { - public Zenith() - { - Name = "Zenith"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Zenith; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class altimeterMode : MicroEntry - { - public altimeterMode() - { - Name = "altimeterMode"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.altimeterMode; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class geeForce : MicroEntry - { - public geeForce() - { - Name = "G-Force"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "g"; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.geeForce; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class gravityForPos : MicroEntry - { - public gravityForPos() - { - Name = "gravityForPos"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.gravityForPos.magnitude; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - - public class launchTime : MicroEntry - { - public launchTime() - { - Name = "launchTime"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.launchTime; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class speedMode : MicroEntry - { - public speedMode() - { - Name = "speedMode"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.speedMode; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class AutopilotStatus_IsEnabled : MicroEntry - { - public AutopilotStatus_IsEnabled() - { - Name = "AutopilotStatus_IsEnabled"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.IsEnabled; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class AutopilotStatus_Mode : MicroEntry - { - public AutopilotStatus_Mode() - { - Name = "AutopilotStatus_Mode"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.Mode; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - - - - public class EccentricAnomaly : MicroEntry - { - public EccentricAnomaly() - { - Name = "Eccentric Anomaly"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.EccentricAnomaly; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); - } - } - } - - public class EndUT : MicroEntry - { - public EndUT() - { - Name = "EndUT"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.EndUT; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class MeanAnomaly : MicroEntry - { - public MeanAnomaly() - { - Name = "MeanAnomaly"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.MeanAnomaly; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); - } - } - } - - public class ObT : MicroEntry - { - public ObT() - { - Name = "Orbit Time"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.ObT; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class ArgumentOfPeriapsis : MicroEntry - { - public ArgumentOfPeriapsis() - { - Name = "ArgumentOfPeriapsis"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.ArgumentOfPeriapsis; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class LongitudeOfAscendingNode : MicroEntry - { - public LongitudeOfAscendingNode() - { - Name = "LAN"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.LongitudeOfAscendingNode; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class SemiMajorAxis : MicroEntry - { - public SemiMajorAxis() - { - Name = "SemiMajorAxis"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.SemiMajorAxis; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class SemiMinorAxis : MicroEntry - { - public SemiMinorAxis() - { - Name = "SemiMinorAxis"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.SemiMinorAxis; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class OrbitalEnergy : MicroEntry - { - public OrbitalEnergy() - { - Name = "OrbitalEnergy"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalEnergy; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class ReferenceBodyConstants_Radius : MicroEntry - { - public ReferenceBodyConstants_Radius() - { - Name = "Ref.Bod.Con.Radius"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.Radius; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class ReferenceBodyConstants_StandardGravitationParameter : MicroEntry - { - public ReferenceBodyConstants_StandardGravitationParameter() - { - Name = "Ref.Bod.Con.GPar"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.StandardGravitationParameter; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class SemiLatusRectum : MicroEntry - { - public SemiLatusRectum() - { - Name = "SemiLatusRectum"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.SemiLatusRectum; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); - } - } - } - - public class StartUT : MicroEntry - { - public StartUT() - { - Name = "StartUT"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.StartUT; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class TrueAnomaly : MicroEntry - { - public TrueAnomaly() - { - Name = "T.Anomaly"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.TrueAnomaly; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.RadiansToDegrees((double)EntryValue)); - } - } - } - - public class UniversalTimeAtClosestApproach : MicroEntry - { - public UniversalTimeAtClosestApproach() - { - Name = "UT Closest Appr."; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtClosestApproach; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class UniversalTimeAtSoiEncounter : MicroEntry - { - public UniversalTimeAtSoiEncounter() - { - Name = "UT SOI Enc"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class orbitPercent : MicroEntry - { - public orbitPercent() - { - Name = "orbitPercent"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "%"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.orbitPercent * 100; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class radius : MicroEntry - { - public radius() - { - Name = "Orbit Radius"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.radius; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - - - - - - - - - - #endregion - -} diff --git a/MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs b/MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs index 0b3c11f..4a4c9a6 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs @@ -58,11 +58,6 @@ public static string DegreesToDMS(double degreeD) return result; } - public static string MetersToDistanceString(double heightInMeters) - { - return $"{heightInMeters:N0}"; - } - public static string SecondsToTimeString(double seconds, bool addSpacing = true, bool returnLastUnit = false) { if (seconds == double.PositiveInfinity) From 145ef8db3a0939f210c85080e11c52c4daa165e9 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Thu, 20 Apr 2023 01:08:14 +0200 Subject: [PATCH 19/38] Add Body entries - Add BodyEntry - Further entry refactoring --- .../MicroEngineer/Entries/BodyEntries.cs | 63 ++ .../MicroEngineer/Entries/FlightEntries.cs | 175 +++- .../MicroEngineer/Entries/ManeuverEntries.cs | 2 +- .../MicroEngineer/Entries/MicroEntries.cs | 931 ------------------ .../MicroEngineer/Entries/MiscEntries.cs | 286 ++++++ .../MicroEngineer/Entries/OrbitalEntries.cs | 283 ++++++ .../MicroEngineer/Entries/SurfaceEntries.cs | 116 ++- .../MicroEngineer/Entries/TargetEntries.cs | 4 +- .../MicroEngineer/Entries/VesselEntries.cs | 59 +- .../MicroEngineer/MicroEngineerMod.cs | 21 +- .../MicroEngineer/Windows/BaseWindow.cs | 1 + 11 files changed, 976 insertions(+), 965 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs create mode 100644 MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs diff --git a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs new file mode 100644 index 0000000..1bc2f20 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs @@ -0,0 +1,63 @@ + +namespace MicroMod +{ + public class BodyEntry : MicroEntry + { } + + public class Body : BodyEntry + { + public Body() + { + Name = "Body"; + Description = "Shows the body that vessel is currently at."; + Category = MicroEntryCategory.Body; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.mainBody.bodyName; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ReferenceBodyConstants_Radius : BodyEntry + { + public ReferenceBodyConstants_Radius() + { + Name = "Body Radius"; + Description = ""; + Category = MicroEntryCategory.Body; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.Radius; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ReferenceBodyConstants_StandardGravitationParameter : BodyEntry + { + public ReferenceBodyConstants_StandardGravitationParameter() + { + Name = "Std. Grav. Param."; + Description = ""; + Category = MicroEntryCategory.Body; + Unit = "μ"; + Formatting = "{0:e4}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.StandardGravitationParameter; + } + + public override string ValueDisplay => base.ValueDisplay; + } +} diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index bb5b620..f7f1315 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -127,7 +127,7 @@ public LiftDivDrag() Description = "Shows the ratio of total lift and drag forces."; Category = MicroEntryCategory.Flight; Unit = null; - Formatting = "{0:N3}"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -185,4 +185,177 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } + + public class DragCoefficient : FlightEntry + { + public DragCoefficient() + { + Name = "DragCoefficient"; + Description = ""; + Category = MicroEntryCategory.Flight; + Unit = null; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.DragCoefficient; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ExposedArea : FlightEntry + { + public ExposedArea() + { + Name = "ExposedArea"; + Description = ""; + Category = MicroEntryCategory.Flight; + Unit = null; // TODO + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.ExposedArea; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Heading : FlightEntry + { + public Heading() + { + Name = "Heading"; + Description = ""; + Category = MicroEntryCategory.Flight; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Heading; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Pitch_HorizonRelative : FlightEntry + { + public Pitch_HorizonRelative() + { + Name = "Pitch"; + Description = ""; + Category = MicroEntryCategory.Flight; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Pitch_HorizonRelative; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Roll_HorizonRelative : FlightEntry + { + public Roll_HorizonRelative() + { + Name = "Roll"; + Description = ""; + Category = MicroEntryCategory.Flight; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Roll_HorizonRelative; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Yaw_HorizonRelative : FlightEntry + { + public Yaw_HorizonRelative() + { + Name = "Yaw"; + Description = ""; + Category = MicroEntryCategory.Flight; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Yaw_HorizonRelative; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Zenith : FlightEntry + { + public Zenith() + { + Name = "Zenith"; + Description = ""; + Category = MicroEntryCategory.Flight; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Zenith; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class SoundSpeed : FlightEntry + { + public SoundSpeed() + { + Name = "Speed of sound"; + Description = ""; + Category = MicroEntryCategory.Flight; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.SoundSpeed; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class GeeForce : FlightEntry + { + public GeeForce() + { + Name = "G-Force"; + Description = ""; + Category = MicroEntryCategory.Flight; + Unit = "g"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.geeForce; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + } diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 6b92daf..048ba97 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -268,7 +268,7 @@ public Maneuver_MeanAnomaly() Description = ""; Category = MicroEntryCategory.Accepted2; Unit = "°"; - Formatting = "{0:N3}"; + Formatting = "{0:N2}"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs index bd005e8..bd3bdc2 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs @@ -38,9 +38,7 @@ public virtual string ValueDisplay public virtual void RefreshData() { } } - - #region Flight scene entries public class StageInfo : MicroEntry { @@ -60,933 +58,4 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - - public class Separator : MicroEntry - { - public Separator() - { - Name = "--------------"; - Description = "It's a separator!"; - Category = MicroEntryCategory.Misc; - Unit = "---"; - Formatting = null; - EntryValue = "---------------"; - } - } - #endregion - - #region New entries - - public class AltitudeFromScenery : MicroEntry - { - public AltitudeFromScenery() - { - Name = "Altitude (Scenery)"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AltitudeFromScenery; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class AtmosphericTemperature : MicroEntry - { - public AtmosphericTemperature() - { - Name = "Static ambient temp."; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "K"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AtmosphericTemperature; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ExternalTemperature : MicroEntry - { - public ExternalTemperature() - { - Name = "External temperature"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "K"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.ExternalTemperature; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class DynamicPressure_kPa : MicroEntry - { - public DynamicPressure_kPa() - { - Name = "Dynamic Pressure"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "kPa"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.DynamicPressure_kPa; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ExposedArea : MicroEntry - { - public ExposedArea() - { - Name = "ExposedArea"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.ExposedArea; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - - - public class FuelPercentage : MicroEntry - { - public FuelPercentage() - { - Name = "FuelPercentage"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "%"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.FuelPercentage; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Heading : MicroEntry - { - public Heading() - { - Name = "Heading"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Heading; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Pitch_HorizonRelative : MicroEntry - { - public Pitch_HorizonRelative() - { - Name = "Pitch"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Pitch_HorizonRelative; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Roll_HorizonRelative : MicroEntry - { - public Roll_HorizonRelative() - { - Name = "Roll"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Roll_HorizonRelative; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Yaw_HorizonRelative : MicroEntry - { - public Yaw_HorizonRelative() - { - Name = "Yaw"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Yaw_HorizonRelative; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class DragCoefficient : MicroEntry - { - public DragCoefficient() - { - Name = "DragCoefficient"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N5}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.DragCoefficient; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class OrbitalSpeed : MicroEntry - { - public OrbitalSpeed() - { - Name = "Orbital Velocity"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m/s"; - Formatting = "{0:N1}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.OrbitalSpeed; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class SoundSpeed : MicroEntry - { - public SoundSpeed() - { - Name = "Speed of sound"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m/s"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.SoundSpeed; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class StageFuelPercentage : MicroEntry - { - public StageFuelPercentage() - { - Name = "StageFuelPercentage"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.StageFuelPercentage; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class StaticPressure_kPa : MicroEntry - { - public StaticPressure_kPa() - { - Name = "Static Pressure"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "kPa"; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.StaticPressure_kPa; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class TimeSinceLaunch : MicroEntry - { - public TimeSinceLaunch() - { - Name = "TimeSinceLaunch"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.TimeSinceLaunch; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class TotalCommandCrewCapacity : MicroEntry - { - public TotalCommandCrewCapacity() - { - Name = "TotalCommandCrewCapacity"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.TotalCommandCrewCapacity; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Zenith : MicroEntry - { - public Zenith() - { - Name = "Zenith"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Zenith; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class altimeterMode : MicroEntry - { - public altimeterMode() - { - Name = "altimeterMode"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.altimeterMode; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class geeForce : MicroEntry - { - public geeForce() - { - Name = "G-Force"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "g"; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.geeForce; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class gravityForPos : MicroEntry - { - public gravityForPos() - { - Name = "gravityForPos"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.gravityForPos.magnitude; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - - public class launchTime : MicroEntry - { - public launchTime() - { - Name = "launchTime"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.launchTime; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class speedMode : MicroEntry - { - public speedMode() - { - Name = "speedMode"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.speedMode; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class AutopilotStatus_IsEnabled : MicroEntry - { - public AutopilotStatus_IsEnabled() - { - Name = "AutopilotStatus_IsEnabled"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.IsEnabled; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class AutopilotStatus_Mode : MicroEntry - { - public AutopilotStatus_Mode() - { - Name = "AutopilotStatus_Mode"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.Mode; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class EccentricAnomaly : MicroEntry - { - public EccentricAnomaly() - { - Name = "Eccentric Anomaly"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.EccentricAnomaly; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); - } - } - } - - public class EndUT : MicroEntry - { - public EndUT() - { - Name = "EndUT"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.EndUT; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class MeanAnomaly : MicroEntry - { - public MeanAnomaly() - { - Name = "MeanAnomaly"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.MeanAnomaly; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); - } - } - } - - public class ObT : MicroEntry - { - public ObT() - { - Name = "Orbit Time"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.ObT; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class ArgumentOfPeriapsis : MicroEntry - { - public ArgumentOfPeriapsis() - { - Name = "ArgumentOfPeriapsis"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.ArgumentOfPeriapsis; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class LongitudeOfAscendingNode : MicroEntry - { - public LongitudeOfAscendingNode() - { - Name = "LAN"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.LongitudeOfAscendingNode; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class SemiMajorAxis : MicroEntry - { - public SemiMajorAxis() - { - Name = "SemiMajorAxis"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.SemiMajorAxis; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class SemiMinorAxis : MicroEntry - { - public SemiMinorAxis() - { - Name = "SemiMinorAxis"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.SemiMinorAxis; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class OrbitalEnergy : MicroEntry - { - public OrbitalEnergy() - { - Name = "OrbitalEnergy"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalEnergy; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ReferenceBodyConstants_Radius : MicroEntry - { - public ReferenceBodyConstants_Radius() - { - Name = "Ref.Bod.Con.Radius"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.Radius; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ReferenceBodyConstants_StandardGravitationParameter : MicroEntry - { - public ReferenceBodyConstants_StandardGravitationParameter() - { - Name = "Ref.Bod.Con.GPar"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.StandardGravitationParameter; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class SemiLatusRectum : MicroEntry - { - public SemiLatusRectum() - { - Name = "SemiLatusRectum"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.SemiLatusRectum; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class StartUT : MicroEntry - { - public StartUT() - { - Name = "StartUT"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.StartUT; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class TrueAnomaly : MicroEntry - { - public TrueAnomaly() - { - Name = "T.Anomaly"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.TrueAnomaly; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.RadiansToDegrees((double)EntryValue)); - } - } - } - - public class UniversalTimeAtClosestApproach : MicroEntry - { - public UniversalTimeAtClosestApproach() - { - Name = "UT Closest Appr."; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtClosestApproach; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class UniversalTimeAtSoiEncounter : MicroEntry - { - public UniversalTimeAtSoiEncounter() - { - Name = "UT SOI Enc"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - - public class orbitPercent : MicroEntry - { - public orbitPercent() - { - Name = "orbitPercent"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "%"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.orbitPercent * 100; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class radius : MicroEntry - { - public radius() - { - Name = "Orbit Radius"; - Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = "m"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.Orbit.radius; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - #endregion - } diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs new file mode 100644 index 0000000..035f2b1 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -0,0 +1,286 @@ +using KSP.Sim; +using System; +using System.Collections.Generic; +using System.Text; + +namespace MicroMod +{ + public class MiscEntry : MicroEntry + { } + + public class Separator : MiscEntry + { + public Separator() + { + Name = "--------------"; + Description = "It's a separator!"; + Category = MicroEntryCategory.Misc; + Unit = "---"; + Formatting = null; + EntryValue = "---------------"; + } + } + + public class AutopilotStatus_IsEnabled : MiscEntry + { + public AutopilotStatus_IsEnabled() + { + Name = "Autopilot"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.IsEnabled; + } + + public override string ValueDisplay => EntryValue != null ? (bool)EntryValue ? "Enabled" : "Disabled" : "-"; + } + + public class AutopilotStatus_Mode : MiscEntry + { + public AutopilotStatus_Mode() + { + Name = "Autopilot Mode"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.Mode; + } + + public override string ValueDisplay => EntryValue != null ? (AutopilotMode)EntryValue == AutopilotMode.StabilityAssist ? "Stability" : EntryValue.ToString() : null; + } + + public class TimeSinceLaunch : MiscEntry + { + public TimeSinceLaunch() + { + Name = "Time since Launch"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TimeSinceLaunch; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class GravityForPos : MiscEntry + { + public GravityForPos() + { + Name = "Local Gravity"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = "ms2"; + Formatting = "{0:N3}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.gravityForPos.magnitude; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class LaunchTime : MiscEntry + { + public LaunchTime() + { + Name = "Launch Time"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.launchTime; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class AltimeterMode : MiscEntry + { + public AltimeterMode() + { + Name = "Altimeter Mode"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.altimeterMode; + } + + public override string ValueDisplay => EntryValue != null ? (AltimeterDisplayMode)EntryValue == AltimeterDisplayMode.SeaLevel ? "Sea Level" : (AltimeterDisplayMode)EntryValue == AltimeterDisplayMode.GroundLevel ? "Ground Level" : "-" : "-"; + } + + public class SpeedMode : MiscEntry + { + public SpeedMode() + { + Name = "Speed Mode"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.speedMode; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StartUT : MiscEntry + { + public StartUT() + { + Name = "Start UT"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.StartUT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class EndUT : MiscEntry + { + public EndUT() + { + Name = "Universal Time"; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.EndUT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class UniversalTimeAtClosestApproach : MiscEntry + { + public UniversalTimeAtClosestApproach() + { + Name = "UT Closest Appr."; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtClosestApproach; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class UniversalTimeAtSoiEncounter : MiscEntry + { + public UniversalTimeAtSoiEncounter() + { + Name = "UT SOI Enc."; + Description = ""; + Category = MicroEntryCategory.Misc; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } +} diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 8590477..71930eb 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -193,4 +193,287 @@ public override string ValueDisplay } } } + + public class OrbitalSpeed : OrbitalEntry + { + public OrbitalSpeed() + { + Name = "Orbital Velocity"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.OrbitalSpeed; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class EccentricAnomaly : OrbitalEntry + { + public EccentricAnomaly() + { + Name = "Eccentric Anomaly"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.EccentricAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } + } + + public class MeanAnomaly : OrbitalEntry + { + public MeanAnomaly() + { + Name = "Mean Anomaly"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.MeanAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } + } + + public class TrueAnomaly : OrbitalEntry + { + public TrueAnomaly() + { + Name = "True Anomaly"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "°"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.TrueAnomaly; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.RadiansToDegrees((double)EntryValue)); + } + } + } + + public class ObT : OrbitalEntry + { + public ObT() + { + Name = "Orbit Time"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.ObT; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + + public class ArgumentOfPeriapsis : OrbitalEntry + { + public ArgumentOfPeriapsis() + { + Name = "Argument of Pe. ω"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.ArgumentOfPeriapsis; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class LongitudeOfAscendingNode : OrbitalEntry + { + public LongitudeOfAscendingNode() + { + Name = "LAN Ω"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.LongitudeOfAscendingNode; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class SemiMajorAxis : OrbitalEntry + { + public SemiMajorAxis() + { + Name = "Semi Major Axis a"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.SemiMajorAxis; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class SemiMinorAxis : OrbitalEntry + { + public SemiMinorAxis() + { + Name = "Semi Minor Axis b"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.SemiMinorAxis; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class OrbitalEnergy : OrbitalEntry + { + public OrbitalEnergy() + { + Name = "Orbital Energy"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "kJ"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalEnergy / 1000.0; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class SemiLatusRectum : OrbitalEntry + { + public SemiLatusRectum() + { + Name = "Semi Latus Rectum ℓ"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.SemiLatusRectum; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class OrbitPercent : OrbitalEntry + { + public OrbitPercent() + { + Name = "Orbit Percent"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "%"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.orbitPercent * 100; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class OrbitRadius : OrbitalEntry + { + public OrbitRadius() + { + Name = "Orbit Radius"; + Description = ""; + Category = MicroEntryCategory.Orbital; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.Orbit.radius; + } + + public override string ValueDisplay => base.ValueDisplay; + } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index d5253c1..4142af1 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -5,26 +5,7 @@ namespace MicroMod { public class SurfaceEntry : MicroEntry { } - - public class Body : SurfaceEntry - { - public Body() - { - Name = "Body"; - Description = "Shows the body that vessel is currently at."; - Category = MicroEntryCategory.Surface; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = MicroUtility.ActiveVessel.mainBody.bodyName; - } - - public override string ValueDisplay => base.ValueDisplay; - } - + public class Situation : SurfaceEntry { public Situation() @@ -175,6 +156,25 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } + public class AltitudeFromScenery : SurfaceEntry + { + public AltitudeFromScenery() + { + Name = "Altitude (Scenery)"; + Description = ""; + Category = MicroEntryCategory.Surface; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AltitudeFromScenery; + } + + public override string ValueDisplay => base.ValueDisplay; + } + public class HorizontalVelocity : SurfaceEntry { public HorizontalVelocity() @@ -212,4 +212,80 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } + + public class AtmosphericTemperature : SurfaceEntry + { + public AtmosphericTemperature() + { + Name = "Static ambient temp."; + Description = ""; + Category = MicroEntryCategory.Surface; + Unit = "K"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.AtmosphericTemperature; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ExternalTemperature : SurfaceEntry + { + public ExternalTemperature() + { + Name = "External temperature"; + Description = ""; + Category = MicroEntryCategory.Surface; + Unit = "K"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.ExternalTemperature; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class DynamicPressure_kPa : SurfaceEntry + { + public DynamicPressure_kPa() + { + Name = "Dynamic Pressure"; + Description = ""; + Category = MicroEntryCategory.Surface; + Unit = "kPa"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.DynamicPressure_kPa; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StaticPressure_kPa : SurfaceEntry + { + public StaticPressure_kPa() + { + Name = "Static Pressure"; + Description = ""; + Category = MicroEntryCategory.Surface; + Unit = "kPa"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.StaticPressure_kPa; + } + + public override string ValueDisplay => base.ValueDisplay; + } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 61ec6bb..c44744d 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -216,8 +216,8 @@ public Target_MeanAnomaly() Name = "[T] Mean Anomaly"; Description = ""; Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 1252070..a9943f1 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -319,7 +319,7 @@ public Throttle() { Name = "Throttle"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Vessel; Unit = "%"; Formatting = "{0:N0}"; } @@ -331,4 +331,61 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } + + public class FuelPercentage : VesselEntry + { + public FuelPercentage() + { + Name = "Vessel Fuel"; + Description = ""; + Category = MicroEntryCategory.Vessel; + Unit = "%"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.FuelPercentage; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class StageFuelPercentage : VesselEntry + { + public StageFuelPercentage() + { + Name = "Stage Fuel"; + Description = ""; + Category = MicroEntryCategory.Vessel; + Unit = "%"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.StageFuelPercentage; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TotalCommandCrewCapacity : VesselEntry + { + public TotalCommandCrewCapacity() + { + Name = "Command Crew Capacity"; + Description = ""; + Category = MicroEntryCategory.Vessel; + Unit = null; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = MicroUtility.ActiveVessel.TotalCommandCrewCapacity; + } + + public override string ValueDisplay => base.ValueDisplay; + } } diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index ccd14fc..84425ee 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1097,8 +1097,7 @@ private void InitializeEntries() MicroEntries.Add(new Period()); MicroEntries.Add(new SoiTransition()); #endregion - #region Surface entries - MicroEntries.Add(new Body()); + #region Surface entries MicroEntries.Add(new Situation()); MicroEntries.Add(new Latitude()); MicroEntries.Add(new Longitude()); @@ -1145,6 +1144,10 @@ private void InitializeEntries() MicroEntries.Add(new StageInfo_OAB()); #endregion + #region Body entries + MicroEntries.Add(new Body()); + #endregion + #region New entries MicroEntries.Add(new AltitudeFromScenery()); MicroEntries.Add(new AtmosphericTemperature()); @@ -1164,11 +1167,11 @@ private void InitializeEntries() MicroEntries.Add(new TimeSinceLaunch()); MicroEntries.Add(new TotalCommandCrewCapacity()); MicroEntries.Add(new Zenith()); - MicroEntries.Add(new altimeterMode()); - MicroEntries.Add(new geeForce()); - MicroEntries.Add(new gravityForPos()); - MicroEntries.Add(new launchTime()); - MicroEntries.Add(new speedMode()); + MicroEntries.Add(new AltimeterMode()); + MicroEntries.Add(new GeeForce()); + MicroEntries.Add(new GravityForPos()); + MicroEntries.Add(new LaunchTime()); + MicroEntries.Add(new SpeedMode()); MicroEntries.Add(new AutopilotStatus_IsEnabled()); MicroEntries.Add(new AutopilotStatus_Mode()); MicroEntries.Add(new EccentricAnomaly()); @@ -1187,8 +1190,8 @@ private void InitializeEntries() MicroEntries.Add(new TrueAnomaly()); MicroEntries.Add(new UniversalTimeAtClosestApproach()); MicroEntries.Add(new UniversalTimeAtSoiEncounter()); - MicroEntries.Add(new orbitPercent()); - MicroEntries.Add(new radius()); + MicroEntries.Add(new OrbitPercent()); + MicroEntries.Add(new OrbitRadius()); MicroEntries.Add(new ManeuverPrograde()); MicroEntries.Add(new ManeuverNormal()); MicroEntries.Add(new ManeuverRadial()); diff --git a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs index a0f999b..bc38784 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs @@ -140,6 +140,7 @@ public enum MicroEntryCategory Target, Maneuver, Stage, + Body, Misc, OAB, New, From 91b39400f7b9b760643e22f5bd4c42c3ad762331 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Thu, 20 Apr 2023 16:09:13 +0200 Subject: [PATCH 20/38] Further refinement --- .../MicroEngineer/Entries/FlightEntries.cs | 4 +- .../MicroEngineer/Entries/ManeuverEntries.cs | 76 +++---- .../MicroEngineer/Entries/MiscEntries.cs | 6 +- .../MicroEngineer/Entries/OrbitalEntries.cs | 14 +- .../MicroEngineer/Entries/TargetEntries.cs | 138 +++++------ .../MicroEngineer/Entries/VesselEntries.cs | 215 +++++++++--------- .../MicroEngineer/MicroEngineerMod.cs | 8 +- 7 files changed, 233 insertions(+), 228 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index f7f1315..9140688 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -154,7 +154,7 @@ public AngleOfAttack() { Name = "Angle of Attack"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Flight; Unit = "°"; Formatting = "{0:N3}"; } @@ -173,7 +173,7 @@ public SideSlip() { Name = "Sideslip"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Flight; Unit = "°"; Formatting = "{0:N3}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 048ba97..dc8d61c 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -204,7 +204,7 @@ public Maneuver_EccentricAnomaly() { Name = "Eccentric Anomaly"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "°"; Formatting = "{0:N2}"; } @@ -233,9 +233,9 @@ public class Maneuver_EndUT : ManeuverEntry { public Maneuver_EndUT() { - Name = "EndUT"; + Name = "UT"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = "{0:N3}"; } @@ -266,7 +266,7 @@ public Maneuver_MeanAnomaly() { Name = "Mean Anomaly"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "°"; Formatting = "{0:N2}"; } @@ -296,10 +296,10 @@ public class Maneuver_ObT : ManeuverEntry public Maneuver_ObT() { Name = "Orbit Time"; - Description = ""; - Category = MicroEntryCategory.Accepted2; + Description = "Shows orbit time in seconds from the Periapsis"; + Category = MicroEntryCategory.Maneuver; Unit = "s"; - Formatting = null; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -326,11 +326,11 @@ public class Maneuver_ArgumentOfPeriapsis : ManeuverEntry { public Maneuver_ArgumentOfPeriapsis() { - Name = "Argument of Periapsis"; + Name = "Argument of Pe."; Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = null; - Formatting = "{0:N3}"; + Category = MicroEntryCategory.Maneuver; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -350,7 +350,7 @@ public Maneuver_Eccentricity() { Name = "Eccentricity"; Description = "Shows the vessel's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = null; Formatting = "{0:N3}"; } @@ -372,7 +372,7 @@ public Maneuver_Inclination() { Name = "Inclination"; Description = "Shows the vessel's orbital inclination relative to the equator."; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "°"; Formatting = "{0:N3}"; } @@ -392,11 +392,11 @@ public class Maneuver_LongitudeOfAscendingNode : ManeuverEntry { public Maneuver_LongitudeOfAscendingNode() { - Name = "LAN"; + Name = "LAN Ω"; Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = null; - Formatting = "{0:N3}"; + Category = MicroEntryCategory.Maneuver; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -416,7 +416,7 @@ public Maneuver_SemiMajorAxis() { Name = "Semi Major Axis"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "m"; Formatting = "{0:N0}"; } @@ -438,7 +438,7 @@ public Maneuver_SemiMinorAxis() { Name = "Semi Minor Axis"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "m"; Formatting = "{0:N0}"; } @@ -460,9 +460,9 @@ public Maneuver_OrbitalEnergy() { Name = "Orbital Energy"; Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = null; - Formatting = "{0:N3}"; + Category = MicroEntryCategory.Maneuver; + Unit = "kJ"; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -480,9 +480,9 @@ public class Maneuver_SemiLatusRectum : ManeuverEntry { public Maneuver_SemiLatusRectum() { - Name = "Semi Latus Rectum ℓ"; + Name = "Semi Latus Rectum"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "m"; Formatting = "{0:N0}"; } @@ -504,7 +504,7 @@ public Maneuver_TimeToAp() { Name = "Time to Ap."; Description = "Shows the time until the vessel reaches apoapsis, the highest point of the orbit."; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = null; } @@ -535,7 +535,7 @@ public Maneuver_TimeToPe() { Name = "Time to Pe."; Description = "Shows the time until the vessel reaches periapsis, the lowest point of the orbit."; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = null; } @@ -566,9 +566,9 @@ public Maneuver_TrueAnomaly() { Name = "True Anomaly"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "°"; - Formatting = "{0:N2}"; + Formatting = "{0:N1}"; } public override void RefreshData() @@ -595,9 +595,9 @@ public class Maneuver_UniversalTimeAtClosestApproach : ManeuverEntry { public Maneuver_UniversalTimeAtClosestApproach() { - Name = "UT Closest Appr."; + Name = "UT Close.App."; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = null; Formatting = null; } @@ -626,9 +626,9 @@ public class Maneuver_UniversalTimeAtSoiEncounter : ManeuverEntry { public Maneuver_UniversalTimeAtSoiEncounter() { - Name = "UT SOI Enc"; + Name = "UT SOI Enc."; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = null; Formatting = null; } @@ -653,13 +653,13 @@ public override string ValueDisplay } } - public class Maneuver_orbitPercent : ManeuverEntry + public class Maneuver_OrbitPercent : ManeuverEntry { - public Maneuver_orbitPercent() + public Maneuver_OrbitPercent() { Name = "Orbit percent"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "%"; Formatting = "{0:N2}"; } @@ -675,13 +675,13 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class Maneuver_period : ManeuverEntry + public class Maneuver_Period : ManeuverEntry { - public Maneuver_period() + public Maneuver_Period() { Name = "Period"; Description = "Shows the amount of time it will take to complete a full orbit."; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = null; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs index 035f2b1..fa42ab1 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -63,7 +63,7 @@ public class TimeSinceLaunch : MiscEntry { public TimeSinceLaunch() { - Name = "Time since Launch"; + Name = "Time since launch"; Description = ""; Category = MicroEntryCategory.Misc; Unit = "s"; @@ -204,7 +204,7 @@ public class EndUT : MiscEntry { public EndUT() { - Name = "Universal Time"; + Name = "UT"; Description = ""; Category = MicroEntryCategory.Misc; Unit = "s"; @@ -232,7 +232,7 @@ public class UniversalTimeAtClosestApproach : MiscEntry { public UniversalTimeAtClosestApproach() { - Name = "UT Closest Appr."; + Name = "UT Close.App."; Description = ""; Category = MicroEntryCategory.Misc; Unit = "s"; diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 71930eb..45bdf16 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -48,7 +48,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.SecondsToTimeString((double)EntryValue); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -95,7 +95,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.SecondsToTimeString((double)EntryValue); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -302,7 +302,7 @@ public class ObT : OrbitalEntry public ObT() { Name = "Orbit Time"; - Description = ""; + Description = "Shows orbit time in seconds from the Periapsis"; Category = MicroEntryCategory.Orbital; Unit = "s"; Formatting = "{0:N0}"; @@ -329,7 +329,7 @@ public class ArgumentOfPeriapsis : OrbitalEntry { public ArgumentOfPeriapsis() { - Name = "Argument of Pe. ω"; + Name = "Argument of Pe."; Description = ""; Category = MicroEntryCategory.Orbital; Unit = "°"; @@ -367,7 +367,7 @@ public class SemiMajorAxis : OrbitalEntry { public SemiMajorAxis() { - Name = "Semi Major Axis a"; + Name = "Semi Major Axis"; Description = ""; Category = MicroEntryCategory.Orbital; Unit = "m"; @@ -386,7 +386,7 @@ public class SemiMinorAxis : OrbitalEntry { public SemiMinorAxis() { - Name = "Semi Minor Axis b"; + Name = "Semi Minor Axis"; Description = ""; Category = MicroEntryCategory.Orbital; Unit = "m"; @@ -424,7 +424,7 @@ public class SemiLatusRectum : OrbitalEntry { public SemiLatusRectum() { - Name = "Semi Latus Rectum ℓ"; + Name = "Semi Latus Rectum"; Description = ""; Category = MicroEntryCategory.Orbital; Unit = "m"; diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index c44744d..be970de 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -147,9 +147,9 @@ public class Target_AltitudeFromSeaLevel : TargetEntry { public Target_AltitudeFromSeaLevel() { - Name = "[T] Altitude (Sea)"; + Name = "Altitude (Sea)"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; } @@ -166,9 +166,9 @@ public class Target_Name : TargetEntry { public Target_Name() { - Name = "[T] Name"; + Name = "Name"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = null; Formatting = null; } @@ -185,10 +185,10 @@ public class Target_EccentricAnomaly : TargetEntry { public Target_EccentricAnomaly() { - Name = "[T] Eccentric Anomaly"; + Name = "Eccentric Anomaly"; Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; + Category = MicroEntryCategory.Target; + Unit = "°"; Formatting = "{0:N2}"; } @@ -213,9 +213,9 @@ public class Target_MeanAnomaly : TargetEntry { public Target_MeanAnomaly() { - Name = "[T] Mean Anomaly"; + Name = "Mean Anomaly"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N2}"; } @@ -241,9 +241,9 @@ public class Target_ObT : TargetEntry { public Target_ObT() { - Name = "[T] Orbit Time"; + Name = "Orbit Time"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "s"; Formatting = "{0:N3}"; } @@ -269,11 +269,11 @@ public class Target_ArgumentOfPeriapsis : TargetEntry { public Target_ArgumentOfPeriapsis() { - Name = "[T] Arg. of Pe."; + Name = "Argument of Pe."; Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Category = MicroEntryCategory.Target; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -288,9 +288,9 @@ public class Target_Eccentricity : TargetEntry { public Target_Eccentricity() { - Name = "[T] Eccentricity"; + Name = "Eccentricity"; Description = "Shows the target's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = null; Formatting = "{0:N3}"; } @@ -307,9 +307,9 @@ public class Target_Inclination : TargetEntry { public Target_Inclination() { - Name = "[T] Inclination"; + Name = "Inclination"; Description = "Shows the target's orbital inclination relative to the equator."; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N3}"; } @@ -326,11 +326,11 @@ public class Target_LongitudeOfAscendingNode : TargetEntry { public Target_LongitudeOfAscendingNode() { - Name = "[T] LAN"; + Name = "LAN Ω"; Description = "Shows the target's Longitude Of Ascending Node"; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Category = MicroEntryCategory.Target; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -345,9 +345,9 @@ public class Target_SemiMajorAxis : TargetEntry { public Target_SemiMajorAxis() { - Name = "[T] Semi Major Axis"; + Name = "Semi Major Axis"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; } @@ -364,11 +364,11 @@ public class Target_ReferenceBodyConstants_Radius : TargetEntry { public Target_ReferenceBodyConstants_Radius() { - Name = "[T] Ref.Bod.Con.Radius"; + Name = "Body Radius"; Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Category = MicroEntryCategory.Target; + Unit = "m"; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -383,16 +383,16 @@ public class Target_ReferenceBodyConstants_StandardGravitationParameter : Target { public Target_ReferenceBodyConstants_StandardGravitationParameter() { - Name = "[T] Ref.Bod.Con.GPar"; + Name = "Std. Grav. Param."; Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Category = MicroEntryCategory.Target; + Unit = "μ"; + Formatting = "{0:e4}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody.gravParameter; + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.gravParameter; } public override string ValueDisplay => base.ValueDisplay; @@ -402,11 +402,11 @@ public class Target_SemiLatusRectum : TargetEntry { public Target_SemiLatusRectum() { - Name = "[T] Semi Latus Rectum"; + Name = "Semi Latus Rectum"; Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Category = MicroEntryCategory.Target; + Unit = "m"; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -421,11 +421,11 @@ public class Target_SemiMinorAxis : TargetEntry { public Target_SemiMinorAxis() { - Name = "[T] Semi Minor Axis"; + Name = "Semi Minor Axis"; Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N3}"; + Category = MicroEntryCategory.Target; + Unit = "m"; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -440,11 +440,11 @@ public class Target_TrueAnomaly : TargetEntry { public Target_TrueAnomaly() { - Name = "[T] True Anomaly"; + Name = "True Anomaly"; Description = ""; - Category = MicroEntryCategory.Accepted; - Unit = null; - Formatting = "{0:N2}"; + Category = MicroEntryCategory.Target; + Unit = "°"; + Formatting = "{0:N1}"; } public override void RefreshData() @@ -468,9 +468,9 @@ public class Target_Period : TargetEntry { public Target_Period() { - Name = "[T] Period"; + Name = "Period"; Description = "Shows the amount of time it will take to complete a full orbit."; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "s"; Formatting = null; } @@ -492,20 +492,20 @@ public override string ValueDisplay } } - public class Target_radius : TargetEntry + public class Target_OrbitRadius : TargetEntry { - public Target_radius() + public Target_OrbitRadius() { - Name = "[T] Orbit Radius"; + Name = "Orbit Radius"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit.radius; + EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.radius; } public override string ValueDisplay => base.ValueDisplay; @@ -515,9 +515,9 @@ public class Target_Obtvelocity : TargetEntry { public Target_Obtvelocity() { - Name = "[T] Orbital Speed"; + Name = "Orbital Speed"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -534,9 +534,9 @@ public class DistanceAtCloseApproach1 : TargetEntry { public DistanceAtCloseApproach1() { - Name = "CloseApp1 Dist"; + Name = "CloseAppDist-1"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; } @@ -555,9 +555,9 @@ public class TimeToCloseApproach1 : TargetEntry { public TimeToCloseApproach1() { - Name = "CloseApp1 Time"; + Name = "CloseAppTime-1"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "s"; Formatting = null; } @@ -585,9 +585,9 @@ public class RelativeSpeedAtCloseApproach1 : TargetEntry { public RelativeSpeedAtCloseApproach1() { - Name = "CloseApp1 Speed"; + Name = "CloseAppSpeed-1"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -606,9 +606,9 @@ public class DistanceAtCloseApproach2 : TargetEntry { public DistanceAtCloseApproach2() { - Name = "CloseApp2 Dist"; + Name = "CloseAppDist-2"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; } @@ -627,9 +627,9 @@ public class TimeToCloseApproach2 : TargetEntry { public TimeToCloseApproach2() { - Name = "CloseApp2 Time"; + Name = "CloseAppTime-2"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "s"; Formatting = null; } @@ -657,9 +657,9 @@ public class RelativeSpeedAtCloseApproach2 : TargetEntry { public RelativeSpeedAtCloseApproach2() { - Name = "CloseApp2 Speed"; + Name = "CloseAppSpeed-2"; Description = ""; - Category = MicroEntryCategory.Accepted; + Category = MicroEntryCategory.Target; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -680,7 +680,7 @@ public PhaseAngle() { Name = "Phase Angle"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N2}"; } @@ -699,7 +699,7 @@ public TransferAngle() { Name = "Transfer Angle"; Description = ""; - Category = MicroEntryCategory.Accepted2; + Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N2}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index a9943f1..9b08a93 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -4,11 +4,11 @@ namespace MicroMod public class VesselEntry : MicroEntry { } - public class Vessel : VesselEntry + public class VesselName : VesselEntry { - public Vessel() + public VesselName() { - Name = "Vessel"; + Name = "Name"; Description = "Name of the current vessel."; Category = MicroEntryCategory.Vessel; Unit = null; @@ -61,257 +61,262 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class StageThrustActual : VesselEntry + public class TotalDeltaVASL : VesselEntry { - public StageThrustActual() + public TotalDeltaVASL() { - Name = "Thrust"; - Description = "Shows the vessel's actual thrust."; + Name = "Total ∆v ASL"; + Description = "Shows the total delta velocity of the vessel At Sea Level."; Category = MicroEntryCategory.Vessel; - Unit = "N"; + Unit = "m/s"; Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustActual * 1000; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVASL; } public override string ValueDisplay => base.ValueDisplay; + } - public class StageTWRActual : VesselEntry + public class TotalDeltaVVac : VesselEntry { - public StageTWRActual() + public TotalDeltaVVac() { - Name = "TWR"; - Description = "Shows the vessel's StageThrustActual to Weight Ratio."; + Name = "Total ∆v Vac"; + Description = "Shows the total delta velocity of the vessel in vacuum."; Category = MicroEntryCategory.Vessel; - Unit = null; - Formatting = "{0:N2}"; + Unit = "m/s"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRActual; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVVac; } public override string ValueDisplay => base.ValueDisplay; } - - // NEW ENTRIES // - - - public class PartsCount : VesselEntry + public class StageThrustActual : VesselEntry { - public PartsCount() + public StageThrustActual() { - Name = "Parts"; - Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = null; - Formatting = null; + Name = "Thrust"; + Description = "Shows the vessel's actual thrust."; + Category = MicroEntryCategory.Vessel; + Unit = "N"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.PartInfo?.Count; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustActual * 1000; } public override string ValueDisplay => base.ValueDisplay; } - public class TotalBurnTime : VesselEntry + public class StageThrustASL : VesselEntry { - public TotalBurnTime() + public StageThrustASL() { - Name = "Total Burn Time"; - Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = "s"; + Name = "Thrust (ASL)"; + Description = "Shows the vessel's actual thrust."; + Category = MicroEntryCategory.Vessel; + Unit = "N"; Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalBurnTime; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.ThrustASL * 1000; } public override string ValueDisplay => base.ValueDisplay; } - public class TotalDeltaVASL : VesselEntry + public class StageThrustVac : VesselEntry { - public TotalDeltaVASL() + public StageThrustVac() { - Name = "Total ∆v ASL"; - Description = "Shows the total delta velocity of the vessel At Sea Level."; - Category = MicroEntryCategory.Accepted2; - Unit = "m/s"; + Name = "Thrust (Vacuum)"; + Description = "Shows the vessel's actual thrust."; + Category = MicroEntryCategory.Vessel; + Unit = "N"; Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVASL; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.ThrustVac * 1000; } public override string ValueDisplay => base.ValueDisplay; - } - public class TotalDeltaVVac : VesselEntry + public class StageTWRActual : VesselEntry { - public TotalDeltaVVac() + public StageTWRActual() { - Name = "Total ∆v Vac"; - Description = "Shows the total delta velocity of the vessel in vacuum."; - Category = MicroEntryCategory.Accepted2; - Unit = "m/s"; - Formatting = "{0:N0}"; + Name = "TWR"; + Description = "Shows the vessel's StageThrustActual to Weight Ratio."; + Category = MicroEntryCategory.Vessel; + Unit = null; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVVac; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRActual; } public override string ValueDisplay => base.ValueDisplay; } - public class StageISPAsl : VesselEntry + public class StageTWRASL : VesselEntry { - public StageISPAsl() + public StageTWRASL() { - Name = "ISP (ASL)"; + Name = "TWR (ASL)"; Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = "s"; - Formatting = "{0:N0}"; + Category = MicroEntryCategory.Vessel; + Unit = null; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.IspASL; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.TWRASL; } public override string ValueDisplay => base.ValueDisplay; } - public class StageISPActual : VesselEntry + public class StageTWRVac : VesselEntry { - public StageISPActual() + public StageTWRVac() { - Name = "ISP (Actual)"; + Name = "TWR (Vacuum)"; Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = "s"; - Formatting = "{0:N0}"; + Category = MicroEntryCategory.Vessel; + Unit = null; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.IspActual; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.TWRVac; } public override string ValueDisplay => base.ValueDisplay; } - public class StageISPVac : VesselEntry + public class PartsCount : VesselEntry { - public StageISPVac() + public PartsCount() { - Name = "ISP (Vacuum)"; + Name = "Parts"; Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = "s"; - Formatting = "{0:N0}"; + Category = MicroEntryCategory.Vessel; + Unit = null; + Formatting = null; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.IspVac; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.PartInfo?.Count; } public override string ValueDisplay => base.ValueDisplay; } - public class StageTWRASL : VesselEntry + public class TotalBurnTime : VesselEntry { - public StageTWRASL() + public TotalBurnTime() { - Name = "TWR (ASL)"; + Name = "Total Burn Time"; Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = null; - Formatting = "{0:N2}"; + Category = MicroEntryCategory.Vessel; + Unit = "s"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRASL; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalBurnTime; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + } + } } - public class StageTWRVac : VesselEntry + public class StageISPActual : VesselEntry { - public StageTWRVac() + public StageISPActual() { - Name = "TWR (Vacuum)"; + Name = "ISP (Actual)"; Description = ""; - Category = MicroEntryCategory.Accepted2; - Unit = null; - Formatting = "{0:N2}"; + Category = MicroEntryCategory.Vessel; + Unit = "s"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRVac; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.IspActual; } public override string ValueDisplay => base.ValueDisplay; } - public class StageThrustASL : VesselEntry + public class StageISPAsl : VesselEntry { - public StageThrustASL() + public StageISPAsl() { - Name = "Thrust (ASL)"; - Description = "Shows the vessel's actual thrust."; - Category = MicroEntryCategory.Accepted2; - Unit = "N"; + Name = "ISP (ASL)"; + Description = ""; + Category = MicroEntryCategory.Vessel; + Unit = "s"; Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustASL * 1000; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.IspASL; } public override string ValueDisplay => base.ValueDisplay; - } + } - public class StageThrustVac : VesselEntry + public class StageISPVac : VesselEntry { - public StageThrustVac() + public StageISPVac() { - Name = "Thrust (Vacuum)"; - Description = "Shows the vessel's actual thrust."; - Category = MicroEntryCategory.Accepted2; - Unit = "N"; + Name = "ISP (Vacuum)"; + Description = ""; + Category = MicroEntryCategory.Vessel; + Unit = "s"; Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustVac * 1000; + EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.IspVac; } public override string ValueDisplay => base.ValueDisplay; - } + } public class Throttle : VesselEntry { @@ -340,7 +345,7 @@ public FuelPercentage() Description = ""; Category = MicroEntryCategory.Vessel; Unit = "%"; - Formatting = "{0:N0}"; + Formatting = "{0:N1}"; } public override void RefreshData() @@ -359,7 +364,7 @@ public StageFuelPercentage() Description = ""; Category = MicroEntryCategory.Vessel; Unit = "%"; - Formatting = "{0:N0}"; + Formatting = "{0:N1}"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 84425ee..54eb879 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1081,7 +1081,7 @@ private void InitializeEntries() MicroEntries = new List(); #region Vessel entries - MicroEntries.Add(new Vessel()); + MicroEntries.Add(new VesselName()); MicroEntries.Add(new Mass()); MicroEntries.Add(new TotalDeltaVActual()); MicroEntries.Add(new StageThrustActual()); @@ -1215,7 +1215,7 @@ private void InitializeEntries() MicroEntries.Add(new Target_SemiMinorAxis()); MicroEntries.Add(new Target_TrueAnomaly()); MicroEntries.Add(new Target_Period()); - MicroEntries.Add(new Target_radius()); + MicroEntries.Add(new Target_OrbitRadius()); MicroEntries.Add(new Target_AltitudeFromSeaLevel()); MicroEntries.Add(new Target_Name()); MicroEntries.Add(new Target_Obtvelocity()); @@ -1247,8 +1247,8 @@ private void InitializeEntries() MicroEntries.Add(new Maneuver_TrueAnomaly()); MicroEntries.Add(new Maneuver_UniversalTimeAtClosestApproach()); MicroEntries.Add(new Maneuver_UniversalTimeAtSoiEncounter()); - MicroEntries.Add(new Maneuver_orbitPercent()); - MicroEntries.Add(new Maneuver_period()); + MicroEntries.Add(new Maneuver_OrbitPercent()); + MicroEntries.Add(new Maneuver_Period()); MicroEntries.Add(new AngleOfAttack()); MicroEntries.Add(new SideSlip()); MicroEntries.Add(new PhaseAngle()); From 987f5db639f0fca1435dcf6751bf8321beb59fa2 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Fri, 21 Apr 2023 00:00:35 +0200 Subject: [PATCH 21/38] Add description to all new entries --- .../MicroEngineer/Entries/BodyEntries.cs | 4 +- .../MicroEngineer/Entries/FlightEntries.cs | 28 ++++----- .../MicroEngineer/Entries/ManeuverEntries.cs | 54 ++++++++-------- .../MicroEngineer/Entries/MiscEntries.cs | 39 ++++++------ .../MicroEngineer/Entries/OrbitalEntries.cs | 34 +++++----- .../MicroEngineer/Entries/SurfaceEntries.cs | 16 ++--- .../MicroEngineer/Entries/TargetEntries.cs | 62 +++++++++---------- .../MicroEngineer/Entries/VesselEntries.cs | 38 ++++++------ .../MicroEngineer/MicroEngineerMod.cs | 55 +--------------- .../MicroEngineer/Utilities/TransferInfo.cs | 4 +- 10 files changed, 135 insertions(+), 199 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs index 1bc2f20..a4a8502 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs @@ -28,7 +28,7 @@ public class ReferenceBodyConstants_Radius : BodyEntry public ReferenceBodyConstants_Radius() { Name = "Body Radius"; - Description = ""; + Description = "Body's radius."; Category = MicroEntryCategory.Body; Unit = "m"; Formatting = "{0:N0}"; @@ -47,7 +47,7 @@ public class ReferenceBodyConstants_StandardGravitationParameter : BodyEntry public ReferenceBodyConstants_StandardGravitationParameter() { Name = "Std. Grav. Param."; - Description = ""; + Description = "Product of the gravitational constant G and the mass M of the body."; Category = MicroEntryCategory.Body; Unit = "μ"; Formatting = "{0:e4}"; diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index 9140688..2d07112 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -152,8 +152,8 @@ public class AngleOfAttack : FlightEntry { public AngleOfAttack() { - Name = "Angle of Attack"; - Description = ""; + Name = "AoA"; + Description = "Angle of Attack specifies the angle between the chord line of the wing and the vector representing the relative motion between the aircraft and the atmosphere."; Category = MicroEntryCategory.Flight; Unit = "°"; Formatting = "{0:N3}"; @@ -172,7 +172,7 @@ public class SideSlip : FlightEntry public SideSlip() { Name = "Sideslip"; - Description = ""; + Description = "A slip is an aerodynamic state where an aircraft is moving somewhat sideways as well as forward relative to the oncoming airflow or relative wind."; Category = MicroEntryCategory.Flight; Unit = "°"; Formatting = "{0:N3}"; @@ -190,8 +190,8 @@ public class DragCoefficient : FlightEntry { public DragCoefficient() { - Name = "DragCoefficient"; - Description = ""; + Name = "Drag Coefficient"; + Description = "Dimensionless quantity that is used to quantify the drag or resistance of an object in a fluid environment, such as air or water."; Category = MicroEntryCategory.Flight; Unit = null; Formatting = "{0:N2}"; @@ -209,8 +209,8 @@ public class ExposedArea : FlightEntry { public ExposedArea() { - Name = "ExposedArea"; - Description = ""; + Name = "Exposed Area"; + Description = "The surface area that interacts with the working fluid or gas."; Category = MicroEntryCategory.Flight; Unit = null; // TODO Formatting = "{0:N2}"; @@ -229,7 +229,7 @@ public class Heading : FlightEntry public Heading() { Name = "Heading"; - Description = ""; + Description = "Heading of a vessel is the compass direction in which the craft's nose is pointed."; Category = MicroEntryCategory.Flight; Unit = "°"; Formatting = "{0:N2}"; @@ -248,7 +248,7 @@ public class Pitch_HorizonRelative : FlightEntry public Pitch_HorizonRelative() { Name = "Pitch"; - Description = ""; + Description = "Lateral axis passes through an aircraft from wingtip to wingtip. Rotation about this axis is called pitch (moving up-down)."; Category = MicroEntryCategory.Flight; Unit = "°"; Formatting = "{0:N2}"; @@ -267,7 +267,7 @@ public class Roll_HorizonRelative : FlightEntry public Roll_HorizonRelative() { Name = "Roll"; - Description = ""; + Description = "Longitudinal axis passes through the aircraft from nose to tail. Rotation about this axis is called roll (rotating left-right)."; Category = MicroEntryCategory.Flight; Unit = "°"; Formatting = "{0:N2}"; @@ -286,7 +286,7 @@ public class Yaw_HorizonRelative : FlightEntry public Yaw_HorizonRelative() { Name = "Yaw"; - Description = ""; + Description = "Vertical axis passes through an aircraft from top to bottom. Rotation about this axis is called yaw (moving left-right)."; Category = MicroEntryCategory.Flight; Unit = "°"; Formatting = "{0:N2}"; @@ -305,7 +305,7 @@ public class Zenith : FlightEntry public Zenith() { Name = "Zenith"; - Description = ""; + Description = "The zenith is an imaginary point directly above a particular location, on the celestial sphere. \"Above\" means in the vertical direction opposite to the gravity direction."; Category = MicroEntryCategory.Flight; Unit = "°"; Formatting = "{0:N2}"; @@ -324,7 +324,7 @@ public class SoundSpeed : FlightEntry public SoundSpeed() { Name = "Speed of sound"; - Description = ""; + Description = "Distance travelled per unit of time by a sound wave as it propagates through the air."; Category = MicroEntryCategory.Flight; Unit = "m/s"; Formatting = "{0:N1}"; @@ -343,7 +343,7 @@ public class GeeForce : FlightEntry public GeeForce() { Name = "G-Force"; - Description = ""; + Description = "Measurement of the type of force per unit mass – typically acceleration – that causes a perception of weight, with a g-force of 1 g equal to the conventional value of gravitational acceleration on Earth/Kerbin."; Category = MicroEntryCategory.Flight; Unit = "g"; Formatting = "{0:N3}"; diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index dc8d61c..ccc2ede 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -14,7 +14,7 @@ public class ProjectedAp : ManeuverEntry public ProjectedAp() { Name = "Projected Ap."; - Description = "Shows the projected apoapsis vessel will have after completing the maneuver."; + Description = "Projected Apoapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "m"; Formatting = "{0:N0}"; @@ -36,7 +36,7 @@ public class ProjectedPe : ManeuverEntry public ProjectedPe() { Name = "Projected Pe."; - Description = "Shows the projected periapsis vessel will have after completing the maneuver."; + Description = "Projected Periapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "m"; Formatting = "{0:N0}"; @@ -58,7 +58,7 @@ public class DeltaVRequired : ManeuverEntry public DeltaVRequired() { Name = "∆v required"; - Description = "Shows the delta velocity needed to complete the maneuver."; + Description = "Delta velocity needed to complete the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "m/s"; Formatting = "{0:N1}"; @@ -82,7 +82,7 @@ public class ManeuverPrograde : ManeuverEntry public ManeuverPrograde() { Name = "∆v Prograde"; - Description = ""; + Description = "Prograde/Retrograde component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; Unit = "m/s"; Formatting = "{0:N1}"; @@ -102,7 +102,7 @@ public class ManeuverNormal : ManeuverEntry public ManeuverNormal() { Name = "∆v Normal"; - Description = ""; + Description = "Normal component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; Unit = "m/s"; Formatting = "{0:N1}"; @@ -122,7 +122,7 @@ public class ManeuverRadial : ManeuverEntry public ManeuverRadial() { Name = "∆v Radial"; - Description = ""; + Description = "Radial component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; Unit = "m/s"; Formatting = "{0:N1}"; @@ -142,7 +142,7 @@ public class TimeToNode : ManeuverEntry public TimeToNode() { Name = "Time to Node"; - Description = "Shows the time until vessel reaches the maneuver node."; + Description = "Time until vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = null; @@ -171,7 +171,7 @@ public class BurnTime : ManeuverEntry public BurnTime() { Name = "Burn Time"; - Description = "Shows the length of time needed to complete the maneuver node."; + Description = "Length of time needed to complete the maneuver node."; Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = null; @@ -203,7 +203,7 @@ public class Maneuver_EccentricAnomaly : ManeuverEntry public Maneuver_EccentricAnomaly() { Name = "Eccentric Anomaly"; - Description = ""; + Description = "Eccentric Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "°"; Formatting = "{0:N2}"; @@ -234,7 +234,7 @@ public class Maneuver_EndUT : ManeuverEntry public Maneuver_EndUT() { Name = "UT"; - Description = ""; + Description = "Universal Time when vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = "{0:N3}"; @@ -265,7 +265,7 @@ public class Maneuver_MeanAnomaly : ManeuverEntry public Maneuver_MeanAnomaly() { Name = "Mean Anomaly"; - Description = ""; + Description = "Mean Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "°"; Formatting = "{0:N2}"; @@ -296,7 +296,7 @@ public class Maneuver_ObT : ManeuverEntry public Maneuver_ObT() { Name = "Orbit Time"; - Description = "Shows orbit time in seconds from the Periapsis"; + Description = "Shows orbit time in seconds from the Periapsis when vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = "{0:N0}"; @@ -327,7 +327,7 @@ public class Maneuver_ArgumentOfPeriapsis : ManeuverEntry public Maneuver_ArgumentOfPeriapsis() { Name = "Argument of Pe."; - Description = ""; + Description = "Argument of Periapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "°"; Formatting = "{0:N2}"; @@ -349,7 +349,7 @@ public class Maneuver_Eccentricity : ManeuverEntry public Maneuver_Eccentricity() { Name = "Eccentricity"; - Description = "Shows the vessel's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; + Description = "The eccentricity of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; Unit = null; Formatting = "{0:N3}"; @@ -371,7 +371,7 @@ public class Maneuver_Inclination : ManeuverEntry public Maneuver_Inclination() { Name = "Inclination"; - Description = "Shows the vessel's orbital inclination relative to the equator."; + Description = "The inclination of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; Unit = "°"; Formatting = "{0:N3}"; @@ -393,7 +393,7 @@ public class Maneuver_LongitudeOfAscendingNode : ManeuverEntry public Maneuver_LongitudeOfAscendingNode() { Name = "LAN Ω"; - Description = ""; + Description = "Longitude of Ascending Node vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "°"; Formatting = "{0:N2}"; @@ -415,7 +415,7 @@ public class Maneuver_SemiMajorAxis : ManeuverEntry public Maneuver_SemiMajorAxis() { Name = "Semi Major Axis"; - Description = ""; + Description = "Semi Major Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "m"; Formatting = "{0:N0}"; @@ -437,7 +437,7 @@ public class Maneuver_SemiMinorAxis : ManeuverEntry public Maneuver_SemiMinorAxis() { Name = "Semi Minor Axis"; - Description = ""; + Description = "Semi Minor Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "m"; Formatting = "{0:N0}"; @@ -459,7 +459,7 @@ public class Maneuver_OrbitalEnergy : ManeuverEntry public Maneuver_OrbitalEnergy() { Name = "Orbital Energy"; - Description = ""; + Description = "Orbital Energy vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "kJ"; Formatting = "{0:N0}"; @@ -481,7 +481,7 @@ public class Maneuver_SemiLatusRectum : ManeuverEntry public Maneuver_SemiLatusRectum() { Name = "Semi Latus Rectum"; - Description = ""; + Description = "Semi Latus Rectum vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "m"; Formatting = "{0:N0}"; @@ -503,7 +503,7 @@ public class Maneuver_TimeToAp : ManeuverEntry public Maneuver_TimeToAp() { Name = "Time to Ap."; - Description = "Shows the time until the vessel reaches apoapsis, the highest point of the orbit."; + Description = "Shows the Time to Apoapsis vessel will have after reaching the maneuver node."; Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = null; @@ -534,7 +534,7 @@ public class Maneuver_TimeToPe : ManeuverEntry public Maneuver_TimeToPe() { Name = "Time to Pe."; - Description = "Shows the time until the vessel reaches periapsis, the lowest point of the orbit."; + Description = "Shows the Time to Periapsis vessel will have after reaching the maneuver node."; Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = null; @@ -565,7 +565,7 @@ public class Maneuver_TrueAnomaly : ManeuverEntry public Maneuver_TrueAnomaly() { Name = "True Anomaly"; - Description = ""; + Description = "True Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "°"; Formatting = "{0:N1}"; @@ -596,7 +596,7 @@ public class Maneuver_UniversalTimeAtClosestApproach : ManeuverEntry public Maneuver_UniversalTimeAtClosestApproach() { Name = "UT Close.App."; - Description = ""; + Description = "Universal Time at the point of closest approach."; Category = MicroEntryCategory.Maneuver; Unit = null; Formatting = null; @@ -627,7 +627,7 @@ public class Maneuver_UniversalTimeAtSoiEncounter : ManeuverEntry public Maneuver_UniversalTimeAtSoiEncounter() { Name = "UT SOI Enc."; - Description = ""; + Description = "Universal Time at the point of transition to another Sphere Of Influence."; Category = MicroEntryCategory.Maneuver; Unit = null; Formatting = null; @@ -658,7 +658,7 @@ public class Maneuver_OrbitPercent : ManeuverEntry public Maneuver_OrbitPercent() { Name = "Orbit percent"; - Description = ""; + Description = "Orbit percent vessel will have passed after completing the maneuver."; Category = MicroEntryCategory.Maneuver; Unit = "%"; Formatting = "{0:N2}"; @@ -680,7 +680,7 @@ public class Maneuver_Period : ManeuverEntry public Maneuver_Period() { Name = "Period"; - Description = "Shows the amount of time it will take to complete a full orbit."; + Description = "The period of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; Unit = "s"; Formatting = null; diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs index fa42ab1..a427407 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -1,7 +1,4 @@ using KSP.Sim; -using System; -using System.Collections.Generic; -using System.Text; namespace MicroMod { @@ -26,7 +23,7 @@ public class AutopilotStatus_IsEnabled : MiscEntry public AutopilotStatus_IsEnabled() { Name = "Autopilot"; - Description = ""; + Description = "Is autopilot enabled or disabled."; Category = MicroEntryCategory.Misc; Unit = null; Formatting = null; @@ -45,7 +42,7 @@ public class AutopilotStatus_Mode : MiscEntry public AutopilotStatus_Mode() { Name = "Autopilot Mode"; - Description = ""; + Description = "Mode vessel's autopilot is using: stability assist, prograde, retrograde, normal, etc."; Category = MicroEntryCategory.Misc; Unit = null; Formatting = null; @@ -64,7 +61,7 @@ public class TimeSinceLaunch : MiscEntry public TimeSinceLaunch() { Name = "Time since launch"; - Description = ""; + Description = "Time since the vessel launched."; Category = MicroEntryCategory.Misc; Unit = "s"; Formatting = "{0:N0}"; @@ -82,17 +79,17 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } - + public class GravityForPos : MiscEntry { public GravityForPos() { Name = "Local Gravity"; - Description = ""; + Description = "Local gravity vessel is experiencing."; Category = MicroEntryCategory.Misc; Unit = "ms2"; Formatting = "{0:N3}"; @@ -111,10 +108,10 @@ public class LaunchTime : MiscEntry public LaunchTime() { Name = "Launch Time"; - Description = ""; + Description = "Universal Time when vessel was launched."; Category = MicroEntryCategory.Misc; Unit = "s"; - Formatting = null; + Formatting = "{0:N3}"; } public override void RefreshData() @@ -129,7 +126,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -139,7 +136,7 @@ public class AltimeterMode : MiscEntry public AltimeterMode() { Name = "Altimeter Mode"; - Description = ""; + Description = "Mode vessel's altimeter is using: Sea Level or Ground Level."; Category = MicroEntryCategory.Misc; Unit = null; Formatting = null; @@ -158,7 +155,7 @@ public class SpeedMode : MiscEntry public SpeedMode() { Name = "Speed Mode"; - Description = ""; + Description = "Mode vessel's velocity meter is using: Orbit, Surface or Target."; Category = MicroEntryCategory.Misc; Unit = null; Formatting = null; @@ -177,7 +174,7 @@ public class StartUT : MiscEntry public StartUT() { Name = "Start UT"; - Description = ""; + Description = "Time passed since vessel was launched."; Category = MicroEntryCategory.Misc; Unit = "s"; Formatting = "{0:N0}"; @@ -195,7 +192,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -205,7 +202,7 @@ public class EndUT : MiscEntry public EndUT() { Name = "UT"; - Description = ""; + Description = "Universal Time."; Category = MicroEntryCategory.Misc; Unit = "s"; Formatting = "{0:N0}"; @@ -223,7 +220,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -233,7 +230,7 @@ public class UniversalTimeAtClosestApproach : MiscEntry public UniversalTimeAtClosestApproach() { Name = "UT Close.App."; - Description = ""; + Description = "Universal Time at closest approach."; Category = MicroEntryCategory.Misc; Unit = "s"; Formatting = "{0:N0}"; @@ -261,7 +258,7 @@ public class UniversalTimeAtSoiEncounter : MiscEntry public UniversalTimeAtSoiEncounter() { Name = "UT SOI Enc."; - Description = ""; + Description = "Universal Time at the point of transfer to another sphere of influence."; Category = MicroEntryCategory.Misc; Unit = "s"; Formatting = "{0:N0}"; @@ -283,4 +280,4 @@ public override string ValueDisplay } } } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 45bdf16..30373af 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -161,7 +161,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.SecondsToTimeString((double)EntryValue); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -171,7 +171,7 @@ public class SoiTransition : OrbitalEntry public SoiTransition() { Name = "SOI Trans."; - Description = "Shows the amount of time it will take to transition to another Sphere of Influence."; + Description = "Shows the amount of time it will take to transition to another Sphere Of Influence."; Category = MicroEntryCategory.Orbital; Unit = "s"; Formatting = null; @@ -198,8 +198,8 @@ public class OrbitalSpeed : OrbitalEntry { public OrbitalSpeed() { - Name = "Orbital Velocity"; - Description = ""; + Name = "Orbital Speed"; + Description = "Shows the vessel's orbital speed"; Category = MicroEntryCategory.Orbital; Unit = "m/s"; Formatting = "{0:N1}"; @@ -218,7 +218,7 @@ public class EccentricAnomaly : OrbitalEntry public EccentricAnomaly() { Name = "Eccentric Anomaly"; - Description = ""; + Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the vessel is."; Category = MicroEntryCategory.Orbital; Unit = "°"; Formatting = "{0:N2}"; @@ -246,7 +246,7 @@ public class MeanAnomaly : OrbitalEntry public MeanAnomaly() { Name = "Mean Anomaly"; - Description = ""; + Description = "Parameter used to describe the position of an object in its orbit around the celestial body."; Category = MicroEntryCategory.Orbital; Unit = "°"; Formatting = "{0:N2}"; @@ -274,7 +274,7 @@ public class TrueAnomaly : OrbitalEntry public TrueAnomaly() { Name = "True Anomaly"; - Description = ""; + Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Orbital; Unit = "°"; Formatting = "{0:N1}"; @@ -302,7 +302,7 @@ public class ObT : OrbitalEntry public ObT() { Name = "Orbit Time"; - Description = "Shows orbit time in seconds from the Periapsis"; + Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Orbital; Unit = "s"; Formatting = "{0:N0}"; @@ -320,7 +320,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -330,7 +330,7 @@ public class ArgumentOfPeriapsis : OrbitalEntry public ArgumentOfPeriapsis() { Name = "Argument of Pe."; - Description = ""; + Description = "Angle from the line of the ascending node on the equatorial plane to the point of periapsis passage."; Category = MicroEntryCategory.Orbital; Unit = "°"; Formatting = "{0:N2}"; @@ -349,7 +349,7 @@ public class LongitudeOfAscendingNode : OrbitalEntry public LongitudeOfAscendingNode() { Name = "LAN Ω"; - Description = ""; + Description = "Longitude of Ascending Node is an angle from a specified reference direction, called the origin of longitude, to the direction of the ascending node, as measured in a specified reference plane."; Category = MicroEntryCategory.Orbital; Unit = "°"; Formatting = "{0:N2}"; @@ -368,7 +368,7 @@ public class SemiMajorAxis : OrbitalEntry public SemiMajorAxis() { Name = "Semi Major Axis"; - Description = ""; + Description = "Shows the distance from the center of an orbit to the farthest edge."; Category = MicroEntryCategory.Orbital; Unit = "m"; Formatting = "{0:N0}"; @@ -387,7 +387,7 @@ public class SemiMinorAxis : OrbitalEntry public SemiMinorAxis() { Name = "Semi Minor Axis"; - Description = ""; + Description = "Shows the distance from the center of an orbit to the nearest edge."; Category = MicroEntryCategory.Orbital; Unit = "m"; Formatting = "{0:N0}"; @@ -406,7 +406,7 @@ public class OrbitalEnergy : OrbitalEntry public OrbitalEnergy() { Name = "Orbital Energy"; - Description = ""; + Description = "Constant sum of two orbiting bodies' mutual potential energy and their total kinetic energy divided by the reduced mass."; Category = MicroEntryCategory.Orbital; Unit = "kJ"; Formatting = "{0:N0}"; @@ -425,7 +425,7 @@ public class SemiLatusRectum : OrbitalEntry public SemiLatusRectum() { Name = "Semi Latus Rectum"; - Description = ""; + Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Orbital; Unit = "m"; Formatting = "{0:N0}"; @@ -444,7 +444,7 @@ public class OrbitPercent : OrbitalEntry public OrbitPercent() { Name = "Orbit Percent"; - Description = ""; + Description = "Percent of the orbit completed."; Category = MicroEntryCategory.Orbital; Unit = "%"; Formatting = "{0:N2}"; @@ -463,7 +463,7 @@ public class OrbitRadius : OrbitalEntry public OrbitRadius() { Name = "Orbit Radius"; - Description = ""; + Description = "Length from the center of the ellipse to the object."; Category = MicroEntryCategory.Orbital; Unit = "m"; Formatting = "{0:N0}"; diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index 4142af1..c98d76a 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -123,7 +123,7 @@ public class AltitudeAsl : SurfaceEntry public AltitudeAsl() { Name = "Altitude (Sea Lvl)"; - Description = "Shows the vessel's altitude Above Sea Level"; + Description = "Shows the vessel's altitude above sea level."; Category = MicroEntryCategory.Surface; Unit = "m"; Formatting = "{0:N0}"; @@ -142,7 +142,7 @@ public class AltitudeAgl : SurfaceEntry public AltitudeAgl() { Name = "Altitude (Ground)"; - Description = "Shows the vessel's altitude Above Ground Level"; + Description = "Shows the vessel's altitude above ground Level."; Category = MicroEntryCategory.Surface; Unit = "m"; Formatting = "{0:N0}"; @@ -161,7 +161,7 @@ public class AltitudeFromScenery : SurfaceEntry public AltitudeFromScenery() { Name = "Altitude (Scenery)"; - Description = ""; + Description = "Shows the vessel's altitude above scenery."; Category = MicroEntryCategory.Surface; Unit = "m"; Formatting = "{0:N0}"; @@ -218,7 +218,7 @@ public class AtmosphericTemperature : SurfaceEntry public AtmosphericTemperature() { Name = "Static ambient temp."; - Description = ""; + Description = "Temperature measured outside the vessel. The sensor which detects SAT must be carefully sited to ensure that airflow over it does not affect the indicated temperature."; Category = MicroEntryCategory.Surface; Unit = "K"; Formatting = "{0:N0}"; @@ -236,8 +236,8 @@ public class ExternalTemperature : SurfaceEntry { public ExternalTemperature() { - Name = "External temperature"; - Description = ""; + Name = "Total air temp."; + Description = "Measured by means of a sensor positioned in the airflow, kinetic heating will result, raising the temperature measured above the Static ambient temperature."; Category = MicroEntryCategory.Surface; Unit = "K"; Formatting = "{0:N0}"; @@ -256,7 +256,7 @@ public class DynamicPressure_kPa : SurfaceEntry public DynamicPressure_kPa() { Name = "Dynamic Pressure"; - Description = ""; + Description = "Dynamic Pressure (q) is a defined property of a moving flow of gas. It describes how much pressure the airflow is having on the vessel."; Category = MicroEntryCategory.Surface; Unit = "kPa"; Formatting = "{0:N2}"; @@ -275,7 +275,7 @@ public class StaticPressure_kPa : SurfaceEntry public StaticPressure_kPa() { Name = "Static Pressure"; - Description = ""; + Description = "Static pressure is a term used to define the amount of pressure exerted by a fluid that is not moving - ambient pressure."; Category = MicroEntryCategory.Surface; Unit = "kPa"; Formatting = "{0:N2}"; diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index be970de..0f113b8 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -137,18 +137,12 @@ public override string ValueDisplay } } - - - - - //////////////////////// NEW ENTRIES //////////////////////// - public class Target_AltitudeFromSeaLevel : TargetEntry { public Target_AltitudeFromSeaLevel() { Name = "Altitude (Sea)"; - Description = ""; + Description = "Shows the target's altitude above sea level."; Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; @@ -167,7 +161,7 @@ public class Target_Name : TargetEntry public Target_Name() { Name = "Name"; - Description = ""; + Description = "Target's name."; Category = MicroEntryCategory.Target; Unit = null; Formatting = null; @@ -186,7 +180,7 @@ public class Target_EccentricAnomaly : TargetEntry public Target_EccentricAnomaly() { Name = "Eccentric Anomaly"; - Description = ""; + Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the target is."; Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N2}"; @@ -214,7 +208,7 @@ public class Target_MeanAnomaly : TargetEntry public Target_MeanAnomaly() { Name = "Mean Anomaly"; - Description = ""; + Description = "Parameter used to describe the position of the target in its orbit around the celestial body."; Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N2}"; @@ -242,7 +236,7 @@ public class Target_ObT : TargetEntry public Target_ObT() { Name = "Orbit Time"; - Description = ""; + Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Target; Unit = "s"; Formatting = "{0:N3}"; @@ -260,7 +254,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -270,7 +264,7 @@ public class Target_ArgumentOfPeriapsis : TargetEntry public Target_ArgumentOfPeriapsis() { Name = "Argument of Pe."; - Description = ""; + Description = "Angle from the line of the ascending node on the equatorial plane to the point of periapsis passage."; Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N2}"; @@ -327,7 +321,7 @@ public class Target_LongitudeOfAscendingNode : TargetEntry public Target_LongitudeOfAscendingNode() { Name = "LAN Ω"; - Description = "Shows the target's Longitude Of Ascending Node"; + Description = "Shows the target's Longitude Of Ascending Node."; Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N2}"; @@ -346,7 +340,7 @@ public class Target_SemiMajorAxis : TargetEntry public Target_SemiMajorAxis() { Name = "Semi Major Axis"; - Description = ""; + Description = "Shows the distance from the center of an orbit to the farthest edge."; Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; @@ -365,7 +359,7 @@ public class Target_ReferenceBodyConstants_Radius : TargetEntry public Target_ReferenceBodyConstants_Radius() { Name = "Body Radius"; - Description = ""; + Description = "Radius of the body that target is orbiting."; Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; @@ -384,7 +378,7 @@ public class Target_ReferenceBodyConstants_StandardGravitationParameter : Target public Target_ReferenceBodyConstants_StandardGravitationParameter() { Name = "Std. Grav. Param."; - Description = ""; + Description = "Product of the gravitational constant G and the mass M of the body target is orbiting."; Category = MicroEntryCategory.Target; Unit = "μ"; Formatting = "{0:e4}"; @@ -403,7 +397,7 @@ public class Target_SemiLatusRectum : TargetEntry public Target_SemiLatusRectum() { Name = "Semi Latus Rectum"; - Description = ""; + Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; @@ -422,7 +416,7 @@ public class Target_SemiMinorAxis : TargetEntry public Target_SemiMinorAxis() { Name = "Semi Minor Axis"; - Description = ""; + Description = "Shows the distance from the center of an orbit to the nearest edge."; Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; @@ -441,7 +435,7 @@ public class Target_TrueAnomaly : TargetEntry public Target_TrueAnomaly() { Name = "True Anomaly"; - Description = ""; + Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N1}"; @@ -469,7 +463,7 @@ public class Target_Period : TargetEntry public Target_Period() { Name = "Period"; - Description = "Shows the amount of time it will take to complete a full orbit."; + Description = "Shows the amount of time it will take the target to complete a full orbit."; Category = MicroEntryCategory.Target; Unit = "s"; Formatting = null; @@ -487,7 +481,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.SecondsToTimeString((double)EntryValue); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -497,7 +491,7 @@ public class Target_OrbitRadius : TargetEntry public Target_OrbitRadius() { Name = "Orbit Radius"; - Description = ""; + Description = "Length from the center of the ellipse to the object."; Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; @@ -516,7 +510,7 @@ public class Target_Obtvelocity : TargetEntry public Target_Obtvelocity() { Name = "Orbital Speed"; - Description = ""; + Description = "Shows the target's orbital speed."; Category = MicroEntryCategory.Target; Unit = "m/s"; Formatting = "{0:N1}"; @@ -535,7 +529,7 @@ public class DistanceAtCloseApproach1 : TargetEntry public DistanceAtCloseApproach1() { Name = "CloseAppDist-1"; - Description = ""; + Description = "Close approach distance to target (1)."; Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; @@ -556,7 +550,7 @@ public class TimeToCloseApproach1 : TargetEntry public TimeToCloseApproach1() { Name = "CloseAppTime-1"; - Description = ""; + Description = "Close approach time to target (1)."; Category = MicroEntryCategory.Target; Unit = "s"; Formatting = null; @@ -576,7 +570,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.SecondsToTimeString((double)EntryValue); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -586,7 +580,7 @@ public class RelativeSpeedAtCloseApproach1 : TargetEntry public RelativeSpeedAtCloseApproach1() { Name = "CloseAppSpeed-1"; - Description = ""; + Description = "Close approach relative speed to target (1)."; Category = MicroEntryCategory.Target; Unit = "m/s"; Formatting = "{0:N1}"; @@ -607,7 +601,7 @@ public class DistanceAtCloseApproach2 : TargetEntry public DistanceAtCloseApproach2() { Name = "CloseAppDist-2"; - Description = ""; + Description = "Close approach distance to target (2)."; Category = MicroEntryCategory.Target; Unit = "m"; Formatting = "{0:N0}"; @@ -628,7 +622,7 @@ public class TimeToCloseApproach2 : TargetEntry public TimeToCloseApproach2() { Name = "CloseAppTime-2"; - Description = ""; + Description = "Close approach time to target (2)."; Category = MicroEntryCategory.Target; Unit = "s"; Formatting = null; @@ -648,7 +642,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.SecondsToTimeString((double)EntryValue); + return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -658,7 +652,7 @@ public class RelativeSpeedAtCloseApproach2 : TargetEntry public RelativeSpeedAtCloseApproach2() { Name = "CloseAppSpeed-2"; - Description = ""; + Description = "Close approach relative speed to target (2)."; Category = MicroEntryCategory.Target; Unit = "m/s"; Formatting = "{0:N1}"; @@ -679,7 +673,7 @@ public class PhaseAngle : TargetEntry public PhaseAngle() { Name = "Phase Angle"; - Description = ""; + Description = "Angle between your vessel, the reference body and the target. How much \"ahead\" or \"behind\" in phase you are with the target."; Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N2}"; @@ -698,7 +692,7 @@ public class TransferAngle : TargetEntry public TransferAngle() { Name = "Transfer Angle"; - Description = ""; + Description = "Phase angle needed for an optimal Hohmann transfer orbit. Use a circular orbit for a more accurate value."; Category = MicroEntryCategory.Target; Unit = "°"; Formatting = "{0:N2}"; diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 9b08a93..ecf092b 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -28,7 +28,7 @@ public class Mass : VesselEntry public Mass() { Name = "Mass"; - Description = "Shows the total mass of the vessel."; + Description = "Total mass of the vessel."; Category = MicroEntryCategory.Vessel; Unit = "kg"; Formatting = "{0:N0}"; @@ -47,7 +47,7 @@ public class TotalDeltaVActual : VesselEntry public TotalDeltaVActual() { Name = "Total ∆v"; - Description = "Shows the vessel's total delta velocity."; + Description = "Vessel's total delta velocity."; Category = MicroEntryCategory.Vessel; Unit = "m/s"; Formatting = "{0:N0}"; @@ -66,7 +66,7 @@ public class TotalDeltaVASL : VesselEntry public TotalDeltaVASL() { Name = "Total ∆v ASL"; - Description = "Shows the total delta velocity of the vessel At Sea Level."; + Description = "Total delta velocity of the vessel At Sea Level."; Category = MicroEntryCategory.Vessel; Unit = "m/s"; Formatting = "{0:N0}"; @@ -86,7 +86,7 @@ public class TotalDeltaVVac : VesselEntry public TotalDeltaVVac() { Name = "Total ∆v Vac"; - Description = "Shows the total delta velocity of the vessel in vacuum."; + Description = "Total delta velocity of the vessel in vacuum."; Category = MicroEntryCategory.Vessel; Unit = "m/s"; Formatting = "{0:N0}"; @@ -105,7 +105,7 @@ public class StageThrustActual : VesselEntry public StageThrustActual() { Name = "Thrust"; - Description = "Shows the vessel's actual thrust."; + Description = "Vessel's actual thrust."; Category = MicroEntryCategory.Vessel; Unit = "N"; Formatting = "{0:N0}"; @@ -124,7 +124,7 @@ public class StageThrustASL : VesselEntry public StageThrustASL() { Name = "Thrust (ASL)"; - Description = "Shows the vessel's actual thrust."; + Description = "Vessel's thrust At Sea Level."; Category = MicroEntryCategory.Vessel; Unit = "N"; Formatting = "{0:N0}"; @@ -143,7 +143,7 @@ public class StageThrustVac : VesselEntry public StageThrustVac() { Name = "Thrust (Vacuum)"; - Description = "Shows the vessel's actual thrust."; + Description = "Vessel's thrust in vacuum."; Category = MicroEntryCategory.Vessel; Unit = "N"; Formatting = "{0:N0}"; @@ -162,7 +162,7 @@ public class StageTWRActual : VesselEntry public StageTWRActual() { Name = "TWR"; - Description = "Shows the vessel's StageThrustActual to Weight Ratio."; + Description = "Vessel's Thrust to Weight Ratio."; Category = MicroEntryCategory.Vessel; Unit = null; Formatting = "{0:N2}"; @@ -181,7 +181,7 @@ public class StageTWRASL : VesselEntry public StageTWRASL() { Name = "TWR (ASL)"; - Description = ""; + Description = "Vessel's Thrust to Weight Ratio At Sea Level."; Category = MicroEntryCategory.Vessel; Unit = null; Formatting = "{0:N2}"; @@ -200,7 +200,7 @@ public class StageTWRVac : VesselEntry public StageTWRVac() { Name = "TWR (Vacuum)"; - Description = ""; + Description = "Vessel's Thrust to Weight Ratio in vacuum."; Category = MicroEntryCategory.Vessel; Unit = null; Formatting = "{0:N2}"; @@ -219,7 +219,7 @@ public class PartsCount : VesselEntry public PartsCount() { Name = "Parts"; - Description = ""; + Description = "Number of parts vessel is constructed of."; Category = MicroEntryCategory.Vessel; Unit = null; Formatting = null; @@ -238,7 +238,7 @@ public class TotalBurnTime : VesselEntry public TotalBurnTime() { Name = "Total Burn Time"; - Description = ""; + Description = "Burn Time vessel can sustain with 100% thrust."; Category = MicroEntryCategory.Vessel; Unit = "s"; Formatting = "{0:N0}"; @@ -266,7 +266,7 @@ public class StageISPActual : VesselEntry public StageISPActual() { Name = "ISP (Actual)"; - Description = ""; + Description = "Specific impulse (ISP) is a measure of how efficiently a reaction mass engine creates thrust."; Category = MicroEntryCategory.Vessel; Unit = "s"; Formatting = "{0:N0}"; @@ -285,7 +285,7 @@ public class StageISPAsl : VesselEntry public StageISPAsl() { Name = "ISP (ASL)"; - Description = ""; + Description = "Specific impulse At Sea Level."; Category = MicroEntryCategory.Vessel; Unit = "s"; Formatting = "{0:N0}"; @@ -304,7 +304,7 @@ public class StageISPVac : VesselEntry public StageISPVac() { Name = "ISP (Vacuum)"; - Description = ""; + Description = "Specific impulse in vacuum."; Category = MicroEntryCategory.Vessel; Unit = "s"; Formatting = "{0:N0}"; @@ -323,7 +323,7 @@ public class Throttle : VesselEntry public Throttle() { Name = "Throttle"; - Description = ""; + Description = "Vessel's current throttle in %."; Category = MicroEntryCategory.Vessel; Unit = "%"; Formatting = "{0:N0}"; @@ -342,7 +342,7 @@ public class FuelPercentage : VesselEntry public FuelPercentage() { Name = "Vessel Fuel"; - Description = ""; + Description = "Vessel's fuel percentage left."; Category = MicroEntryCategory.Vessel; Unit = "%"; Formatting = "{0:N1}"; @@ -361,7 +361,7 @@ public class StageFuelPercentage : VesselEntry public StageFuelPercentage() { Name = "Stage Fuel"; - Description = ""; + Description = "Stage fuel percentage left."; Category = MicroEntryCategory.Vessel; Unit = "%"; Formatting = "{0:N1}"; @@ -380,7 +380,7 @@ public class TotalCommandCrewCapacity : VesselEntry public TotalCommandCrewCapacity() { Name = "Command Crew Capacity"; - Description = ""; + Description = "Crew capacity of all parts."; Category = MicroEntryCategory.Vessel; Unit = null; Formatting = "{0:N0}"; diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 54eb879..a5e8f6c 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -434,7 +434,7 @@ private void FillMainGUI(int windowID) Logger.LogError(ex); } } - private int _selectedNode = 0; + /// /// Draws all windows that are toggled and popped out /// @@ -452,59 +452,6 @@ private void DrawPopoutWindow(int windowIndex) windowToDraw.DrawWindowFooter(); - // TEMP - MOVE SOMEWHERE ELSE WHEN DONE - /* - if (windowToDraw.Name == "Maneuver") - { - if (GUILayout.Button("Delete")) - { - // OLD - DOESN'T WORK - var activeVesselPlan2 = GameManager.Instance.Game.SpaceSimulation.Maneuvers.GetNodesForVessel(MicroUtility.ActiveVessel.GlobalId); - if (activeVesselPlan2 != null) - { - var node = activeVesselPlan2.FirstOrDefault(); - if (node != null) - { - - GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, new List { node }); - } - } - - // THIS WORKS! - var _activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); - List nodeData = new List(); - nodeData.Add(_activeVesselPlan.ActiveNode); - - foreach (ManeuverNodeData node in _activeVesselPlan.GetNodes()) - { - if (!nodeData.Contains(node) && (!_activeVesselPlan.ActiveNode.IsOnManeuverTrajectory || _activeVesselPlan.ActiveNode.Time < node.Time)) - nodeData.Add(node); - } - GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodeData); - - - - var _activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); - List nodeData = new List(); - - var nodeToDelete = _activeVesselPlan.GetNodes()[_selectedNode]; - nodeData.Add(nodeToDelete); - - foreach (ManeuverNodeData node in _activeVesselPlan.GetNodes()) - { - if (!nodeData.Contains(node) && (!nodeToDelete.IsOnManeuverTrajectory || nodeToDelete.Time < node.Time)) - nodeData.Add(node); - } - GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodeData); - - - - //this.RemoveNodesFromVessel(this._activeVesselPlan.ActiveNode.RelatedSimID, nodeData); - //this.NormalizedManeuverTime = ManeuverProvider.NORMALIZED_MANEUVER_BOUND; - } - }*/ - - // END TEMP DrawSectionEnd(windowToDraw); } private void DrawSettingsWindow(int windowIndex) diff --git a/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs b/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs index 8199274..c229df1 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs @@ -1,8 +1,6 @@ using KSP.Sim.impl; using KSP.Sim; using UnityEngine; -using static UnityEngine.GraphicsBuffer; -using System.Runtime.ConstrainedExecution; namespace MicroMod { @@ -115,4 +113,4 @@ private static bool CalculateParameters() return Math.Round(transfer, 1); } } -} +} \ No newline at end of file From dc6ff29ec6525752e575e9bef844c87ba142f011 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Fri, 21 Apr 2023 09:02:59 +0200 Subject: [PATCH 22/38] Rename MicroUtility to Utility --- .../MicroEngineer/Entries/BodyEntries.cs | 6 +- .../MicroEngineer/Entries/FlightEntries.cs | 24 ++--- .../MicroEngineer/Entries/ManeuverEntries.cs | 74 +++++++------- .../MicroEngineer/Entries/MicroEntries.cs | 2 +- .../MicroEngineer/Entries/MiscEntries.cs | 34 +++---- .../Entries/OabStageInfoEntries.cs | 14 +-- .../MicroEngineer/Entries/OrbitalEntries.cs | 54 +++++------ .../MicroEngineer/Entries/SurfaceEntries.cs | 38 ++++---- .../MicroEngineer/Entries/TargetEntries.cs | 90 ++++++++--------- .../MicroEngineer/Entries/VesselEntries.cs | 42 ++++---- .../MicroEngineer/MicroEngineerMod.cs | 96 +++++++++---------- .../MicroEngineer/Utilities/AeroForces.cs | 16 ++-- .../MicroEngineer/Utilities/TransferInfo.cs | 12 +-- .../Utilities/{MicroUtility.cs => Utility.cs} | 4 +- .../MicroEngineer/Windows/ManeuverWindow.cs | 8 +- 15 files changed, 257 insertions(+), 257 deletions(-) rename MicroEngineerProject/MicroEngineer/Utilities/{MicroUtility.cs => Utility.cs} (99%) diff --git a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs index a4a8502..d61e15e 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs @@ -17,7 +17,7 @@ public Body() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.mainBody.bodyName; + EntryValue = Utility.ActiveVessel.mainBody.bodyName; } public override string ValueDisplay => base.ValueDisplay; @@ -36,7 +36,7 @@ public ReferenceBodyConstants_Radius() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.Radius; + EntryValue = Utility.ActiveVessel.Orbit.ReferenceBodyConstants.Radius; } public override string ValueDisplay => base.ValueDisplay; @@ -55,7 +55,7 @@ public ReferenceBodyConstants_StandardGravitationParameter() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.ReferenceBodyConstants.StandardGravitationParameter; + EntryValue = Utility.ActiveVessel.Orbit.ReferenceBodyConstants.StandardGravitationParameter; } public override string ValueDisplay => base.ValueDisplay; diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index 2d07112..12ebf21 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -17,7 +17,7 @@ public Speed() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.SurfaceVelocity.magnitude; + EntryValue = Utility.ActiveVessel.SurfaceVelocity.magnitude; } public override string ValueDisplay => base.ValueDisplay; @@ -36,7 +36,7 @@ public MachNumber() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.MachNumber; + EntryValue = Utility.ActiveVessel.SimulationObject.Telemetry.MachNumber; } public override string ValueDisplay => base.ValueDisplay; @@ -55,7 +55,7 @@ public AtmosphericDensity() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.AtmosphericDensity; + EntryValue = Utility.ActiveVessel.SimulationObject.Telemetry.AtmosphericDensity; } public override string ValueDisplay => base.ValueDisplay; @@ -199,7 +199,7 @@ public DragCoefficient() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.DragCoefficient; + EntryValue = Utility.ActiveVessel.DragCoefficient; } public override string ValueDisplay => base.ValueDisplay; @@ -218,7 +218,7 @@ public ExposedArea() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.ExposedArea; + EntryValue = Utility.ActiveVessel.ExposedArea; } public override string ValueDisplay => base.ValueDisplay; @@ -237,7 +237,7 @@ public Heading() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Heading; + EntryValue = Utility.ActiveVessel.Heading; } public override string ValueDisplay => base.ValueDisplay; @@ -256,7 +256,7 @@ public Pitch_HorizonRelative() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Pitch_HorizonRelative; + EntryValue = Utility.ActiveVessel.Pitch_HorizonRelative; } public override string ValueDisplay => base.ValueDisplay; @@ -275,7 +275,7 @@ public Roll_HorizonRelative() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Roll_HorizonRelative; + EntryValue = Utility.ActiveVessel.Roll_HorizonRelative; } public override string ValueDisplay => base.ValueDisplay; @@ -294,7 +294,7 @@ public Yaw_HorizonRelative() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Yaw_HorizonRelative; + EntryValue = Utility.ActiveVessel.Yaw_HorizonRelative; } public override string ValueDisplay => base.ValueDisplay; @@ -313,7 +313,7 @@ public Zenith() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Zenith; + EntryValue = Utility.ActiveVessel.Zenith; } public override string ValueDisplay => base.ValueDisplay; @@ -332,7 +332,7 @@ public SoundSpeed() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.SoundSpeed; + EntryValue = Utility.ActiveVessel.SoundSpeed; } public override string ValueDisplay => base.ValueDisplay; @@ -351,7 +351,7 @@ public GeeForce() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.geeForce; + EntryValue = Utility.ActiveVessel.geeForce; } public override string ValueDisplay => base.ValueDisplay; diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index ccc2ede..989b549 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -22,7 +22,7 @@ public ProjectedAp() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .ApoapsisArl; @@ -44,7 +44,7 @@ public ProjectedPe() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .PeriapsisArl; @@ -66,10 +66,10 @@ public DeltaVRequired() public override void RefreshData() { - List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + List nodes = Utility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); EntryValue = (nodes == null || nodes.Count == 0) ? null : - (nodes.Count == 1) ? (MicroUtility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector - MicroUtility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut)).magnitude : + (nodes.Count == 1) ? (Utility.ActiveVessel.Orbiter.ManeuverPlanSolver.GetVelocityAfterFirstManeuver(out double ut).vector - Utility.ActiveVessel.Orbit.GetOrbitalVelocityAtUTZup(ut)).magnitude : (nodes.Count >= base.SelectedNodeIndex + 1) ? nodes[base.SelectedNodeIndex].BurnRequiredDV : null; } @@ -90,7 +90,7 @@ public ManeuverPrograde() public override void RefreshData() { - List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + List nodes = Utility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.BurnVector.z; } @@ -110,7 +110,7 @@ public ManeuverNormal() public override void RefreshData() { - List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + List nodes = Utility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.BurnVector.y; } @@ -130,7 +130,7 @@ public ManeuverRadial() public override void RefreshData() { - List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + List nodes = Utility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.BurnVector.x; } @@ -150,7 +150,7 @@ public TimeToNode() public override void RefreshData() { - List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + List nodes = Utility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.Time - GameManager.Instance.Game.UniverseModel.UniversalTime; } @@ -161,7 +161,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -179,7 +179,7 @@ public BurnTime() public override void RefreshData() { - List nodes = MicroUtility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); + List nodes = Utility.ActiveVessel?.SimulationObject?.FindComponent()?.GetNodes(); EntryValue = nodes?.ElementAtOrDefault(base.SelectedNodeIndex)?.BurnDuration; } @@ -190,7 +190,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -211,7 +211,7 @@ public Maneuver_EccentricAnomaly() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .EccentricAnomaly; @@ -242,7 +242,7 @@ public Maneuver_EndUT() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .EndUT; @@ -255,7 +255,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -273,7 +273,7 @@ public Maneuver_MeanAnomaly() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .MeanAnomaly; @@ -304,7 +304,7 @@ public Maneuver_ObT() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .ObT; @@ -317,7 +317,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -335,7 +335,7 @@ public Maneuver_ArgumentOfPeriapsis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .OrbitalElements.ArgumentOfPeriapsis; @@ -357,7 +357,7 @@ public Maneuver_Eccentricity() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .OrbitalElements.Eccentricity; @@ -379,7 +379,7 @@ public Maneuver_Inclination() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .OrbitalElements.Inclination; @@ -401,7 +401,7 @@ public Maneuver_LongitudeOfAscendingNode() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .OrbitalElements.LongitudeOfAscendingNode; @@ -423,7 +423,7 @@ public Maneuver_SemiMajorAxis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .OrbitalElements.SemiMajorAxis; @@ -445,7 +445,7 @@ public Maneuver_SemiMinorAxis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .SemiMinorAxis; @@ -467,7 +467,7 @@ public Maneuver_OrbitalEnergy() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .OrbitalEnergy; @@ -489,7 +489,7 @@ public Maneuver_SemiLatusRectum() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .SemiLatusRectum; @@ -511,7 +511,7 @@ public Maneuver_TimeToAp() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .TimeToAp; @@ -524,7 +524,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -542,7 +542,7 @@ public Maneuver_TimeToPe() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .TimeToPe; @@ -555,7 +555,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -573,7 +573,7 @@ public Maneuver_TrueAnomaly() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .TrueAnomaly; @@ -604,7 +604,7 @@ public Maneuver_UniversalTimeAtClosestApproach() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .UniversalTimeAtClosestApproach; @@ -617,7 +617,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -635,7 +635,7 @@ public Maneuver_UniversalTimeAtSoiEncounter() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .UniversalTimeAtSoiEncounter; @@ -648,7 +648,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -666,7 +666,7 @@ public Maneuver_OrbitPercent() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .orbitPercent * 100; @@ -688,7 +688,7 @@ public Maneuver_Period() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? .period; @@ -701,7 +701,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs index bd3bdc2..593ad09 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs @@ -53,7 +53,7 @@ public StageInfo() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo; } public override string ValueDisplay => base.ValueDisplay; diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs index a427407..2ecf609 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -31,7 +31,7 @@ public AutopilotStatus_IsEnabled() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.IsEnabled; + EntryValue = Utility.ActiveVessel.AutopilotStatus.IsEnabled; } public override string ValueDisplay => EntryValue != null ? (bool)EntryValue ? "Enabled" : "Disabled" : "-"; @@ -50,7 +50,7 @@ public AutopilotStatus_Mode() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.AutopilotStatus.Mode; + EntryValue = Utility.ActiveVessel.AutopilotStatus.Mode; } public override string ValueDisplay => EntryValue != null ? (AutopilotMode)EntryValue == AutopilotMode.StabilityAssist ? "Stability" : EntryValue.ToString() : null; @@ -69,7 +69,7 @@ public TimeSinceLaunch() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TimeSinceLaunch; + EntryValue = Utility.ActiveVessel.TimeSinceLaunch; } public override string ValueDisplay @@ -79,7 +79,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -97,7 +97,7 @@ public GravityForPos() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.gravityForPos.magnitude; + EntryValue = Utility.ActiveVessel.gravityForPos.magnitude; } public override string ValueDisplay => base.ValueDisplay; @@ -116,7 +116,7 @@ public LaunchTime() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.launchTime; + EntryValue = Utility.ActiveVessel.launchTime; } public override string ValueDisplay @@ -126,7 +126,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -144,7 +144,7 @@ public AltimeterMode() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.altimeterMode; + EntryValue = Utility.ActiveVessel.altimeterMode; } public override string ValueDisplay => EntryValue != null ? (AltimeterDisplayMode)EntryValue == AltimeterDisplayMode.SeaLevel ? "Sea Level" : (AltimeterDisplayMode)EntryValue == AltimeterDisplayMode.GroundLevel ? "Ground Level" : "-" : "-"; @@ -163,7 +163,7 @@ public SpeedMode() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.speedMode; + EntryValue = Utility.ActiveVessel.speedMode; } public override string ValueDisplay => base.ValueDisplay; @@ -182,7 +182,7 @@ public StartUT() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.StartUT; + EntryValue = Utility.ActiveVessel.Orbit.StartUT; } public override string ValueDisplay @@ -192,7 +192,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -210,7 +210,7 @@ public EndUT() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.EndUT; + EntryValue = Utility.ActiveVessel.Orbit.EndUT; } public override string ValueDisplay @@ -220,7 +220,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -238,7 +238,7 @@ public UniversalTimeAtClosestApproach() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtClosestApproach; + EntryValue = Utility.ActiveVessel.Orbit.UniversalTimeAtClosestApproach; } public override string ValueDisplay @@ -248,7 +248,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -266,7 +266,7 @@ public UniversalTimeAtSoiEncounter() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter; + EntryValue = Utility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter; } public override string ValueDisplay @@ -276,7 +276,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs index 99196eb..9c46c1f 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs @@ -24,7 +24,7 @@ public TotalBurnTime_OAB() public override void RefreshData() { - EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalBurnTime; + EntryValue = Utility.VesselDeltaVComponentOAB?.TotalBurnTime; } public override string ValueDisplay @@ -35,7 +35,7 @@ public override string ValueDisplay return "-"; if (UseDHMSFormatting) - return MicroUtility.SecondsToTimeString((double)EntryValue); + return Utility.SecondsToTimeString((double)EntryValue); else return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); } @@ -54,7 +54,7 @@ public TotalDeltaVASL_OAB() } public override void RefreshData() { - EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalDeltaVASL; + EntryValue = Utility.VesselDeltaVComponentOAB?.TotalDeltaVASL; } public override string ValueDisplay => base.ValueDisplay; @@ -72,7 +72,7 @@ public TotalDeltaVActual_OAB() } public override void RefreshData() { - EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalDeltaVActual; + EntryValue = Utility.VesselDeltaVComponentOAB?.TotalDeltaVActual; } public override string ValueDisplay => base.ValueDisplay; @@ -90,7 +90,7 @@ public TotalDeltaVVac_OAB() } public override void RefreshData() { - EntryValue = MicroUtility.VesselDeltaVComponentOAB?.TotalDeltaVVac; + EntryValue = Utility.VesselDeltaVComponentOAB?.TotalDeltaVVac; } public override string ValueDisplay => base.ValueDisplay; @@ -180,9 +180,9 @@ public override void RefreshData() ((List)EntryValue).Clear(); - if (MicroUtility.VesselDeltaVComponentOAB?.StageInfo == null) return; + if (Utility.VesselDeltaVComponentOAB?.StageInfo == null) return; - foreach (var stage in MicroUtility.VesselDeltaVComponentOAB.StageInfo) + foreach (var stage in Utility.VesselDeltaVComponentOAB.StageInfo) { ((List)EntryValue).Add(new DeltaVStageInfo_OAB { diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 30373af..ea1aaf7 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -19,7 +19,7 @@ public Apoapsis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.ApoapsisArl; + EntryValue = Utility.ActiveVessel.Orbit.ApoapsisArl; } public override string ValueDisplay => base.ValueDisplay; @@ -38,7 +38,7 @@ public TimeToApoapsis() public override void RefreshData() { - EntryValue = (MicroUtility.ActiveVessel.Situation == VesselSituations.Landed || MicroUtility.ActiveVessel.Situation == VesselSituations.PreLaunch) ? 0f : MicroUtility.ActiveVessel.Orbit.TimeToAp; + EntryValue = (Utility.ActiveVessel.Situation == VesselSituations.Landed || Utility.ActiveVessel.Situation == VesselSituations.PreLaunch) ? 0f : Utility.ActiveVessel.Orbit.TimeToAp; } public override string ValueDisplay @@ -48,7 +48,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -66,7 +66,7 @@ public Periapsis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.PeriapsisArl; + EntryValue = Utility.ActiveVessel.Orbit.PeriapsisArl; } public override string ValueDisplay => base.ValueDisplay; @@ -85,7 +85,7 @@ public TimeToPeriapsis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.TimeToPe; + EntryValue = Utility.ActiveVessel.Orbit.TimeToPe; } public override string ValueDisplay @@ -95,7 +95,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -113,7 +113,7 @@ public Inclination() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.inclination; + EntryValue = Utility.ActiveVessel.Orbit.inclination; } public override string ValueDisplay => base.ValueDisplay; @@ -132,7 +132,7 @@ public Eccentricity() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.eccentricity; + EntryValue = Utility.ActiveVessel.Orbit.eccentricity; } public override string ValueDisplay => base.ValueDisplay; @@ -151,7 +151,7 @@ public Period() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.period; + EntryValue = Utility.ActiveVessel.Orbit.period; } public override string ValueDisplay @@ -161,7 +161,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -179,7 +179,7 @@ public SoiTransition() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter - GameManager.Instance.Game.UniverseModel.UniversalTime; + EntryValue = Utility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter - GameManager.Instance.Game.UniverseModel.UniversalTime; } public override string ValueDisplay @@ -189,7 +189,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return (double)EntryValue >= 0 ? MicroUtility.SecondsToTimeString((double)EntryValue) : "-"; + return (double)EntryValue >= 0 ? Utility.SecondsToTimeString((double)EntryValue) : "-"; } } } @@ -207,7 +207,7 @@ public OrbitalSpeed() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.OrbitalSpeed; + EntryValue = Utility.ActiveVessel.OrbitalSpeed; } public override string ValueDisplay => base.ValueDisplay; @@ -226,7 +226,7 @@ public EccentricAnomaly() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.EccentricAnomaly; + EntryValue = Utility.ActiveVessel.Orbit.EccentricAnomaly; } public override string ValueDisplay @@ -254,7 +254,7 @@ public MeanAnomaly() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.MeanAnomaly; + EntryValue = Utility.ActiveVessel.Orbit.MeanAnomaly; } public override string ValueDisplay @@ -282,7 +282,7 @@ public TrueAnomaly() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.TrueAnomaly; + EntryValue = Utility.ActiveVessel.Orbit.TrueAnomaly; } public override string ValueDisplay @@ -292,7 +292,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.RadiansToDegrees((double)EntryValue)); + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, Utility.RadiansToDegrees((double)EntryValue)); } } } @@ -310,7 +310,7 @@ public ObT() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.ObT; + EntryValue = Utility.ActiveVessel.Orbit.ObT; } public override string ValueDisplay @@ -320,7 +320,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -338,7 +338,7 @@ public ArgumentOfPeriapsis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.ArgumentOfPeriapsis; + EntryValue = Utility.ActiveVessel.Orbit.OrbitalElements.ArgumentOfPeriapsis; } public override string ValueDisplay => base.ValueDisplay; @@ -357,7 +357,7 @@ public LongitudeOfAscendingNode() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.LongitudeOfAscendingNode; + EntryValue = Utility.ActiveVessel.Orbit.OrbitalElements.LongitudeOfAscendingNode; } public override string ValueDisplay => base.ValueDisplay; @@ -376,7 +376,7 @@ public SemiMajorAxis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalElements.SemiMajorAxis; + EntryValue = Utility.ActiveVessel.Orbit.OrbitalElements.SemiMajorAxis; } public override string ValueDisplay => base.ValueDisplay; @@ -395,7 +395,7 @@ public SemiMinorAxis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.SemiMinorAxis; + EntryValue = Utility.ActiveVessel.Orbit.SemiMinorAxis; } public override string ValueDisplay => base.ValueDisplay; @@ -414,7 +414,7 @@ public OrbitalEnergy() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.OrbitalEnergy / 1000.0; + EntryValue = Utility.ActiveVessel.Orbit.OrbitalEnergy / 1000.0; } public override string ValueDisplay => base.ValueDisplay; @@ -433,7 +433,7 @@ public SemiLatusRectum() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.SemiLatusRectum; + EntryValue = Utility.ActiveVessel.Orbit.SemiLatusRectum; } public override string ValueDisplay => base.ValueDisplay; @@ -452,7 +452,7 @@ public OrbitPercent() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.orbitPercent * 100; + EntryValue = Utility.ActiveVessel.Orbit.orbitPercent * 100; } public override string ValueDisplay => base.ValueDisplay; @@ -471,7 +471,7 @@ public OrbitRadius() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbit.radius; + EntryValue = Utility.ActiveVessel.Orbit.radius; } public override string ValueDisplay => base.ValueDisplay; diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index c98d76a..e7dcd82 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -19,7 +19,7 @@ public Situation() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Situation; + EntryValue = Utility.ActiveVessel.Situation; } public override string ValueDisplay @@ -29,7 +29,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.SituationToString((VesselSituations)EntryValue); + return Utility.SituationToString((VesselSituations)EntryValue); } } } @@ -46,8 +46,8 @@ public Latitude() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Latitude; - Unit = MicroUtility.ActiveVessel.Latitude < 0 ? "S" : "N"; + EntryValue = Utility.ActiveVessel.Latitude; + Unit = Utility.ActiveVessel.Latitude < 0 ? "S" : "N"; } public override string ValueDisplay @@ -57,7 +57,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.DegreesToDMS((double)EntryValue); + return Utility.DegreesToDMS((double)EntryValue); } } } @@ -74,8 +74,8 @@ public Longitude() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Longitude; - Unit = MicroUtility.ActiveVessel.Longitude < 0 ? "W" : "E"; + EntryValue = Utility.ActiveVessel.Longitude; + Unit = Utility.ActiveVessel.Longitude < 0 ? "W" : "E"; } public override string ValueDisplay @@ -85,7 +85,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.DegreesToDMS((double)EntryValue); + return Utility.DegreesToDMS((double)EntryValue); } } } @@ -103,7 +103,7 @@ public Biome() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.SimulationObject.Telemetry.SurfaceBiome; + EntryValue = Utility.ActiveVessel.SimulationObject.Telemetry.SurfaceBiome; } public override string ValueDisplay @@ -113,7 +113,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return MicroUtility.BiomeToString((BiomeSurfaceData)EntryValue); + return Utility.BiomeToString((BiomeSurfaceData)EntryValue); } } } @@ -131,7 +131,7 @@ public AltitudeAsl() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.AltitudeFromSeaLevel; + EntryValue = Utility.ActiveVessel.AltitudeFromSeaLevel; } public override string ValueDisplay => base.ValueDisplay; @@ -150,7 +150,7 @@ public AltitudeAgl() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.AltitudeFromTerrain; + EntryValue = Utility.ActiveVessel.AltitudeFromTerrain; } public override string ValueDisplay => base.ValueDisplay; @@ -169,7 +169,7 @@ public AltitudeFromScenery() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.AltitudeFromScenery; + EntryValue = Utility.ActiveVessel.AltitudeFromScenery; } public override string ValueDisplay => base.ValueDisplay; @@ -188,7 +188,7 @@ public HorizontalVelocity() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.HorizontalSrfSpeed; + EntryValue = Utility.ActiveVessel.HorizontalSrfSpeed; } public override string ValueDisplay => base.ValueDisplay; @@ -207,7 +207,7 @@ public VerticalVelocity() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VerticalSrfSpeed; + EntryValue = Utility.ActiveVessel.VerticalSrfSpeed; } public override string ValueDisplay => base.ValueDisplay; @@ -226,7 +226,7 @@ public AtmosphericTemperature() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.AtmosphericTemperature; + EntryValue = Utility.ActiveVessel.AtmosphericTemperature; } public override string ValueDisplay => base.ValueDisplay; @@ -245,7 +245,7 @@ public ExternalTemperature() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.ExternalTemperature; + EntryValue = Utility.ActiveVessel.ExternalTemperature; } public override string ValueDisplay => base.ValueDisplay; @@ -264,7 +264,7 @@ public DynamicPressure_kPa() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.DynamicPressure_kPa; + EntryValue = Utility.ActiveVessel.DynamicPressure_kPa; } public override string ValueDisplay => base.ValueDisplay; @@ -283,7 +283,7 @@ public StaticPressure_kPa() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.StaticPressure_kPa; + EntryValue = Utility.ActiveVessel.StaticPressure_kPa; } public override string ValueDisplay => base.ValueDisplay; diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 0f113b8..9f9b72f 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -18,7 +18,7 @@ public TargetApoapsis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.ApoapsisArl; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.ApoapsisArl; } public override string ValueDisplay => base.ValueDisplay; @@ -37,7 +37,7 @@ public TargetPeriapsis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.PeriapsisArl; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.PeriapsisArl; } public override string ValueDisplay => base.ValueDisplay; @@ -56,7 +56,7 @@ public DistanceToTarget() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit != null ? (MicroUtility.ActiveVessel.Orbit.Position - MicroUtility.ActiveVessel.TargetObject.Orbit.Position).magnitude : null; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit != null ? (Utility.ActiveVessel.Orbit.Position - Utility.ActiveVessel.TargetObject.Orbit.Position).magnitude : null; } public override string ValueDisplay @@ -67,7 +67,7 @@ public override string ValueDisplay return "-"; // return value only if vessel and target are in the same SOI - return MicroUtility.ActiveVessel.Orbit.referenceBody == MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody ? + return Utility.ActiveVessel.Orbit.referenceBody == Utility.ActiveVessel.TargetObject.Orbit.referenceBody ? String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue) : "-"; } } @@ -86,7 +86,7 @@ public RelativeSpeed() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit != null ? (MicroUtility.ActiveVessel.Orbit.relativeVelocity - MicroUtility.ActiveVessel.TargetObject.Orbit.relativeVelocity).magnitude : null; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit != null ? (Utility.ActiveVessel.Orbit.relativeVelocity - Utility.ActiveVessel.TargetObject.Orbit.relativeVelocity).magnitude : null; } public override string ValueDisplay @@ -97,7 +97,7 @@ public override string ValueDisplay return "-"; // return value only if vessel and target are in the same SOI - if (MicroUtility.ActiveVessel.Orbit.referenceBody != MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody) + if (Utility.ActiveVessel.Orbit.referenceBody != Utility.ActiveVessel.TargetObject.Orbit.referenceBody) return "-"; return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); @@ -118,7 +118,7 @@ public RelativeInclination() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.AscendingNodeTarget.Inclination; + EntryValue = Utility.ActiveVessel.Orbiter?.OrbitTargeter?.AscendingNodeTarget.Inclination; } public override string ValueDisplay @@ -129,7 +129,7 @@ public override string ValueDisplay return "-"; // return value only if vessel and target are in the same SOI - if (MicroUtility.ActiveVessel.Orbit.referenceBody != MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody) + if (Utility.ActiveVessel.Orbit.referenceBody != Utility.ActiveVessel.TargetObject?.Orbit?.referenceBody) return "-"; return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); @@ -150,7 +150,7 @@ public Target_AltitudeFromSeaLevel() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.AltitudeFromSeaLevel; + EntryValue = Utility.ActiveVessel.TargetObject?.AltitudeFromSeaLevel; } public override string ValueDisplay => base.ValueDisplay; @@ -169,7 +169,7 @@ public Target_Name() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.DisplayName; + EntryValue = Utility.ActiveVessel.TargetObject?.DisplayName; } public override string ValueDisplay => base.ValueDisplay; @@ -188,7 +188,7 @@ public Target_EccentricAnomaly() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.EccentricAnomaly; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.EccentricAnomaly; } public override string ValueDisplay @@ -216,7 +216,7 @@ public Target_MeanAnomaly() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.MeanAnomaly; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.MeanAnomaly; } public override string ValueDisplay @@ -244,7 +244,7 @@ public Target_ObT() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.ObT; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.ObT; } public override string ValueDisplay @@ -254,7 +254,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -272,7 +272,7 @@ public Target_ArgumentOfPeriapsis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.argumentOfPeriapsis; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.argumentOfPeriapsis; } public override string ValueDisplay => base.ValueDisplay; @@ -291,7 +291,7 @@ public Target_Eccentricity() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.eccentricity; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.eccentricity; } public override string ValueDisplay => base.ValueDisplay; @@ -310,7 +310,7 @@ public Target_Inclination() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.inclination; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.inclination; } public override string ValueDisplay => base.ValueDisplay; @@ -329,7 +329,7 @@ public Target_LongitudeOfAscendingNode() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.longitudeOfAscendingNode; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.longitudeOfAscendingNode; } public override string ValueDisplay => base.ValueDisplay; @@ -348,7 +348,7 @@ public Target_SemiMajorAxis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.semiMajorAxis; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.semiMajorAxis; } public override string ValueDisplay => base.ValueDisplay; @@ -367,7 +367,7 @@ public Target_ReferenceBodyConstants_Radius() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.radius; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.radius; } public override string ValueDisplay => base.ValueDisplay; @@ -386,7 +386,7 @@ public Target_ReferenceBodyConstants_StandardGravitationParameter() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.gravParameter; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.gravParameter; } public override string ValueDisplay => base.ValueDisplay; @@ -405,7 +405,7 @@ public Target_SemiLatusRectum() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.SemiLatusRectum; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.SemiLatusRectum; } public override string ValueDisplay => base.ValueDisplay; @@ -424,7 +424,7 @@ public Target_SemiMinorAxis() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.SemiMinorAxis; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.SemiMinorAxis; } public override string ValueDisplay => base.ValueDisplay; @@ -443,7 +443,7 @@ public Target_TrueAnomaly() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.TrueAnomaly; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.TrueAnomaly; } public override string ValueDisplay @@ -453,7 +453,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.RadiansToDegrees((double)EntryValue)); + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, Utility.RadiansToDegrees((double)EntryValue)); } } } @@ -471,7 +471,7 @@ public Target_Period() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.period; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.period; } public override string ValueDisplay @@ -481,7 +481,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -499,7 +499,7 @@ public Target_OrbitRadius() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.Orbit?.radius; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.radius; } public override string ValueDisplay => base.ValueDisplay; @@ -518,7 +518,7 @@ public Target_Obtvelocity() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TargetObject?.ObtVelocity.magnitude; + EntryValue = Utility.ActiveVessel.TargetObject?.ObtVelocity.magnitude; } public override string ValueDisplay => base.ValueDisplay; @@ -537,9 +537,9 @@ public DistanceAtCloseApproach1() public override void RefreshData() { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; + bool? isValid = Utility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; - EntryValue = isValid != null && isValid == true ? MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeDistance : null; + EntryValue = isValid != null && isValid == true ? Utility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeDistance : null; } public override string ValueDisplay => base.ValueDisplay; @@ -558,9 +558,9 @@ public TimeToCloseApproach1() public override void RefreshData() { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; + bool? isValid = Utility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.UniversalTime - MicroUtility.UniversalTime : null; + EntryValue = isValid != null && isValid == true ? EntryValue = Utility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.UniversalTime - Utility.UniversalTime : null; } public override string ValueDisplay @@ -570,7 +570,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -588,9 +588,9 @@ public RelativeSpeedAtCloseApproach1() public override void RefreshData() { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; + bool? isValid = Utility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect1Target?.IsValid; - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeSpeed : null; + EntryValue = isValid != null && isValid == true ? EntryValue = Utility.ActiveVessel.Orbiter.OrbitTargeter.Intersect1Target.RelativeSpeed : null; } public override string ValueDisplay => base.ValueDisplay; @@ -609,9 +609,9 @@ public DistanceAtCloseApproach2() public override void RefreshData() { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; + bool? isValid = Utility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeDistance : null; + EntryValue = isValid != null && isValid == true ? EntryValue = Utility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeDistance : null; } public override string ValueDisplay => base.ValueDisplay; @@ -630,9 +630,9 @@ public TimeToCloseApproach2() public override void RefreshData() { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; + bool? isValid = Utility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.UniversalTime - MicroUtility.UniversalTime : null; + EntryValue = isValid != null && isValid == true ? EntryValue = Utility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.UniversalTime - Utility.UniversalTime : null; } public override string ValueDisplay @@ -642,7 +642,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? MicroUtility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -660,9 +660,9 @@ public RelativeSpeedAtCloseApproach2() public override void RefreshData() { - bool? isValid = MicroUtility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; + bool? isValid = Utility.ActiveVessel.Orbiter?.OrbitTargeter?.Intersect2Target?.IsValid; - EntryValue = isValid != null && isValid == true ? EntryValue = MicroUtility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeSpeed : null; + EntryValue = isValid != null && isValid == true ? EntryValue = Utility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeSpeed : null; } public override string ValueDisplay => base.ValueDisplay; @@ -681,7 +681,7 @@ public PhaseAngle() public override void RefreshData() { - EntryValue = MicroUtility.TargetExists() ? TransferInfo.GetPhaseAngle() : null; + EntryValue = Utility.TargetExists() ? TransferInfo.GetPhaseAngle() : null; } public override string ValueDisplay => base.ValueDisplay; @@ -700,7 +700,7 @@ public TransferAngle() public override void RefreshData() { - EntryValue = MicroUtility.TargetExists() ? TransferInfo.GetTransferAngle() : null; + EntryValue = Utility.TargetExists() ? TransferInfo.GetTransferAngle() : null; } public override string ValueDisplay => base.ValueDisplay; diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index ecf092b..aae52e2 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -17,7 +17,7 @@ public VesselName() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.DisplayName; + EntryValue = Utility.ActiveVessel.DisplayName; } public override string ValueDisplay => EntryValue?.ToString(); @@ -36,7 +36,7 @@ public Mass() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.totalMass * 1000; + EntryValue = Utility.ActiveVessel.totalMass * 1000; } public override string ValueDisplay => base.ValueDisplay; @@ -55,7 +55,7 @@ public TotalDeltaVActual() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVActual; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.TotalDeltaVActual; } public override string ValueDisplay => base.ValueDisplay; @@ -74,7 +74,7 @@ public TotalDeltaVASL() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVASL; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.TotalDeltaVASL; } public override string ValueDisplay => base.ValueDisplay; @@ -94,7 +94,7 @@ public TotalDeltaVVac() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalDeltaVVac; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.TotalDeltaVVac; } public override string ValueDisplay => base.ValueDisplay; @@ -113,7 +113,7 @@ public StageThrustActual() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustActual * 1000; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustActual * 1000; } public override string ValueDisplay => base.ValueDisplay; @@ -132,7 +132,7 @@ public StageThrustASL() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.ThrustASL * 1000; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.ThrustASL * 1000; } public override string ValueDisplay => base.ValueDisplay; @@ -151,7 +151,7 @@ public StageThrustVac() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.ThrustVac * 1000; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.ThrustVac * 1000; } public override string ValueDisplay => base.ValueDisplay; @@ -170,7 +170,7 @@ public StageTWRActual() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRActual; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.TWRActual; } public override string ValueDisplay => base.ValueDisplay; @@ -189,7 +189,7 @@ public StageTWRASL() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.TWRASL; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.TWRASL; } public override string ValueDisplay => base.ValueDisplay; @@ -208,7 +208,7 @@ public StageTWRVac() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.TWRVac; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.TWRVac; } public override string ValueDisplay => base.ValueDisplay; @@ -227,7 +227,7 @@ public PartsCount() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.PartInfo?.Count; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.PartInfo?.Count; } public override string ValueDisplay => base.ValueDisplay; @@ -246,7 +246,7 @@ public TotalBurnTime() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.TotalBurnTime; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.TotalBurnTime; } public override string ValueDisplay @@ -256,7 +256,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, MicroUtility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } @@ -274,7 +274,7 @@ public StageISPActual() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.IspActual; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.IspActual; } public override string ValueDisplay => base.ValueDisplay; @@ -293,7 +293,7 @@ public StageISPAsl() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.IspASL; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.IspASL; } public override string ValueDisplay => base.ValueDisplay; @@ -312,7 +312,7 @@ public StageISPVac() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.IspVac; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo?.FirstOrDefault()?.IspVac; } public override string ValueDisplay => base.ValueDisplay; @@ -331,7 +331,7 @@ public Throttle() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.flightCtrlState.mainThrottle * 100; + EntryValue = Utility.ActiveVessel.flightCtrlState.mainThrottle * 100; } public override string ValueDisplay => base.ValueDisplay; @@ -350,7 +350,7 @@ public FuelPercentage() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.FuelPercentage; + EntryValue = Utility.ActiveVessel.FuelPercentage; } public override string ValueDisplay => base.ValueDisplay; @@ -369,7 +369,7 @@ public StageFuelPercentage() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.StageFuelPercentage; + EntryValue = Utility.ActiveVessel.StageFuelPercentage; } public override string ValueDisplay => base.ValueDisplay; @@ -388,7 +388,7 @@ public TotalCommandCrewCapacity() public override void RefreshData() { - EntryValue = MicroUtility.ActiveVessel.TotalCommandCrewCapacity; + EntryValue = Utility.ActiveVessel.TotalCommandCrewCapacity; } public override string ValueDisplay => base.ValueDisplay; diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index a5e8f6c..21fa9b4 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -59,7 +59,7 @@ public override void OnInitialized() InitializeCelestialBodies(); // Load window positions and states from disk, if file exists - MicroUtility.LoadLayout(MicroWindows); + Utility.LoadLayout(MicroWindows); BackwardCompatibilityInitializations(); @@ -94,7 +94,7 @@ private void BackwardCompatibilityInitializations() InitializeStageInfoOABWindow(); // Preserve backward compatibility with SpaceWarp 1.0.1 - if (MicroUtility.IsModOlderThan("SpaceWarp", 1, 1, 0)) + if (Utility.IsModOlderThan("SpaceWarp", 1, 1, 0)) { Logger.LogInfo("Space Warp older version detected. Loading old Styles."); Styles.SetStylesForOldSpaceWarpSkin(); @@ -107,7 +107,7 @@ private void BackwardCompatibilityInitializations() if (stageOabWindow.Entries.Find(e => e.Name == "Torque") == null) { stageOabWindow.Entries.Add(this.MicroEntries.Find(e => e.Name == "Torque")); - MicroUtility.SaveLayout(this.MicroWindows); + Utility.SaveLayout(this.MicroWindows); } } @@ -116,22 +116,22 @@ private void BackwardCompatibilityInitializations() /// private void SubscribeToMessages() { - MicroUtility.RefreshGameManager(); + Utility.RefreshGameManager(); // While in OAB we use the VesselDeltaVCalculationMessage event to refresh data as it's triggered a lot less frequently than Update() - MicroUtility.MessageCenter.Subscribe(new Action(this.RefreshStagingDataOAB)); + Utility.MessageCenter.Subscribe(new Action(this.RefreshStagingDataOAB)); // We are loading layout state when entering Flight or OAB game state - MicroUtility.MessageCenter.Subscribe(new Action(this.GameStateEntered)); + Utility.MessageCenter.Subscribe(new Action(this.GameStateEntered)); // We are saving layout state when exiting from Flight or OAB game state - MicroUtility.MessageCenter.Subscribe(new Action(this.GameStateLeft)); + Utility.MessageCenter.Subscribe(new Action(this.GameStateLeft)); // Sets the selected node index to the newly created node - MicroUtility.MessageCenter.Subscribe(new Action(this.OnManeuverCreatedMessage)); + Utility.MessageCenter.Subscribe(new Action(this.OnManeuverCreatedMessage)); // Resets node index - MicroUtility.MessageCenter.Subscribe(new Action(this.OnManeuverRemovedMessage)); + Utility.MessageCenter.Subscribe(new Action(this.OnManeuverRemovedMessage)); } private void OnManeuverCreatedMessage(MessageCenterMessage message) @@ -150,15 +150,15 @@ private void GameStateEntered(MessageCenterMessage obj) { Logger.LogInfo("Message triggered: GameStateEnteredMessage"); - MicroUtility.RefreshGameManager(); - if (MicroUtility.GameState.GameState == GameState.FlightView || MicroUtility.GameState.GameState == GameState.VehicleAssemblyBuilder || MicroUtility.GameState.GameState == GameState.Map3DView) + Utility.RefreshGameManager(); + if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView) { - MicroUtility.LoadLayout(MicroWindows); + Utility.LoadLayout(MicroWindows); - if(MicroUtility.GameState.GameState == GameState.FlightView || MicroUtility.GameState.GameState == GameState.Map3DView) + if(Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) _showGuiFlight = MicroWindows.Find(w => w.MainWindow == MainWindow.MainGui).IsFlightActive; - if(MicroUtility.GameState.GameState == GameState.VehicleAssemblyBuilder) + if(Utility.GameState.GameState == GameState.VehicleAssemblyBuilder) { _showGuiOAB = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive; InitializeCelestialBodies(); @@ -171,15 +171,15 @@ private void GameStateLeft(MessageCenterMessage obj) { Logger.LogInfo("Message triggered: GameStateLeftMessage"); - MicroUtility.RefreshGameManager(); - if (MicroUtility.GameState.GameState == GameState.FlightView || MicroUtility.GameState.GameState == GameState.VehicleAssemblyBuilder || MicroUtility.GameState.GameState == GameState.Map3DView) + Utility.RefreshGameManager(); + if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView) { - MicroUtility.SaveLayout(MicroWindows); + Utility.SaveLayout(MicroWindows); - if (MicroUtility.GameState.GameState == GameState.FlightView || MicroUtility.GameState.GameState == GameState.Map3DView) + if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) _showGuiFlight = false; - if (MicroUtility.GameState.GameState == GameState.VehicleAssemblyBuilder) + if (Utility.GameState.GameState == GameState.VehicleAssemblyBuilder) _showGuiOAB = false; } } @@ -194,14 +194,14 @@ private void RefreshStagingDataOAB(MessageCenterMessage obj) VesselDeltaVCalculationMessage msg = (VesselDeltaVCalculationMessage)obj; if (msg.DeltaVComponent.Ship == null || !msg.DeltaVComponent.Ship.IsLaunchAssembly()) return; - MicroUtility.RefreshGameManager(); - if (MicroUtility.GameState.GameState != GameState.VehicleAssemblyBuilder) return; + Utility.RefreshGameManager(); + if (Utility.GameState.GameState != GameState.VehicleAssemblyBuilder) return; - MicroUtility.RefreshStagesOAB(); + Utility.RefreshStagesOAB(); BaseWindow stageWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); - if (MicroUtility.VesselDeltaVComponentOAB?.StageInfo == null) + if (Utility.VesselDeltaVComponentOAB?.StageInfo == null) { stageWindow.Entries.Find(e => e.Name == "Stage Info (OAB)").EntryValue = null; return; @@ -213,10 +213,10 @@ private void RefreshStagingDataOAB(MessageCenterMessage obj) public void Update() { - MicroUtility.RefreshGameManager(); + Utility.RefreshGameManager(); // Perform OAB updates only if we're in OAB - if (MicroUtility.GameState != null && MicroUtility.GameState.IsObjectAssembly) + if (Utility.GameState != null && Utility.GameState.IsObjectAssembly) { // Do updates every 1 sec if (Time.time - _lastUpdate > 1) @@ -230,11 +230,11 @@ public void Update() } // Perform flight UI updates only if we're in Flight or Map view - if (MicroUtility.GameState != null && (MicroUtility.GameState.GameState == GameState.FlightView || MicroUtility.GameState.GameState == GameState.Map3DView)) + if (Utility.GameState != null && (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView)) { - MicroUtility.RefreshActiveVesselAndCurrentManeuver(); + Utility.RefreshActiveVesselAndCurrentManeuver(); - if (MicroUtility.ActiveVessel == null) + if (Utility.ActiveVessel == null) return; // Refresh all active windows' entries @@ -248,8 +248,8 @@ private void OnGUI() { GUI.skin = Styles.SpaceWarpUISkin; - MicroUtility.RefreshGameManager(); - if (MicroUtility.GameState?.GameState == GameState.VehicleAssemblyBuilder) + Utility.RefreshGameManager(); + if (Utility.GameState?.GameState == GameState.VehicleAssemblyBuilder) OnGUI_OAB(); else OnGUI_Flight(); @@ -258,9 +258,9 @@ private void OnGUI() #region Flight scene UI and logic private void OnGUI_Flight() { - _gameInputState = MicroUtility.ToggleGameInputOnControlInFocus(_gameInputState, _showGuiFlight); + _gameInputState = Utility.ToggleGameInputOnControlInFocus(_gameInputState, _showGuiFlight); - if (!_showGuiFlight || MicroUtility.ActiveVessel == null) return; + if (!_showGuiFlight || Utility.ActiveVessel == null) return; BaseWindow mainGui = MicroWindows.Find(window => window.MainWindow == MainWindow.MainGui); @@ -273,7 +273,7 @@ private void OnGUI_Flight() Styles.MainWindowStyle, GUILayout.Height(0) ); - mainGui.FlightRect.position = MicroUtility.ClampToScreen(mainGui.FlightRect.position, mainGui.FlightRect.size); + mainGui.FlightRect.position = Utility.ClampToScreen(mainGui.FlightRect.position, mainGui.FlightRect.size); // Draw all other popped out windows foreach (var (window, index) in MicroWindows @@ -282,11 +282,11 @@ private void OnGUI_Flight() .Where(x => x.window.MainWindow != MainWindow.Settings && x.window.MainWindow != MainWindow.Stage && x.window.MainWindow != MainWindow.MainGui)) // MainGUI, Settings and Stage are special, they'll be drawn separately { // Skip drawing of Target window if there's no active target - if (window.MainWindow == MainWindow.Target && !MicroUtility.TargetExists()) + if (window.MainWindow == MainWindow.Target && !Utility.TargetExists()) continue; // Skip drawing of Maneuver window if there's no active maneuver - if (window.MainWindow == MainWindow.Maneuver && !MicroUtility.ManeuverExists()) + if (window.MainWindow == MainWindow.Maneuver && !Utility.ManeuverExists()) continue; // If window is locked set alpha to 80% @@ -307,7 +307,7 @@ private void OnGUI_Flight() if (window.IsLocked) GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1); - window.FlightRect.position = MicroUtility.ClampToScreen(window.FlightRect.position, window.FlightRect.size); + window.FlightRect.position = Utility.ClampToScreen(window.FlightRect.position, window.FlightRect.size); } // Draw popped out Settings @@ -324,7 +324,7 @@ private void OnGUI_Flight() GUILayout.Width(Styles.WindowWidth) ); - MicroWindows[settingsIndex].FlightRect.position = MicroUtility.ClampToScreen(MicroWindows[settingsIndex].FlightRect.position, MicroWindows[settingsIndex].FlightRect.size); + MicroWindows[settingsIndex].FlightRect.position = Utility.ClampToScreen(MicroWindows[settingsIndex].FlightRect.position, MicroWindows[settingsIndex].FlightRect.size); } // Draw popped out Stages @@ -341,7 +341,7 @@ private void OnGUI_Flight() GUILayout.Width(Styles.WindowWidth) ); - MicroWindows[stageIndex].FlightRect.position = MicroUtility.ClampToScreen(MicroWindows[stageIndex].FlightRect.position, MicroWindows[stageIndex].FlightRect.size); + MicroWindows[stageIndex].FlightRect.position = Utility.ClampToScreen(MicroWindows[stageIndex].FlightRect.position, MicroWindows[stageIndex].FlightRect.size); } // Draw Edit Window @@ -408,11 +408,11 @@ private void FillMainGUI(int windowID) { // Skip drawing of Target window if there's no active target - if (window.MainWindow == MainWindow.Target && !MicroUtility.TargetExists()) + if (window.MainWindow == MainWindow.Target && !Utility.TargetExists()) continue; // Skip drawing of Maneuver window if there's no active maneuver - if (window.MainWindow == MainWindow.Maneuver && !MicroUtility.ManeuverExists()) + if (window.MainWindow == MainWindow.Maneuver && !Utility.ManeuverExists()) continue; DrawSectionHeader(window.Name, ref window.IsFlightPoppedOut, window.IsLocked, ""); @@ -463,10 +463,10 @@ private void DrawSettingsWindow(int windowIndex) GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("SAVE LAYOUT", Styles.NormalBtnStyle)) - MicroUtility.SaveLayout(MicroWindows); + Utility.SaveLayout(MicroWindows); GUILayout.Space(5); if (GUILayout.Button("LOAD LAYOUT", Styles.NormalBtnStyle)) - MicroUtility.LoadLayout(MicroWindows); + Utility.LoadLayout(MicroWindows); GUILayout.Space(5); if (GUILayout.Button("RESET", Styles.NormalBtnStyle)) ResetLayout(); @@ -581,7 +581,7 @@ private void DrawStageEntry(int stageID, DeltaVStageInfo stageInfo, string twrFo GUILayout.Space(16); GUILayout.Label($"{stageInfo.TWRActual.ToString(twrFormatString)}", Styles.ValueLabelStyle, GUILayout.Width(40)); GUILayout.Space(16); - string burnTime = MicroUtility.SecondsToTimeString(stageInfo.StageBurnTime, false); + string burnTime = Utility.SecondsToTimeString(stageInfo.StageBurnTime, false); string lastUnit = "s"; if (burnTime.Contains('h')) { @@ -633,10 +633,10 @@ private void DrawEditWindow(int windowIndex) { selectedWindowId = selectedWindowId > 0 ? selectedWindowId - 1 : editableWindows.Count - 1; } - GUI.SetNextControlName(MicroUtility.InputDisableWindowAbbreviation); + GUI.SetNextControlName(Utility.InputDisableWindowAbbreviation); editableWindows[selectedWindowId].Abbreviation = GUILayout.TextField(editableWindows[selectedWindowId].Abbreviation, Styles.WindowSelectionAbbrevitionTextFieldStyle); - editableWindows[selectedWindowId].Abbreviation = MicroUtility.ValidateAbbreviation(editableWindows[selectedWindowId].Abbreviation); - GUI.SetNextControlName(MicroUtility.InputDisableWindowName); + editableWindows[selectedWindowId].Abbreviation = Utility.ValidateAbbreviation(editableWindows[selectedWindowId].Abbreviation); + GUI.SetNextControlName(Utility.InputDisableWindowName); editableWindows[selectedWindowId].Name = GUILayout.TextField(editableWindows[selectedWindowId].Name, Styles.WindowSelectionTextFieldStyle); if (GUILayout.Button(">", Styles.OneCharacterBtnStyle)) { @@ -820,7 +820,7 @@ private void OnGUI_OAB() Styles.StageOABWindowStyle, GUILayout.Height(0) ); - stageInfoOAB.EditorRect.position = MicroUtility.ClampToScreen(stageInfoOAB.EditorRect.position, stageInfoOAB.EditorRect.size); + stageInfoOAB.EditorRect.position = Utility.ClampToScreen(stageInfoOAB.EditorRect.position, stageInfoOAB.EditorRect.size); // Draw window for selecting CelestialBody for a stage // -1 -> no selection of CelestialBody is taking place @@ -943,7 +943,7 @@ private void DrawStageInfoOAB(int windowID) GUILayout.Label(String.Format("{0:N0}", stages[stageIndex].DeltaVVac), Styles.ValueLabelStyle, GUILayout.Width(75)); GUILayout.Label("m/s", Styles.UnitLabelStyleStageOAB, GUILayout.Width(30)); - GUILayout.Label(MicroUtility.SecondsToTimeString(stages[stageIndex].StageBurnTime, true, true), Styles.ValueLabelStyle, GUILayout.Width(110)); + GUILayout.Label(Utility.SecondsToTimeString(stages[stageIndex].StageBurnTime, true, true), Styles.ValueLabelStyle, GUILayout.Width(110)); GUILayout.Space(20); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); diff --git a/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs b/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs index 0392fd4..e31e2b4 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs @@ -26,8 +26,8 @@ public static double TotalLift { double toReturn = 0.0; - IEnumerable parts = MicroUtility.ActiveVessel?.SimulationObject?.PartOwner?.Parts; - if (parts == null || !MicroUtility.ActiveVessel.IsInAtmosphere) + IEnumerable parts = Utility.ActiveVessel?.SimulationObject?.PartOwner?.Parts; + if (parts == null || !Utility.ActiveVessel.IsInAtmosphere) { return toReturn; } @@ -53,8 +53,8 @@ public static double TotalDrag { double toReturn = 0.0; - IEnumerable parts = MicroUtility.ActiveVessel?.SimulationObject?.PartOwner?.Parts; - if (parts == null || !MicroUtility.ActiveVessel.IsInAtmosphere) + IEnumerable parts = Utility.ActiveVessel?.SimulationObject?.PartOwner?.Parts; + if (parts == null || !Utility.ActiveVessel.IsInAtmosphere) return toReturn; foreach (PartComponent part in parts) @@ -78,10 +78,10 @@ public static double AngleOfAttack { double aoe = 0.0; - ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(MicroUtility.ActiveVessel.SimulationObject); + ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(Utility.ActiveVessel.SimulationObject); if (simulationViewIfLoaded != null) { - Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(MicroUtility.ActiveVessel.SurfaceVelocity).normalized; + Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(Utility.ActiveVessel.SurfaceVelocity).normalized; Vector up = simulationViewIfLoaded.Model.Vessel.ControlTransform.up; Vector3 lhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(up); Vector right = simulationViewIfLoaded.Model.Vessel.ControlTransform.right; @@ -107,10 +107,10 @@ public static double SideSlip { double sideSlip = 0.0; - ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(MicroUtility.ActiveVessel.SimulationObject); + ISimulationObjectView simulationViewIfLoaded = GameManager.Instance.Game.ViewController.GetSimulationViewIfLoaded(Utility.ActiveVessel.SimulationObject); if (simulationViewIfLoaded != null) { - Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(MicroUtility.ActiveVessel.SurfaceVelocity).normalized; + Vector3d normalized = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(Utility.ActiveVessel.SurfaceVelocity).normalized; Vector up = simulationViewIfLoaded.Model.Vessel.ControlTransform.up; Vector3 lhs = GameManager.Instance.Game.UniverseView.PhysicsSpace.VectorToPhysics(up); Vector right = simulationViewIfLoaded.Model.Vessel.ControlTransform.right; diff --git a/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs b/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs index c229df1..067835d 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs @@ -19,7 +19,7 @@ public static class TransferInfo private static bool CalculateParameters() { // If Target is the body that vessel is orbiting, there is no phase angle - if (MicroUtility.ActiveVessel.Orbit.referenceBody == MicroUtility.ActiveVessel.TargetObject.CelestialBody) + if (Utility.ActiveVessel.Orbit.referenceBody == Utility.ActiveVessel.TargetObject.CelestialBody) { _fromLocalPosition = null; _toLocalPosition = null; @@ -28,8 +28,8 @@ private static bool CalculateParameters() return false; } - (CelestialBodyComponent referenceBody, Vector3 localPosition, IKeplerOrbit currentOrbit) from = (MicroUtility.ActiveVessel.Orbit.referenceBody, MicroUtility.ActiveVessel.Orbit.Position.localPosition, MicroUtility.ActiveVessel.Orbit); - (CelestialBodyComponent referenceBody, Vector3 localPosition, IKeplerOrbit currentOrbit) to = (MicroUtility.ActiveVessel.TargetObject.Orbit.referenceBody, MicroUtility.ActiveVessel.TargetObject.Orbit.Position.localPosition, MicroUtility.ActiveVessel.TargetObject.Orbit); + (CelestialBodyComponent referenceBody, Vector3 localPosition, IKeplerOrbit currentOrbit) from = (Utility.ActiveVessel.Orbit.referenceBody, Utility.ActiveVessel.Orbit.Position.localPosition, Utility.ActiveVessel.Orbit); + (CelestialBodyComponent referenceBody, Vector3 localPosition, IKeplerOrbit currentOrbit) to = (Utility.ActiveVessel.TargetObject.Orbit.referenceBody, Utility.ActiveVessel.TargetObject.Orbit.Position.localPosition, Utility.ActiveVessel.TargetObject.Orbit); // We search for the common celestial body that both ActiveVessel and TargetObject are orbiting and then calculate the phase angle bool commonReferenceBodyFound = false; @@ -40,9 +40,9 @@ private static bool CalculateParameters() // Outer loop => TargetObject (to) for (int i = 0; i < numberOfLoopTries; i++) { - from.referenceBody = MicroUtility.ActiveVessel.Orbit.referenceBody; - from.localPosition = MicroUtility.ActiveVessel.Orbit.Position.localPosition; - from.currentOrbit = MicroUtility.ActiveVessel.Orbit; + from.referenceBody = Utility.ActiveVessel.Orbit.referenceBody; + from.localPosition = Utility.ActiveVessel.Orbit.Position.localPosition; + from.currentOrbit = Utility.ActiveVessel.Orbit; // Inner lookp => ActiveVessel (from) for (int j = 0; j < numberOfLoopTries; j++) diff --git a/MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs similarity index 99% rename from MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs rename to MicroEngineerProject/MicroEngineer/Utilities/Utility.cs index 4a4c9a6..8c51741 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/MicroUtility.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs @@ -13,12 +13,12 @@ namespace MicroMod { - public static class MicroUtility + public static class Utility { public static VesselComponent ActiveVessel; public static ManeuverNodeData CurrentManeuver; public static string LayoutPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MicroLayout.json"); - private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.MicroUtility"); + private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Utility"); public static GameStateConfiguration GameState; public static MessageCenter MessageCenter; public static VesselDeltaVComponent VesselDeltaVComponentOAB; diff --git a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs index bc9582c..430213d 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs @@ -47,7 +47,7 @@ override internal void DrawWindowFooter() private void DeleteNodes() { - var nodes = MicroUtility.ActiveVessel.SimulationObject?.FindComponent()?.GetNodes(); + var nodes = Utility.ActiveVessel.SimulationObject?.FindComponent()?.GetNodes(); List nodesToDelete = new List(); // This should never happen, but better be safe @@ -62,7 +62,7 @@ private void DeleteNodes() if (!nodesToDelete.Contains(node) && (!nodeToDelete.IsOnManeuverTrajectory || nodeToDelete.Time < node.Time)) nodesToDelete.Add(node); } - GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(MicroUtility.ActiveVessel.GlobalId, nodesToDelete); + GameManager.Instance.Game.SpaceSimulation.Maneuvers.RemoveNodesFromVessel(Utility.ActiveVessel.GlobalId, nodesToDelete); _selectedNodeIndex = 0; } @@ -80,7 +80,7 @@ internal override void RefreshData() private void RefreshManeuverNodes() { - ManeuverPlanComponent activeVesselPlan = MicroUtility.ActiveVessel.SimulationObject.FindComponent(); + ManeuverPlanComponent activeVesselPlan = Utility.ActiveVessel.SimulationObject.FindComponent(); if (activeVesselPlan != null) { _nodes = activeVesselPlan.GetNodes(); @@ -89,7 +89,7 @@ private void RefreshManeuverNodes() internal void OnManeuverCreatedMessage(MessageCenterMessage message) { - var nodeData = MicroUtility.ActiveVessel.SimulationObject?.FindComponent()?.GetNodes(); + var nodeData = Utility.ActiveVessel.SimulationObject?.FindComponent()?.GetNodes(); _selectedNodeIndex = nodeData != null ? nodeData.Count > 0 ? nodeData.Count - 1 : 0 : 0; } From 1a849a79f86e401d3973ba4af6f58cae7a1393f4 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Fri, 21 Apr 2023 09:52:07 +0200 Subject: [PATCH 23/38] Add layout version control --- MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs | 1 + MicroEngineerProject/MicroEngineer/Utilities/Utility.cs | 9 +++++++++ MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs | 7 +++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 21fa9b4..2550dda 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1219,6 +1219,7 @@ private void InitializeWindows() MicroWindows.Add(new BaseWindow { Name = "MainGui", + LayoutVersion = Utility.CurrentLayoutVersion, Abbreviation = null, Description = "Main GUI", IsEditorActive = false, diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs index 8c51741..0a243b7 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs @@ -18,6 +18,7 @@ public static class Utility public static VesselComponent ActiveVessel; public static ManeuverNodeData CurrentManeuver; public static string LayoutPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MicroLayout.json"); + public static int CurrentLayoutVersion = 1; private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Utility"); public static GameStateConfiguration GameState; public static MessageCenter MessageCenter; @@ -186,6 +187,14 @@ internal static void LoadLayout(List windows) { List deserializedWindows = JsonConvert.DeserializeObject>(File.ReadAllText(LayoutPath)); + // Check if user has an old layout version. If it's older, it's not supported, so the default layout will remain active. Once the new layout is saved, it will persist. + var MainGui = deserializedWindows.Find(w => w.MainWindow == MainWindow.MainGui); + if (MainGui.LayoutVersion < Utility.CurrentLayoutVersion) + { + Logger.LogInfo("Loaded layout version is older than the current supported version. Layout will be reset."); + return; + } + windows.Clear(); windows.AddRange(deserializedWindows); diff --git a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs index bc38784..0658f76 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs @@ -12,6 +12,8 @@ internal class BaseWindow [JsonProperty] internal string Name; [JsonProperty] + internal int LayoutVersion; + [JsonProperty] internal string Abbreviation; [JsonProperty] internal string Description; // not used @@ -142,10 +144,7 @@ public enum MicroEntryCategory Stage, Body, Misc, - OAB, - New, - Accepted, - Accepted2 + OAB } /// From 067ea78c306aefdfa19d827a468e31d132664258 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Fri, 21 Apr 2023 13:53:32 +0200 Subject: [PATCH 24/38] Refactor --- .../MicroEngineer/Entries/BodyEntries.cs | 3 + .../MicroEngineer/Entries/FlightEntries.cs | 17 ++ .../MicroEngineer/Entries/ManeuverEntries.cs | 32 ++- .../MicroEngineer/Entries/MicroEntries.cs | 25 +- .../MicroEngineer/Entries/MiscEntries.cs | 12 + .../Entries/OabStageInfoEntries.cs | 6 + .../MicroEngineer/Entries/OrbitalEntries.cs | 21 ++ .../MicroEngineer/Entries/StageInfoEntries.cs | 26 +++ .../MicroEngineer/Entries/SurfaceEntries.cs | 13 ++ .../MicroEngineer/Entries/TargetEntries.cs | 49 +++- .../MicroEngineer/Entries/VesselEntries.cs | 22 +- .../MicroEngineer/MicroEngineerMod.cs | 216 +++--------------- .../MicroEngineer/Utilities/TransferInfo.cs | 15 +- .../MicroEngineer/Utilities/Utility.cs | 2 +- 14 files changed, 235 insertions(+), 224 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs diff --git a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs index d61e15e..fdcaa32 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs @@ -11,6 +11,7 @@ public Body() Name = "Body"; Description = "Shows the body that vessel is currently at."; Category = MicroEntryCategory.Body; + IsDefault = false; Unit = null; Formatting = null; } @@ -30,6 +31,7 @@ public ReferenceBodyConstants_Radius() Name = "Body Radius"; Description = "Body's radius."; Category = MicroEntryCategory.Body; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -49,6 +51,7 @@ public ReferenceBodyConstants_StandardGravitationParameter() Name = "Std. Grav. Param."; Description = "Product of the gravitational constant G and the mass M of the body."; Category = MicroEntryCategory.Body; + IsDefault = false; Unit = "μ"; Formatting = "{0:e4}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index 12ebf21..f88cb6d 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -11,6 +11,7 @@ public Speed() Name = "Speed"; Description = "Shows the vessel's total velocity."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -30,6 +31,7 @@ public MachNumber() Name = "Mach Number"; Description = "Shows the ratio of vessel's speed and local speed of sound."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = null; Formatting = "{0:N2}"; } @@ -49,6 +51,7 @@ public AtmosphericDensity() Name = "Atm. Density"; Description = "Shows the atmospheric density."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "g/L"; Formatting = "{0:N3}"; } @@ -68,6 +71,7 @@ public TotalLift() Name = "Total Lift"; Description = "Shows the total lift force produced by the vessel."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "N"; Formatting = "{0:N0}"; } @@ -97,6 +101,7 @@ public TotalDrag() Name = "Total Drag"; Description = "Shows the total drag force exerted on the vessel."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "N"; Formatting = "{0:N0}"; } @@ -126,6 +131,7 @@ public LiftDivDrag() Name = "Lift / Drag"; Description = "Shows the ratio of total lift and drag forces."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = null; Formatting = "{0:N2}"; } @@ -155,6 +161,7 @@ public AngleOfAttack() Name = "AoA"; Description = "Angle of Attack specifies the angle between the chord line of the wing and the vector representing the relative motion between the aircraft and the atmosphere."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "°"; Formatting = "{0:N3}"; } @@ -174,6 +181,7 @@ public SideSlip() Name = "Sideslip"; Description = "A slip is an aerodynamic state where an aircraft is moving somewhat sideways as well as forward relative to the oncoming airflow or relative wind."; Category = MicroEntryCategory.Flight; + IsDefault = false; Unit = "°"; Formatting = "{0:N3}"; } @@ -193,6 +201,7 @@ public DragCoefficient() Name = "Drag Coefficient"; Description = "Dimensionless quantity that is used to quantify the drag or resistance of an object in a fluid environment, such as air or water."; Category = MicroEntryCategory.Flight; + IsDefault = false; Unit = null; Formatting = "{0:N2}"; } @@ -212,6 +221,7 @@ public ExposedArea() Name = "Exposed Area"; Description = "The surface area that interacts with the working fluid or gas."; Category = MicroEntryCategory.Flight; + IsDefault = false; Unit = null; // TODO Formatting = "{0:N2}"; } @@ -231,6 +241,7 @@ public Heading() Name = "Heading"; Description = "Heading of a vessel is the compass direction in which the craft's nose is pointed."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "°"; Formatting = "{0:N2}"; } @@ -250,6 +261,7 @@ public Pitch_HorizonRelative() Name = "Pitch"; Description = "Lateral axis passes through an aircraft from wingtip to wingtip. Rotation about this axis is called pitch (moving up-down)."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "°"; Formatting = "{0:N2}"; } @@ -269,6 +281,7 @@ public Roll_HorizonRelative() Name = "Roll"; Description = "Longitudinal axis passes through the aircraft from nose to tail. Rotation about this axis is called roll (rotating left-right)."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "°"; Formatting = "{0:N2}"; } @@ -288,6 +301,7 @@ public Yaw_HorizonRelative() Name = "Yaw"; Description = "Vertical axis passes through an aircraft from top to bottom. Rotation about this axis is called yaw (moving left-right)."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "°"; Formatting = "{0:N2}"; } @@ -307,6 +321,7 @@ public Zenith() Name = "Zenith"; Description = "The zenith is an imaginary point directly above a particular location, on the celestial sphere. \"Above\" means in the vertical direction opposite to the gravity direction."; Category = MicroEntryCategory.Flight; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -326,6 +341,7 @@ public SoundSpeed() Name = "Speed of sound"; Description = "Distance travelled per unit of time by a sound wave as it propagates through the air."; Category = MicroEntryCategory.Flight; + IsDefault = false; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -345,6 +361,7 @@ public GeeForce() Name = "G-Force"; Description = "Measurement of the type of force per unit mass – typically acceleration – that causes a perception of weight, with a g-force of 1 g equal to the conventional value of gravitational acceleration on Earth/Kerbin."; Category = MicroEntryCategory.Flight; + IsDefault = true; Unit = "g"; Formatting = "{0:N3}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 989b549..fe44597 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -16,6 +16,7 @@ public ProjectedAp() Name = "Projected Ap."; Description = "Projected Apoapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -38,6 +39,7 @@ public ProjectedPe() Name = "Projected Pe."; Description = "Projected Periapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -60,6 +62,7 @@ public DeltaVRequired() Name = "∆v required"; Description = "Delta velocity needed to complete the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -84,6 +87,7 @@ public ManeuverPrograde() Name = "∆v Prograde"; Description = "Prograde/Retrograde component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -104,6 +108,7 @@ public ManeuverNormal() Name = "∆v Normal"; Description = "Normal component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -124,6 +129,7 @@ public ManeuverRadial() Name = "∆v Radial"; Description = "Radial component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -144,6 +150,7 @@ public TimeToNode() Name = "Time to Node"; Description = "Time until vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = "s"; Formatting = null; } @@ -173,6 +180,7 @@ public BurnTime() Name = "Burn Time"; Description = "Length of time needed to complete the maneuver node."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = "s"; Formatting = null; } @@ -195,9 +203,6 @@ public override string ValueDisplay } } - - // NEW ENTRIES - public class Maneuver_EccentricAnomaly : ManeuverEntry { public Maneuver_EccentricAnomaly() @@ -205,6 +210,7 @@ public Maneuver_EccentricAnomaly() Name = "Eccentric Anomaly"; Description = "Eccentric Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -236,6 +242,7 @@ public Maneuver_EndUT() Name = "UT"; Description = "Universal Time when vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "s"; Formatting = "{0:N3}"; } @@ -267,6 +274,7 @@ public Maneuver_MeanAnomaly() Name = "Mean Anomaly"; Description = "Mean Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -298,6 +306,7 @@ public Maneuver_ObT() Name = "Orbit Time"; Description = "Shows orbit time in seconds from the Periapsis when vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -329,6 +338,7 @@ public Maneuver_ArgumentOfPeriapsis() Name = "Argument of Pe."; Description = "Argument of Periapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -351,6 +361,7 @@ public Maneuver_Eccentricity() Name = "Eccentricity"; Description = "The eccentricity of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = null; Formatting = "{0:N3}"; } @@ -373,6 +384,7 @@ public Maneuver_Inclination() Name = "Inclination"; Description = "The inclination of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = "°"; Formatting = "{0:N3}"; } @@ -395,6 +407,7 @@ public Maneuver_LongitudeOfAscendingNode() Name = "LAN Ω"; Description = "Longitude of Ascending Node vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -417,6 +430,7 @@ public Maneuver_SemiMajorAxis() Name = "Semi Major Axis"; Description = "Semi Major Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -439,6 +453,7 @@ public Maneuver_SemiMinorAxis() Name = "Semi Minor Axis"; Description = "Semi Minor Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -461,6 +476,7 @@ public Maneuver_OrbitalEnergy() Name = "Orbital Energy"; Description = "Orbital Energy vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "kJ"; Formatting = "{0:N0}"; } @@ -483,6 +499,7 @@ public Maneuver_SemiLatusRectum() Name = "Semi Latus Rectum"; Description = "Semi Latus Rectum vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -505,6 +522,7 @@ public Maneuver_TimeToAp() Name = "Time to Ap."; Description = "Shows the Time to Apoapsis vessel will have after reaching the maneuver node."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = "s"; Formatting = null; } @@ -536,6 +554,7 @@ public Maneuver_TimeToPe() Name = "Time to Pe."; Description = "Shows the Time to Periapsis vessel will have after reaching the maneuver node."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = "s"; Formatting = null; } @@ -567,6 +586,7 @@ public Maneuver_TrueAnomaly() Name = "True Anomaly"; Description = "True Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "°"; Formatting = "{0:N1}"; } @@ -598,6 +618,7 @@ public Maneuver_UniversalTimeAtClosestApproach() Name = "UT Close.App."; Description = "Universal Time at the point of closest approach."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = null; Formatting = null; } @@ -629,6 +650,7 @@ public Maneuver_UniversalTimeAtSoiEncounter() Name = "UT SOI Enc."; Description = "Universal Time at the point of transition to another Sphere Of Influence."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = null; Formatting = null; } @@ -660,6 +682,7 @@ public Maneuver_OrbitPercent() Name = "Orbit percent"; Description = "Orbit percent vessel will have passed after completing the maneuver."; Category = MicroEntryCategory.Maneuver; + IsDefault = false; Unit = "%"; Formatting = "{0:N2}"; } @@ -682,6 +705,7 @@ public Maneuver_Period() Name = "Period"; Description = "The period of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; + IsDefault = true; Unit = "s"; Formatting = null; } @@ -705,6 +729,4 @@ public override string ValueDisplay } } } - - } diff --git a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs index 593ad09..64da926 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs @@ -15,6 +15,9 @@ public class MicroEntry public string Description; [JsonProperty] public MicroEntryCategory Category; + public bool IsDefault; + [JsonProperty] + public bool HideWhenNoData; [JsonProperty] public string Unit; [JsonProperty] @@ -37,25 +40,5 @@ public virtual string ValueDisplay } public virtual void RefreshData() { } - } - - - public class StageInfo : MicroEntry - { - public StageInfo() - { - Name = "Stage Info"; - Description = "Stage Info object, not implemented yet."; // TODO Stage Info display and description - Category = MicroEntryCategory.Stage; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo; - } - - public override string ValueDisplay => base.ValueDisplay; - } + } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs index 2ecf609..d0eb849 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -12,6 +12,7 @@ public Separator() Name = "--------------"; Description = "It's a separator!"; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = "---"; Formatting = null; EntryValue = "---------------"; @@ -25,6 +26,7 @@ public AutopilotStatus_IsEnabled() Name = "Autopilot"; Description = "Is autopilot enabled or disabled."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = null; Formatting = null; } @@ -44,6 +46,7 @@ public AutopilotStatus_Mode() Name = "Autopilot Mode"; Description = "Mode vessel's autopilot is using: stability assist, prograde, retrograde, normal, etc."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = null; Formatting = null; } @@ -63,6 +66,7 @@ public TimeSinceLaunch() Name = "Time since launch"; Description = "Time since the vessel launched."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -91,6 +95,7 @@ public GravityForPos() Name = "Local Gravity"; Description = "Local gravity vessel is experiencing."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = "ms2"; Formatting = "{0:N3}"; } @@ -110,6 +115,7 @@ public LaunchTime() Name = "Launch Time"; Description = "Universal Time when vessel was launched."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = "s"; Formatting = "{0:N3}"; } @@ -138,6 +144,7 @@ public AltimeterMode() Name = "Altimeter Mode"; Description = "Mode vessel's altimeter is using: Sea Level or Ground Level."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = null; Formatting = null; } @@ -157,6 +164,7 @@ public SpeedMode() Name = "Speed Mode"; Description = "Mode vessel's velocity meter is using: Orbit, Surface or Target."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = null; Formatting = null; } @@ -176,6 +184,7 @@ public StartUT() Name = "Start UT"; Description = "Time passed since vessel was launched."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -204,6 +213,7 @@ public EndUT() Name = "UT"; Description = "Universal Time."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -232,6 +242,7 @@ public UniversalTimeAtClosestApproach() Name = "UT Close.App."; Description = "Universal Time at closest approach."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -260,6 +271,7 @@ public UniversalTimeAtSoiEncounter() Name = "UT SOI Enc."; Description = "Universal Time at the point of transfer to another sphere of influence."; Category = MicroEntryCategory.Misc; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs index 9c46c1f..9fac384 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs @@ -17,6 +17,7 @@ public TotalBurnTime_OAB() Name = "Total Burn Time (OAB)"; Description = "Shows the total length of burn the vessel can mantain."; Category = MicroEntryCategory.OAB; + IsDefault = true; Unit = "s"; Formatting = "{0:N1}"; UseDHMSFormatting = true; @@ -49,6 +50,7 @@ public TotalDeltaVASL_OAB() Name = "Total ∆v ASL (OAB)"; Description = "Shows the vessel's total delta velocity At Sea Level."; Category = MicroEntryCategory.OAB; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N0}"; } @@ -67,6 +69,7 @@ public TotalDeltaVActual_OAB() Name = "Total ∆v Actual (OAB)"; Description = "Shows the vessel's actual total delta velocity (not used in OAB)."; Category = MicroEntryCategory.OAB; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N0}"; } @@ -85,6 +88,7 @@ public TotalDeltaVVac_OAB() Name = "Total ∆v Vac (OAB)"; Description = "Shows the vessel's total delta velocity in Vacuum."; Category = MicroEntryCategory.OAB; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N0}"; } @@ -109,6 +113,7 @@ public Torque() Name = "Torque"; Description = "Thrust torque that is generated by not having Thrust Vector and Center of Mass aligned. Turn on the Center of Thrust and Center of Mass VAB indicators to get an accurate value."; Category = MicroEntryCategory.OAB; + IsDefault = true; Unit = null; Formatting = null; } @@ -170,6 +175,7 @@ public StageInfo_OAB() Name = "Stage Info (OAB)"; Description = "Holds a list of stage info parameters."; Category = MicroEntryCategory.OAB; + IsDefault = true; Unit = null; Formatting = null; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index ea1aaf7..3d103be 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -13,6 +13,7 @@ public Apoapsis() Name = "Apoapsis"; Description = "Vessel's apoapsis height relative to the sea level. Apoapsis is the highest point of an orbit."; Category = MicroEntryCategory.Orbital; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -32,6 +33,7 @@ public TimeToApoapsis() Name = "Time to Ap."; Description = "Shows the time until the vessel reaches apoapsis, the highest point of the orbit."; Category = MicroEntryCategory.Orbital; + IsDefault = true; Unit = "s"; Formatting = null; } @@ -60,6 +62,7 @@ public Periapsis() Name = "Periapsis"; Description = "Vessel's periapsis height relative to the sea level. Periapsis is the lowest point of an orbit."; Category = MicroEntryCategory.Orbital; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -79,6 +82,7 @@ public TimeToPeriapsis() Name = "Time to Pe."; Description = "Shows the time until the vessel reaches periapsis, the lowest point of the orbit."; Category = MicroEntryCategory.Orbital; + IsDefault = true; Unit = "s"; Formatting = null; } @@ -107,6 +111,7 @@ public Inclination() Name = "Inclination"; Description = "Shows the vessel's orbital inclination relative to the equator."; Category = MicroEntryCategory.Orbital; + IsDefault = true; Unit = "°"; Formatting = "{0:N3}"; } @@ -126,6 +131,7 @@ public Eccentricity() Name = "Eccentricity"; Description = "Shows the vessel's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; Category = MicroEntryCategory.Orbital; + IsDefault = true; Unit = null; Formatting = "{0:N3}"; } @@ -145,6 +151,7 @@ public Period() Name = "Period"; Description = "Shows the amount of time it will take to complete a full orbit."; Category = MicroEntryCategory.Orbital; + IsDefault = true; Unit = "s"; Formatting = null; } @@ -173,6 +180,7 @@ public SoiTransition() Name = "SOI Trans."; Description = "Shows the amount of time it will take to transition to another Sphere Of Influence."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "s"; Formatting = null; } @@ -201,6 +209,7 @@ public OrbitalSpeed() Name = "Orbital Speed"; Description = "Shows the vessel's orbital speed"; Category = MicroEntryCategory.Orbital; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -220,6 +229,7 @@ public EccentricAnomaly() Name = "Eccentric Anomaly"; Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the vessel is."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -248,6 +258,7 @@ public MeanAnomaly() Name = "Mean Anomaly"; Description = "Parameter used to describe the position of an object in its orbit around the celestial body."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -276,6 +287,7 @@ public TrueAnomaly() Name = "True Anomaly"; Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "°"; Formatting = "{0:N1}"; } @@ -304,6 +316,7 @@ public ObT() Name = "Orbit Time"; Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -332,6 +345,7 @@ public ArgumentOfPeriapsis() Name = "Argument of Pe."; Description = "Angle from the line of the ascending node on the equatorial plane to the point of periapsis passage."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -351,6 +365,7 @@ public LongitudeOfAscendingNode() Name = "LAN Ω"; Description = "Longitude of Ascending Node is an angle from a specified reference direction, called the origin of longitude, to the direction of the ascending node, as measured in a specified reference plane."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -370,6 +385,7 @@ public SemiMajorAxis() Name = "Semi Major Axis"; Description = "Shows the distance from the center of an orbit to the farthest edge."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -389,6 +405,7 @@ public SemiMinorAxis() Name = "Semi Minor Axis"; Description = "Shows the distance from the center of an orbit to the nearest edge."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -408,6 +425,7 @@ public OrbitalEnergy() Name = "Orbital Energy"; Description = "Constant sum of two orbiting bodies' mutual potential energy and their total kinetic energy divided by the reduced mass."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "kJ"; Formatting = "{0:N0}"; } @@ -427,6 +445,7 @@ public SemiLatusRectum() Name = "Semi Latus Rectum"; Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -446,6 +465,7 @@ public OrbitPercent() Name = "Orbit Percent"; Description = "Percent of the orbit completed."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "%"; Formatting = "{0:N2}"; } @@ -465,6 +485,7 @@ public OrbitRadius() Name = "Orbit Radius"; Description = "Length from the center of the ellipse to the object."; Category = MicroEntryCategory.Orbital; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs new file mode 100644 index 0000000..09febd5 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs @@ -0,0 +1,26 @@ + +namespace MicroMod +{ + public class StageInfoEntry: MicroEntry + { } + + public class StageInfo : StageInfoEntry + { + public StageInfo() + { + Name = "Stage Info"; + Description = "Stage Info object, not implemented yet."; // TODO Stage Info display and description + Category = MicroEntryCategory.Stage; + IsDefault = true; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo; + } + + public override string ValueDisplay => base.ValueDisplay; + } +} diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index e7dcd82..ead1323 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -13,6 +13,7 @@ public Situation() Name = "Situation"; Description = "Shows the vessel's current situation: Landed, Flying, Orbiting, etc."; Category = MicroEntryCategory.Surface; + IsDefault = true; Unit = null; Formatting = null; } @@ -41,6 +42,7 @@ public Latitude() Name = "Latitude"; Description = "Shows the vessel's latitude position around the celestial body. Latitude is the angle from the equator towards the poles."; Category = MicroEntryCategory.Surface; + IsDefault = true; Formatting = null; } @@ -69,6 +71,7 @@ public Longitude() Name = "Longitude"; Description = "Shows the vessel's longitude position around the celestial body. Longitude is the angle from the body's prime meridian to the current meridian."; Category = MicroEntryCategory.Surface; + IsDefault = true; Formatting = null; } @@ -97,6 +100,7 @@ public Biome() Name = "Biome"; Description = "Shows the biome currently below the vessel."; Category = MicroEntryCategory.Surface; + IsDefault = true; Unit = null; Formatting = null; } @@ -125,6 +129,7 @@ public AltitudeAsl() Name = "Altitude (Sea Lvl)"; Description = "Shows the vessel's altitude above sea level."; Category = MicroEntryCategory.Surface; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -144,6 +149,7 @@ public AltitudeAgl() Name = "Altitude (Ground)"; Description = "Shows the vessel's altitude above ground Level."; Category = MicroEntryCategory.Surface; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -163,6 +169,7 @@ public AltitudeFromScenery() Name = "Altitude (Scenery)"; Description = "Shows the vessel's altitude above scenery."; Category = MicroEntryCategory.Surface; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -182,6 +189,7 @@ public HorizontalVelocity() Name = "Horizontal Vel."; Description = "Shows the vessel's horizontal velocity across a celestial body's surface."; Category = MicroEntryCategory.Surface; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -201,6 +209,7 @@ public VerticalVelocity() Name = "Vertical Vel."; Description = "Shows the vessel's vertical velocity (up/down)."; Category = MicroEntryCategory.Surface; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -220,6 +229,7 @@ public AtmosphericTemperature() Name = "Static ambient temp."; Description = "Temperature measured outside the vessel. The sensor which detects SAT must be carefully sited to ensure that airflow over it does not affect the indicated temperature."; Category = MicroEntryCategory.Surface; + IsDefault = false; Unit = "K"; Formatting = "{0:N0}"; } @@ -239,6 +249,7 @@ public ExternalTemperature() Name = "Total air temp."; Description = "Measured by means of a sensor positioned in the airflow, kinetic heating will result, raising the temperature measured above the Static ambient temperature."; Category = MicroEntryCategory.Surface; + IsDefault = false; Unit = "K"; Formatting = "{0:N0}"; } @@ -258,6 +269,7 @@ public DynamicPressure_kPa() Name = "Dynamic Pressure"; Description = "Dynamic Pressure (q) is a defined property of a moving flow of gas. It describes how much pressure the airflow is having on the vessel."; Category = MicroEntryCategory.Surface; + IsDefault = false; Unit = "kPa"; Formatting = "{0:N2}"; } @@ -277,6 +289,7 @@ public StaticPressure_kPa() Name = "Static Pressure"; Description = "Static pressure is a term used to define the amount of pressure exerted by a fluid that is not moving - ambient pressure."; Category = MicroEntryCategory.Surface; + IsDefault = false; Unit = "kPa"; Formatting = "{0:N2}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 9f9b72f..f986166 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -12,6 +12,7 @@ public TargetApoapsis() Name = "Target Ap."; Description = "Shows the target's apoapsis height relative to the sea level."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -31,6 +32,7 @@ public TargetPeriapsis() Name = "Target Pe."; Description = "Shows the target's periapsis height relative to the sea level."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -50,6 +52,7 @@ public DistanceToTarget() Name = "Distance to Target"; Description = "Shows the current distance between the vessel and the target."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -80,6 +83,7 @@ public RelativeSpeed() Name = "Rel. Speed"; Description = "Shows the relative velocity between the vessel and the target."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -112,6 +116,7 @@ public RelativeInclination() Name = "Rel. Inclination"; Description = "Shows the relative inclination between the vessel and the target."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "°"; Formatting = "{0:N3}"; } @@ -144,6 +149,7 @@ public Target_AltitudeFromSeaLevel() Name = "Altitude (Sea)"; Description = "Shows the target's altitude above sea level."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -163,6 +169,7 @@ public Target_Name() Name = "Name"; Description = "Target's name."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = null; Formatting = null; } @@ -182,6 +189,7 @@ public Target_EccentricAnomaly() Name = "Eccentric Anomaly"; Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the target is."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -210,6 +218,7 @@ public Target_MeanAnomaly() Name = "Mean Anomaly"; Description = "Parameter used to describe the position of the target in its orbit around the celestial body."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -238,6 +247,7 @@ public Target_ObT() Name = "Orbit Time"; Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "s"; Formatting = "{0:N3}"; } @@ -266,6 +276,7 @@ public Target_ArgumentOfPeriapsis() Name = "Argument of Pe."; Description = "Angle from the line of the ascending node on the equatorial plane to the point of periapsis passage."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -285,6 +296,7 @@ public Target_Eccentricity() Name = "Eccentricity"; Description = "Shows the target's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = null; Formatting = "{0:N3}"; } @@ -304,6 +316,7 @@ public Target_Inclination() Name = "Inclination"; Description = "Shows the target's orbital inclination relative to the equator."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "°"; Formatting = "{0:N3}"; } @@ -323,6 +336,7 @@ public Target_LongitudeOfAscendingNode() Name = "LAN Ω"; Description = "Shows the target's Longitude Of Ascending Node."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "°"; Formatting = "{0:N2}"; } @@ -342,6 +356,7 @@ public Target_SemiMajorAxis() Name = "Semi Major Axis"; Description = "Shows the distance from the center of an orbit to the farthest edge."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -361,6 +376,7 @@ public Target_ReferenceBodyConstants_Radius() Name = "Body Radius"; Description = "Radius of the body that target is orbiting."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -380,6 +396,7 @@ public Target_ReferenceBodyConstants_StandardGravitationParameter() Name = "Std. Grav. Param."; Description = "Product of the gravitational constant G and the mass M of the body target is orbiting."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "μ"; Formatting = "{0:e4}"; } @@ -399,6 +416,7 @@ public Target_SemiLatusRectum() Name = "Semi Latus Rectum"; Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -418,6 +436,7 @@ public Target_SemiMinorAxis() Name = "Semi Minor Axis"; Description = "Shows the distance from the center of an orbit to the nearest edge."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -437,6 +456,7 @@ public Target_TrueAnomaly() Name = "True Anomaly"; Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "°"; Formatting = "{0:N1}"; } @@ -465,6 +485,7 @@ public Target_Period() Name = "Period"; Description = "Shows the amount of time it will take the target to complete a full orbit."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "s"; Formatting = null; } @@ -493,6 +514,7 @@ public Target_OrbitRadius() Name = "Orbit Radius"; Description = "Length from the center of the ellipse to the object."; Category = MicroEntryCategory.Target; + IsDefault = false; Unit = "m"; Formatting = "{0:N0}"; } @@ -512,6 +534,7 @@ public Target_Obtvelocity() Name = "Orbital Speed"; Description = "Shows the target's orbital speed."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -528,9 +551,11 @@ public class DistanceAtCloseApproach1 : TargetEntry { public DistanceAtCloseApproach1() { - Name = "CloseAppDist-1"; + Name = "C.A.Dist.1"; Description = "Close approach distance to target (1)."; Category = MicroEntryCategory.Target; + IsDefault = true; + HideWhenNoData = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -549,9 +574,11 @@ public class TimeToCloseApproach1 : TargetEntry { public TimeToCloseApproach1() { - Name = "CloseAppTime-1"; + Name = "C.A.Time1"; Description = "Close approach time to target (1)."; Category = MicroEntryCategory.Target; + IsDefault = true; + HideWhenNoData = true; Unit = "s"; Formatting = null; } @@ -579,9 +606,11 @@ public class RelativeSpeedAtCloseApproach1 : TargetEntry { public RelativeSpeedAtCloseApproach1() { - Name = "CloseAppSpeed-1"; + Name = "C.A.Speed1"; Description = "Close approach relative speed to target (1)."; Category = MicroEntryCategory.Target; + IsDefault = true; + HideWhenNoData = true; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -600,9 +629,11 @@ public class DistanceAtCloseApproach2 : TargetEntry { public DistanceAtCloseApproach2() { - Name = "CloseAppDist-2"; + Name = "C.A.Dist.2"; Description = "Close approach distance to target (2)."; Category = MicroEntryCategory.Target; + IsDefault = false; + HideWhenNoData = true; Unit = "m"; Formatting = "{0:N0}"; } @@ -621,9 +652,11 @@ public class TimeToCloseApproach2 : TargetEntry { public TimeToCloseApproach2() { - Name = "CloseAppTime-2"; + Name = "C.A.Time2"; Description = "Close approach time to target (2)."; Category = MicroEntryCategory.Target; + IsDefault = false; + HideWhenNoData = true; Unit = "s"; Formatting = null; } @@ -651,9 +684,11 @@ public class RelativeSpeedAtCloseApproach2 : TargetEntry { public RelativeSpeedAtCloseApproach2() { - Name = "CloseAppSpeed-2"; + Name = "C.A.Speed2"; Description = "Close approach relative speed to target (2)."; Category = MicroEntryCategory.Target; + IsDefault = false; + HideWhenNoData = true; Unit = "m/s"; Formatting = "{0:N1}"; } @@ -675,6 +710,7 @@ public PhaseAngle() Name = "Phase Angle"; Description = "Angle between your vessel, the reference body and the target. How much \"ahead\" or \"behind\" in phase you are with the target."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "°"; Formatting = "{0:N2}"; } @@ -694,6 +730,7 @@ public TransferAngle() Name = "Transfer Angle"; Description = "Phase angle needed for an optimal Hohmann transfer orbit. Use a circular orbit for a more accurate value."; Category = MicroEntryCategory.Target; + IsDefault = true; Unit = "°"; Formatting = "{0:N2}"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index aae52e2..88dc1e3 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -11,6 +11,7 @@ public VesselName() Name = "Name"; Description = "Name of the current vessel."; Category = MicroEntryCategory.Vessel; + IsDefault = true; Unit = null; Formatting = null; } @@ -30,6 +31,7 @@ public Mass() Name = "Mass"; Description = "Total mass of the vessel."; Category = MicroEntryCategory.Vessel; + IsDefault = true; Unit = "kg"; Formatting = "{0:N0}"; } @@ -49,6 +51,7 @@ public TotalDeltaVActual() Name = "Total ∆v"; Description = "Vessel's total delta velocity."; Category = MicroEntryCategory.Vessel; + IsDefault = true; Unit = "m/s"; Formatting = "{0:N0}"; } @@ -68,6 +71,7 @@ public TotalDeltaVASL() Name = "Total ∆v ASL"; Description = "Total delta velocity of the vessel At Sea Level."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "m/s"; Formatting = "{0:N0}"; } @@ -88,6 +92,7 @@ public TotalDeltaVVac() Name = "Total ∆v Vac"; Description = "Total delta velocity of the vessel in vacuum."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "m/s"; Formatting = "{0:N0}"; } @@ -107,6 +112,7 @@ public StageThrustActual() Name = "Thrust"; Description = "Vessel's actual thrust."; Category = MicroEntryCategory.Vessel; + IsDefault = true; Unit = "N"; Formatting = "{0:N0}"; } @@ -126,6 +132,7 @@ public StageThrustASL() Name = "Thrust (ASL)"; Description = "Vessel's thrust At Sea Level."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "N"; Formatting = "{0:N0}"; } @@ -145,6 +152,7 @@ public StageThrustVac() Name = "Thrust (Vacuum)"; Description = "Vessel's thrust in vacuum."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "N"; Formatting = "{0:N0}"; } @@ -164,6 +172,7 @@ public StageTWRActual() Name = "TWR"; Description = "Vessel's Thrust to Weight Ratio."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = null; Formatting = "{0:N2}"; } @@ -183,6 +192,7 @@ public StageTWRASL() Name = "TWR (ASL)"; Description = "Vessel's Thrust to Weight Ratio At Sea Level."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = null; Formatting = "{0:N2}"; } @@ -202,6 +212,7 @@ public StageTWRVac() Name = "TWR (Vacuum)"; Description = "Vessel's Thrust to Weight Ratio in vacuum."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = null; Formatting = "{0:N2}"; } @@ -221,6 +232,7 @@ public PartsCount() Name = "Parts"; Description = "Number of parts vessel is constructed of."; Category = MicroEntryCategory.Vessel; + IsDefault = true; Unit = null; Formatting = null; } @@ -240,6 +252,7 @@ public TotalBurnTime() Name = "Total Burn Time"; Description = "Burn Time vessel can sustain with 100% thrust."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -265,9 +278,10 @@ public class StageISPActual : VesselEntry { public StageISPActual() { - Name = "ISP (Actual)"; + Name = "ISP"; Description = "Specific impulse (ISP) is a measure of how efficiently a reaction mass engine creates thrust."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -287,6 +301,7 @@ public StageISPAsl() Name = "ISP (ASL)"; Description = "Specific impulse At Sea Level."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -306,6 +321,7 @@ public StageISPVac() Name = "ISP (Vacuum)"; Description = "Specific impulse in vacuum."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "s"; Formatting = "{0:N0}"; } @@ -325,6 +341,7 @@ public Throttle() Name = "Throttle"; Description = "Vessel's current throttle in %."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "%"; Formatting = "{0:N0}"; } @@ -344,6 +361,7 @@ public FuelPercentage() Name = "Vessel Fuel"; Description = "Vessel's fuel percentage left."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "%"; Formatting = "{0:N1}"; } @@ -363,6 +381,7 @@ public StageFuelPercentage() Name = "Stage Fuel"; Description = "Stage fuel percentage left."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = "%"; Formatting = "{0:N1}"; } @@ -382,6 +401,7 @@ public TotalCommandCrewCapacity() Name = "Command Crew Capacity"; Description = "Crew capacity of all parts."; Category = MicroEntryCategory.Vessel; + IsDefault = false; Unit = null; Formatting = "{0:N0}"; } diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 2550dda..7ff97ae 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -9,6 +9,7 @@ using KSP.Sim.DeltaV; using KSP.Messages; using KSP.Sim.impl; +using System.Reflection; namespace MicroMod { @@ -420,7 +421,12 @@ private void FillMainGUI(int windowID) window.DrawWindowHeader(); foreach (MicroEntry entry in window.Entries) + { + if (entry.HideWhenNoData && entry.ValueDisplay == "-") + continue; DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); + } + window.DrawWindowFooter(); @@ -448,7 +454,11 @@ private void DrawPopoutWindow(int windowIndex) windowToDraw.DrawWindowHeader(); foreach (MicroEntry entry in windowToDraw.Entries) + { + if (entry.HideWhenNoData && entry.ValueDisplay == "-") + continue; DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); + } windowToDraw.DrawWindowFooter(); @@ -1025,186 +1035,22 @@ private bool SettingsButton(Rect rect) /// private void InitializeEntries() { - MicroEntries = new List(); - - #region Vessel entries - MicroEntries.Add(new VesselName()); - MicroEntries.Add(new Mass()); - MicroEntries.Add(new TotalDeltaVActual()); - MicroEntries.Add(new StageThrustActual()); - MicroEntries.Add(new StageTWRActual()); - #endregion - #region Orbital entries - MicroEntries.Add(new Apoapsis()); - MicroEntries.Add(new TimeToApoapsis()); - MicroEntries.Add(new Periapsis()); - MicroEntries.Add(new TimeToPeriapsis()); - MicroEntries.Add(new Inclination()); - MicroEntries.Add(new Eccentricity()); - MicroEntries.Add(new Period()); - MicroEntries.Add(new SoiTransition()); - #endregion - #region Surface entries - MicroEntries.Add(new Situation()); - MicroEntries.Add(new Latitude()); - MicroEntries.Add(new Longitude()); - MicroEntries.Add(new Biome()); - MicroEntries.Add(new AltitudeAsl()); - MicroEntries.Add(new AltitudeAgl()); - MicroEntries.Add(new HorizontalVelocity()); - MicroEntries.Add(new VerticalVelocity()); - #endregion - #region Flight entries - MicroEntries.Add(new Speed()); - MicroEntries.Add(new MachNumber()); - MicroEntries.Add(new AtmosphericDensity()); - MicroEntries.Add(new TotalLift()); - MicroEntries.Add(new TotalDrag()); - MicroEntries.Add(new LiftDivDrag()); - #endregion - #region Flight entries - MicroEntries.Add(new TargetApoapsis()); - MicroEntries.Add(new TargetPeriapsis()); - MicroEntries.Add(new DistanceToTarget()); - MicroEntries.Add(new RelativeSpeed()); - MicroEntries.Add(new RelativeInclination()); - #endregion - #region Maneuver entries - MicroEntries.Add(new ProjectedAp()); - MicroEntries.Add(new ProjectedPe()); - MicroEntries.Add(new DeltaVRequired()); - MicroEntries.Add(new TimeToNode()); - MicroEntries.Add(new BurnTime()); - #endregion - #region Stage entries - MicroEntries.Add(new StageInfo()); - #endregion - #region Misc entries - MicroEntries.Add(new Separator()); - #endregion - #region OAB entries - MicroEntries.Add(new TotalBurnTime_OAB()); - MicroEntries.Add(new TotalDeltaVASL_OAB()); - MicroEntries.Add(new TotalDeltaVActual_OAB()); - MicroEntries.Add(new TotalDeltaVVac_OAB()); - MicroEntries.Add(new Torque()); - MicroEntries.Add(new StageInfo_OAB()); - #endregion - - #region Body entries - MicroEntries.Add(new Body()); - #endregion - - #region New entries - MicroEntries.Add(new AltitudeFromScenery()); - MicroEntries.Add(new AtmosphericTemperature()); - MicroEntries.Add(new DynamicPressure_kPa()); - MicroEntries.Add(new ExposedArea()); - MicroEntries.Add(new ExternalTemperature()); - MicroEntries.Add(new FuelPercentage()); - MicroEntries.Add(new Heading()); - MicroEntries.Add(new Pitch_HorizonRelative()); - MicroEntries.Add(new Roll_HorizonRelative()); - MicroEntries.Add(new Yaw_HorizonRelative()); - MicroEntries.Add(new DragCoefficient()); - MicroEntries.Add(new OrbitalSpeed()); - MicroEntries.Add(new SoundSpeed()); - MicroEntries.Add(new StageFuelPercentage()); - MicroEntries.Add(new StaticPressure_kPa()); - MicroEntries.Add(new TimeSinceLaunch()); - MicroEntries.Add(new TotalCommandCrewCapacity()); - MicroEntries.Add(new Zenith()); - MicroEntries.Add(new AltimeterMode()); - MicroEntries.Add(new GeeForce()); - MicroEntries.Add(new GravityForPos()); - MicroEntries.Add(new LaunchTime()); - MicroEntries.Add(new SpeedMode()); - MicroEntries.Add(new AutopilotStatus_IsEnabled()); - MicroEntries.Add(new AutopilotStatus_Mode()); - MicroEntries.Add(new EccentricAnomaly()); - MicroEntries.Add(new EndUT()); - MicroEntries.Add(new MeanAnomaly()); - MicroEntries.Add(new ObT()); - MicroEntries.Add(new ArgumentOfPeriapsis()); - MicroEntries.Add(new LongitudeOfAscendingNode()); - MicroEntries.Add(new SemiMajorAxis()); - MicroEntries.Add(new SemiMinorAxis()); - MicroEntries.Add(new OrbitalEnergy()); - MicroEntries.Add(new ReferenceBodyConstants_Radius()); - MicroEntries.Add(new ReferenceBodyConstants_StandardGravitationParameter()); - MicroEntries.Add(new SemiLatusRectum()); - MicroEntries.Add(new StartUT()); - MicroEntries.Add(new TrueAnomaly()); - MicroEntries.Add(new UniversalTimeAtClosestApproach()); - MicroEntries.Add(new UniversalTimeAtSoiEncounter()); - MicroEntries.Add(new OrbitPercent()); - MicroEntries.Add(new OrbitRadius()); - MicroEntries.Add(new ManeuverPrograde()); - MicroEntries.Add(new ManeuverNormal()); - MicroEntries.Add(new ManeuverRadial()); - MicroEntries.Add(new DistanceAtCloseApproach1()); - MicroEntries.Add(new TimeToCloseApproach1()); - MicroEntries.Add(new RelativeSpeedAtCloseApproach1()); - MicroEntries.Add(new DistanceAtCloseApproach2()); - MicroEntries.Add(new TimeToCloseApproach2()); - MicroEntries.Add(new RelativeSpeedAtCloseApproach2()); - MicroEntries.Add(new Target_EccentricAnomaly()); - MicroEntries.Add(new Target_MeanAnomaly()); - MicroEntries.Add(new Target_ObT()); - MicroEntries.Add(new Target_ArgumentOfPeriapsis()); - MicroEntries.Add(new Target_Eccentricity()); - MicroEntries.Add(new Target_Inclination()); - MicroEntries.Add(new Target_LongitudeOfAscendingNode()); - MicroEntries.Add(new Target_SemiMajorAxis()); - MicroEntries.Add(new Target_ReferenceBodyConstants_Radius()); - MicroEntries.Add(new Target_ReferenceBodyConstants_StandardGravitationParameter()); - MicroEntries.Add(new Target_SemiLatusRectum()); - MicroEntries.Add(new Target_SemiMinorAxis()); - MicroEntries.Add(new Target_TrueAnomaly()); - MicroEntries.Add(new Target_Period()); - MicroEntries.Add(new Target_OrbitRadius()); - MicroEntries.Add(new Target_AltitudeFromSeaLevel()); - MicroEntries.Add(new Target_Name()); - MicroEntries.Add(new Target_Obtvelocity()); - MicroEntries.Add(new PartsCount()); - MicroEntries.Add(new TotalBurnTime()); - MicroEntries.Add(new TotalDeltaVASL()); - MicroEntries.Add(new TotalDeltaVVac()); - MicroEntries.Add(new StageISPAsl()); - MicroEntries.Add(new StageISPActual()); - MicroEntries.Add(new StageISPVac()); - MicroEntries.Add(new StageTWRASL()); - MicroEntries.Add(new StageTWRVac()); - MicroEntries.Add(new StageThrustASL()); - MicroEntries.Add(new StageThrustVac()); - MicroEntries.Add(new Maneuver_EccentricAnomaly()); - MicroEntries.Add(new Maneuver_EndUT()); - MicroEntries.Add(new Maneuver_MeanAnomaly()); - MicroEntries.Add(new Maneuver_ObT()); - MicroEntries.Add(new Maneuver_ArgumentOfPeriapsis()); - MicroEntries.Add(new Maneuver_Eccentricity()); - MicroEntries.Add(new Maneuver_Inclination()); - MicroEntries.Add(new Maneuver_LongitudeOfAscendingNode()); - MicroEntries.Add(new Maneuver_SemiMajorAxis()); - MicroEntries.Add(new Maneuver_SemiMinorAxis()); - MicroEntries.Add(new Maneuver_OrbitalEnergy()); - MicroEntries.Add(new Maneuver_SemiLatusRectum()); - MicroEntries.Add(new Maneuver_TimeToAp()); - MicroEntries.Add(new Maneuver_TimeToPe()); - MicroEntries.Add(new Maneuver_TrueAnomaly()); - MicroEntries.Add(new Maneuver_UniversalTimeAtClosestApproach()); - MicroEntries.Add(new Maneuver_UniversalTimeAtSoiEncounter()); - MicroEntries.Add(new Maneuver_OrbitPercent()); - MicroEntries.Add(new Maneuver_Period()); - MicroEntries.Add(new AngleOfAttack()); - MicroEntries.Add(new SideSlip()); - MicroEntries.Add(new PhaseAngle()); - MicroEntries.Add(new TransferAngle()); - MicroEntries.Add(new Throttle()); + MicroEntries = new List(); + Assembly assembly = Assembly.GetExecutingAssembly(); + Type[] types = assembly.GetTypes(); + // Exclude base classes + Type[] excludedTypes = new [] { typeof(MicroEntry), typeof(BodyEntry), typeof(FlightEntry), typeof(ManeuverEntry), typeof(MiscEntry), typeof(OabStageInfoEntry), typeof(OrbitalEntry), typeof(StageInfoEntry), typeof(SurfaceEntry), typeof(TargetEntry), typeof(VesselEntry) }; + + Type[] entryTypes = types.Where(t => typeof(MicroEntry).IsAssignableFrom(t) && !excludedTypes.Contains(t)).ToArray(); - #endregion + foreach (Type entryType in entryTypes) + { + MicroEntry entry = Activator.CreateInstance(entryType) as MicroEntry; + if (entry != null) + MicroEntries.Add(entry); + } } /// @@ -1268,7 +1114,7 @@ private void InitializeWindows() MainWindow = MainWindow.Vessel, //EditorRect = null, FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Vessel).ToList() + Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Vessel && entry.IsDefault).ToList() }); MicroWindows.Add(new BaseWindow @@ -1286,7 +1132,7 @@ private void InitializeWindows() MainWindow = MainWindow.Orbital, //EditorRect = null, FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Orbital).ToList() + Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Orbital && entry.IsDefault).ToList() }); MicroWindows.Add(new BaseWindow @@ -1304,7 +1150,7 @@ private void InitializeWindows() MainWindow = MainWindow.Surface, //EditorRect = null, FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Surface).ToList() + Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Surface && entry.IsDefault).ToList() }); MicroWindows.Add(new BaseWindow @@ -1322,7 +1168,7 @@ private void InitializeWindows() MainWindow = MainWindow.Flight, //EditorRect = null, FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Flight).ToList() + Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Flight && entry.IsDefault).ToList() }); MicroWindows.Add(new BaseWindow @@ -1340,7 +1186,7 @@ private void InitializeWindows() MainWindow = MainWindow.Target, //EditorRect = null, FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Target).ToList() + Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Target && entry.IsDefault).ToList() }); MicroWindows.Add(new ManeuverWindow @@ -1359,7 +1205,7 @@ private void InitializeWindows() MainWindow = MainWindow.Maneuver, //EditorRect = null, FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Maneuver).ToList() + Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Maneuver && entry.IsDefault).ToList() }); MicroWindows.Add(new BaseWindow @@ -1377,7 +1223,7 @@ private void InitializeWindows() MainWindow = MainWindow.Stage, //EditorRect = null, FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Stage).ToList() + Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Stage && entry.IsDefault).ToList() }); InitializeStageInfoOABWindow(); @@ -1404,7 +1250,7 @@ private void InitializeStageInfoOABWindow() IsLocked = false, // Not used MainWindow = MainWindow.StageInfoOAB, EditorRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, 0, 0), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.OAB).ToList() + Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.OAB && entry.IsDefault).ToList() }); } diff --git a/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs b/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs index 067835d..b596ccf 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/TransferInfo.cs @@ -106,11 +106,16 @@ private static bool CalculateParameters() public static double? GetTransferAngle() { - double ellipseA = (_toOrbit.semiMajorAxis + _fromOrbit.semiMajorAxis) / 2; - double time = Mathf.PI * Mathf.Sqrt((float)((ellipseA) * (ellipseA) * (ellipseA)) / ((float)_toOrbit.referenceBody.Mass * 6.67e-11f)); - double transfer = 180 - ((time / _toOrbit.period) * 360); - while (transfer < -180) { transfer += 360; } - return Math.Round(transfer, 1); + if (CalculateParameters()) + { + double ellipseA = (_toOrbit.semiMajorAxis + _fromOrbit.semiMajorAxis) / 2; + double time = Mathf.PI * Mathf.Sqrt((float)((ellipseA) * (ellipseA) * (ellipseA)) / ((float)_toOrbit.referenceBody.Mass * 6.67e-11f)); + double transfer = 180 - ((time / _toOrbit.period) * 360); + while (transfer < -180) { transfer += 360; } + return Math.Round(transfer, 1); + } + else + return null; } } } \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs index 0a243b7..5c0cb01 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs @@ -18,7 +18,7 @@ public static class Utility public static VesselComponent ActiveVessel; public static ManeuverNodeData CurrentManeuver; public static string LayoutPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MicroLayout.json"); - public static int CurrentLayoutVersion = 1; + public static int CurrentLayoutVersion = 3; private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Utility"); public static GameStateConfiguration GameState; public static MessageCenter MessageCenter; From 1ee150a5edb993e21094b82e5484261e377a8e88 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:44:15 +0200 Subject: [PATCH 25/38] Reorder entries to have a logical order --- .../MicroEngineer/Entries/FlightEntries.cs | 280 ++++++------ .../MicroEngineer/Entries/ManeuverEntries.cs | 426 +++++++++--------- .../MicroEngineer/Entries/MiscEntries.cs | 160 +++---- .../MicroEngineer/Entries/OrbitalEntries.cs | 188 ++++---- .../MicroEngineer/Entries/SurfaceEntries.cs | 254 +++++------ .../MicroEngineer/Entries/TargetEntries.cs | 358 +++++++-------- .../MicroEngineer/Entries/VesselEntries.cs | 136 +++--- .../MicroEngineer/MicroEngineerMod.cs | 2 +- 8 files changed, 901 insertions(+), 903 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index f88cb6d..184d997 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -44,335 +44,333 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class AtmosphericDensity : FlightEntry + public class GeeForce : FlightEntry { - public AtmosphericDensity() + public GeeForce() { - Name = "Atm. Density"; - Description = "Shows the atmospheric density."; + Name = "G-Force"; + Description = "Measurement of the type of force per unit mass – typically acceleration – that causes a perception of weight, with a g-force of 1 g equal to the conventional value of gravitational acceleration on Earth/Kerbin."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "g/L"; + Unit = "g"; Formatting = "{0:N3}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.SimulationObject.Telemetry.AtmosphericDensity; + EntryValue = Utility.ActiveVessel.geeForce; } public override string ValueDisplay => base.ValueDisplay; } - public class TotalLift : FlightEntry + public class AngleOfAttack : FlightEntry { - public TotalLift() + public AngleOfAttack() { - Name = "Total Lift"; - Description = "Shows the total lift force produced by the vessel."; + Name = "AoA"; + Description = "Angle of Attack specifies the angle between the chord line of the wing and the vector representing the relative motion between the aircraft and the atmosphere."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "N"; - Formatting = "{0:N0}"; + Unit = "°"; + Formatting = "{0:N3}"; } public override void RefreshData() { - EntryValue = AeroForces.TotalLift; + EntryValue = AeroForces.AngleOfAttack; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - double toReturn = (double)EntryValue * 1000; - return String.IsNullOrEmpty(base.Formatting) ? toReturn.ToString() : String.Format(base.Formatting, toReturn); - } - } + public override string ValueDisplay => base.ValueDisplay; } - public class TotalDrag : FlightEntry + public class SideSlip : FlightEntry { - public TotalDrag() + public SideSlip() { - Name = "Total Drag"; - Description = "Shows the total drag force exerted on the vessel."; + Name = "Sideslip"; + Description = "A slip is an aerodynamic state where an aircraft is moving somewhat sideways as well as forward relative to the oncoming airflow or relative wind."; Category = MicroEntryCategory.Flight; - IsDefault = true; - Unit = "N"; - Formatting = "{0:N0}"; + IsDefault = false; + Unit = "°"; + Formatting = "{0:N3}"; } public override void RefreshData() { - EntryValue = AeroForces.TotalDrag; + EntryValue = AeroForces.SideSlip; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - double toReturn = (double)EntryValue * 1000; - return String.IsNullOrEmpty(base.Formatting) ? toReturn.ToString() : String.Format(base.Formatting, toReturn); - } - } + public override string ValueDisplay => base.ValueDisplay; } - public class LiftDivDrag : FlightEntry + public class Heading : FlightEntry { - public LiftDivDrag() + public Heading() { - Name = "Lift / Drag"; - Description = "Shows the ratio of total lift and drag forces."; + Name = "Heading"; + Description = "Heading of a vessel is the compass direction in which the craft's nose is pointed."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = null; + Unit = "°"; Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = AeroForces.TotalLift / AeroForces.TotalDrag; + EntryValue = Utility.ActiveVessel.Heading; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - double toReturn = (double)EntryValue * 1000; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); - } - } + public override string ValueDisplay => base.ValueDisplay; } - public class AngleOfAttack : FlightEntry + public class Pitch_HorizonRelative : FlightEntry { - public AngleOfAttack() + public Pitch_HorizonRelative() { - Name = "AoA"; - Description = "Angle of Attack specifies the angle between the chord line of the wing and the vector representing the relative motion between the aircraft and the atmosphere."; + Name = "Pitch"; + Description = "Lateral axis passes through an aircraft from wingtip to wingtip. Rotation about this axis is called pitch (moving up-down)."; Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "°"; - Formatting = "{0:N3}"; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = AeroForces.AngleOfAttack; + EntryValue = Utility.ActiveVessel.Pitch_HorizonRelative; } public override string ValueDisplay => base.ValueDisplay; } - public class SideSlip : FlightEntry + public class Roll_HorizonRelative : FlightEntry { - public SideSlip() + public Roll_HorizonRelative() { - Name = "Sideslip"; - Description = "A slip is an aerodynamic state where an aircraft is moving somewhat sideways as well as forward relative to the oncoming airflow or relative wind."; + Name = "Roll"; + Description = "Longitudinal axis passes through the aircraft from nose to tail. Rotation about this axis is called roll (rotating left-right)."; Category = MicroEntryCategory.Flight; - IsDefault = false; + IsDefault = true; Unit = "°"; - Formatting = "{0:N3}"; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = AeroForces.SideSlip; + EntryValue = Utility.ActiveVessel.Roll_HorizonRelative; } public override string ValueDisplay => base.ValueDisplay; } - public class DragCoefficient : FlightEntry + public class Yaw_HorizonRelative : FlightEntry { - public DragCoefficient() + public Yaw_HorizonRelative() { - Name = "Drag Coefficient"; - Description = "Dimensionless quantity that is used to quantify the drag or resistance of an object in a fluid environment, such as air or water."; + Name = "Yaw"; + Description = "Vertical axis passes through an aircraft from top to bottom. Rotation about this axis is called yaw (moving left-right)."; Category = MicroEntryCategory.Flight; - IsDefault = false; - Unit = null; + IsDefault = true; + Unit = "°"; Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.DragCoefficient; + EntryValue = Utility.ActiveVessel.Yaw_HorizonRelative; } public override string ValueDisplay => base.ValueDisplay; } - public class ExposedArea : FlightEntry + public class Zenith : FlightEntry { - public ExposedArea() + public Zenith() { - Name = "Exposed Area"; - Description = "The surface area that interacts with the working fluid or gas."; + Name = "Zenith"; + Description = "The zenith is an imaginary point directly above a particular location, on the celestial sphere. \"Above\" means in the vertical direction opposite to the gravity direction."; Category = MicroEntryCategory.Flight; IsDefault = false; - Unit = null; // TODO + Unit = "°"; Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.ExposedArea; + EntryValue = Utility.ActiveVessel.Zenith; } public override string ValueDisplay => base.ValueDisplay; } - public class Heading : FlightEntry + public class TotalLift : FlightEntry { - public Heading() + public TotalLift() { - Name = "Heading"; - Description = "Heading of a vessel is the compass direction in which the craft's nose is pointed."; + Name = "Total Lift"; + Description = "Shows the total lift force produced by the vessel."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "°"; - Formatting = "{0:N2}"; + Unit = "N"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Heading; + EntryValue = AeroForces.TotalLift; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + double toReturn = (double)EntryValue * 1000; + return String.IsNullOrEmpty(base.Formatting) ? toReturn.ToString() : String.Format(base.Formatting, toReturn); + } + } } - public class Pitch_HorizonRelative : FlightEntry + public class TotalDrag : FlightEntry { - public Pitch_HorizonRelative() + public TotalDrag() { - Name = "Pitch"; - Description = "Lateral axis passes through an aircraft from wingtip to wingtip. Rotation about this axis is called pitch (moving up-down)."; + Name = "Total Drag"; + Description = "Shows the total drag force exerted on the vessel."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "°"; - Formatting = "{0:N2}"; + Unit = "N"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Pitch_HorizonRelative; + EntryValue = AeroForces.TotalDrag; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + double toReturn = (double)EntryValue * 1000; + return String.IsNullOrEmpty(base.Formatting) ? toReturn.ToString() : String.Format(base.Formatting, toReturn); + } + } } - public class Roll_HorizonRelative : FlightEntry + public class LiftDivDrag : FlightEntry { - public Roll_HorizonRelative() + public LiftDivDrag() { - Name = "Roll"; - Description = "Longitudinal axis passes through the aircraft from nose to tail. Rotation about this axis is called roll (rotating left-right)."; + Name = "Lift / Drag"; + Description = "Shows the ratio of total lift and drag forces."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "°"; + Unit = null; Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Roll_HorizonRelative; + EntryValue = AeroForces.TotalLift / AeroForces.TotalDrag; } - public override string ValueDisplay => base.ValueDisplay; - } + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; - public class Yaw_HorizonRelative : FlightEntry + double toReturn = (double)EntryValue * 1000; + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(base.Formatting, EntryValue); + } + } + } + + public class DragCoefficient : FlightEntry { - public Yaw_HorizonRelative() + public DragCoefficient() { - Name = "Yaw"; - Description = "Vertical axis passes through an aircraft from top to bottom. Rotation about this axis is called yaw (moving left-right)."; + Name = "Drag Coefficient"; + Description = "Dimensionless quantity that is used to quantify the drag or resistance of an object in a fluid environment, such as air or water."; Category = MicroEntryCategory.Flight; - IsDefault = true; - Unit = "°"; + IsDefault = false; + Unit = null; Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Yaw_HorizonRelative; + EntryValue = Utility.ActiveVessel.DragCoefficient; } public override string ValueDisplay => base.ValueDisplay; } - public class Zenith : FlightEntry + public class ExposedArea : FlightEntry { - public Zenith() + public ExposedArea() { - Name = "Zenith"; - Description = "The zenith is an imaginary point directly above a particular location, on the celestial sphere. \"Above\" means in the vertical direction opposite to the gravity direction."; + Name = "Exposed Area"; + Description = "The surface area that interacts with the working fluid or gas."; Category = MicroEntryCategory.Flight; IsDefault = false; - Unit = "°"; + Unit = null; // TODO Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Zenith; + EntryValue = Utility.ActiveVessel.ExposedArea; } public override string ValueDisplay => base.ValueDisplay; } - public class SoundSpeed : FlightEntry + public class AtmosphericDensity : FlightEntry { - public SoundSpeed() + public AtmosphericDensity() { - Name = "Speed of sound"; - Description = "Distance travelled per unit of time by a sound wave as it propagates through the air."; + Name = "Atm. Density"; + Description = "Shows the atmospheric density."; Category = MicroEntryCategory.Flight; - IsDefault = false; - Unit = "m/s"; - Formatting = "{0:N1}"; + IsDefault = true; + Unit = "g/L"; + Formatting = "{0:N3}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.SoundSpeed; + EntryValue = Utility.ActiveVessel.SimulationObject.Telemetry.AtmosphericDensity; } public override string ValueDisplay => base.ValueDisplay; } - public class GeeForce : FlightEntry + public class SoundSpeed : FlightEntry { - public GeeForce() + public SoundSpeed() { - Name = "G-Force"; - Description = "Measurement of the type of force per unit mass – typically acceleration – that causes a perception of weight, with a g-force of 1 g equal to the conventional value of gravitational acceleration on Earth/Kerbin."; + Name = "Speed of sound"; + Description = "Distance travelled per unit of time by a sound wave as it propagates through the air."; Category = MicroEntryCategory.Flight; - IsDefault = true; - Unit = "g"; - Formatting = "{0:N3}"; + IsDefault = false; + Unit = "m/s"; + Formatting = "{0:N1}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.geeForce; + EntryValue = Utility.ActiveVessel.SoundSpeed; } public override string ValueDisplay => base.ValueDisplay; } - - } diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index fe44597..6b25fab 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -9,52 +9,6 @@ public class ManeuverEntry : MicroEntry internal int SelectedNodeIndex = 0; } - public class ProjectedAp : ManeuverEntry - { - public ProjectedAp() - { - Name = "Projected Ap."; - Description = "Projected Apoapsis vessel will have after completing the maneuver."; - Category = MicroEntryCategory.Maneuver; - IsDefault = true; - Unit = "m"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? - .Where(p => p.ActivePatch == true) - .ElementAtOrDefault(base.SelectedNodeIndex)? - .ApoapsisArl; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class ProjectedPe : ManeuverEntry - { - public ProjectedPe() - { - Name = "Projected Pe."; - Description = "Projected Periapsis vessel will have after completing the maneuver."; - Category = MicroEntryCategory.Maneuver; - IsDefault = true; - Unit = "m"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? - .Where(p => p.ActivePatch == true) - .ElementAtOrDefault(base.SelectedNodeIndex)? - .PeriapsisArl; - } - - public override string ValueDisplay => base.ValueDisplay; - } - public class DeltaVRequired : ManeuverEntry { public DeltaVRequired() @@ -203,16 +157,16 @@ public override string ValueDisplay } } - public class Maneuver_EccentricAnomaly : ManeuverEntry + public class ProjectedAp : ManeuverEntry { - public Maneuver_EccentricAnomaly() + public ProjectedAp() { - Name = "Eccentric Anomaly"; - Description = "Eccentric Anomaly vessel will have after completing the maneuver."; + Name = "Projected Ap."; + Description = "Projected Apoapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; - IsDefault = false; - Unit = "°"; - Formatting = "{0:N2}"; + IsDefault = true; + Unit = "m"; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -220,7 +174,53 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .EccentricAnomaly; + .ApoapsisArl; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class ProjectedPe : ManeuverEntry + { + public ProjectedPe() + { + Name = "Projected Pe."; + Description = "Projected Periapsis vessel will have after completing the maneuver."; + Category = MicroEntryCategory.Maneuver; + IsDefault = true; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .PeriapsisArl; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_TimeToAp : ManeuverEntry + { + public Maneuver_TimeToAp() + { + Name = "Time to Ap."; + Description = "Shows the Time to Apoapsis vessel will have after reaching the maneuver node."; + Category = MicroEntryCategory.Maneuver; + IsDefault = true; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .TimeToAp; } public override string ValueDisplay @@ -230,21 +230,21 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } - public class Maneuver_EndUT : ManeuverEntry + public class Maneuver_TimeToPe : ManeuverEntry { - public Maneuver_EndUT() + public Maneuver_TimeToPe() { - Name = "UT"; - Description = "Universal Time when vessel reaches the maneuver node."; + Name = "Time to Pe."; + Description = "Shows the Time to Periapsis vessel will have after reaching the maneuver node."; Category = MicroEntryCategory.Maneuver; - IsDefault = false; + IsDefault = true; Unit = "s"; - Formatting = "{0:N3}"; + Formatting = null; } public override void RefreshData() @@ -252,7 +252,7 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .EndUT; + .TimeToPe; } public override string ValueDisplay @@ -267,16 +267,16 @@ public override string ValueDisplay } } - public class Maneuver_MeanAnomaly : ManeuverEntry + public class Maneuver_Inclination : ManeuverEntry { - public Maneuver_MeanAnomaly() + public Maneuver_Inclination() { - Name = "Mean Anomaly"; - Description = "Mean Anomaly vessel will have after completing the maneuver."; + Name = "Inclination"; + Description = "The inclination of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; - IsDefault = false; + IsDefault = true; Unit = "°"; - Formatting = "{0:N2}"; + Formatting = "{0:N3}"; } public override void RefreshData() @@ -284,31 +284,45 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .MeanAnomaly; + .OrbitalElements.Inclination; } - public override string ValueDisplay + public override string ValueDisplay => base.ValueDisplay; + } + + public class Maneuver_Eccentricity : ManeuverEntry + { + public Maneuver_Eccentricity() { - get - { - if (EntryValue == null) - return "-"; + Name = "Eccentricity"; + Description = "The eccentricity of the vessel's orbit after the burn."; + Category = MicroEntryCategory.Maneuver; + IsDefault = true; + Unit = null; + Formatting = "{0:N3}"; + } - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); - } + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? + .Where(p => p.ActivePatch == true) + .ElementAtOrDefault(base.SelectedNodeIndex)? + .OrbitalElements.Eccentricity; } + + public override string ValueDisplay => base.ValueDisplay; } - public class Maneuver_ObT : ManeuverEntry + public class Maneuver_Period : ManeuverEntry { - public Maneuver_ObT() + public Maneuver_Period() { - Name = "Orbit Time"; - Description = "Shows orbit time in seconds from the Periapsis when vessel reaches the maneuver node."; + Name = "Period"; + Description = "The period of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; - IsDefault = false; + IsDefault = true; Unit = "s"; - Formatting = "{0:N0}"; + Formatting = null; } public override void RefreshData() @@ -316,7 +330,7 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .ObT; + .period; } public override string ValueDisplay @@ -331,16 +345,16 @@ public override string ValueDisplay } } - public class Maneuver_ArgumentOfPeriapsis : ManeuverEntry + public class Maneuver_TrueAnomaly : ManeuverEntry { - public Maneuver_ArgumentOfPeriapsis() + public Maneuver_TrueAnomaly() { - Name = "Argument of Pe."; - Description = "Argument of Periapsis vessel will have after completing the maneuver."; + Name = "True Anomaly"; + Description = "True Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + Formatting = "{0:N1}"; } public override void RefreshData() @@ -348,22 +362,31 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .OrbitalElements.ArgumentOfPeriapsis; + .TrueAnomaly; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } } - public class Maneuver_Eccentricity : ManeuverEntry + public class Maneuver_MeanAnomaly : ManeuverEntry { - public Maneuver_Eccentricity() + public Maneuver_MeanAnomaly() { - Name = "Eccentricity"; - Description = "The eccentricity of the vessel's orbit after the burn."; + Name = "Mean Anomaly"; + Description = "Mean Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; - IsDefault = true; - Unit = null; - Formatting = "{0:N3}"; + IsDefault = false; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -371,22 +394,31 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .OrbitalElements.Eccentricity; + .MeanAnomaly; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } } - public class Maneuver_Inclination : ManeuverEntry + public class Maneuver_EccentricAnomaly : ManeuverEntry { - public Maneuver_Inclination() + public Maneuver_EccentricAnomaly() { - Name = "Inclination"; - Description = "The inclination of the vessel's orbit after the burn."; + Name = "Eccentric Anomaly"; + Description = "Eccentric Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; - IsDefault = true; + IsDefault = false; Unit = "°"; - Formatting = "{0:N3}"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -394,10 +426,19 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .OrbitalElements.Inclination; + .EccentricAnomaly; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } } public class Maneuver_LongitudeOfAscendingNode : ManeuverEntry @@ -423,16 +464,16 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class Maneuver_SemiMajorAxis : ManeuverEntry + public class Maneuver_ArgumentOfPeriapsis : ManeuverEntry { - public Maneuver_SemiMajorAxis() + public Maneuver_ArgumentOfPeriapsis() { - Name = "Semi Major Axis"; - Description = "Semi Major Axis vessel will have after completing the maneuver."; + Name = "Argument of Pe."; + Description = "Argument of Periapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "m"; - Formatting = "{0:N0}"; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -440,18 +481,18 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .OrbitalElements.SemiMajorAxis; + .OrbitalElements.ArgumentOfPeriapsis; } public override string ValueDisplay => base.ValueDisplay; } - public class Maneuver_SemiMinorAxis : ManeuverEntry + public class Maneuver_SemiLatusRectum : ManeuverEntry { - public Maneuver_SemiMinorAxis() + public Maneuver_SemiLatusRectum() { - Name = "Semi Minor Axis"; - Description = "Semi Minor Axis vessel will have after completing the maneuver."; + Name = "Semi Latus Rectum"; + Description = "Semi Latus Rectum vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "m"; @@ -463,21 +504,21 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .SemiMinorAxis; + .SemiLatusRectum; } public override string ValueDisplay => base.ValueDisplay; } - public class Maneuver_OrbitalEnergy : ManeuverEntry + public class Maneuver_SemiMajorAxis : ManeuverEntry { - public Maneuver_OrbitalEnergy() + public Maneuver_SemiMajorAxis() { - Name = "Orbital Energy"; - Description = "Orbital Energy vessel will have after completing the maneuver."; + Name = "Semi Major Axis"; + Description = "Semi Major Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "kJ"; + Unit = "m"; Formatting = "{0:N0}"; } @@ -486,18 +527,18 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .OrbitalEnergy; + .OrbitalElements.SemiMajorAxis; } public override string ValueDisplay => base.ValueDisplay; } - public class Maneuver_SemiLatusRectum : ManeuverEntry + public class Maneuver_SemiMinorAxis : ManeuverEntry { - public Maneuver_SemiLatusRectum() + public Maneuver_SemiMinorAxis() { - Name = "Semi Latus Rectum"; - Description = "Semi Latus Rectum vessel will have after completing the maneuver."; + Name = "Semi Minor Axis"; + Description = "Semi Minor Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "m"; @@ -509,22 +550,22 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .SemiLatusRectum; + .SemiMinorAxis; } public override string ValueDisplay => base.ValueDisplay; } - public class Maneuver_TimeToAp : ManeuverEntry + public class Maneuver_OrbitalEnergy : ManeuverEntry { - public Maneuver_TimeToAp() + public Maneuver_OrbitalEnergy() { - Name = "Time to Ap."; - Description = "Shows the Time to Apoapsis vessel will have after reaching the maneuver node."; + Name = "Orbital Energy"; + Description = "Orbital Energy vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; - IsDefault = true; - Unit = "s"; - Formatting = null; + IsDefault = false; + Unit = "kJ"; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -532,31 +573,22 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .TimeToAp; + .OrbitalEnergy; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); - } - } + public override string ValueDisplay => base.ValueDisplay; } - public class Maneuver_TimeToPe : ManeuverEntry + public class Maneuver_ObT : ManeuverEntry { - public Maneuver_TimeToPe() + public Maneuver_ObT() { - Name = "Time to Pe."; - Description = "Shows the Time to Periapsis vessel will have after reaching the maneuver node."; + Name = "Orbit Time"; + Description = "Shows orbit time in seconds from the Periapsis when vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; - IsDefault = true; + IsDefault = false; Unit = "s"; - Formatting = null; + Formatting = "{0:N0}"; } public override void RefreshData() @@ -564,7 +596,7 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .TimeToPe; + .ObT; } public override string ValueDisplay @@ -579,16 +611,16 @@ public override string ValueDisplay } } - public class Maneuver_TrueAnomaly : ManeuverEntry + public class Maneuver_OrbitPercent : ManeuverEntry { - public Maneuver_TrueAnomaly() + public Maneuver_OrbitPercent() { - Name = "True Anomaly"; - Description = "True Anomaly vessel will have after completing the maneuver."; + Name = "Orbit percent"; + Description = "Orbit percent vessel will have passed after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "°"; - Formatting = "{0:N1}"; + Unit = "%"; + Formatting = "{0:N2}"; } public override void RefreshData() @@ -596,31 +628,22 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .TrueAnomaly; + .orbitPercent * 100; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); - } - } + public override string ValueDisplay => base.ValueDisplay; } - public class Maneuver_UniversalTimeAtClosestApproach : ManeuverEntry + public class Maneuver_EndUT : ManeuverEntry { - public Maneuver_UniversalTimeAtClosestApproach() + public Maneuver_EndUT() { - Name = "UT Close.App."; - Description = "Universal Time at the point of closest approach."; + Name = "UT"; + Description = "Universal Time when vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = null; - Formatting = null; + Unit = "s"; + Formatting = "{0:N3}"; } public override void RefreshData() @@ -628,7 +651,7 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .UniversalTimeAtClosestApproach; + .EndUT; } public override string ValueDisplay @@ -643,12 +666,12 @@ public override string ValueDisplay } } - public class Maneuver_UniversalTimeAtSoiEncounter : ManeuverEntry + public class Maneuver_UniversalTimeAtClosestApproach : ManeuverEntry { - public Maneuver_UniversalTimeAtSoiEncounter() + public Maneuver_UniversalTimeAtClosestApproach() { - Name = "UT SOI Enc."; - Description = "Universal Time at the point of transition to another Sphere Of Influence."; + Name = "UT Close.App."; + Description = "Universal Time at the point of closest approach."; Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = null; @@ -660,7 +683,7 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .UniversalTimeAtSoiEncounter; + .UniversalTimeAtClosestApproach; } public override string ValueDisplay @@ -675,38 +698,15 @@ public override string ValueDisplay } } - public class Maneuver_OrbitPercent : ManeuverEntry + public class Maneuver_UniversalTimeAtSoiEncounter : ManeuverEntry { - public Maneuver_OrbitPercent() + public Maneuver_UniversalTimeAtSoiEncounter() { - Name = "Orbit percent"; - Description = "Orbit percent vessel will have passed after completing the maneuver."; + Name = "UT SOI Enc."; + Description = "Universal Time at the point of transition to another Sphere Of Influence."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "%"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? - .Where(p => p.ActivePatch == true) - .ElementAtOrDefault(base.SelectedNodeIndex)? - .orbitPercent * 100; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Maneuver_Period : ManeuverEntry - { - public Maneuver_Period() - { - Name = "Period"; - Description = "The period of the vessel's orbit after the burn."; - Category = MicroEntryCategory.Maneuver; - IsDefault = true; - Unit = "s"; + Unit = null; Formatting = null; } @@ -715,7 +715,7 @@ public override void RefreshData() EntryValue = Utility.ActiveVessel.Orbiter?.ManeuverPlanSolver?.PatchedConicsList? .Where(p => p.ActivePatch == true) .ElementAtOrDefault(base.SelectedNodeIndex)? - .period; + .UniversalTimeAtSoiEncounter; } public override string ValueDisplay diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs index d0eb849..6444194 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -19,52 +19,61 @@ public Separator() } } - public class AutopilotStatus_IsEnabled : MiscEntry + public class GravityForPos : MiscEntry { - public AutopilotStatus_IsEnabled() + public GravityForPos() { - Name = "Autopilot"; - Description = "Is autopilot enabled or disabled."; + Name = "Local Gravity"; + Description = "Local gravity vessel is experiencing."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = null; - Formatting = null; + Unit = "ms2"; + Formatting = "{0:N3}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.AutopilotStatus.IsEnabled; + EntryValue = Utility.ActiveVessel.gravityForPos.magnitude; } - public override string ValueDisplay => EntryValue != null ? (bool)EntryValue ? "Enabled" : "Disabled" : "-"; + public override string ValueDisplay => base.ValueDisplay; } - public class AutopilotStatus_Mode : MiscEntry + public class EndUT : MiscEntry { - public AutopilotStatus_Mode() + public EndUT() { - Name = "Autopilot Mode"; - Description = "Mode vessel's autopilot is using: stability assist, prograde, retrograde, normal, etc."; + Name = "UT"; + Description = "Universal Time."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = null; - Formatting = null; + Unit = "s"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.AutopilotStatus.Mode; + EntryValue = Utility.ActiveVessel.Orbit.EndUT; } - public override string ValueDisplay => EntryValue != null ? (AutopilotMode)EntryValue == AutopilotMode.StabilityAssist ? "Stability" : EntryValue.ToString() : null; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); + } + } } - public class TimeSinceLaunch : MiscEntry + public class StartUT : MiscEntry { - public TimeSinceLaunch() + public StartUT() { - Name = "Time since launch"; - Description = "Time since the vessel launched."; + Name = "Start UT"; + Description = "Time passed since vessel was launched."; Category = MicroEntryCategory.Misc; IsDefault = false; Unit = "s"; @@ -73,7 +82,7 @@ public TimeSinceLaunch() public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TimeSinceLaunch; + EntryValue = Utility.ActiveVessel.Orbit.StartUT; } public override string ValueDisplay @@ -88,41 +97,50 @@ public override string ValueDisplay } } - public class GravityForPos : MiscEntry + public class LaunchTime : MiscEntry { - public GravityForPos() + public LaunchTime() { - Name = "Local Gravity"; - Description = "Local gravity vessel is experiencing."; + Name = "Launch Time"; + Description = "Universal Time when vessel was launched."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "ms2"; + Unit = "s"; Formatting = "{0:N3}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.gravityForPos.magnitude; + EntryValue = Utility.ActiveVessel.launchTime; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); + } + } } - public class LaunchTime : MiscEntry + public class TimeSinceLaunch : MiscEntry { - public LaunchTime() + public TimeSinceLaunch() { - Name = "Launch Time"; - Description = "Universal Time when vessel was launched."; + Name = "Time since launch"; + Description = "Time since the vessel launched."; Category = MicroEntryCategory.Misc; IsDefault = false; Unit = "s"; - Formatting = "{0:N3}"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.launchTime; + EntryValue = Utility.ActiveVessel.TimeSinceLaunch; } public override string ValueDisplay @@ -137,12 +155,12 @@ public override string ValueDisplay } } - public class AltimeterMode : MiscEntry + public class AutopilotStatus_IsEnabled : MiscEntry { - public AltimeterMode() + public AutopilotStatus_IsEnabled() { - Name = "Altimeter Mode"; - Description = "Mode vessel's altimeter is using: Sea Level or Ground Level."; + Name = "Autopilot"; + Description = "Is autopilot enabled or disabled."; Category = MicroEntryCategory.Misc; IsDefault = false; Unit = null; @@ -151,18 +169,18 @@ public AltimeterMode() public override void RefreshData() { - EntryValue = Utility.ActiveVessel.altimeterMode; + EntryValue = Utility.ActiveVessel.AutopilotStatus.IsEnabled; } - public override string ValueDisplay => EntryValue != null ? (AltimeterDisplayMode)EntryValue == AltimeterDisplayMode.SeaLevel ? "Sea Level" : (AltimeterDisplayMode)EntryValue == AltimeterDisplayMode.GroundLevel ? "Ground Level" : "-" : "-"; + public override string ValueDisplay => EntryValue != null ? (bool)EntryValue ? "Enabled" : "Disabled" : "-"; } - public class SpeedMode : MiscEntry + public class AutopilotStatus_Mode : MiscEntry { - public SpeedMode() + public AutopilotStatus_Mode() { - Name = "Speed Mode"; - Description = "Mode vessel's velocity meter is using: Orbit, Surface or Target."; + Name = "Autopilot Mode"; + Description = "Mode vessel's autopilot is using: stability assist, prograde, retrograde, normal, etc."; Category = MicroEntryCategory.Misc; IsDefault = false; Unit = null; @@ -171,68 +189,50 @@ public SpeedMode() public override void RefreshData() { - EntryValue = Utility.ActiveVessel.speedMode; + EntryValue = Utility.ActiveVessel.AutopilotStatus.Mode; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay => EntryValue != null ? (AutopilotMode)EntryValue == AutopilotMode.StabilityAssist ? "Stability" : EntryValue.ToString() : null; } - public class StartUT : MiscEntry + public class AltimeterMode : MiscEntry { - public StartUT() + public AltimeterMode() { - Name = "Start UT"; - Description = "Time passed since vessel was launched."; + Name = "Altimeter Mode"; + Description = "Mode vessel's altimeter is using: Sea Level or Ground Level."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "s"; - Formatting = "{0:N0}"; + Unit = null; + Formatting = null; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Orbit.StartUT; + EntryValue = Utility.ActiveVessel.altimeterMode; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); - } - } + public override string ValueDisplay => EntryValue != null ? (AltimeterDisplayMode)EntryValue == AltimeterDisplayMode.SeaLevel ? "Sea Level" : (AltimeterDisplayMode)EntryValue == AltimeterDisplayMode.GroundLevel ? "Ground Level" : "-" : "-"; } - public class EndUT : MiscEntry + public class SpeedMode : MiscEntry { - public EndUT() + public SpeedMode() { - Name = "UT"; - Description = "Universal Time."; + Name = "Speed Mode"; + Description = "Mode vessel's velocity meter is using: Orbit, Surface or Target."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "s"; - Formatting = "{0:N0}"; + Unit = null; + Formatting = null; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Orbit.EndUT; + EntryValue = Utility.ActiveVessel.speedMode; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class UniversalTimeAtClosestApproach : MiscEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 3d103be..5fefb51 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -26,6 +26,26 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } + public class Periapsis : OrbitalEntry + { + public Periapsis() + { + Name = "Periapsis"; + Description = "Vessel's periapsis height relative to the sea level. Periapsis is the lowest point of an orbit."; + Category = MicroEntryCategory.Orbital; + IsDefault = true; + Unit = "m"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.Orbit.PeriapsisArl; + } + + public override string ValueDisplay => base.ValueDisplay; + } + public class TimeToApoapsis : OrbitalEntry { public TimeToApoapsis() @@ -55,26 +75,6 @@ public override string ValueDisplay } } - public class Periapsis : OrbitalEntry - { - public Periapsis() - { - Name = "Periapsis"; - Description = "Vessel's periapsis height relative to the sea level. Periapsis is the lowest point of an orbit."; - Category = MicroEntryCategory.Orbital; - IsDefault = true; - Unit = "m"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.Orbit.PeriapsisArl; - } - - public override string ValueDisplay => base.ValueDisplay; - } - public class TimeToPeriapsis : OrbitalEntry { public TimeToPeriapsis() @@ -173,35 +173,6 @@ public override string ValueDisplay } } - public class SoiTransition : OrbitalEntry - { - public SoiTransition() - { - Name = "SOI Trans."; - Description = "Shows the amount of time it will take to transition to another Sphere Of Influence."; - Category = MicroEntryCategory.Orbital; - IsDefault = false; - Unit = "s"; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter - GameManager.Instance.Game.UniverseModel.UniversalTime; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return (double)EntryValue >= 0 ? Utility.SecondsToTimeString((double)EntryValue) : "-"; - } - } - } - public class OrbitalSpeed : OrbitalEntry { public OrbitalSpeed() @@ -222,21 +193,21 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class EccentricAnomaly : OrbitalEntry + public class TrueAnomaly : OrbitalEntry { - public EccentricAnomaly() + public TrueAnomaly() { - Name = "Eccentric Anomaly"; - Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the vessel is."; + Name = "True Anomaly"; + Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + Formatting = "{0:N1}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Orbit.EccentricAnomaly; + EntryValue = Utility.ActiveVessel.Orbit.TrueAnomaly; } public override string ValueDisplay @@ -246,7 +217,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, Utility.RadiansToDegrees((double)EntryValue)); } } } @@ -280,21 +251,21 @@ public override string ValueDisplay } } - public class TrueAnomaly : OrbitalEntry + public class EccentricAnomaly : OrbitalEntry { - public TrueAnomaly() + public EccentricAnomaly() { - Name = "True Anomaly"; - Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; + Name = "Eccentric Anomaly"; + Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the vessel is."; Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "°"; - Formatting = "{0:N1}"; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Orbit.TrueAnomaly; + EntryValue = Utility.ActiveVessel.Orbit.EccentricAnomaly; } public override string ValueDisplay @@ -304,38 +275,29 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, Utility.RadiansToDegrees((double)EntryValue)); + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); } } } - public class ObT : OrbitalEntry + public class LongitudeOfAscendingNode : OrbitalEntry { - public ObT() + public LongitudeOfAscendingNode() { - Name = "Orbit Time"; - Description = "Shows orbit time in seconds from the Periapsis."; + Name = "LAN Ω"; + Description = "Longitude of Ascending Node is an angle from a specified reference direction, called the origin of longitude, to the direction of the ascending node, as measured in a specified reference plane."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "s"; - Formatting = "{0:N0}"; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Orbit.ObT; + EntryValue = Utility.ActiveVessel.Orbit.OrbitalElements.LongitudeOfAscendingNode; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); - } - } + public override string ValueDisplay => base.ValueDisplay; } public class ArgumentOfPeriapsis : OrbitalEntry @@ -358,21 +320,21 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class LongitudeOfAscendingNode : OrbitalEntry + public class SemiLatusRectum : OrbitalEntry { - public LongitudeOfAscendingNode() + public SemiLatusRectum() { - Name = "LAN Ω"; - Description = "Longitude of Ascending Node is an angle from a specified reference direction, called the origin of longitude, to the direction of the ascending node, as measured in a specified reference plane."; + Name = "Semi Latus Rectum"; + Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "°"; - Formatting = "{0:N2}"; + Unit = "m"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Orbit.OrbitalElements.LongitudeOfAscendingNode; + EntryValue = Utility.ActiveVessel.Orbit.SemiLatusRectum; } public override string ValueDisplay => base.ValueDisplay; @@ -438,24 +400,33 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class SemiLatusRectum : OrbitalEntry + public class ObT : OrbitalEntry { - public SemiLatusRectum() + public ObT() { - Name = "Semi Latus Rectum"; - Description = "Half the length of the chord through one focus, perpendicular to the major axis."; + Name = "Orbit Time"; + Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "m"; + Unit = "s"; Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Orbit.SemiLatusRectum; + EntryValue = Utility.ActiveVessel.Orbit.ObT; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); + } + } } public class OrbitPercent : OrbitalEntry @@ -497,4 +468,33 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } + + public class SoiTransition : OrbitalEntry + { + public SoiTransition() + { + Name = "SOI Trans."; + Description = "Shows the amount of time it will take to transition to another Sphere Of Influence."; + Category = MicroEntryCategory.Orbital; + IsDefault = false; + Unit = "s"; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.Orbit.UniversalTimeAtSoiEncounter - GameManager.Instance.Game.UniverseModel.UniversalTime; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return (double)EntryValue >= 0 ? Utility.SecondsToTimeString((double)EntryValue) : "-"; + } + } + } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index ead1323..0e153c8 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -5,80 +5,122 @@ namespace MicroMod { public class SurfaceEntry : MicroEntry { } - - public class Situation : SurfaceEntry + + public class AltitudeAgl : SurfaceEntry { - public Situation() + public AltitudeAgl() { - Name = "Situation"; - Description = "Shows the vessel's current situation: Landed, Flying, Orbiting, etc."; + Name = "Altitude (Ground)"; + Description = "Shows the vessel's altitude above ground Level."; Category = MicroEntryCategory.Surface; IsDefault = true; - Unit = null; - Formatting = null; + Unit = "m"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Situation; + EntryValue = Utility.ActiveVessel.AltitudeFromTerrain; } - public override string ValueDisplay + public override string ValueDisplay => base.ValueDisplay; + } + + public class AltitudeAsl : SurfaceEntry + { + public AltitudeAsl() { - get - { - if (EntryValue == null) - return "-"; + Name = "Altitude (Sea Lvl)"; + Description = "Shows the vessel's altitude above sea level."; + Category = MicroEntryCategory.Surface; + IsDefault = true; + Unit = "m"; + Formatting = "{0:N0}"; + } - return Utility.SituationToString((VesselSituations)EntryValue); - } + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.AltitudeFromSeaLevel; } + + public override string ValueDisplay => base.ValueDisplay; } - public class Latitude : SurfaceEntry + public class AltitudeFromScenery : SurfaceEntry { - public Latitude() + public AltitudeFromScenery() { - Name = "Latitude"; - Description = "Shows the vessel's latitude position around the celestial body. Latitude is the angle from the equator towards the poles."; + Name = "Altitude (Scenery)"; + Description = "Shows the vessel's altitude above scenery."; Category = MicroEntryCategory.Surface; - IsDefault = true; - Formatting = null; + IsDefault = false; + Unit = "m"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Latitude; - Unit = Utility.ActiveVessel.Latitude < 0 ? "S" : "N"; + EntryValue = Utility.ActiveVessel.AltitudeFromScenery; } - public override string ValueDisplay + public override string ValueDisplay => base.ValueDisplay; + } + + public class VerticalVelocity : SurfaceEntry + { + public VerticalVelocity() { - get - { - if (EntryValue == null) - return "-"; + Name = "Vertical Vel."; + Description = "Shows the vessel's vertical velocity (up/down)."; + Category = MicroEntryCategory.Surface; + IsDefault = true; + Unit = "m/s"; + Formatting = "{0:N1}"; + } - return Utility.DegreesToDMS((double)EntryValue); - } + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.VerticalSrfSpeed; } + + public override string ValueDisplay => base.ValueDisplay; } - public class Longitude : SurfaceEntry + public class HorizontalVelocity : SurfaceEntry { - public Longitude() + public HorizontalVelocity() { - Name = "Longitude"; - Description = "Shows the vessel's longitude position around the celestial body. Longitude is the angle from the body's prime meridian to the current meridian."; + Name = "Horizontal Vel."; + Description = "Shows the vessel's horizontal velocity across a celestial body's surface."; Category = MicroEntryCategory.Surface; IsDefault = true; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.HorizontalSrfSpeed; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Situation : SurfaceEntry + { + public Situation() + { + Name = "Situation"; + Description = "Shows the vessel's current situation: Landed, Flying, Orbiting, etc."; + Category = MicroEntryCategory.Surface; + IsDefault = true; + Unit = null; Formatting = null; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.Longitude; - Unit = Utility.ActiveVessel.Longitude < 0 ? "W" : "E"; + EntryValue = Utility.ActiveVessel.Situation; } public override string ValueDisplay @@ -88,7 +130,7 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return Utility.DegreesToDMS((double)EntryValue); + return Utility.SituationToString((VesselSituations)EntryValue); } } } @@ -122,101 +164,99 @@ public override string ValueDisplay } } - public class AltitudeAsl : SurfaceEntry + public class Latitude : SurfaceEntry { - public AltitudeAsl() + public Latitude() { - Name = "Altitude (Sea Lvl)"; - Description = "Shows the vessel's altitude above sea level."; + Name = "Latitude"; + Description = "Shows the vessel's latitude position around the celestial body. Latitude is the angle from the equator towards the poles."; Category = MicroEntryCategory.Surface; IsDefault = true; - Unit = "m"; - Formatting = "{0:N0}"; + Formatting = null; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.AltitudeFromSeaLevel; + EntryValue = Utility.ActiveVessel.Latitude; + Unit = Utility.ActiveVessel.Latitude < 0 ? "S" : "N"; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return Utility.DegreesToDMS((double)EntryValue); + } + } } - public class AltitudeAgl : SurfaceEntry + public class Longitude : SurfaceEntry { - public AltitudeAgl() + public Longitude() { - Name = "Altitude (Ground)"; - Description = "Shows the vessel's altitude above ground Level."; + Name = "Longitude"; + Description = "Shows the vessel's longitude position around the celestial body. Longitude is the angle from the body's prime meridian to the current meridian."; Category = MicroEntryCategory.Surface; IsDefault = true; - Unit = "m"; - Formatting = "{0:N0}"; + Formatting = null; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.AltitudeFromTerrain; + EntryValue = Utility.ActiveVessel.Longitude; + Unit = Utility.ActiveVessel.Longitude < 0 ? "W" : "E"; } - public override string ValueDisplay => base.ValueDisplay; - } - - public class AltitudeFromScenery : SurfaceEntry - { - public AltitudeFromScenery() + public override string ValueDisplay { - Name = "Altitude (Scenery)"; - Description = "Shows the vessel's altitude above scenery."; - Category = MicroEntryCategory.Surface; - IsDefault = false; - Unit = "m"; - Formatting = "{0:N0}"; - } + get + { + if (EntryValue == null) + return "-"; - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.AltitudeFromScenery; + return Utility.DegreesToDMS((double)EntryValue); + } } - - public override string ValueDisplay => base.ValueDisplay; } - public class HorizontalVelocity : SurfaceEntry + public class DynamicPressure_kPa : SurfaceEntry { - public HorizontalVelocity() + public DynamicPressure_kPa() { - Name = "Horizontal Vel."; - Description = "Shows the vessel's horizontal velocity across a celestial body's surface."; + Name = "Dynamic Pressure"; + Description = "Dynamic Pressure (q) is a defined property of a moving flow of gas. It describes how much pressure the airflow is having on the vessel."; Category = MicroEntryCategory.Surface; - IsDefault = true; - Unit = "m/s"; - Formatting = "{0:N1}"; + IsDefault = false; + Unit = "kPa"; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.HorizontalSrfSpeed; + EntryValue = Utility.ActiveVessel.DynamicPressure_kPa; } public override string ValueDisplay => base.ValueDisplay; } - public class VerticalVelocity : SurfaceEntry + public class StaticPressure_kPa : SurfaceEntry { - public VerticalVelocity() + public StaticPressure_kPa() { - Name = "Vertical Vel."; - Description = "Shows the vessel's vertical velocity (up/down)."; + Name = "Static Pressure"; + Description = "Static pressure is a term used to define the amount of pressure exerted by a fluid that is not moving - ambient pressure."; Category = MicroEntryCategory.Surface; - IsDefault = true; - Unit = "m/s"; - Formatting = "{0:N1}"; + IsDefault = false; + Unit = "kPa"; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.VerticalSrfSpeed; + EntryValue = Utility.ActiveVessel.StaticPressure_kPa; } public override string ValueDisplay => base.ValueDisplay; @@ -260,45 +300,5 @@ public override void RefreshData() } public override string ValueDisplay => base.ValueDisplay; - } - - public class DynamicPressure_kPa : SurfaceEntry - { - public DynamicPressure_kPa() - { - Name = "Dynamic Pressure"; - Description = "Dynamic Pressure (q) is a defined property of a moving flow of gas. It describes how much pressure the airflow is having on the vessel."; - Category = MicroEntryCategory.Surface; - IsDefault = false; - Unit = "kPa"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.DynamicPressure_kPa; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class StaticPressure_kPa : SurfaceEntry - { - public StaticPressure_kPa() - { - Name = "Static Pressure"; - Description = "Static pressure is a term used to define the amount of pressure exerted by a fluid that is not moving - ambient pressure."; - Category = MicroEntryCategory.Surface; - IsDefault = false; - Unit = "kPa"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.StaticPressure_kPa; - } - - public override string ValueDisplay => base.ValueDisplay; - } + } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index f986166..92e3ad3 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -5,6 +5,26 @@ namespace MicroMod public class TargetEntry : MicroEntry { } + public class Target_Name : TargetEntry + { + public Target_Name() + { + Name = "Name"; + Description = "Target's name."; + Category = MicroEntryCategory.Target; + IsDefault = true; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.TargetObject?.DisplayName; + } + + public override string ValueDisplay => base.ValueDisplay; + } + public class TargetApoapsis : TargetEntry { public TargetApoapsis() @@ -162,70 +182,61 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class Target_Name : TargetEntry + public class Target_Inclination : TargetEntry { - public Target_Name() + public Target_Inclination() { - Name = "Name"; - Description = "Target's name."; + Name = "Inclination"; + Description = "Shows the target's orbital inclination relative to the equator."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = null; - Formatting = null; + Unit = "°"; + Formatting = "{0:N3}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.DisplayName; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.inclination; } public override string ValueDisplay => base.ValueDisplay; } - public class Target_EccentricAnomaly : TargetEntry + public class Target_Eccentricity : TargetEntry { - public Target_EccentricAnomaly() + public Target_Eccentricity() { - Name = "Eccentric Anomaly"; - Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the target is."; + Name = "Eccentricity"; + Description = "Shows the target's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "°"; - Formatting = "{0:N2}"; + Unit = null; + Formatting = "{0:N3}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.EccentricAnomaly; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.eccentricity; } - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); - } - } + public override string ValueDisplay => base.ValueDisplay; } - public class Target_MeanAnomaly : TargetEntry + public class Target_Period : TargetEntry { - public Target_MeanAnomaly() + public Target_Period() { - Name = "Mean Anomaly"; - Description = "Parameter used to describe the position of the target in its orbit around the celestial body."; + Name = "Period"; + Description = "Shows the amount of time it will take the target to complete a full orbit."; Category = MicroEntryCategory.Target; - IsDefault = false; - Unit = "°"; - Formatting = "{0:N2}"; + IsDefault = true; + Unit = "s"; + Formatting = null; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.MeanAnomaly; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.period; } public override string ValueDisplay @@ -235,26 +246,46 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } - public class Target_ObT : TargetEntry + public class Target_Obtvelocity : TargetEntry { - public Target_ObT() + public Target_Obtvelocity() { - Name = "Orbit Time"; - Description = "Shows orbit time in seconds from the Periapsis."; + Name = "Orbital Speed"; + Description = "Shows the target's orbital speed."; + Category = MicroEntryCategory.Target; + IsDefault = true; + Unit = "m/s"; + Formatting = "{0:N1}"; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.TargetObject?.ObtVelocity.magnitude; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Target_TrueAnomaly : TargetEntry + { + public Target_TrueAnomaly() + { + Name = "True Anomaly"; + Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "s"; - Formatting = "{0:N3}"; + Unit = "°"; + Formatting = "{0:N1}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.ObT; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.TrueAnomaly; } public override string ValueDisplay @@ -264,17 +295,17 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, Utility.RadiansToDegrees((double)EntryValue)); } } } - public class Target_ArgumentOfPeriapsis : TargetEntry + public class Target_MeanAnomaly : TargetEntry { - public Target_ArgumentOfPeriapsis() + public Target_MeanAnomaly() { - Name = "Argument of Pe."; - Description = "Angle from the line of the ascending node on the equatorial plane to the point of periapsis passage."; + Name = "Mean Anomaly"; + Description = "Parameter used to describe the position of the target in its orbit around the celestial body."; Category = MicroEntryCategory.Target; IsDefault = false; Unit = "°"; @@ -283,50 +314,48 @@ public Target_ArgumentOfPeriapsis() public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.argumentOfPeriapsis; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.MeanAnomaly; } - public override string ValueDisplay => base.ValueDisplay; - } - - public class Target_Eccentricity : TargetEntry - { - public Target_Eccentricity() + public override string ValueDisplay { - Name = "Eccentricity"; - Description = "Shows the target's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; - Category = MicroEntryCategory.Target; - IsDefault = false; - Unit = null; - Formatting = "{0:N3}"; - } + get + { + if (EntryValue == null) + return "-"; - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.eccentricity; + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } } - - public override string ValueDisplay => base.ValueDisplay; } - public class Target_Inclination : TargetEntry + public class Target_EccentricAnomaly : TargetEntry { - public Target_Inclination() + public Target_EccentricAnomaly() { - Name = "Inclination"; - Description = "Shows the target's orbital inclination relative to the equator."; + Name = "Eccentric Anomaly"; + Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the target is."; Category = MicroEntryCategory.Target; - IsDefault = true; + IsDefault = false; Unit = "°"; - Formatting = "{0:N3}"; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.inclination; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.EccentricAnomaly; } - public override string ValueDisplay => base.ValueDisplay; + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, (double)EntryValue * PatchedConicsOrbit.Rad2Deg); + } + } } public class Target_LongitudeOfAscendingNode : TargetEntry @@ -349,32 +378,32 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class Target_SemiMajorAxis : TargetEntry + public class Target_ArgumentOfPeriapsis : TargetEntry { - public Target_SemiMajorAxis() + public Target_ArgumentOfPeriapsis() { - Name = "Semi Major Axis"; - Description = "Shows the distance from the center of an orbit to the farthest edge."; + Name = "Argument of Pe."; + Description = "Angle from the line of the ascending node on the equatorial plane to the point of periapsis passage."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "m"; - Formatting = "{0:N0}"; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.semiMajorAxis; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.argumentOfPeriapsis; } public override string ValueDisplay => base.ValueDisplay; } - public class Target_ReferenceBodyConstants_Radius : TargetEntry + public class Target_SemiLatusRectum : TargetEntry { - public Target_ReferenceBodyConstants_Radius() + public Target_SemiLatusRectum() { - Name = "Body Radius"; - Description = "Radius of the body that target is orbiting."; + Name = "Semi Latus Rectum"; + Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Target; IsDefault = false; Unit = "m"; @@ -383,38 +412,18 @@ public Target_ReferenceBodyConstants_Radius() public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.radius; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class Target_ReferenceBodyConstants_StandardGravitationParameter : TargetEntry - { - public Target_ReferenceBodyConstants_StandardGravitationParameter() - { - Name = "Std. Grav. Param."; - Description = "Product of the gravitational constant G and the mass M of the body target is orbiting."; - Category = MicroEntryCategory.Target; - IsDefault = false; - Unit = "μ"; - Formatting = "{0:e4}"; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.gravParameter; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.SemiLatusRectum; } public override string ValueDisplay => base.ValueDisplay; } - public class Target_SemiLatusRectum : TargetEntry + public class Target_SemiMajorAxis : TargetEntry { - public Target_SemiLatusRectum() + public Target_SemiMajorAxis() { - Name = "Semi Latus Rectum"; - Description = "Half the length of the chord through one focus, perpendicular to the major axis."; + Name = "Semi Major Axis"; + Description = "Shows the distance from the center of an orbit to the farthest edge."; Category = MicroEntryCategory.Target; IsDefault = false; Unit = "m"; @@ -423,7 +432,7 @@ public Target_SemiLatusRectum() public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.SemiLatusRectum; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.semiMajorAxis; } public override string ValueDisplay => base.ValueDisplay; @@ -449,21 +458,21 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class Target_TrueAnomaly : TargetEntry + public class Target_ObT : TargetEntry { - public Target_TrueAnomaly() + public Target_ObT() { - Name = "True Anomaly"; - Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; + Name = "Orbit Time"; + Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "°"; - Formatting = "{0:N1}"; + Unit = "s"; + Formatting = "{0:N3}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.TrueAnomaly; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.ObT; } public override string ValueDisplay @@ -473,38 +482,49 @@ public override string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, Utility.RadiansToDegrees((double)EntryValue)); + return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); } } } - public class Target_Period : TargetEntry + public class Target_ReferenceBodyConstants_Radius : TargetEntry { - public Target_Period() + public Target_ReferenceBodyConstants_Radius() { - Name = "Period"; - Description = "Shows the amount of time it will take the target to complete a full orbit."; + Name = "Body Radius"; + Description = "Radius of the body that target is orbiting."; Category = MicroEntryCategory.Target; - IsDefault = true; - Unit = "s"; - Formatting = null; + IsDefault = false; + Unit = "m"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.period; + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.radius; } - public override string ValueDisplay + public override string ValueDisplay => base.ValueDisplay; + } + + public class Target_ReferenceBodyConstants_StandardGravitationParameter : TargetEntry + { + public Target_ReferenceBodyConstants_StandardGravitationParameter() { - get - { - if (EntryValue == null) - return "-"; + Name = "Std. Grav. Param."; + Description = "Product of the gravitational constant G and the mass M of the body target is orbiting."; + Category = MicroEntryCategory.Target; + IsDefault = false; + Unit = "μ"; + Formatting = "{0:e4}"; + } - return String.IsNullOrEmpty(base.Formatting) ? Utility.SecondsToTimeString((double)EntryValue, true, false) : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); - } + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.TargetObject?.Orbit?.referenceBody?.gravParameter; } + + public override string ValueDisplay => base.ValueDisplay; } public class Target_OrbitRadius : TargetEntry @@ -527,21 +547,41 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class Target_Obtvelocity : TargetEntry + public class PhaseAngle : TargetEntry { - public Target_Obtvelocity() + public PhaseAngle() { - Name = "Orbital Speed"; - Description = "Shows the target's orbital speed."; + Name = "Phase Angle"; + Description = "Angle between your vessel, the reference body and the target. How much \"ahead\" or \"behind\" in phase you are with the target."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "m/s"; - Formatting = "{0:N1}"; + Unit = "°"; + Formatting = "{0:N2}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.TargetObject?.ObtVelocity.magnitude; + EntryValue = Utility.TargetExists() ? TransferInfo.GetPhaseAngle() : null; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class TransferAngle : TargetEntry + { + public TransferAngle() + { + Name = "Transfer Angle"; + Description = "Phase angle needed for an optimal Hohmann transfer orbit. Use a circular orbit for a more accurate value."; + Category = MicroEntryCategory.Target; + IsDefault = true; + Unit = "°"; + Formatting = "{0:N2}"; + } + + public override void RefreshData() + { + EntryValue = Utility.TargetExists() ? TransferInfo.GetTransferAngle() : null; } public override string ValueDisplay => base.ValueDisplay; @@ -700,46 +740,6 @@ public override void RefreshData() EntryValue = isValid != null && isValid == true ? EntryValue = Utility.ActiveVessel.Orbiter.OrbitTargeter.Intersect2Target.RelativeSpeed : null; } - public override string ValueDisplay => base.ValueDisplay; - } - - public class PhaseAngle : TargetEntry - { - public PhaseAngle() - { - Name = "Phase Angle"; - Description = "Angle between your vessel, the reference body and the target. How much \"ahead\" or \"behind\" in phase you are with the target."; - Category = MicroEntryCategory.Target; - IsDefault = true; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = Utility.TargetExists() ? TransferInfo.GetPhaseAngle() : null; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class TransferAngle : TargetEntry - { - public TransferAngle() - { - Name = "Transfer Angle"; - Description = "Phase angle needed for an optimal Hohmann transfer orbit. Use a circular orbit for a more accurate value."; - Category = MicroEntryCategory.Target; - IsDefault = true; - Unit = "°"; - Formatting = "{0:N2}"; - } - - public override void RefreshData() - { - EntryValue = Utility.TargetExists() ? TransferInfo.GetTransferAngle() : null; - } - public override string ValueDisplay => base.ValueDisplay; } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 88dc1e3..835eacf 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -105,6 +105,35 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } + public class TotalBurnTime : VesselEntry + { + public TotalBurnTime() + { + Name = "Total Burn Time"; + Description = "Burn Time vessel can sustain with 100% thrust."; + Category = MicroEntryCategory.Vessel; + IsDefault = false; + Unit = "s"; + Formatting = "{0:N0}"; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.VesselDeltaV?.TotalBurnTime; + } + + public override string ValueDisplay + { + get + { + if (EntryValue == null) + return "-"; + + return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); + } + } + } + public class StageThrustActual : VesselEntry { public StageThrustActual() @@ -225,55 +254,6 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } - public class PartsCount : VesselEntry - { - public PartsCount() - { - Name = "Parts"; - Description = "Number of parts vessel is constructed of."; - Category = MicroEntryCategory.Vessel; - IsDefault = true; - Unit = null; - Formatting = null; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.VesselDeltaV?.PartInfo?.Count; - } - - public override string ValueDisplay => base.ValueDisplay; - } - - public class TotalBurnTime : VesselEntry - { - public TotalBurnTime() - { - Name = "Total Burn Time"; - Description = "Burn Time vessel can sustain with 100% thrust."; - Category = MicroEntryCategory.Vessel; - IsDefault = false; - Unit = "s"; - Formatting = "{0:N0}"; - } - - public override void RefreshData() - { - EntryValue = Utility.ActiveVessel.VesselDeltaV?.TotalBurnTime; - } - - public override string ValueDisplay - { - get - { - if (EntryValue == null) - return "-"; - - return String.IsNullOrEmpty(base.Formatting) ? EntryValue.ToString() : String.Format(Formatting, Utility.SecondsToTimeString((double)EntryValue, true, false)); - } - } - } - public class StageISPActual : VesselEntry { public StageISPActual() @@ -332,34 +312,34 @@ public override void RefreshData() } public override string ValueDisplay => base.ValueDisplay; - } + } - public class Throttle : VesselEntry + public class FuelPercentage : VesselEntry { - public Throttle() + public FuelPercentage() { - Name = "Throttle"; - Description = "Vessel's current throttle in %."; + Name = "Vessel Fuel"; + Description = "Vessel's fuel percentage left."; Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "%"; - Formatting = "{0:N0}"; + Formatting = "{0:N1}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.flightCtrlState.mainThrottle * 100; + EntryValue = Utility.ActiveVessel.FuelPercentage; } public override string ValueDisplay => base.ValueDisplay; } - public class FuelPercentage : VesselEntry + public class StageFuelPercentage : VesselEntry { - public FuelPercentage() + public StageFuelPercentage() { - Name = "Vessel Fuel"; - Description = "Vessel's fuel percentage left."; + Name = "Stage Fuel"; + Description = "Stage fuel percentage left."; Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "%"; @@ -368,32 +348,52 @@ public FuelPercentage() public override void RefreshData() { - EntryValue = Utility.ActiveVessel.FuelPercentage; + EntryValue = Utility.ActiveVessel.StageFuelPercentage; } public override string ValueDisplay => base.ValueDisplay; } - public class StageFuelPercentage : VesselEntry + public class PartsCount : VesselEntry { - public StageFuelPercentage() + public PartsCount() { - Name = "Stage Fuel"; - Description = "Stage fuel percentage left."; + Name = "Parts"; + Description = "Number of parts vessel is constructed of."; + Category = MicroEntryCategory.Vessel; + IsDefault = true; + Unit = null; + Formatting = null; + } + + public override void RefreshData() + { + EntryValue = Utility.ActiveVessel.VesselDeltaV?.PartInfo?.Count; + } + + public override string ValueDisplay => base.ValueDisplay; + } + + public class Throttle : VesselEntry + { + public Throttle() + { + Name = "Throttle"; + Description = "Vessel's current throttle in %."; Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "%"; - Formatting = "{0:N1}"; + Formatting = "{0:N0}"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.StageFuelPercentage; + EntryValue = Utility.ActiveVessel.flightCtrlState.mainThrottle * 100; } public override string ValueDisplay => base.ValueDisplay; } - + public class TotalCommandCrewCapacity : VesselEntry { public TotalCommandCrewCapacity() diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 7ff97ae..fc4a197 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1177,7 +1177,7 @@ private void InitializeWindows() Abbreviation = "TGT", Description = "Flight entries", IsEditorActive = false, - IsFlightActive = false, + IsFlightActive = true, IsMapActive = false, IsEditorPoppedOut = false, IsFlightPoppedOut = false, From 5592c1672779c33f322158e2f1b24cd863103b1c Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Fri, 21 Apr 2023 17:10:53 +0200 Subject: [PATCH 26/38] Move torque OAB updates to PartManipulationCompletedMessage --- .../MicroEngineer/MicroEngineerMod.cs | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index fc4a197..ca94991 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -49,8 +49,6 @@ public class MicroEngineerMod : BaseSpaceWarpPlugin // If game input is enabled or disabled (used for locking controls when user is editing a text field private bool _gameInputState = true; - private float _lastUpdate = 0; - public override void OnInitialized() { Styles.InitializeStyles(); @@ -133,6 +131,9 @@ private void SubscribeToMessages() // Resets node index Utility.MessageCenter.Subscribe(new Action(this.OnManeuverRemovedMessage)); + + // Torque update for StageInfoOAB + Utility.MessageCenter.Subscribe(new Action(this.OnPartManipulationCompletedMessage)); } private void OnManeuverCreatedMessage(MessageCenterMessage message) @@ -147,6 +148,12 @@ private void OnManeuverRemovedMessage(MessageCenterMessage message) maneuverWindow.OnManeuverRemovedMessage(message); } + private void OnPartManipulationCompletedMessage(MessageCenterMessage obj) + { + Torque torque = (Torque)MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Torque"); + torque.RefreshData(); + } + private void GameStateEntered(MessageCenterMessage obj) { Logger.LogInfo("Message triggered: GameStateEnteredMessage"); @@ -216,20 +223,6 @@ public void Update() { Utility.RefreshGameManager(); - // Perform OAB updates only if we're in OAB - if (Utility.GameState != null && Utility.GameState.IsObjectAssembly) - { - // Do updates every 1 sec - if (Time.time - _lastUpdate > 1) - { - _lastUpdate = Time.time; - - Torque torque = (Torque)MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Torque"); - if (torque.IsActive) - torque.RefreshData(); - } - } - // Perform flight UI updates only if we're in Flight or Map view if (Utility.GameState != null && (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView)) { From d530cd89d58b910934e144a9e23ea5e29b1bbdd5 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Fri, 21 Apr 2023 21:08:53 +0200 Subject: [PATCH 27/38] Remove backward compatibility as we now have layout versioning --- .../MicroEngineer/MicroEngineerMod.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index ca94991..e4c236d 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -88,10 +88,6 @@ public override void OnInitialized() private void BackwardCompatibilityInitializations() { - // Preserve backward compatibility with 0.6.0. If user previously saved the layout and then upgraded without deleting the original folder, then StageInfoOAB window will be wiped by LoadLayout(). So, we add it manually now. - if (MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB) == null) - InitializeStageInfoOABWindow(); - // Preserve backward compatibility with SpaceWarp 1.0.1 if (Utility.IsModOlderThan("SpaceWarp", 1, 1, 0)) { @@ -100,14 +96,6 @@ private void BackwardCompatibilityInitializations() } else Logger.LogInfo("Space Warp new version detected. Loading new Styles."); - - // Preserve backward compatibility with 0.7.2. If user previously saved the layout and then upgraded without deleting the original folder, then the Torque entry won't be in the loaded StageOAB window. So, we add it manually now. - BaseWindow stageOabWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); - if (stageOabWindow.Entries.Find(e => e.Name == "Torque") == null) - { - stageOabWindow.Entries.Add(this.MicroEntries.Find(e => e.Name == "Torque")); - Utility.SaveLayout(this.MicroWindows); - } } /// From c85d07ee427eb0fb2637def342ed325d93ef3f64 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sat, 22 Apr 2023 01:27:02 +0200 Subject: [PATCH 28/38] Major refactor - move logic to manager classes, GUI to UI class --- .../MicroEngineer/Entries/BodyEntries.cs | 2 +- .../MicroEngineer/Entries/FlightEntries.cs | 2 +- .../MicroEngineer/Entries/ManeuverEntries.cs | 2 +- .../MicroEngineer/Entries/MicroEntries.cs | 5 +- .../MicroEngineer/Entries/MiscEntries.cs | 2 +- .../Entries/OabStageInfoEntries.cs | 2 +- .../MicroEngineer/Entries/OrbitalEntries.cs | 2 +- .../MicroEngineer/Entries/StageInfoEntries.cs | 2 +- .../MicroEngineer/Entries/SurfaceEntries.cs | 2 +- .../MicroEngineer/Entries/TargetEntries.cs | 2 +- .../MicroEngineer/Entries/VesselEntries.cs | 2 +- .../MicroEngineer/Managers/Manager.cs | 312 +++++ .../MicroEngineer/Managers/MessageManager.cs | 135 ++ .../{ => Managers}/MicroCelestialBodies.cs | 0 .../MicroEngineer/Managers/UI.cs | 806 +++++++++++ .../MicroEngineer/MicroEngineerMod.cs | 1198 +---------------- .../MicroEngineer/{ => Utilities}/Styles.cs | 0 .../MicroEngineer/Windows/BaseWindow.cs | 8 +- 18 files changed, 1282 insertions(+), 1202 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Managers/Manager.cs create mode 100644 MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs rename MicroEngineerProject/MicroEngineer/{ => Managers}/MicroCelestialBodies.cs (100%) create mode 100644 MicroEngineerProject/MicroEngineer/Managers/UI.cs rename MicroEngineerProject/MicroEngineer/{ => Utilities}/Styles.cs (100%) diff --git a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs index fdcaa32..2d5340b 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs @@ -1,7 +1,7 @@  namespace MicroMod { - public class BodyEntry : MicroEntry + public class BodyEntry : BaseEntry { } public class Body : BodyEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index 184d997..01354a6 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -1,7 +1,7 @@  namespace MicroMod { - public class FlightEntry : MicroEntry + public class FlightEntry : BaseEntry { } public class Speed : FlightEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 6b25fab..3c515de 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -4,7 +4,7 @@ namespace MicroMod { - public class ManeuverEntry : MicroEntry + public class ManeuverEntry : BaseEntry { internal int SelectedNodeIndex = 0; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs index 64da926..9cce3c6 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs @@ -1,5 +1,4 @@ -using KSP.Sim.impl; -using Newtonsoft.Json; +using Newtonsoft.Json; namespace MicroMod { @@ -7,7 +6,7 @@ namespace MicroMod /// Base class for all Entries (values that can be attached to windows) /// [JsonObject(MemberSerialization.OptIn)] - public class MicroEntry + public class BaseEntry { [JsonProperty] public string Name; diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs index 6444194..028be8e 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -2,7 +2,7 @@ namespace MicroMod { - public class MiscEntry : MicroEntry + public class MiscEntry : BaseEntry { } public class Separator : MiscEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs index 9fac384..c838d97 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs @@ -5,7 +5,7 @@ namespace MicroMod { - public class OabStageInfoEntry : MicroEntry + public class OabStageInfoEntry : BaseEntry { } public class TotalBurnTime_OAB : OabStageInfoEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 5fefb51..2ded6a5 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -3,7 +3,7 @@ namespace MicroMod { - public class OrbitalEntry : MicroEntry + public class OrbitalEntry : BaseEntry { } public class Apoapsis : OrbitalEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs index 09febd5..f599eb0 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs @@ -1,7 +1,7 @@  namespace MicroMod { - public class StageInfoEntry: MicroEntry + public class StageInfoEntry: BaseEntry { } public class StageInfo : StageInfoEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index 0e153c8..5db5970 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -3,7 +3,7 @@ namespace MicroMod { - public class SurfaceEntry : MicroEntry + public class SurfaceEntry : BaseEntry { } public class AltitudeAgl : SurfaceEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 92e3ad3..1c2a872 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -2,7 +2,7 @@ namespace MicroMod { - public class TargetEntry : MicroEntry + public class TargetEntry : BaseEntry { } public class Target_Name : TargetEntry diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 835eacf..706f267 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -1,7 +1,7 @@  namespace MicroMod { - public class VesselEntry : MicroEntry + public class VesselEntry : BaseEntry { } public class VesselName : VesselEntry diff --git a/MicroEngineerProject/MicroEngineer/Managers/Manager.cs b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs new file mode 100644 index 0000000..14ad7ec --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs @@ -0,0 +1,312 @@ +using BepInEx.Logging; +using KSP.Game; +using MicroMod; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using UnityEngine; + +namespace MicroMod +{ + internal class Manager + { + internal List Windows; + internal List Entries; + private MicroEngineerMod _plugin; + + private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Manager"); + + internal Manager(MicroEngineerMod plugin) + { + _plugin = plugin; + Entries = InitializeEntries(); + Windows = InitializeWindows(); + + // Load window positions and states from disk, if file exists + Utility.LoadLayout(Windows); + } + + public void Update() + { + Utility.RefreshGameManager(); + + // Perform flight UI updates only if we're in Flight or Map view + if (Utility.GameState != null && (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView)) + { + Utility.RefreshActiveVesselAndCurrentManeuver(); + + if (Utility.ActiveVessel == null) + return; + + // Refresh all active windows' entries + foreach (BaseWindow window in Windows.Where(w => w.IsFlightActive)) + window.RefreshData(); + } + } + + /// + /// Builds the list of all Entries + /// + internal List InitializeEntries() + { + Entries = new List(); + + Assembly assembly = Assembly.GetExecutingAssembly(); + Type[] types = assembly.GetTypes(); + + // Exclude base classes + Type[] excludedTypes = new[] { typeof(BaseEntry), typeof(BodyEntry), typeof(FlightEntry), + typeof(ManeuverEntry), typeof(MiscEntry), typeof(OabStageInfoEntry), typeof(OrbitalEntry), + typeof(StageInfoEntry), typeof(SurfaceEntry), typeof(TargetEntry), typeof(VesselEntry) }; + + Type[] entryTypes = types.Where(t => typeof(BaseEntry).IsAssignableFrom(t) && !excludedTypes.Contains(t)).ToArray(); + + foreach (Type entryType in entryTypes) + { + BaseEntry entry = Activator.CreateInstance(entryType) as BaseEntry; + if (entry != null) + Entries.Add(entry); + } + + return Entries; + } + + /// + /// Builds the default Windows and fills them with default Entries + /// + internal List InitializeWindows() + { + Windows = new List(); + + try + { + Windows.Add(new BaseWindow + { + Name = "MainGui", + LayoutVersion = Utility.CurrentLayoutVersion, + Abbreviation = null, + Description = "Main GUI", + IsEditorActive = false, + IsFlightActive = false, + IsMapActive = false, + IsEditorPoppedOut = false, // not relevant to Main GUI + IsFlightPoppedOut = false, // not relevant to Main GUI + IsMapPoppedOut = false, // not relevant to Main GUI + IsLocked = false, + MainWindow = MainWindow.MainGui, + //EditorRect = null, + FlightRect = new Rect(Styles.MainGuiX, Styles.MainGuiY, Styles.WindowWidth, Styles.WindowHeight), + Entries = null + }); + + Windows.Add(new BaseWindow + { + Name = "Settings", + Abbreviation = "SET", + Description = "Settings", + IsEditorActive = false, + IsFlightActive = false, + IsMapActive = false, + IsEditorPoppedOut = false, + IsFlightPoppedOut = false, + IsMapPoppedOut = false, + IsLocked = false, + MainWindow = MainWindow.Settings, + //EditorRect = null, + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), + Entries = null + }); + + Windows.Add(new BaseWindow + { + Name = "Vessel", + Abbreviation = "VES", + Description = "Vessel entries", + IsEditorActive = false, + IsFlightActive = true, + IsMapActive = false, + IsEditorPoppedOut = false, + IsFlightPoppedOut = false, + IsMapPoppedOut = false, + IsLocked = false, + MainWindow = MainWindow.Vessel, + //EditorRect = null, + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), + Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Vessel && entry.IsDefault).ToList() + }); + + Windows.Add(new BaseWindow + { + Name = "Orbital", + Abbreviation = "ORB", + Description = "Orbital entries", + IsEditorActive = false, + IsFlightActive = true, + IsMapActive = false, + IsEditorPoppedOut = false, + IsFlightPoppedOut = false, + IsMapPoppedOut = false, + IsLocked = false, + MainWindow = MainWindow.Orbital, + //EditorRect = null, + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), + Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Orbital && entry.IsDefault).ToList() + }); + + Windows.Add(new BaseWindow + { + Name = "Surface", + Abbreviation = "SUR", + Description = "Surface entries", + IsEditorActive = false, + IsFlightActive = true, + IsMapActive = false, + IsEditorPoppedOut = false, + IsFlightPoppedOut = false, + IsMapPoppedOut = false, + IsLocked = false, + MainWindow = MainWindow.Surface, + //EditorRect = null, + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), + Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Surface && entry.IsDefault).ToList() + }); + + Windows.Add(new BaseWindow + { + Name = "Flight", + Abbreviation = "FLT", + Description = "Flight entries", + IsEditorActive = false, + IsFlightActive = false, + IsMapActive = false, + IsEditorPoppedOut = false, + IsFlightPoppedOut = false, + IsMapPoppedOut = false, + IsLocked = false, + MainWindow = MainWindow.Flight, + //EditorRect = null, + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), + Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Flight && entry.IsDefault).ToList() + }); + + Windows.Add(new BaseWindow + { + Name = "Target", + Abbreviation = "TGT", + Description = "Flight entries", + IsEditorActive = false, + IsFlightActive = true, + IsMapActive = false, + IsEditorPoppedOut = false, + IsFlightPoppedOut = false, + IsMapPoppedOut = false, + IsLocked = false, + MainWindow = MainWindow.Target, + //EditorRect = null, + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), + Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Target && entry.IsDefault).ToList() + }); + + Windows.Add(new ManeuverWindow + { + Name = "Maneuver", + Abbreviation = "MAN", + Description = "Maneuver entries", + WindowType = typeof(ManeuverWindow), + IsEditorActive = false, + IsFlightActive = true, + IsMapActive = false, + IsEditorPoppedOut = false, + IsFlightPoppedOut = false, + IsMapPoppedOut = false, + IsLocked = false, + MainWindow = MainWindow.Maneuver, + //EditorRect = null, + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), + Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Maneuver && entry.IsDefault).ToList() + }); + + Windows.Add(new BaseWindow + { + Name = "Stage", + Abbreviation = "STG", + Description = "Stage entries", + IsEditorActive = false, + IsFlightActive = true, + IsMapActive = false, + IsEditorPoppedOut = false, + IsFlightPoppedOut = false, + IsMapPoppedOut = false, + IsLocked = false, + MainWindow = MainWindow.Stage, + //EditorRect = null, + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), + Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Stage && entry.IsDefault).ToList() + }); + + Windows.Add(new BaseWindow + { + Name = "Stage (OAB)", + Abbreviation = "SOAB", + Description = "Stage Info window for OAB", + IsEditorActive = false, + IsFlightActive = false, // Not used + IsMapActive = false, // Not used + IsEditorPoppedOut = true, // Not used + IsFlightPoppedOut = false, // Not used + IsMapPoppedOut = false, // Not used + IsLocked = false, // Not used + MainWindow = MainWindow.StageInfoOAB, + EditorRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, 0, 0), + Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.OAB && entry.IsDefault).ToList() + }); + + return Windows; + } + catch (Exception ex) + { + _logger.LogError("Error creating a BaseWindow. Full exception: " + ex); + return null; + } + } + + /// + /// Creates a new custom window user can fill with any entry + /// + /// + internal int CreateCustomWindow(List editableWindows) + { + // Default window's name will be CustomX where X represents the first not used integer + int nameID = 1; + foreach (BaseWindow window in editableWindows) + { + if (window.Name == "Custom" + nameID) + nameID++; + } + + BaseWindow newWindow = new() + { + Name = "Custom" + nameID, + Abbreviation = nameID.ToString().Length == 1 ? "Cu" + nameID : nameID.ToString().Length == 2 ? "C" + nameID : nameID.ToString(), + Description = "", + IsEditorActive = false, + IsFlightActive = true, + IsMapActive = false, + IsEditorPoppedOut = false, + IsFlightPoppedOut = false, + IsMapPoppedOut = false, + IsLocked = false, + MainWindow = MainWindow.None, + //EditorRect = null, + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), + Entries = new List() + }; + + Windows.Add(newWindow); + editableWindows.Add(newWindow); + + return editableWindows.Count - 1; + } + } +} diff --git a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs new file mode 100644 index 0000000..a9362c9 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs @@ -0,0 +1,135 @@ +using BepInEx.Logging; +using KSP.Game; +using KSP.Messages; + +namespace MicroMod +{ + internal class MessageManager + { + MicroEngineerMod _plugin; + private Manager _manager; + private UI _ui; + private List _windows; + + private static readonly ManualLogSource _logger = Logger.CreateLogSource("MicroEngineer.MessageManager"); + + internal MessageManager(MicroEngineerMod plugin, Manager manager, UI ui) + { + _plugin = plugin; + _manager = manager; + _ui = ui; + _windows = _manager.Windows; + + SubscribeToMessages(); + } + + /// + /// Subscribe to KSP2 messages + /// + internal void SubscribeToMessages() + { + Utility.RefreshGameManager(); + + // While in OAB we use the VesselDeltaVCalculationMessage event to refresh data as it's triggered a lot less frequently than Update() + Utility.MessageCenter.Subscribe(new Action(this.RefreshStagingDataOAB)); + + // We are loading layout state when entering Flight or OAB game state + Utility.MessageCenter.Subscribe(new Action(this.GameStateEntered)); + + // We are saving layout state when exiting from Flight or OAB game state + Utility.MessageCenter.Subscribe(new Action(this.GameStateLeft)); + + // Sets the selected node index to the newly created node + Utility.MessageCenter.Subscribe(new Action(this.OnManeuverCreatedMessage)); + + // Resets node index + Utility.MessageCenter.Subscribe(new Action(this.OnManeuverRemovedMessage)); + + // Torque update for StageInfoOAB + Utility.MessageCenter.Subscribe(new Action(this.OnPartManipulationCompletedMessage)); + } + + private void OnManeuverCreatedMessage(MessageCenterMessage message) + { + var maneuverWindow = _windows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; + maneuverWindow.OnManeuverCreatedMessage(message); + } + + private void OnManeuverRemovedMessage(MessageCenterMessage message) + { + var maneuverWindow = _windows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; + maneuverWindow.OnManeuverRemovedMessage(message); + } + + private void OnPartManipulationCompletedMessage(MessageCenterMessage obj) + { + Torque torque = (Torque)_windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Torque"); + torque.RefreshData(); + } + + private void GameStateEntered(MessageCenterMessage obj) + { + _logger.LogInfo("Message triggered: GameStateEnteredMessage"); + + Utility.RefreshGameManager(); + if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView) + { + Utility.LoadLayout(_windows); + _manager.Windows = _windows; + + if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) + _ui.ShowGuiFlight = _windows.Find(w => w.MainWindow == MainWindow.MainGui).IsFlightActive; + + if (Utility.GameState.GameState == GameState.VehicleAssemblyBuilder) + { + _ui.ShowGuiOAB = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive; + _ui.CelestialBodies.GetBodies(); + _ui.CelestialBodySelectionStageIndex = -1; + } + } + } + + private void GameStateLeft(MessageCenterMessage obj) + { + _logger.LogInfo("Message triggered: GameStateLeftMessage"); + + Utility.RefreshGameManager(); + if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView) + { + Utility.SaveLayout(_windows); + + if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) + _ui.ShowGuiFlight = false; + + if (Utility.GameState.GameState == GameState.VehicleAssemblyBuilder) + _ui.ShowGuiOAB = false; + } + } + + /// + /// Refresh all staging data while in OAB + /// + private void RefreshStagingDataOAB(MessageCenterMessage obj) + { + // Check if message originated from ships in flight. If yes, return. + VesselDeltaVCalculationMessage msg = (VesselDeltaVCalculationMessage)obj; + if (msg.DeltaVComponent.Ship == null || !msg.DeltaVComponent.Ship.IsLaunchAssembly()) return; + + Utility.RefreshGameManager(); + if (Utility.GameState.GameState != GameState.VehicleAssemblyBuilder) return; + + Utility.RefreshStagesOAB(); + + BaseWindow stageWindow = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + + if (Utility.VesselDeltaVComponentOAB?.StageInfo == null) + { + stageWindow.Entries.Find(e => e.Name == "Stage Info (OAB)").EntryValue = null; + return; + } + + foreach (var entry in stageWindow.Entries) + entry.RefreshData(); + } + } +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/MicroCelestialBodies.cs b/MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs similarity index 100% rename from MicroEngineerProject/MicroEngineer/MicroCelestialBodies.cs rename to MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs diff --git a/MicroEngineerProject/MicroEngineer/Managers/UI.cs b/MicroEngineerProject/MicroEngineer/Managers/UI.cs new file mode 100644 index 0000000..5777a61 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Managers/UI.cs @@ -0,0 +1,806 @@ +using BepInEx.Logging; +using KSP.Game; +using KSP.Sim.DeltaV; +using KSP.Sim.impl; +using KSP.UI.Binding; +using UnityEngine; + +namespace MicroMod +{ + internal class UI + { + private MicroEngineerMod _plugin; + private Manager _manager; + + private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.MessageManager"); + + private List _windows; + + internal bool ShowGuiFlight; + internal bool ShowGuiOAB; + + // If game input is enabled or disabled (used for locking controls when user is editing a text field + private bool _gameInputState = true; + + #region Editing window + private bool _showEditWindow = false; + private int _selectedWindowId = 0; + private MicroEntryCategory _selectedCategory = MicroEntryCategory.Vessel; + private (bool condition, int index) _showTooltip = (false, 0); + #endregion + + // Index of the stage for which user wants to select a different CelestialBody for different TWR calculations. -1 -> no stage is selected + internal int CelestialBodySelectionStageIndex = -1; + private bool _showGuiSettingsOAB; + + /// + /// Holds data on all bodies for calculating TWR (currently) + /// + internal MicroCelestialBodies CelestialBodies = new(); + + internal UI(MicroEngineerMod plugin, Manager manager) + { + _plugin = plugin; + _manager = manager; + _windows = manager.Windows; + } + + internal void OnGUI() + { + GUI.skin = Styles.SpaceWarpUISkin; + + Utility.RefreshGameManager(); + if (Utility.GameState?.GameState == GameState.VehicleAssemblyBuilder) + OnGUI_OAB(); + else + OnGUI_Flight(); + } + + private void OnGUI_Flight() + { + _gameInputState = Utility.ToggleGameInputOnControlInFocus(_gameInputState, ShowGuiFlight); + + if (!ShowGuiFlight || Utility.ActiveVessel == null) return; + + BaseWindow mainGui = _windows.Find(window => window.MainWindow == MainWindow.MainGui); + + // Draw main GUI that contains docked windows + mainGui.FlightRect = GUILayout.Window( + GUIUtility.GetControlID(FocusType.Passive), + mainGui.FlightRect, + FillMainGUI, + "// MICRO ENGINEER", + Styles.MainWindowStyle, + GUILayout.Height(0) + ); + mainGui.FlightRect.position = Utility.ClampToScreen(mainGui.FlightRect.position, mainGui.FlightRect.size); + + // Draw all other popped out windows + foreach (var (window, index) in _windows + .Select((window, index) => (window, index)) + .Where(x => x.window.IsFlightActive && x.window.IsFlightPoppedOut) // must be active & popped out + .Where(x => x.window.MainWindow != MainWindow.Settings && x.window.MainWindow != MainWindow.Stage && x.window.MainWindow != MainWindow.MainGui)) // MainGUI, Settings and Stage are special, they'll be drawn separately + { + // Skip drawing of Target window if there's no active target + if (window.MainWindow == MainWindow.Target && !Utility.TargetExists()) + continue; + + // Skip drawing of Maneuver window if there's no active maneuver + if (window.MainWindow == MainWindow.Maneuver && !Utility.ManeuverExists()) + continue; + + // If window is locked set alpha to 80% + if (window.IsLocked) + GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.8f); + + window.FlightRect = GUILayout.Window( + index, + window.FlightRect, + DrawPopoutWindow, + "", + Styles.PopoutWindowStyle, + GUILayout.Height(0), + GUILayout.Width(Styles.WindowWidth + )); + + // Set alpha back to 100% + if (window.IsLocked) + GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1); + + window.FlightRect.position = Utility.ClampToScreen(window.FlightRect.position, window.FlightRect.size); + } + + // Draw popped out Settings + int settingsIndex = _windows.FindIndex(window => window.MainWindow == MainWindow.Settings); + if (_windows[settingsIndex].IsFlightActive && _windows[settingsIndex].IsFlightPoppedOut) + { + _windows[settingsIndex].FlightRect = GUILayout.Window( + settingsIndex, + _windows[settingsIndex].FlightRect, + DrawSettingsWindow, + "", + Styles.PopoutWindowStyle, + GUILayout.Height(0), + GUILayout.Width(Styles.WindowWidth) + ); + + _windows[settingsIndex].FlightRect.position = Utility.ClampToScreen(_windows[settingsIndex].FlightRect.position, _windows[settingsIndex].FlightRect.size); + } + + // Draw popped out Stages + int stageIndex = _windows.FindIndex(window => window.MainWindow == MainWindow.Stage); + if (_windows[stageIndex].IsFlightActive && _windows[stageIndex].IsFlightPoppedOut) + { + _windows[stageIndex].FlightRect = GUILayout.Window( + stageIndex, + _windows[stageIndex].FlightRect, + DrawStages, + "", + Styles.PopoutWindowStyle, + GUILayout.Height(0), + GUILayout.Width(Styles.WindowWidth) + ); + + _windows[stageIndex].FlightRect.position = Utility.ClampToScreen(_windows[stageIndex].FlightRect.position, _windows[stageIndex].FlightRect.size); + } + + // Draw Edit Window + if (_showEditWindow) + { + Styles.EditWindowRect = GUILayout.Window( + GUIUtility.GetControlID(FocusType.Passive), + Styles.EditWindowRect, + DrawEditWindow, + "", + Styles.EditWindowStyle, + GUILayout.Height(0) + ); + } + } + + private void OnGUI_OAB() + { + if (!ShowGuiOAB) return; + + BaseWindow stageInfoOAB = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + if (stageInfoOAB.Entries.Find(e => e.Name == "Stage Info (OAB)").EntryValue == null) return; + + stageInfoOAB.EditorRect = GUILayout.Window( + GUIUtility.GetControlID(FocusType.Passive), + stageInfoOAB.EditorRect, + DrawStageInfoOAB, + "", + Styles.StageOABWindowStyle, + GUILayout.Height(0) + ); + stageInfoOAB.EditorRect.position = Utility.ClampToScreen(stageInfoOAB.EditorRect.position, stageInfoOAB.EditorRect.size); + + // Draw window for selecting CelestialBody for a stage + // -1 -> no selection of CelestialBody is taking place + // any other int -> index represents the stage number for which the selection was clicked + if (CelestialBodySelectionStageIndex > -1) + { + Rect stageInfoOabRect = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).EditorRect; + Rect celestialBodyRect = new Rect(stageInfoOabRect.x + stageInfoOabRect.width, stageInfoOabRect.y, 0, 0); + + celestialBodyRect = GUILayout.Window( + GUIUtility.GetControlID(FocusType.Passive), + celestialBodyRect, + DrawCelestialBodySelection, + "", + Styles.CelestialSelectionStyle, + GUILayout.Height(0) + ); + } + + // Draw Settings window for the StageInfoOAB + if (_showGuiSettingsOAB) + { + Rect stageInfoOabRect = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).EditorRect; + Rect settingsRect = new Rect(stageInfoOabRect.x + stageInfoOabRect.width, stageInfoOabRect.y, 0, 0); + + settingsRect = GUILayout.Window( + GUIUtility.GetControlID(FocusType.Passive), + settingsRect, + DrawSettingsOabWindow, + "", + Styles.SettingsOabStyle, + GUILayout.Height(0) + ); + } + } + + #region Flight scene UI + /// + /// Draws the main GUI with all windows that are toggled and docked + /// + /// + private void FillMainGUI(int windowID) + { + try + { + if (CloseButton(Styles.CloseBtnRect)) + { + CloseWindow(); + } + + GUILayout.Space(5); + + GUILayout.BeginHorizontal(); + + int toggleIndex = -1; + // Draw toggles for all windows except MainGui and StageInfoOAB + foreach (BaseWindow window in _windows.Where(x => x.MainWindow != MainWindow.MainGui && x.MainWindow != MainWindow.StageInfoOAB)) + { + // layout can fit 6 toggles, so if all 6 slots are filled then go to a new line. Index == 0 is the MainGUI which isn't rendered + if (++toggleIndex % 6 == 0 && toggleIndex > 0) + { + GUILayout.EndHorizontal(); + GUILayout.BeginHorizontal(); + } + window.IsFlightActive = GUILayout.Toggle(window.IsFlightActive, window.Abbreviation, Styles.SectionToggleStyle); + } + GUILayout.EndHorizontal(); + GUILayout.Space(5); + + // Draw Settings window first + int settingsIndex = _windows.FindIndex(window => window.MainWindow == MainWindow.Settings); + if (_windows[settingsIndex].IsFlightActive && !_windows[settingsIndex].IsFlightPoppedOut) + DrawSettingsWindow(settingsIndex); + + // Draw Stage window next + int stageIndex = _windows.FindIndex(window => window.MainWindow == MainWindow.Stage); + if (_windows[stageIndex].IsFlightActive && !_windows[stageIndex].IsFlightPoppedOut) + DrawStages(stageIndex); + + // Draw all other windows + foreach (var (window, index) in _windows + .Select((window, index) => (window, index)) + .Where(x => x.window.IsFlightActive && !x.window.IsFlightPoppedOut) // must be active & docked + .Where(x => x.window.MainWindow != MainWindow.Settings && x.window.MainWindow != MainWindow.Stage && x.window.MainWindow != MainWindow.MainGui)) // MainGUI, Settings and Stage are special, they'll be drawn separately + + { + // Skip drawing of Target window if there's no active target + if (window.MainWindow == MainWindow.Target && !Utility.TargetExists()) + continue; + + // Skip drawing of Maneuver window if there's no active maneuver + if (window.MainWindow == MainWindow.Maneuver && !Utility.ManeuverExists()) + continue; + + DrawSectionHeader(window.Name, ref window.IsFlightPoppedOut, window.IsLocked, ""); + + window.DrawWindowHeader(); + + foreach (BaseEntry entry in window.Entries) + { + if (entry.HideWhenNoData && entry.ValueDisplay == "-") + continue; + DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); + } + + + window.DrawWindowFooter(); + + DrawSectionEnd(window); + } + + GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); + } + catch (Exception ex) + { + _logger.LogError(ex); + } + } + + /// + /// Draws all windows that are toggled and popped out + /// + /// + private void DrawPopoutWindow(int windowIndex) + { + BaseWindow windowToDraw = _windows[windowIndex]; + + DrawSectionHeader(windowToDraw.Name, ref windowToDraw.IsFlightPoppedOut, windowToDraw.IsLocked, ""); + + windowToDraw.DrawWindowHeader(); + + foreach (BaseEntry entry in windowToDraw.Entries) + { + if (entry.HideWhenNoData && entry.ValueDisplay == "-") + continue; + DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); + } + + windowToDraw.DrawWindowFooter(); + + DrawSectionEnd(windowToDraw); + } + + private void DrawSettingsWindow(int windowIndex) + { + BaseWindow windowToDraw = _windows[windowIndex]; + + DrawSectionHeader(windowToDraw.Name, ref windowToDraw.IsFlightPoppedOut, windowToDraw.IsLocked, ""); + + GUILayout.Space(10); + GUILayout.BeginHorizontal(); + if (GUILayout.Button("SAVE LAYOUT", Styles.NormalBtnStyle)) + Utility.SaveLayout(_windows); + GUILayout.Space(5); + if (GUILayout.Button("LOAD LAYOUT", Styles.NormalBtnStyle)) + { + Utility.LoadLayout(_windows); + _manager.Windows = _windows; + } + + GUILayout.Space(5); + if (GUILayout.Button("RESET", Styles.NormalBtnStyle)) + ResetLayout(); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + if (GUILayout.Button("Edit Windows", Styles.NormalBtnStyle)) + { + _showEditWindow = !_showEditWindow; + } + GUILayout.EndHorizontal(); + + DrawSectionEnd(windowToDraw); + } + + private void DrawStages(int windowIndex) + { + BaseWindow windowToDraw = _windows[windowIndex]; + + DrawStagesHeader(windowToDraw); + + List stages = (List)windowToDraw.Entries.Find(entry => entry.Name == "Stage Info").EntryValue; + + int stageCount = stages?.Count ?? 0; + if (stages != null && stageCount > 0) + { + float highestTwr = Mathf.Floor(stages.Max(stage => stage.TWRActual)); + int preDecimalDigits = Mathf.FloorToInt(Mathf.Log10(highestTwr)) + 1; + string twrFormatString = "N2"; + + if (preDecimalDigits == 3) + { + twrFormatString = "N1"; + } + else if (preDecimalDigits == 4) + { + twrFormatString = "N0"; + } + + for (int i = stages.Count - 1; i >= 0; i--) + { + + DeltaVStageInfo stageInfo = stages[i]; + if (stageInfo.DeltaVinVac > 0.0001 || stageInfo.DeltaVatASL > 0.0001) + { + int stageNum = stageCount - stageInfo.Stage; + DrawStageEntry(stageNum, stageInfo, twrFormatString); + } + } + } + + DrawSectionEnd(windowToDraw); + } + + private void DrawSectionHeader(string sectionName, ref bool isPopout, bool isLocked, string value = "") + { + GUILayout.BeginHorizontal(); + + // If window is popped out and it's not locked => show the close button. If it's not popped out => show to popup arrow + isPopout = isPopout && !isLocked ? !CloseButton(Styles.CloseBtnRect) : !isPopout ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : isPopout; + + GUILayout.Label($"{sectionName}"); + GUILayout.FlexibleSpace(); + GUILayout.Label(value, Styles.ValueLabelStyle); + GUILayout.Space(5); + GUILayout.Label("", Styles.UnitLabelStyle); + GUILayout.EndHorizontal(); + GUILayout.Space(Styles.SpacingAfterHeader); + } + + private void DrawStagesHeader(BaseWindow stageWindow) + { + GUILayout.BeginHorizontal(); + stageWindow.IsFlightPoppedOut = stageWindow.IsFlightPoppedOut ? !CloseButton(Styles.CloseBtnRect) : GUILayout.Button("⇖", Styles.PopoutBtnStyle); + + GUILayout.Label($"{stageWindow.Name}"); + GUILayout.FlexibleSpace(); + GUILayout.Label("∆v", Styles.TableHeaderLabelStyle); + GUILayout.Space(16); + GUILayout.Label($"TWR", Styles.TableHeaderLabelStyle, GUILayout.Width(40)); + GUILayout.Space(16); + if (stageWindow.IsFlightPoppedOut) + { + GUILayout.Label($"Burn", GUILayout.Width(56)); + } + else + { + GUILayout.Label($"Burn", Styles.TableHeaderLabelStyle, GUILayout.Width(56)); + } + GUILayout.EndHorizontal(); + GUILayout.Space(Styles.SpacingAfterHeader); + } + + private void DrawEntry(string entryName, string value, string unit = "") + { + GUILayout.BeginHorizontal(); + GUILayout.Label(entryName, Styles.NameLabelStyle); + GUILayout.FlexibleSpace(); + GUILayout.Label(value, Styles.ValueLabelStyle); + GUILayout.Space(5); + GUILayout.Label(unit, Styles.UnitLabelStyle); + GUILayout.EndHorizontal(); + GUILayout.Space(Styles.SpacingAfterEntry); + } + + private void DrawStageEntry(int stageID, DeltaVStageInfo stageInfo, string twrFormatString) + { + GUILayout.BeginHorizontal(); + GUILayout.Label($"{stageID:00.}", Styles.NameLabelStyle, GUILayout.Width(24)); + GUILayout.FlexibleSpace(); + GUILayout.Label($"{stageInfo.DeltaVActual:N0} m/s", Styles.ValueLabelStyle); + GUILayout.Space(16); + GUILayout.Label($"{stageInfo.TWRActual.ToString(twrFormatString)}", Styles.ValueLabelStyle, GUILayout.Width(40)); + GUILayout.Space(16); + string burnTime = Utility.SecondsToTimeString(stageInfo.StageBurnTime, false); + string lastUnit = "s"; + if (burnTime.Contains('h')) + { + burnTime = burnTime.Remove(burnTime.LastIndexOf("{lastUnit}", Styles.ValueLabelStyle, GUILayout.Width(56)); + GUILayout.EndHorizontal(); + GUILayout.Space(Styles.SpacingAfterEntry); + } + + private void DrawSectionEnd(BaseWindow window) + { + if (window.IsFlightPoppedOut) + { + if (!window.IsLocked) + GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); + + GUILayout.Space(Styles.SpacingBelowPopout); + } + else + { + GUILayout.Space(Styles.SpacingAfterSection); + } + } + + /// + /// Window for edditing window contents. Add/Remove/Reorder entries. + /// + /// + private void DrawEditWindow(int windowIndex) + { + List editableWindows = _windows.FindAll(w => w.IsEditable); // Editable windows are all except MainGUI, Settings, Stage and StageInfoOAB + List entriesByCategory = _manager.Entries.FindAll(e => e.Category == _selectedCategory); // All window stageInfoOabEntries belong to a category, but they can still be placed in any window + + _showEditWindow = !CloseButton(Styles.CloseBtnRect); + + #region Selection of window to be edited + GUILayout.BeginHorizontal(); + GUILayout.Label("EDITING WINDOW", Styles.TitleLabelStyle); + GUILayout.FlexibleSpace(); + if (GUILayout.Button("<", Styles.OneCharacterBtnStyle)) + { + _selectedWindowId = _selectedWindowId > 0 ? _selectedWindowId - 1 : editableWindows.Count - 1; + } + GUI.SetNextControlName(Utility.InputDisableWindowAbbreviation); + editableWindows[_selectedWindowId].Abbreviation = GUILayout.TextField(editableWindows[_selectedWindowId].Abbreviation, Styles.WindowSelectionAbbrevitionTextFieldStyle); + editableWindows[_selectedWindowId].Abbreviation = Utility.ValidateAbbreviation(editableWindows[_selectedWindowId].Abbreviation); + GUI.SetNextControlName(Utility.InputDisableWindowName); + editableWindows[_selectedWindowId].Name = GUILayout.TextField(editableWindows[_selectedWindowId].Name, Styles.WindowSelectionTextFieldStyle); + if (GUILayout.Button(">", Styles.OneCharacterBtnStyle)) + { + _selectedWindowId = _selectedWindowId < editableWindows.Count - 1 ? _selectedWindowId + 1 : 0; + } + GUILayout.EndHorizontal(); + #endregion + + GUILayout.Space(-10); + GUILayout.BeginHorizontal(); + GUILayout.BeginVertical(); + GUILayout.Space(10); + editableWindows[_selectedWindowId].IsLocked = GUILayout.Toggle(editableWindows[_selectedWindowId].IsLocked, "Locked"); + GUILayout.EndVertical(); + GUILayout.FlexibleSpace(); + if (editableWindows[_selectedWindowId].IsDeletable) + { + if (GUILayout.Button("DEL WINDOW", Styles.NormalBtnStyle)) + { + _windows.Remove(editableWindows[_selectedWindowId]); + editableWindows.Remove(editableWindows[_selectedWindowId]); + _selectedWindowId--; + } + } + if (GUILayout.Button("NEW WINDOW", Styles.NormalBtnStyle)) + _selectedWindowId = _manager.CreateCustomWindow(editableWindows); + GUILayout.EndHorizontal(); + + GUILayout.Space(10); + Styles.DrawHorizontalLine(); + GUILayout.Space(10); + + #region Installed entries in the selected window + GUILayout.BeginHorizontal(); + GUILayout.Label("Installed", Styles.NormalLabelStyle); + GUILayout.EndHorizontal(); + + var entries = editableWindows[_selectedWindowId].Entries.ToList(); + foreach (var (entry, index) in entries.Select((entry, index) => (entry, index))) + { + GUILayout.BeginHorizontal(); + GUILayout.Label(entry.Name, Styles.NameLabelStyle); + if (GUILayout.Button("↑", Styles.OneCharacterBtnStyle)) + { + if (index > 0) + editableWindows[_selectedWindowId].MoveEntryUp(index); + } + if (GUILayout.Button("↓", Styles.OneCharacterBtnStyle)) + { + if (index < editableWindows[_selectedWindowId].Entries.Count - 1) + editableWindows[_selectedWindowId].MoveEntryDown(index); + } + if (GUILayout.Button("X", Styles.OneCharacterBtnStyle)) + editableWindows[_selectedWindowId].RemoveEntry(index); + GUILayout.EndHorizontal(); + } + #endregion + + GUILayout.Space(10); + Styles.DrawHorizontalLine(); + GUILayout.Space(10); + + #region All entries that can be added to any IsEditable window + GUILayout.BeginHorizontal(); + GUILayout.Label("Add", Styles.NormalLabelStyle); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + GUILayout.Label("Category", Styles.NormalLabelStyle); + GUILayout.FlexibleSpace(); + + if (GUILayout.Button("<", Styles.OneCharacterBtnStyle)) + { + _selectedCategory = (int)_selectedCategory > 0 ? + _selectedCategory - 1 : + Enum.GetValues(typeof(MicroEntryCategory)).Cast().Last(); + } + GUILayout.Label(_selectedCategory.ToString(), Styles.NormalCenteredLabelStyle); + if (GUILayout.Button(">", Styles.OneCharacterBtnStyle)) + { + _selectedCategory = (int)_selectedCategory < (int)Enum.GetValues(typeof(MicroEntryCategory)).Cast().Last() ? + _selectedCategory + 1 : + Enum.GetValues(typeof(MicroEntryCategory)).Cast().First(); + } + GUILayout.EndHorizontal(); + + foreach (var (entry, index) in entriesByCategory.Select((entry, index) => (entry, index))) + { + GUILayout.BeginHorizontal(); + GUILayout.Label(entry.Name, Styles.NameLabelStyle); + if (GUILayout.Button("?", Styles.OneCharacterBtnStyle)) + { + if (!_showTooltip.condition) + _showTooltip = (true, index); + else + { + if (_showTooltip.index != index) + _showTooltip = (true, index); + else + _showTooltip = (false, index); + } + } + if (GUILayout.Button("+", Styles.OneCharacterBtnStyle)) + { + editableWindows[_selectedWindowId].AddEntry(entry); + } + GUILayout.EndHorizontal(); + + if (_showTooltip.condition && _showTooltip.index == index) + { + GUILayout.BeginHorizontal(); + GUILayout.Label(entry.Description, Styles.BlueLabelStyle); + GUILayout.EndHorizontal(); + } + } + #endregion + + GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); + } + + #endregion + + #region OAB scene UI + + private void DrawStageInfoOAB(int windowID) + { + BaseWindow stageInfoOabWindow = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + List stageInfoOabEntries = stageInfoOabWindow.Entries; + + GUILayout.BeginHorizontal(); + if (SettingsButton(Styles.SettingsOABRect)) + _showGuiSettingsOAB = !_showGuiSettingsOAB; + + if (CloseButton(Styles.CloseBtnStagesOABRect)) + { + stageInfoOabWindow.IsEditorActive = false; + ShowGuiOAB = false; + } + GUILayout.Label($"Stage Info"); + GUILayout.EndHorizontal(); + + // Draw StageInfo header - Delta V fields + GUILayout.BeginHorizontal(); + GUILayout.Label("Total ∆v (ASL, vacuum)", Styles.NameLabelStyle); + GUILayout.FlexibleSpace(); + GUILayout.Label($"{stageInfoOabEntries.Find(e => e.Name == "Total ∆v Actual (OAB)").ValueDisplay}, {stageInfoOabEntries.Find(e => e.Name == "Total ∆v Vac (OAB)").ValueDisplay}", Styles.ValueLabelStyle); + GUILayout.Space(5); + GUILayout.Label("m/s", Styles.UnitLabelStyle); + GUILayout.EndHorizontal(); + + // Draw Torque + Torque torque = (Torque)stageInfoOabEntries.Find(e => e.Name == "Torque"); + if (torque.IsActive) + { + GUILayout.Space(Styles.SpacingAfterEntry); + GUILayout.BeginHorizontal(); + GUILayout.Label("Torque", Styles.NameLabelStyle); + GUILayout.FlexibleSpace(); + GUILayout.Label(torque.ValueDisplay, Styles.ValueLabelStyle); + GUILayout.Space(5); + GUILayout.Label(torque.Unit, Styles.UnitLabelStyle); + GUILayout.EndHorizontal(); + } + + // Draw Stage table header + GUILayout.BeginHorizontal(); + GUILayout.Label("Stage", Styles.NameLabelStyle, GUILayout.Width(40)); + GUILayout.FlexibleSpace(); + GUILayout.Label("TWR", Styles.TableHeaderLabelStyle, GUILayout.Width(65)); + GUILayout.Label("SLT", Styles.TableHeaderLabelStyle, GUILayout.Width(75)); + GUILayout.Label("", Styles.TableHeaderLabelStyle, GUILayout.Width(30)); + GUILayout.Label("ASL ∆v", Styles.TableHeaderLabelStyle, GUILayout.Width(75)); + GUILayout.Label("", Styles.TableHeaderLabelStyle, GUILayout.Width(30)); + GUILayout.Label("Vac ∆v", Styles.TableHeaderLabelStyle, GUILayout.Width(75)); + GUILayout.Label("Burn Time", Styles.TableHeaderLabelStyle, GUILayout.Width(110)); + GUILayout.Space(20); + GUILayout.Label("Body", Styles.TableHeaderCenteredLabelStyle, GUILayout.Width(80)); + GUILayout.EndHorizontal(); + GUILayout.Space(Styles.SpacingAfterEntry); + + StageInfo_OAB stageInfoOab = (StageInfo_OAB)stageInfoOabWindow.Entries + .Find(e => e.Name == "Stage Info (OAB)"); + + // Draw each stage that has delta v + var stages = ((List)stageInfoOab.EntryValue) + .FindAll(s => s.DeltaVVac > 0.0001 || s.DeltaVASL > 0.0001); + + int celestialIndex = -1; + for (int stageIndex = stages.Count - 1; stageIndex >= 0; stageIndex--) + { + // Check if this stage has a CelestialBody attached. If not, create a new CelestialBody and assign it to HomeWorld (i.e. Kerbin) + if (stageInfoOab.CelestialBodyForStage.Count == ++celestialIndex) + stageInfoOab.AddNewCelestialBody(CelestialBodies); + + GUILayout.BeginHorizontal(); + GUILayout.Label(String.Format("{0:00}", ((List)stageInfoOab.EntryValue).Count - stages[stageIndex].Stage), Styles.NameLabelStyle, GUILayout.Width(40)); + GUILayout.FlexibleSpace(); + + // We calculate what factor needs to be applied to TWR in order to compensate for different gravity of the selected celestial body + double twrFactor = CelestialBodies.GetTwrFactor(stageInfoOab.CelestialBodyForStage[celestialIndex]); + GUILayout.Label(String.Format("{0:N2}", stages[stageIndex].TWRVac * twrFactor), Styles.ValueLabelStyle, GUILayout.Width(65)); + + // Calculate Sea Level TWR and DeltaV + CelestialBodyComponent cel = CelestialBodies.Bodies.Find(b => b.Name == stageInfoOab.CelestialBodyForStage[celestialIndex]).CelestialBodyComponent; + GUILayout.Label(String.Format("{0:N2}", stages[stageIndex].GetTWRAtSeaLevel(cel) * twrFactor), Styles.ValueLabelStyle, GUILayout.Width(75)); + GUILayout.Label(String.Format("{0:N0}", stages[stageIndex].GetDeltaVelAtSeaLevel(cel)), Styles.ValueLabelStyle, GUILayout.Width(75)); + GUILayout.Label("m/s", Styles.UnitLabelStyleStageOAB, GUILayout.Width(30)); + + GUILayout.Label(String.Format("{0:N0}", stages[stageIndex].DeltaVVac), Styles.ValueLabelStyle, GUILayout.Width(75)); + GUILayout.Label("m/s", Styles.UnitLabelStyleStageOAB, GUILayout.Width(30)); + GUILayout.Label(Utility.SecondsToTimeString(stages[stageIndex].StageBurnTime, true, true), Styles.ValueLabelStyle, GUILayout.Width(110)); + GUILayout.Space(20); + GUILayout.BeginVertical(); + GUILayout.FlexibleSpace(); + if (GUILayout.Button(stageInfoOab.CelestialBodyForStage[celestialIndex], Styles.CelestialBodyBtnStyle)) + { + CelestialBodySelectionStageIndex = celestialIndex; + } + GUILayout.EndVertical(); + GUILayout.EndHorizontal(); + GUILayout.Space(Styles.SpacingAfterEntry); + } + + GUILayout.Space(Styles.SpacingBelowPopout); + + GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height)); + } + + /// + /// Opens a window for selecting a CelestialObject for the stage on the given index + /// + private void DrawCelestialBodySelection(int id) + { + GUILayout.BeginVertical(); + + foreach (var body in CelestialBodies.Bodies) + { + if (GUILayout.Button(body.DisplayName, Styles.CelestialSelectionBtnStyle)) + { + StageInfo_OAB stageInfoOab = (StageInfo_OAB)_windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Stage Info (OAB)"); + stageInfoOab.CelestialBodyForStage[CelestialBodySelectionStageIndex] = body.Name; + + // Hide the selection window + CelestialBodySelectionStageIndex = -1; + } + } + + GUILayout.EndVertical(); + } + + /// + /// Opens a Settings window for OAB + /// + private void DrawSettingsOabWindow(int id) + { + if (CloseButton(Styles.CloseBtnSettingsOABRect)) + _showGuiSettingsOAB = false; + + BaseWindow stageInfoOabWindow = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + List stageInfoOabEntries = stageInfoOabWindow.Entries; + Torque torqueEntry = (Torque)stageInfoOabEntries.Find(e => e.Name == "Torque"); + + torqueEntry.IsActive = GUILayout.Toggle(torqueEntry.IsActive, "Display Torque (experimental)\nTurn on CoT & CoM for this", Styles.SectionToggleStyle); + } + + /// + /// Draws a Settings button (≡) + /// + /// + /// + private bool SettingsButton(Rect rect) + { + return GUI.Button(rect, "≡", Styles.SettingsBtnStyle); + } + + #endregion + + private void ResetLayout() + { + _windows = _manager.InitializeWindows(); + _selectedWindowId = 0; + } + + private void CloseWindow() + { + GameObject.Find("BTN-MicroEngineerBtn")?.GetComponent()?.SetValue(false); + ShowGuiFlight = false; + } + + /// + /// Draws a close button (X) + /// + /// Where to position the close button + /// + private bool CloseButton(Rect rect) + { + return GUI.Button(rect, "X", Styles.CloseBtnStyle); + } + } +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index e4c236d..da90013 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -1,15 +1,10 @@ using BepInEx; -using KSP.Game; using UnityEngine; using SpaceWarp; using SpaceWarp.API.Assets; using SpaceWarp.API.Mods; using SpaceWarp.API.UI.Appbar; using KSP.UI.Binding; -using KSP.Sim.DeltaV; -using KSP.Messages; -using KSP.Sim.impl; -using System.Reflection; namespace MicroMod { @@ -17,48 +12,17 @@ namespace MicroMod [BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)] public class MicroEngineerMod : BaseSpaceWarpPlugin { - private bool _showGuiFlight; - private bool _showGuiOAB; - private bool _showGuiSettingsOAB; - - #region Editing window - private bool showEditWindow = false; - private int selectedWindowId = 0; - private MicroEntryCategory selectedCategory = MicroEntryCategory.Vessel; - private (bool condition, int index) showTooltip = (false, 0); - #endregion - - /// - /// Holds all entries we can have in any window - /// - private List MicroEntries; - - /// - /// All windows that can be rendered - /// - private List MicroWindows; - - /// - /// Holds data on all bodies for calculating TWR (currently) - /// - private MicroCelestialBodies _celestialBodies = new(); - - // Index of the stage for which user wants to select a different CelestialBody for different TWR calculations. -1 -> no stage is selected - private int _celestialBodySelectionStageIndex = -1; - - // If game input is enabled or disabled (used for locking controls when user is editing a text field - private bool _gameInputState = true; + private Manager _manager; + private MessageManager _messagesManager; + private UI _ui; public override void OnInitialized() { Styles.InitializeStyles(); - InitializeEntries(); - InitializeWindows(); - SubscribeToMessages(); - InitializeCelestialBodies(); - - // Load window positions and states from disk, if file exists - Utility.LoadLayout(MicroWindows); + + _manager = new Manager(this); + _ui = new UI(this, _manager); + _messagesManager = new MessageManager(this, _manager, _ui); BackwardCompatibilityInitializations(); @@ -69,8 +33,8 @@ public override void OnInitialized() AssetManager.GetAsset($"{SpaceWarpMetadata.ModID}/images/icon.png"), isOpen => { - _showGuiFlight = isOpen; - MicroWindows.Find(w => w.MainWindow == MainWindow.MainGui).IsFlightActive = isOpen; + _ui.ShowGuiFlight = isOpen; + _manager.Windows.Find(w => w.MainWindow == MainWindow.MainGui).IsFlightActive = isOpen; GameObject.Find("BTN-MicroEngineerBtn")?.GetComponent()?.SetValue(isOpen); }); @@ -80,8 +44,8 @@ public override void OnInitialized() AssetManager.GetAsset($"{SpaceWarpMetadata.ModID}/images/icon.png"), isOpen => { - _showGuiOAB = isOpen; - MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive = isOpen; + _ui.ShowGuiOAB = isOpen; + _manager.Windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive = isOpen; GameObject.Find("BTN - MicroEngineerOAB")?.GetComponent()?.SetValue(isOpen); }); } @@ -97,1151 +61,15 @@ private void BackwardCompatibilityInitializations() else Logger.LogInfo("Space Warp new version detected. Loading new Styles."); } - - /// - /// Subscribe to Messages KSP2 is using - /// - private void SubscribeToMessages() - { - Utility.RefreshGameManager(); - - // While in OAB we use the VesselDeltaVCalculationMessage event to refresh data as it's triggered a lot less frequently than Update() - Utility.MessageCenter.Subscribe(new Action(this.RefreshStagingDataOAB)); - - // We are loading layout state when entering Flight or OAB game state - Utility.MessageCenter.Subscribe(new Action(this.GameStateEntered)); - - // We are saving layout state when exiting from Flight or OAB game state - Utility.MessageCenter.Subscribe(new Action(this.GameStateLeft)); - - // Sets the selected node index to the newly created node - Utility.MessageCenter.Subscribe(new Action(this.OnManeuverCreatedMessage)); - - // Resets node index - Utility.MessageCenter.Subscribe(new Action(this.OnManeuverRemovedMessage)); - - // Torque update for StageInfoOAB - Utility.MessageCenter.Subscribe(new Action(this.OnPartManipulationCompletedMessage)); - } - private void OnManeuverCreatedMessage(MessageCenterMessage message) - { - var maneuverWindow = MicroWindows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; - maneuverWindow.OnManeuverCreatedMessage(message); - } - - private void OnManeuverRemovedMessage(MessageCenterMessage message) - { - var maneuverWindow = MicroWindows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; - maneuverWindow.OnManeuverRemovedMessage(message); - } - - private void OnPartManipulationCompletedMessage(MessageCenterMessage obj) - { - Torque torque = (Torque)MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Torque"); - torque.RefreshData(); - } - - private void GameStateEntered(MessageCenterMessage obj) - { - Logger.LogInfo("Message triggered: GameStateEnteredMessage"); - - Utility.RefreshGameManager(); - if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView) - { - Utility.LoadLayout(MicroWindows); - - if(Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) - _showGuiFlight = MicroWindows.Find(w => w.MainWindow == MainWindow.MainGui).IsFlightActive; - - if(Utility.GameState.GameState == GameState.VehicleAssemblyBuilder) - { - _showGuiOAB = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive; - InitializeCelestialBodies(); - _celestialBodySelectionStageIndex = -1; - } - } - } - - private void GameStateLeft(MessageCenterMessage obj) - { - Logger.LogInfo("Message triggered: GameStateLeftMessage"); - - Utility.RefreshGameManager(); - if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView) - { - Utility.SaveLayout(MicroWindows); - - if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) - _showGuiFlight = false; - - if (Utility.GameState.GameState == GameState.VehicleAssemblyBuilder) - _showGuiOAB = false; - } - } - - #region Data refreshing - /// - /// Refresh all staging data while in OAB - /// - private void RefreshStagingDataOAB(MessageCenterMessage obj) - { - // Check if message originated from ships in flight. If yes, return. - VesselDeltaVCalculationMessage msg = (VesselDeltaVCalculationMessage)obj; - if (msg.DeltaVComponent.Ship == null || !msg.DeltaVComponent.Ship.IsLaunchAssembly()) return; - - Utility.RefreshGameManager(); - if (Utility.GameState.GameState != GameState.VehicleAssemblyBuilder) return; - - Utility.RefreshStagesOAB(); - - BaseWindow stageWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); - - if (Utility.VesselDeltaVComponentOAB?.StageInfo == null) - { - stageWindow.Entries.Find(e => e.Name == "Stage Info (OAB)").EntryValue = null; - return; - } - - foreach (var entry in stageWindow.Entries) - entry.RefreshData(); - } - public void Update() { - Utility.RefreshGameManager(); - - // Perform flight UI updates only if we're in Flight or Map view - if (Utility.GameState != null && (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView)) - { - Utility.RefreshActiveVesselAndCurrentManeuver(); - - if (Utility.ActiveVessel == null) - return; - - // Refresh all active windows' entries - foreach (BaseWindow window in MicroWindows.Where(w => w.IsFlightActive)) - window.RefreshData(); - } + _manager?.Update(); } - #endregion private void OnGUI() { - GUI.skin = Styles.SpaceWarpUISkin; - - Utility.RefreshGameManager(); - if (Utility.GameState?.GameState == GameState.VehicleAssemblyBuilder) - OnGUI_OAB(); - else - OnGUI_Flight(); - } - - #region Flight scene UI and logic - private void OnGUI_Flight() - { - _gameInputState = Utility.ToggleGameInputOnControlInFocus(_gameInputState, _showGuiFlight); - - if (!_showGuiFlight || Utility.ActiveVessel == null) return; - - BaseWindow mainGui = MicroWindows.Find(window => window.MainWindow == MainWindow.MainGui); - - // Draw main GUI that contains docked windows - mainGui.FlightRect = GUILayout.Window( - GUIUtility.GetControlID(FocusType.Passive), - mainGui.FlightRect, - FillMainGUI, - "// MICRO ENGINEER", - Styles.MainWindowStyle, - GUILayout.Height(0) - ); - mainGui.FlightRect.position = Utility.ClampToScreen(mainGui.FlightRect.position, mainGui.FlightRect.size); - - // Draw all other popped out windows - foreach (var (window, index) in MicroWindows - .Select((window, index) => (window, index)) - .Where(x => x.window.IsFlightActive && x.window.IsFlightPoppedOut) // must be active & popped out - .Where(x => x.window.MainWindow != MainWindow.Settings && x.window.MainWindow != MainWindow.Stage && x.window.MainWindow != MainWindow.MainGui)) // MainGUI, Settings and Stage are special, they'll be drawn separately - { - // Skip drawing of Target window if there's no active target - if (window.MainWindow == MainWindow.Target && !Utility.TargetExists()) - continue; - - // Skip drawing of Maneuver window if there's no active maneuver - if (window.MainWindow == MainWindow.Maneuver && !Utility.ManeuverExists()) - continue; - - // If window is locked set alpha to 80% - if (window.IsLocked) - GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.8f); - - window.FlightRect = GUILayout.Window( - index, - window.FlightRect, - DrawPopoutWindow, - "", - Styles.PopoutWindowStyle, - GUILayout.Height(0), - GUILayout.Width(Styles.WindowWidth - )); - - // Set alpha back to 100% - if (window.IsLocked) - GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 1); - - window.FlightRect.position = Utility.ClampToScreen(window.FlightRect.position, window.FlightRect.size); - } - - // Draw popped out Settings - int settingsIndex = MicroWindows.FindIndex(window => window.MainWindow == MainWindow.Settings); - if (MicroWindows[settingsIndex].IsFlightActive && MicroWindows[settingsIndex].IsFlightPoppedOut) - { - MicroWindows[settingsIndex].FlightRect = GUILayout.Window( - settingsIndex, - MicroWindows[settingsIndex].FlightRect, - DrawSettingsWindow, - "", - Styles.PopoutWindowStyle, - GUILayout.Height(0), - GUILayout.Width(Styles.WindowWidth) - ); - - MicroWindows[settingsIndex].FlightRect.position = Utility.ClampToScreen(MicroWindows[settingsIndex].FlightRect.position, MicroWindows[settingsIndex].FlightRect.size); - } - - // Draw popped out Stages - int stageIndex = MicroWindows.FindIndex(window => window.MainWindow == MainWindow.Stage); - if (MicroWindows[stageIndex].IsFlightActive && MicroWindows[stageIndex].IsFlightPoppedOut) - { - MicroWindows[stageIndex].FlightRect = GUILayout.Window( - stageIndex, - MicroWindows[stageIndex].FlightRect, - DrawStages, - "", - Styles.PopoutWindowStyle, - GUILayout.Height(0), - GUILayout.Width(Styles.WindowWidth) - ); - - MicroWindows[stageIndex].FlightRect.position = Utility.ClampToScreen(MicroWindows[stageIndex].FlightRect.position, MicroWindows[stageIndex].FlightRect.size); - } - - // Draw Edit Window - if (showEditWindow) - { - Styles.EditWindowRect = GUILayout.Window( - GUIUtility.GetControlID(FocusType.Passive), - Styles.EditWindowRect, - DrawEditWindow, - "", - Styles.EditWindowStyle, - GUILayout.Height(0) - ); - } - } - - /// - /// Draws the main GUI with all windows that are toggled and docked - /// - /// - private void FillMainGUI(int windowID) - { - try - { - if (CloseButton(Styles.CloseBtnRect)) - { - CloseWindow(); - } - - GUILayout.Space(5); - - GUILayout.BeginHorizontal(); - - int toggleIndex = -1; - // Draw toggles for all windows except MainGui and StageInfoOAB - foreach (BaseWindow window in MicroWindows.Where(x => x.MainWindow != MainWindow.MainGui && x.MainWindow != MainWindow.StageInfoOAB)) - { - // layout can fit 6 toggles, so if all 6 slots are filled then go to a new line. Index == 0 is the MainGUI which isn't rendered - if (++toggleIndex % 6 == 0 && toggleIndex > 0) - { - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(); - } - window.IsFlightActive = GUILayout.Toggle(window.IsFlightActive, window.Abbreviation, Styles.SectionToggleStyle); - } - GUILayout.EndHorizontal(); - GUILayout.Space(5); - - // Draw Settings window first - int settingsIndex = MicroWindows.FindIndex(window => window.MainWindow == MainWindow.Settings); - if (MicroWindows[settingsIndex].IsFlightActive && !MicroWindows[settingsIndex].IsFlightPoppedOut) - DrawSettingsWindow(settingsIndex); - - // Draw Stage window next - int stageIndex = MicroWindows.FindIndex(window => window.MainWindow == MainWindow.Stage); - if (MicroWindows[stageIndex].IsFlightActive && !MicroWindows[stageIndex].IsFlightPoppedOut) - DrawStages(stageIndex); - - // Draw all other windows - foreach (var (window, index) in MicroWindows - .Select((window, index) => (window, index)) - .Where(x => x.window.IsFlightActive && !x.window.IsFlightPoppedOut) // must be active & docked - .Where(x => x.window.MainWindow != MainWindow.Settings && x.window.MainWindow != MainWindow.Stage && x.window.MainWindow != MainWindow.MainGui)) // MainGUI, Settings and Stage are special, they'll be drawn separately - - { - // Skip drawing of Target window if there's no active target - if (window.MainWindow == MainWindow.Target && !Utility.TargetExists()) - continue; - - // Skip drawing of Maneuver window if there's no active maneuver - if (window.MainWindow == MainWindow.Maneuver && !Utility.ManeuverExists()) - continue; - - DrawSectionHeader(window.Name, ref window.IsFlightPoppedOut, window.IsLocked, ""); - - window.DrawWindowHeader(); - - foreach (MicroEntry entry in window.Entries) - { - if (entry.HideWhenNoData && entry.ValueDisplay == "-") - continue; - DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); - } - - - window.DrawWindowFooter(); - - DrawSectionEnd(window); - } - - GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); - } - catch (Exception ex) - { - Logger.LogError(ex); - } - } - - /// - /// Draws all windows that are toggled and popped out - /// - /// - private void DrawPopoutWindow(int windowIndex) - { - BaseWindow windowToDraw = MicroWindows[windowIndex]; - - DrawSectionHeader(windowToDraw.Name, ref windowToDraw.IsFlightPoppedOut, windowToDraw.IsLocked, ""); - - windowToDraw.DrawWindowHeader(); - - foreach (MicroEntry entry in windowToDraw.Entries) - { - if (entry.HideWhenNoData && entry.ValueDisplay == "-") - continue; - DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); - } - - windowToDraw.DrawWindowFooter(); - - DrawSectionEnd(windowToDraw); - } - private void DrawSettingsWindow(int windowIndex) - { - BaseWindow windowToDraw = MicroWindows[windowIndex]; - - DrawSectionHeader(windowToDraw.Name, ref windowToDraw.IsFlightPoppedOut, windowToDraw.IsLocked, ""); - - GUILayout.Space(10); - GUILayout.BeginHorizontal(); - if (GUILayout.Button("SAVE LAYOUT", Styles.NormalBtnStyle)) - Utility.SaveLayout(MicroWindows); - GUILayout.Space(5); - if (GUILayout.Button("LOAD LAYOUT", Styles.NormalBtnStyle)) - Utility.LoadLayout(MicroWindows); - GUILayout.Space(5); - if (GUILayout.Button("RESET", Styles.NormalBtnStyle)) - ResetLayout(); - GUILayout.EndHorizontal(); - - GUILayout.BeginHorizontal(); - if (GUILayout.Button("Edit Windows", Styles.NormalBtnStyle)) - { - showEditWindow = !showEditWindow; - } - GUILayout.EndHorizontal(); - - DrawSectionEnd(windowToDraw); - } - - private void DrawStages(int windowIndex) - { - BaseWindow windowToDraw = MicroWindows[windowIndex]; - - DrawStagesHeader(windowToDraw); - - List stages = (List)windowToDraw.Entries.Find(entry => entry.Name == "Stage Info").EntryValue; - - int stageCount = stages?.Count ?? 0; - if (stages != null && stageCount > 0) - { - float highestTwr = Mathf.Floor(stages.Max(stage => stage.TWRActual)); - int preDecimalDigits = Mathf.FloorToInt(Mathf.Log10(highestTwr)) + 1; - string twrFormatString = "N2"; - - if (preDecimalDigits == 3) - { - twrFormatString = "N1"; - } - else if (preDecimalDigits == 4) - { - twrFormatString = "N0"; - } - - for (int i = stages.Count - 1; i >= 0; i--) - { - - DeltaVStageInfo stageInfo = stages[i]; - if (stageInfo.DeltaVinVac > 0.0001 || stageInfo.DeltaVatASL > 0.0001) - { - int stageNum = stageCount - stageInfo.Stage; - DrawStageEntry(stageNum, stageInfo, twrFormatString); - } - } - } - - DrawSectionEnd(windowToDraw); - } - - private void DrawSectionHeader(string sectionName, ref bool isPopout, bool isLocked, string value = "") - { - GUILayout.BeginHorizontal(); - - // If window is popped out and it's not locked => show the close button. If it's not popped out => show to popup arrow - isPopout = isPopout && !isLocked ? !CloseButton(Styles.CloseBtnRect) : !isPopout ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : isPopout; - - GUILayout.Label($"{sectionName}"); - GUILayout.FlexibleSpace(); - GUILayout.Label(value, Styles.ValueLabelStyle); - GUILayout.Space(5); - GUILayout.Label("", Styles.UnitLabelStyle); - GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterHeader); - } - - private void DrawStagesHeader(BaseWindow stageWindow) - { - GUILayout.BeginHorizontal(); - stageWindow.IsFlightPoppedOut = stageWindow.IsFlightPoppedOut ? !CloseButton(Styles.CloseBtnRect) : GUILayout.Button("⇖", Styles.PopoutBtnStyle); - - GUILayout.Label($"{stageWindow.Name}"); - GUILayout.FlexibleSpace(); - GUILayout.Label("∆v", Styles.TableHeaderLabelStyle); - GUILayout.Space(16); - GUILayout.Label($"TWR", Styles.TableHeaderLabelStyle, GUILayout.Width(40)); - GUILayout.Space(16); - if (stageWindow.IsFlightPoppedOut) - { - GUILayout.Label($"Burn", GUILayout.Width(56)); - } - else - { - GUILayout.Label($"Burn", Styles.TableHeaderLabelStyle, GUILayout.Width(56)); - } - GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterHeader); - } - - private void DrawEntry(string entryName, string value, string unit = "") - { - GUILayout.BeginHorizontal(); - GUILayout.Label(entryName, Styles.NameLabelStyle); - GUILayout.FlexibleSpace(); - GUILayout.Label(value, Styles.ValueLabelStyle); - GUILayout.Space(5); - GUILayout.Label(unit, Styles.UnitLabelStyle); - GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); - } - - private void DrawStageEntry(int stageID, DeltaVStageInfo stageInfo, string twrFormatString) - { - GUILayout.BeginHorizontal(); - GUILayout.Label($"{stageID:00.}", Styles.NameLabelStyle, GUILayout.Width(24)); - GUILayout.FlexibleSpace(); - GUILayout.Label($"{stageInfo.DeltaVActual:N0} m/s", Styles.ValueLabelStyle); - GUILayout.Space(16); - GUILayout.Label($"{stageInfo.TWRActual.ToString(twrFormatString)}", Styles.ValueLabelStyle, GUILayout.Width(40)); - GUILayout.Space(16); - string burnTime = Utility.SecondsToTimeString(stageInfo.StageBurnTime, false); - string lastUnit = "s"; - if (burnTime.Contains('h')) - { - burnTime = burnTime.Remove(burnTime.LastIndexOf("{lastUnit}", Styles.ValueLabelStyle, GUILayout.Width(56)); - GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); - } - - private void DrawSectionEnd(BaseWindow window) - { - if (window.IsFlightPoppedOut) - { - if (!window.IsLocked) - GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); - - GUILayout.Space(Styles.SpacingBelowPopout); - } - else - { - GUILayout.Space(Styles.SpacingAfterSection); - } - } - - /// - /// Window for edditing window contents. Add/Remove/Reorder entries. - /// - /// - private void DrawEditWindow(int windowIndex) - { - List editableWindows = MicroWindows.FindAll(w => w.IsEditable); // Editable windows are all except MainGUI, Settings, Stage and StageInfoOAB - List entriesByCategory = MicroEntries.FindAll(e => e.Category == selectedCategory); // All window stageInfoOabEntries belong to a category, but they can still be placed in any window - - showEditWindow = !CloseButton(Styles.CloseBtnRect); - - #region Selection of window to be edited - GUILayout.BeginHorizontal(); - GUILayout.Label("EDITING WINDOW", Styles.TitleLabelStyle); - GUILayout.FlexibleSpace(); - if (GUILayout.Button("<", Styles.OneCharacterBtnStyle)) - { - selectedWindowId = selectedWindowId > 0 ? selectedWindowId - 1 : editableWindows.Count - 1; - } - GUI.SetNextControlName(Utility.InputDisableWindowAbbreviation); - editableWindows[selectedWindowId].Abbreviation = GUILayout.TextField(editableWindows[selectedWindowId].Abbreviation, Styles.WindowSelectionAbbrevitionTextFieldStyle); - editableWindows[selectedWindowId].Abbreviation = Utility.ValidateAbbreviation(editableWindows[selectedWindowId].Abbreviation); - GUI.SetNextControlName(Utility.InputDisableWindowName); - editableWindows[selectedWindowId].Name = GUILayout.TextField(editableWindows[selectedWindowId].Name, Styles.WindowSelectionTextFieldStyle); - if (GUILayout.Button(">", Styles.OneCharacterBtnStyle)) - { - selectedWindowId = selectedWindowId < editableWindows.Count - 1 ? selectedWindowId + 1 : 0; - } - GUILayout.EndHorizontal(); - #endregion - - GUILayout.Space(-10); - GUILayout.BeginHorizontal(); - GUILayout.BeginVertical(); - GUILayout.Space(10); - editableWindows[selectedWindowId].IsLocked = GUILayout.Toggle(editableWindows[selectedWindowId].IsLocked, "Locked"); - GUILayout.EndVertical(); - GUILayout.FlexibleSpace(); - if (editableWindows[selectedWindowId].IsDeletable) - { - if (GUILayout.Button("DEL WINDOW", Styles.NormalBtnStyle)) - { - MicroWindows.Remove(editableWindows[selectedWindowId]); - editableWindows.Remove(editableWindows[selectedWindowId]); - selectedWindowId--; - } - } - if (GUILayout.Button("NEW WINDOW", Styles.NormalBtnStyle)) - CreateCustomWindow(editableWindows); - GUILayout.EndHorizontal(); - - GUILayout.Space(10); - Styles.DrawHorizontalLine(); - GUILayout.Space(10); - - #region Installed entries in the selected window - GUILayout.BeginHorizontal(); - GUILayout.Label("Installed", Styles.NormalLabelStyle); - GUILayout.EndHorizontal(); - - var entries = editableWindows[selectedWindowId].Entries.ToList(); - foreach (var (entry, index) in entries.Select((entry, index) => (entry, index))) - { - GUILayout.BeginHorizontal(); - GUILayout.Label(entry.Name, Styles.NameLabelStyle); - if (GUILayout.Button("↑", Styles.OneCharacterBtnStyle)) - { - if (index > 0) - editableWindows[selectedWindowId].MoveEntryUp(index); - } - if (GUILayout.Button("↓", Styles.OneCharacterBtnStyle)) - { - if (index < editableWindows[selectedWindowId].Entries.Count - 1) - editableWindows[selectedWindowId].MoveEntryDown(index); - } - if (GUILayout.Button("X", Styles.OneCharacterBtnStyle)) - editableWindows[selectedWindowId].RemoveEntry(index); - GUILayout.EndHorizontal(); - } - #endregion - - GUILayout.Space(10); - Styles.DrawHorizontalLine(); - GUILayout.Space(10); - - #region All entries that can be added to any IsEditable window - GUILayout.BeginHorizontal(); - GUILayout.Label("Add", Styles.NormalLabelStyle); - GUILayout.EndHorizontal(); - - GUILayout.BeginHorizontal(); - GUILayout.Label("Category", Styles.NormalLabelStyle); - GUILayout.FlexibleSpace(); - - if (GUILayout.Button("<", Styles.OneCharacterBtnStyle)) - { - selectedCategory = (int)selectedCategory > 0 ? selectedCategory - 1 : Enum.GetValues(typeof(MicroEntryCategory)).Cast().Last(); - } - GUILayout.Label(selectedCategory.ToString(), Styles.NormalCenteredLabelStyle); - if (GUILayout.Button(">", Styles.OneCharacterBtnStyle)) - { - selectedCategory = (int)selectedCategory < (int)Enum.GetValues(typeof(MicroEntryCategory)).Cast().Last() ? selectedCategory + 1 : Enum.GetValues(typeof(MicroEntryCategory)).Cast().First(); - } - GUILayout.EndHorizontal(); - - foreach (var (entry, index) in entriesByCategory.Select((entry, index) => (entry, index))) - { - GUILayout.BeginHorizontal(); - GUILayout.Label(entry.Name, Styles.NameLabelStyle); - if (GUILayout.Button("?", Styles.OneCharacterBtnStyle)) - { - if (!showTooltip.condition) - showTooltip = (true, index); - else - { - if (showTooltip.index != index) - showTooltip = (true, index); - else - showTooltip = (false, index); - } - } - if (GUILayout.Button("+", Styles.OneCharacterBtnStyle)) - { - editableWindows[selectedWindowId].AddEntry(entry); - } - GUILayout.EndHorizontal(); - - if (showTooltip.condition && showTooltip.index == index) - { - GUILayout.BeginHorizontal(); - GUILayout.Label(entry.Description, Styles.BlueLabelStyle); - GUILayout.EndHorizontal(); - } - } - #endregion - - GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); - } - - /// - /// Creates a new custom window user can fill with any entry - /// - /// - private void CreateCustomWindow(List editableWindows) - { - // Default window's name will be CustomX where X represents the first not used integer - int nameID = 1; - foreach (BaseWindow window in editableWindows) - { - if (window.Name == "Custom" + nameID) - nameID++; - } - - BaseWindow newWindow = new BaseWindow() - { - Name = "Custom" + nameID, - Abbreviation = nameID.ToString().Length == 1 ? "Cu" + nameID : nameID.ToString().Length == 2 ? "C" + nameID : nameID.ToString(), - Description = "", - IsEditorActive = false, - IsFlightActive = true, - IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.None, - //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = new List() - }; - - MicroWindows.Add(newWindow); - editableWindows.Add(newWindow); - - selectedWindowId = editableWindows.Count - 1; - } - - private void ResetLayout() - { - InitializeWindows(); - } - - private void CloseWindow() - { - GameObject.Find("BTN-MicroEngineerBtn")?.GetComponent()?.SetValue(false); - _showGuiFlight = false; - } - - #endregion - - #region OAB scene UI and logic - private void OnGUI_OAB() - { - if (!_showGuiOAB) return; - - BaseWindow stageInfoOAB = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); - if (stageInfoOAB.Entries.Find(e => e.Name == "Stage Info (OAB)").EntryValue == null) return; - - stageInfoOAB.EditorRect = GUILayout.Window( - GUIUtility.GetControlID(FocusType.Passive), - stageInfoOAB.EditorRect, - DrawStageInfoOAB, - "", - Styles.StageOABWindowStyle, - GUILayout.Height(0) - ); - stageInfoOAB.EditorRect.position = Utility.ClampToScreen(stageInfoOAB.EditorRect.position, stageInfoOAB.EditorRect.size); - - // Draw window for selecting CelestialBody for a stage - // -1 -> no selection of CelestialBody is taking place - // any other int -> index represents the stage number for which the selection was clicked - if (_celestialBodySelectionStageIndex > -1) - { - Rect stageInfoOabRect = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).EditorRect; - Rect celestialBodyRect = new Rect(stageInfoOabRect.x + stageInfoOabRect.width, stageInfoOabRect.y, 0, 0); - - celestialBodyRect = GUILayout.Window( - GUIUtility.GetControlID(FocusType.Passive), - celestialBodyRect, - DrawCelestialBodySelection, - "", - Styles.CelestialSelectionStyle, - GUILayout.Height(0) - ); - } - - // Draw Settings window for the StageInfoOAB - if(_showGuiSettingsOAB) - { - Rect stageInfoOabRect = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).EditorRect; - Rect settingsRect = new Rect(stageInfoOabRect.x + stageInfoOabRect.width, stageInfoOabRect.y, 0, 0); - - settingsRect = GUILayout.Window( - GUIUtility.GetControlID(FocusType.Passive), - settingsRect, - DrawSettingsOabWindow, - "", - Styles.SettingsOabStyle, - GUILayout.Height(0) - ); - } - } - - private void DrawStageInfoOAB(int windowID) - { - BaseWindow stageInfoOabWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); - List stageInfoOabEntries = stageInfoOabWindow.Entries; - - GUILayout.BeginHorizontal(); - if (SettingsButton(Styles.SettingsOABRect)) - _showGuiSettingsOAB = !_showGuiSettingsOAB; - - if (CloseButton(Styles.CloseBtnStagesOABRect)) - { - stageInfoOabWindow.IsEditorActive = false; - _showGuiOAB = false; - } - GUILayout.Label($"Stage Info"); - GUILayout.EndHorizontal(); - - // Draw StageInfo header - Delta V fields - GUILayout.BeginHorizontal(); - GUILayout.Label("Total ∆v (ASL, vacuum)", Styles.NameLabelStyle); - GUILayout.FlexibleSpace(); - GUILayout.Label($"{stageInfoOabEntries.Find(e => e.Name == "Total ∆v Actual (OAB)").ValueDisplay}, {stageInfoOabEntries.Find(e => e.Name == "Total ∆v Vac (OAB)").ValueDisplay}", Styles.ValueLabelStyle); - GUILayout.Space(5); - GUILayout.Label("m/s", Styles.UnitLabelStyle); - GUILayout.EndHorizontal(); - - // Draw Torque - Torque torque = (Torque)stageInfoOabEntries.Find(e => e.Name == "Torque"); - if (torque.IsActive) - { - GUILayout.Space(Styles.SpacingAfterEntry); - GUILayout.BeginHorizontal(); - GUILayout.Label("Torque", Styles.NameLabelStyle); - GUILayout.FlexibleSpace(); - GUILayout.Label(torque.ValueDisplay, Styles.ValueLabelStyle); - GUILayout.Space(5); - GUILayout.Label(torque.Unit, Styles.UnitLabelStyle); - GUILayout.EndHorizontal(); - } - - // Draw Stage table header - GUILayout.BeginHorizontal(); - GUILayout.Label("Stage", Styles.NameLabelStyle, GUILayout.Width(40)); - GUILayout.FlexibleSpace(); - GUILayout.Label("TWR", Styles.TableHeaderLabelStyle, GUILayout.Width(65)); - GUILayout.Label("SLT", Styles.TableHeaderLabelStyle, GUILayout.Width(75)); - GUILayout.Label("", Styles.TableHeaderLabelStyle, GUILayout.Width(30)); - GUILayout.Label("ASL ∆v", Styles.TableHeaderLabelStyle, GUILayout.Width(75)); - GUILayout.Label("", Styles.TableHeaderLabelStyle, GUILayout.Width(30)); - GUILayout.Label("Vac ∆v", Styles.TableHeaderLabelStyle, GUILayout.Width(75)); - GUILayout.Label("Burn Time", Styles.TableHeaderLabelStyle, GUILayout.Width(110)); - GUILayout.Space(20); - GUILayout.Label("Body", Styles.TableHeaderCenteredLabelStyle, GUILayout.Width(80)); - GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); - - StageInfo_OAB stageInfoOab = (StageInfo_OAB)stageInfoOabWindow.Entries - .Find(e => e.Name == "Stage Info (OAB)"); - - // Draw each stage that has delta v - var stages = ((List)stageInfoOab.EntryValue) - .FindAll(s => s.DeltaVVac > 0.0001 || s.DeltaVASL > 0.0001); - - int celestialIndex = -1; - for (int stageIndex = stages.Count - 1; stageIndex >= 0; stageIndex--) - { - // Check if this stage has a CelestialBody attached. If not, create a new CelestialBody and assign it to HomeWorld (i.e. Kerbin) - if (stageInfoOab.CelestialBodyForStage.Count == ++celestialIndex) - stageInfoOab.AddNewCelestialBody(_celestialBodies); - - GUILayout.BeginHorizontal(); - GUILayout.Label(String.Format("{0:00}", ((List)stageInfoOab.EntryValue).Count - stages[stageIndex].Stage), Styles.NameLabelStyle, GUILayout.Width(40)); - GUILayout.FlexibleSpace(); - - // We calculate what factor needs to be applied to TWR in order to compensate for different gravity of the selected celestial body - double twrFactor = _celestialBodies.GetTwrFactor(stageInfoOab.CelestialBodyForStage[celestialIndex]); - GUILayout.Label(String.Format("{0:N2}", stages[stageIndex].TWRVac * twrFactor), Styles.ValueLabelStyle, GUILayout.Width(65)); - - // Calculate Sea Level TWR and DeltaV - CelestialBodyComponent cel = _celestialBodies.Bodies.Find(b => b.Name == stageInfoOab.CelestialBodyForStage[celestialIndex]).CelestialBodyComponent; - GUILayout.Label(String.Format("{0:N2}", stages[stageIndex].GetTWRAtSeaLevel(cel) * twrFactor), Styles.ValueLabelStyle, GUILayout.Width(75)); - GUILayout.Label(String.Format("{0:N0}", stages[stageIndex].GetDeltaVelAtSeaLevel(cel)), Styles.ValueLabelStyle, GUILayout.Width(75)); - GUILayout.Label("m/s", Styles.UnitLabelStyleStageOAB, GUILayout.Width(30)); - - GUILayout.Label(String.Format("{0:N0}", stages[stageIndex].DeltaVVac), Styles.ValueLabelStyle, GUILayout.Width(75)); - GUILayout.Label("m/s", Styles.UnitLabelStyleStageOAB, GUILayout.Width(30)); - GUILayout.Label(Utility.SecondsToTimeString(stages[stageIndex].StageBurnTime, true, true), Styles.ValueLabelStyle, GUILayout.Width(110)); - GUILayout.Space(20); - GUILayout.BeginVertical(); - GUILayout.FlexibleSpace(); - if (GUILayout.Button(stageInfoOab.CelestialBodyForStage[celestialIndex], Styles.CelestialBodyBtnStyle)) - { - _celestialBodySelectionStageIndex = celestialIndex; - } - GUILayout.EndVertical(); - GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); - } - - GUILayout.Space(Styles.SpacingBelowPopout); - - GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height)); - } - - /// - /// Opens a window for selecting a CelestialObject for the stage on the given index - /// - private void DrawCelestialBodySelection(int id) - { - GUILayout.BeginVertical(); - - foreach (var body in _celestialBodies.Bodies) - { - if (GUILayout.Button(body.DisplayName, Styles.CelestialSelectionBtnStyle)) - { - StageInfo_OAB stageInfoOab = (StageInfo_OAB)MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Stage Info (OAB)"); - stageInfoOab.CelestialBodyForStage[_celestialBodySelectionStageIndex] = body.Name; - - // Hide the selection window - _celestialBodySelectionStageIndex = -1; - } - } - - GUILayout.EndVertical(); - } - - /// - /// Opens a Settings window for OAB - /// - private void DrawSettingsOabWindow(int id) - { - if (CloseButton(Styles.CloseBtnSettingsOABRect)) - _showGuiSettingsOAB = false; - - BaseWindow stageInfoOabWindow = MicroWindows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); - List stageInfoOabEntries = stageInfoOabWindow.Entries; - Torque torqueEntry = (Torque)stageInfoOabEntries.Find(e => e.Name == "Torque"); - - torqueEntry.IsActive = GUILayout.Toggle(torqueEntry.IsActive, "Display Torque (experimental)\nTurn on CoT & CoM for this", Styles.SectionToggleStyle); - } - #endregion - - /// - /// Draws a close button (X) - /// - /// Where to position the close button - /// - private bool CloseButton(Rect rect) - { - return GUI.Button(rect, "X", Styles.CloseBtnStyle); - } - - /// - /// Draws a Settings butoon (≡) - /// - /// - /// - private bool SettingsButton(Rect rect) - { - return GUI.Button(rect, "≡", Styles.SettingsBtnStyle); - } - - #region Window and data initialization - /// - /// Builds the list of all Entries - /// - private void InitializeEntries() - { - MicroEntries = new List(); - - Assembly assembly = Assembly.GetExecutingAssembly(); - Type[] types = assembly.GetTypes(); - - // Exclude base classes - Type[] excludedTypes = new [] { typeof(MicroEntry), typeof(BodyEntry), typeof(FlightEntry), typeof(ManeuverEntry), typeof(MiscEntry), typeof(OabStageInfoEntry), typeof(OrbitalEntry), typeof(StageInfoEntry), typeof(SurfaceEntry), typeof(TargetEntry), typeof(VesselEntry) }; - - Type[] entryTypes = types.Where(t => typeof(MicroEntry).IsAssignableFrom(t) && !excludedTypes.Contains(t)).ToArray(); - - foreach (Type entryType in entryTypes) - { - MicroEntry entry = Activator.CreateInstance(entryType) as MicroEntry; - if (entry != null) - MicroEntries.Add(entry); - } - } - - /// - /// Builds the default Windows and fills them with default Entries - /// - private void InitializeWindows() - { - MicroWindows = new List(); - - try - { - MicroWindows.Add(new BaseWindow - { - Name = "MainGui", - LayoutVersion = Utility.CurrentLayoutVersion, - Abbreviation = null, - Description = "Main GUI", - IsEditorActive = false, - IsFlightActive = false, - IsMapActive = false, - IsEditorPoppedOut = false, // not relevant to Main GUI - IsFlightPoppedOut = false, // not relevant to Main GUI - IsMapPoppedOut = false, // not relevant to Main GUI - IsLocked = false, - MainWindow = MainWindow.MainGui, - //EditorRect = null, - FlightRect = new Rect(Styles.MainGuiX, Styles.MainGuiY, Styles.WindowWidth, Styles.WindowHeight), - Entries = null - }); - - MicroWindows.Add(new BaseWindow - { - Name = "Settings", - Abbreviation = "SET", - Description = "Settings", - IsEditorActive = false, - IsFlightActive = false, - IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.Settings, - //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = null - }); - - MicroWindows.Add(new BaseWindow - { - Name = "Vessel", - Abbreviation = "VES", - Description = "Vessel entries", - IsEditorActive = false, - IsFlightActive = true, - IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.Vessel, - //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Vessel && entry.IsDefault).ToList() - }); - - MicroWindows.Add(new BaseWindow - { - Name = "Orbital", - Abbreviation = "ORB", - Description = "Orbital entries", - IsEditorActive = false, - IsFlightActive = true, - IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.Orbital, - //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Orbital && entry.IsDefault).ToList() - }); - - MicroWindows.Add(new BaseWindow - { - Name = "Surface", - Abbreviation = "SUR", - Description = "Surface entries", - IsEditorActive = false, - IsFlightActive = true, - IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.Surface, - //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Surface && entry.IsDefault).ToList() - }); - - MicroWindows.Add(new BaseWindow - { - Name = "Flight", - Abbreviation = "FLT", - Description = "Flight entries", - IsEditorActive = false, - IsFlightActive = false, - IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.Flight, - //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Flight && entry.IsDefault).ToList() - }); - - MicroWindows.Add(new BaseWindow - { - Name = "Target", - Abbreviation = "TGT", - Description = "Flight entries", - IsEditorActive = false, - IsFlightActive = true, - IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.Target, - //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Target && entry.IsDefault).ToList() - }); - - MicroWindows.Add(new ManeuverWindow - { - Name = "Maneuver", - Abbreviation = "MAN", - Description = "Maneuver entries", - WindowType = typeof(ManeuverWindow), - IsEditorActive = false, - IsFlightActive = true, - IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.Maneuver, - //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Maneuver && entry.IsDefault).ToList() - }); - - MicroWindows.Add(new BaseWindow - { - Name = "Stage", - Abbreviation = "STG", - Description = "Stage entries", - IsEditorActive = false, - IsFlightActive = true, - IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.Stage, - //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.Stage && entry.IsDefault).ToList() - }); - - InitializeStageInfoOABWindow(); - } - catch (Exception ex) - { - Logger.LogError("Error creating a BaseWindow. Full exception: " + ex); - } - } - - private void InitializeStageInfoOABWindow() - { - MicroWindows.Add(new BaseWindow - { - Name = "Stage (OAB)", - Abbreviation = "SOAB", - Description = "Stage Info window for OAB", - IsEditorActive = false, - IsFlightActive = false, // Not used - IsMapActive = false, // Not used - IsEditorPoppedOut = true, // Not used - IsFlightPoppedOut = false, // Not used - IsMapPoppedOut = false, // Not used - IsLocked = false, // Not used - MainWindow = MainWindow.StageInfoOAB, - EditorRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, 0, 0), - Entries = Enumerable.Where(MicroEntries, entry => entry.Category == MicroEntryCategory.OAB && entry.IsDefault).ToList() - }); - } - - private void InitializeCelestialBodies() - { - if (_celestialBodies.Bodies.Count > 0) - return; - - _celestialBodies.GetBodies(); + _ui?.OnGUI(); } - #endregion } } \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Styles.cs b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs similarity index 100% rename from MicroEngineerProject/MicroEngineer/Styles.cs rename to MicroEngineerProject/MicroEngineer/Utilities/Styles.cs diff --git a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs index 0658f76..f5b5a6f 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs @@ -59,7 +59,7 @@ internal class BaseWindow [JsonProperty] internal Rect FlightRect; [JsonProperty] - internal List Entries; + internal List Entries; /// /// Moves entry upwards in the window. Does nothing if it's already first. @@ -105,14 +105,14 @@ internal void RemoveEntry(int entryIndex) /// Adds an entry to the window to the last position /// /// - internal void AddEntry(MicroEntry entry) => Entries.Add(entry); + internal void AddEntry(BaseEntry entry) => Entries.Add(entry); /// /// Grabs new data for each entry in the window /// internal void RefreshEntryData() { - foreach (MicroEntry entry in Entries) + foreach (BaseEntry entry in Entries) entry.RefreshData(); } @@ -125,7 +125,7 @@ internal virtual void RefreshData() if (Entries == null || Entries.Count == 0) return; - foreach (MicroEntry entry in Entries) + foreach (BaseEntry entry in Entries) entry.RefreshData(); } } From 1cfbeb4544224e4a9225e08ba5a707b26b11450c Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sun, 23 Apr 2023 14:01:33 +0200 Subject: [PATCH 29/38] Add Themes, refactor windows - Add Themes functionality -> munix, Gray and Black themes - Add textures for newly added themes ..\assets\images\x.png - New Settings window that is always drawn popped out - Settings window: edit windows, save-load-reset layout, theme selection - Add Settings button with a new texture, button drawn on the top-left of MainGuiWindow ..\assets\images\settings-30.png - Move entry windows to new EntryWindow class (inherits from BaseWindow) - Move MainGui window to new MainGuiWindow class (inherits from BaseWindow) - Move Settings window to new SettingsWindow class (inherits from BaseWindow) - Locked transparency 80% -> 20% --- .../MicroEngineer/Managers/Manager.cs | 52 ++-- .../MicroEngineer/Managers/MessageManager.cs | 10 +- .../MicroEngineer/Managers/UI.cs | 240 +++++++++++------- .../MicroEngineer/MicroEngineerMod.cs | 6 +- .../MicroEngineer/Utilities/Styles.cs | 198 ++++++++++++++- .../MicroEngineer/Utilities/Utility.cs | 10 +- .../MicroEngineer/Windows/BaseWindow.cs | 106 +------- .../MicroEngineer/Windows/EntryWindow.cs | 109 ++++++++ .../MicroEngineer/Windows/MainGuiWindow.cs | 10 + .../MicroEngineer/Windows/ManeuverWindow.cs | 2 +- .../MicroEngineer/Windows/SettingsWIndow.cs | 16 ++ .../Other/MicroEngineer_BackgroundStyles.psd | Bin 0 -> 35924 bytes .../assets/images/background_black_first.png | Bin 0 -> 438 bytes .../assets/images/background_black_last.png | Bin 0 -> 414 bytes .../assets/images/background_black_middle.png | Bin 0 -> 174 bytes .../images/background_darkgray_first.png | Bin 0 -> 428 bytes .../images/background_darkgray_last.png | Bin 0 -> 406 bytes .../images/background_darkgray_middle.png | Bin 0 -> 170 bytes .../assets/images/background_white_first.png | Bin 0 -> 461 bytes .../assets/images/background_white_last.png | Bin 0 -> 430 bytes .../assets/images/background_white_middle.png | Bin 0 -> 174 bytes .../assets/images/settings-30.png | Bin 0 -> 559 bytes 22 files changed, 494 insertions(+), 265 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Windows/EntryWindow.cs create mode 100644 MicroEngineerProject/MicroEngineer/Windows/MainGuiWindow.cs create mode 100644 MicroEngineerProject/MicroEngineer/Windows/SettingsWIndow.cs create mode 100644 MicroEngineerProject/Other/MicroEngineer_BackgroundStyles.psd create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/background_black_first.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/background_black_last.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/background_black_middle.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/background_darkgray_first.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/background_darkgray_last.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/background_darkgray_middle.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/background_white_first.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/background_white_last.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/background_white_middle.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/settings-30.png diff --git a/MicroEngineerProject/MicroEngineer/Managers/Manager.cs b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs index 14ad7ec..2e64b99 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/Manager.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs @@ -1,10 +1,6 @@ using BepInEx.Logging; using KSP.Game; -using MicroMod; -using System; -using System.Collections.Generic; using System.Reflection; -using System.Text; using UnityEngine; namespace MicroMod @@ -40,7 +36,7 @@ public void Update() return; // Refresh all active windows' entries - foreach (BaseWindow window in Windows.Where(w => w.IsFlightActive)) + foreach (EntryWindow window in Windows.Where(w => w.IsFlightActive && w is EntryWindow)) window.RefreshData(); } } @@ -81,44 +77,27 @@ internal List InitializeWindows() try { - Windows.Add(new BaseWindow + Windows.Add(new MainGuiWindow { - Name = "MainGui", LayoutVersion = Utility.CurrentLayoutVersion, - Abbreviation = null, - Description = "Main GUI", IsEditorActive = false, IsFlightActive = false, IsMapActive = false, - IsEditorPoppedOut = false, // not relevant to Main GUI - IsFlightPoppedOut = false, // not relevant to Main GUI - IsMapPoppedOut = false, // not relevant to Main GUI - IsLocked = false, - MainWindow = MainWindow.MainGui, //EditorRect = null, FlightRect = new Rect(Styles.MainGuiX, Styles.MainGuiY, Styles.WindowWidth, Styles.WindowHeight), - Entries = null }); - Windows.Add(new BaseWindow + Windows.Add(new SettingsWIndow { - Name = "Settings", - Abbreviation = "SET", - Description = "Settings", + ActiveTheme = Styles.ActiveTheme, IsEditorActive = false, IsFlightActive = false, IsMapActive = false, - IsEditorPoppedOut = false, - IsFlightPoppedOut = false, - IsMapPoppedOut = false, - IsLocked = false, - MainWindow = MainWindow.Settings, //EditorRect = null, - FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight), - Entries = null + FlightRect = new Rect(Styles.PoppedOutX, Styles.PoppedOutY, Styles.WindowWidth, Styles.WindowHeight) }); - Windows.Add(new BaseWindow + Windows.Add(new EntryWindow { Name = "Vessel", Abbreviation = "VES", @@ -136,7 +115,7 @@ internal List InitializeWindows() Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Vessel && entry.IsDefault).ToList() }); - Windows.Add(new BaseWindow + Windows.Add(new EntryWindow { Name = "Orbital", Abbreviation = "ORB", @@ -154,7 +133,7 @@ internal List InitializeWindows() Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Orbital && entry.IsDefault).ToList() }); - Windows.Add(new BaseWindow + Windows.Add(new EntryWindow { Name = "Surface", Abbreviation = "SUR", @@ -172,7 +151,7 @@ internal List InitializeWindows() Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Surface && entry.IsDefault).ToList() }); - Windows.Add(new BaseWindow + Windows.Add(new EntryWindow { Name = "Flight", Abbreviation = "FLT", @@ -190,7 +169,7 @@ internal List InitializeWindows() Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Flight && entry.IsDefault).ToList() }); - Windows.Add(new BaseWindow + Windows.Add(new EntryWindow { Name = "Target", Abbreviation = "TGT", @@ -213,7 +192,6 @@ internal List InitializeWindows() Name = "Maneuver", Abbreviation = "MAN", Description = "Maneuver entries", - WindowType = typeof(ManeuverWindow), IsEditorActive = false, IsFlightActive = true, IsMapActive = false, @@ -227,7 +205,7 @@ internal List InitializeWindows() Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Maneuver && entry.IsDefault).ToList() }); - Windows.Add(new BaseWindow + Windows.Add(new EntryWindow { Name = "Stage", Abbreviation = "STG", @@ -245,7 +223,7 @@ internal List InitializeWindows() Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Stage && entry.IsDefault).ToList() }); - Windows.Add(new BaseWindow + Windows.Add(new EntryWindow { Name = "Stage (OAB)", Abbreviation = "SOAB", @@ -275,17 +253,17 @@ internal List InitializeWindows() /// Creates a new custom window user can fill with any entry /// /// - internal int CreateCustomWindow(List editableWindows) + internal int CreateCustomWindow(List editableWindows) { // Default window's name will be CustomX where X represents the first not used integer int nameID = 1; - foreach (BaseWindow window in editableWindows) + foreach (EntryWindow window in editableWindows) { if (window.Name == "Custom" + nameID) nameID++; } - BaseWindow newWindow = new() + EntryWindow newWindow = new() { Name = "Custom" + nameID, Abbreviation = nameID.ToString().Length == 1 ? "Cu" + nameID : nameID.ToString().Length == 2 ? "C" + nameID : nameID.ToString(), diff --git a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs index a9362c9..08fea3f 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs @@ -63,7 +63,9 @@ private void OnManeuverRemovedMessage(MessageCenterMessage message) private void OnPartManipulationCompletedMessage(MessageCenterMessage obj) { - Torque torque = (Torque)_windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Torque"); + EntryWindow stageInfoOabWindow = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); + + Torque torque = (Torque)_windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Torque"); torque.RefreshData(); } @@ -78,11 +80,11 @@ private void GameStateEntered(MessageCenterMessage obj) _manager.Windows = _windows; if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) - _ui.ShowGuiFlight = _windows.Find(w => w.MainWindow == MainWindow.MainGui).IsFlightActive; + _ui.ShowGuiFlight = _windows.OfType().FirstOrDefault().IsFlightActive; if (Utility.GameState.GameState == GameState.VehicleAssemblyBuilder) { - _ui.ShowGuiOAB = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive; + _ui.ShowGuiOAB = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive; _ui.CelestialBodies.GetBodies(); _ui.CelestialBodySelectionStageIndex = -1; } @@ -120,7 +122,7 @@ private void RefreshStagingDataOAB(MessageCenterMessage obj) Utility.RefreshStagesOAB(); - BaseWindow stageWindow = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + EntryWindow stageWindow = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); if (Utility.VesselDeltaVComponentOAB?.StageInfo == null) { diff --git a/MicroEngineerProject/MicroEngineer/Managers/UI.cs b/MicroEngineerProject/MicroEngineer/Managers/UI.cs index 5777a61..d110ec5 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/UI.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/UI.cs @@ -18,6 +18,7 @@ internal class UI internal bool ShowGuiFlight; internal bool ShowGuiOAB; + private bool _showGuiSettingsFlight; // If game input is enabled or disabled (used for locking controls when user is editing a text field private bool _gameInputState = true; @@ -33,6 +34,8 @@ internal class UI internal int CelestialBodySelectionStageIndex = -1; private bool _showGuiSettingsOAB; + Rect settingsFlightRect; + /// /// Holds data on all bodies for calculating TWR (currently) /// @@ -62,7 +65,7 @@ private void OnGUI_Flight() if (!ShowGuiFlight || Utility.ActiveVessel == null) return; - BaseWindow mainGui = _windows.Find(window => window.MainWindow == MainWindow.MainGui); + MainGuiWindow mainGui = (MainGuiWindow)_windows.Find(w => w is MainGuiWindow); // window => window.MainWindow == MainWindow.MainGui); // Draw main GUI that contains docked windows mainGui.FlightRect = GUILayout.Window( @@ -75,11 +78,13 @@ private void OnGUI_Flight() ); mainGui.FlightRect.position = Utility.ClampToScreen(mainGui.FlightRect.position, mainGui.FlightRect.size); + List entryWindows = _windows.FindAll(w => w is EntryWindow).Cast().ToList(); + // Draw all other popped out windows - foreach (var (window, index) in _windows + foreach (var (window, index) in entryWindows .Select((window, index) => (window, index)) .Where(x => x.window.IsFlightActive && x.window.IsFlightPoppedOut) // must be active & popped out - .Where(x => x.window.MainWindow != MainWindow.Settings && x.window.MainWindow != MainWindow.Stage && x.window.MainWindow != MainWindow.MainGui)) // MainGUI, Settings and Stage are special, they'll be drawn separately + .Where(x => x.window.MainWindow != MainWindow.Stage)) // Stage is special, it'll be drawn separately { // Skip drawing of Target window if there's no active target if (window.MainWindow == MainWindow.Target && !Utility.TargetExists()) @@ -89,9 +94,9 @@ private void OnGUI_Flight() if (window.MainWindow == MainWindow.Maneuver && !Utility.ManeuverExists()) continue; - // If window is locked set alpha to 80% + // If window is locked set alpha to 20% if (window.IsLocked) - GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.8f); + GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.2f); window.FlightRect = GUILayout.Window( index, @@ -110,30 +115,13 @@ private void OnGUI_Flight() window.FlightRect.position = Utility.ClampToScreen(window.FlightRect.position, window.FlightRect.size); } - // Draw popped out Settings - int settingsIndex = _windows.FindIndex(window => window.MainWindow == MainWindow.Settings); - if (_windows[settingsIndex].IsFlightActive && _windows[settingsIndex].IsFlightPoppedOut) - { - _windows[settingsIndex].FlightRect = GUILayout.Window( - settingsIndex, - _windows[settingsIndex].FlightRect, - DrawSettingsWindow, - "", - Styles.PopoutWindowStyle, - GUILayout.Height(0), - GUILayout.Width(Styles.WindowWidth) - ); - - _windows[settingsIndex].FlightRect.position = Utility.ClampToScreen(_windows[settingsIndex].FlightRect.position, _windows[settingsIndex].FlightRect.size); - } - // Draw popped out Stages - int stageIndex = _windows.FindIndex(window => window.MainWindow == MainWindow.Stage); - if (_windows[stageIndex].IsFlightActive && _windows[stageIndex].IsFlightPoppedOut) + int stageIndex = entryWindows.FindIndex(window => window.MainWindow == MainWindow.Stage); + if (entryWindows[stageIndex].IsFlightActive && entryWindows[stageIndex].IsFlightPoppedOut) { - _windows[stageIndex].FlightRect = GUILayout.Window( + entryWindows[stageIndex].FlightRect = GUILayout.Window( stageIndex, - _windows[stageIndex].FlightRect, + entryWindows[stageIndex].FlightRect, DrawStages, "", Styles.PopoutWindowStyle, @@ -141,7 +129,7 @@ private void OnGUI_Flight() GUILayout.Width(Styles.WindowWidth) ); - _windows[stageIndex].FlightRect.position = Utility.ClampToScreen(_windows[stageIndex].FlightRect.position, _windows[stageIndex].FlightRect.size); + entryWindows[stageIndex].FlightRect.position = Utility.ClampToScreen(entryWindows[stageIndex].FlightRect.position, entryWindows[stageIndex].FlightRect.size); } // Draw Edit Window @@ -156,13 +144,84 @@ private void OnGUI_Flight() GUILayout.Height(0) ); } + + // Draw Settings window in Flight + if (_showGuiSettingsFlight) + { + settingsFlightRect = GUILayout.Window( + GUIUtility.GetControlID(FocusType.Passive), + settingsFlightRect, + DrawSettingsFlightWindow, + "", + Styles.SettingsFlightStyle, + GUILayout.Height(0) + ); + } + } + + private void DrawSettingsFlightWindow(int id) + { + if (CloseButton(Styles.CloseBtnRect)) + _showGuiSettingsFlight = false; + + GUILayout.Label("// SETTINGS"); + + GUILayout.Space(10); + GUILayout.Label("Edit window entries"); + if (GUILayout.Button("EDIT WINDOWS", Styles.NormalBtnStyle)) + _showEditWindow = !_showEditWindow; + + GUILayout.Space(10); + GUILayout.Label("Layout control"); + if (GUILayout.Button("SAVE LAYOUT", Styles.NormalBtnStyle)) + Utility.SaveLayout(_windows); + GUILayout.Space(5); + if (GUILayout.Button("LOAD LAYOUT", Styles.NormalBtnStyle)) + { + Utility.LoadLayout(_windows); + _manager.Windows = _windows; + } + if (GUILayout.Button("RESET LAYOUT", Styles.NormalBtnStyle)) + ResetLayout(); + + GUILayout.Space(10); + GUILayout.Label("Theme"); + GUILayout.Space(-10); + + GUILayout.BeginHorizontal(); + var settingsWindow = _windows.Find(w => w.GetType() == typeof(SettingsWIndow)) as SettingsWIndow; + if (GUILayout.Toggle(Styles.ActiveTheme == Theme.munix, "munix", Styles.SectionToggleStyle)) + { + Styles.SetActiveTheme(Theme.munix); + settingsWindow.ActiveTheme = Theme.munix; + } + GUILayout.FlexibleSpace(); + if (GUILayout.Toggle(Styles.ActiveTheme == Theme.Gray, "Gray", Styles.SectionToggleStyle)) + { + Styles.SetActiveTheme(Theme.Gray); + settingsWindow.ActiveTheme = Theme.Gray; + } + GUILayout.FlexibleSpace(); + if (GUILayout.Toggle(Styles.ActiveTheme == Theme.Black, "Black", Styles.SectionToggleStyle)) + { + Styles.SetActiveTheme(Theme.Black); + settingsWindow.ActiveTheme = Theme.Black; + } + GUILayout.EndHorizontal(); + + GUILayout.Space(10); + GUILayout.Label("Other"); + GUILayout.Space(-10); + GUILayout.Toggle(true, "use large units for large values", Styles.SectionToggleStyle); + + GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height)); } private void OnGUI_OAB() { if (!ShowGuiOAB) return; - BaseWindow stageInfoOAB = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + EntryWindow stageInfoOAB = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); if (stageInfoOAB.Entries.Find(e => e.Name == "Stage Info (OAB)").EntryValue == null) return; stageInfoOAB.EditorRect = GUILayout.Window( @@ -180,7 +239,7 @@ private void OnGUI_OAB() // any other int -> index represents the stage number for which the selection was clicked if (CelestialBodySelectionStageIndex > -1) { - Rect stageInfoOabRect = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).EditorRect; + Rect stageInfoOabRect = stageInfoOAB.EditorRect; Rect celestialBodyRect = new Rect(stageInfoOabRect.x + stageInfoOabRect.width, stageInfoOabRect.y, 0, 0); celestialBodyRect = GUILayout.Window( @@ -196,7 +255,7 @@ private void OnGUI_OAB() // Draw Settings window for the StageInfoOAB if (_showGuiSettingsOAB) { - Rect stageInfoOabRect = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).EditorRect; + Rect stageInfoOabRect = stageInfoOAB.EditorRect; Rect settingsRect = new Rect(stageInfoOabRect.x + stageInfoOabRect.width, stageInfoOabRect.y, 0, 0); settingsRect = GUILayout.Window( @@ -217,6 +276,15 @@ private void OnGUI_OAB() /// private void FillMainGUI(int windowID) { + List entryWindows = _windows.FindAll(w => w is EntryWindow).Cast().ToList(); + + if (SettingsButtonOnMainGui(Styles.SettingsMainBtnBtnRect)) + { + Rect mainGuiRect = _windows.OfType().FirstOrDefault().FlightRect; + settingsFlightRect = new Rect(mainGuiRect.x - Styles.WindowWidthSettingsFlight, mainGuiRect.y, Styles.WindowWidthSettingsFlight, 0); + _showGuiSettingsFlight = !_showGuiSettingsFlight; + } + try { if (CloseButton(Styles.CloseBtnRect)) @@ -230,7 +298,7 @@ private void FillMainGUI(int windowID) int toggleIndex = -1; // Draw toggles for all windows except MainGui and StageInfoOAB - foreach (BaseWindow window in _windows.Where(x => x.MainWindow != MainWindow.MainGui && x.MainWindow != MainWindow.StageInfoOAB)) + foreach (EntryWindow window in entryWindows.Where(x => x.MainWindow != MainWindow.MainGui && x.MainWindow != MainWindow.StageInfoOAB)) { // layout can fit 6 toggles, so if all 6 slots are filled then go to a new line. Index == 0 is the MainGUI which isn't rendered if (++toggleIndex % 6 == 0 && toggleIndex > 0) @@ -243,21 +311,16 @@ private void FillMainGUI(int windowID) GUILayout.EndHorizontal(); GUILayout.Space(5); - // Draw Settings window first - int settingsIndex = _windows.FindIndex(window => window.MainWindow == MainWindow.Settings); - if (_windows[settingsIndex].IsFlightActive && !_windows[settingsIndex].IsFlightPoppedOut) - DrawSettingsWindow(settingsIndex); - // Draw Stage window next - int stageIndex = _windows.FindIndex(window => window.MainWindow == MainWindow.Stage); - if (_windows[stageIndex].IsFlightActive && !_windows[stageIndex].IsFlightPoppedOut) + int stageIndex = entryWindows.FindIndex(window => window.MainWindow == MainWindow.Stage); + if (entryWindows[stageIndex].IsFlightActive && !entryWindows[stageIndex].IsFlightPoppedOut) DrawStages(stageIndex); // Draw all other windows - foreach (var (window, index) in _windows + foreach (var (window, index) in entryWindows .Select((window, index) => (window, index)) .Where(x => x.window.IsFlightActive && !x.window.IsFlightPoppedOut) // must be active & docked - .Where(x => x.window.MainWindow != MainWindow.Settings && x.window.MainWindow != MainWindow.Stage && x.window.MainWindow != MainWindow.MainGui)) // MainGUI, Settings and Stage are special, they'll be drawn separately + .Where(x => x.window.MainWindow != MainWindow.Stage)) // Stage is special, it'll be drawn separately { // Skip drawing of Target window if there's no active target @@ -271,12 +334,14 @@ private void FillMainGUI(int windowID) DrawSectionHeader(window.Name, ref window.IsFlightPoppedOut, window.IsLocked, ""); window.DrawWindowHeader(); + GUILayout.Space(10); - foreach (BaseEntry entry in window.Entries) + for (int i = 0; i < window.Entries.Count; i++) { - if (entry.HideWhenNoData && entry.ValueDisplay == "-") + if (window.Entries[i].HideWhenNoData && window.Entries[i].ValueDisplay == "-") continue; - DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); + GUIStyle s = i == 0 ? Styles.EntryBackground_First : i < window.Entries.Count - 1 ? Styles.EntryBackground_Middle : Styles.EntryBackground_Last; + DrawEntry(s, window.Entries[i].Name, window.Entries[i].ValueDisplay, window.Entries[i].Unit); } @@ -299,59 +364,31 @@ private void FillMainGUI(int windowID) /// private void DrawPopoutWindow(int windowIndex) { - BaseWindow windowToDraw = _windows[windowIndex]; + List entryWindows = _windows.FindAll(w => w is EntryWindow).Cast().ToList(); + EntryWindow w = _windows.FindAll(w => w is EntryWindow).Cast().ToList()[windowIndex]; - DrawSectionHeader(windowToDraw.Name, ref windowToDraw.IsFlightPoppedOut, windowToDraw.IsLocked, ""); + DrawSectionHeader(w.Name, ref w.IsFlightPoppedOut, w.IsLocked, ""); - windowToDraw.DrawWindowHeader(); + w.DrawWindowHeader(); + GUILayout.Space(10); - foreach (BaseEntry entry in windowToDraw.Entries) + for (int i = 0; i < w.Entries.Count; i++) + //foreach (BaseEntry entry in w.Entries) { - if (entry.HideWhenNoData && entry.ValueDisplay == "-") + if (w.Entries[i].HideWhenNoData && w.Entries[i].ValueDisplay == "-") continue; - DrawEntry(entry.Name, entry.ValueDisplay, entry.Unit); - } - - windowToDraw.DrawWindowFooter(); - - DrawSectionEnd(windowToDraw); - } - - private void DrawSettingsWindow(int windowIndex) - { - BaseWindow windowToDraw = _windows[windowIndex]; - - DrawSectionHeader(windowToDraw.Name, ref windowToDraw.IsFlightPoppedOut, windowToDraw.IsLocked, ""); - - GUILayout.Space(10); - GUILayout.BeginHorizontal(); - if (GUILayout.Button("SAVE LAYOUT", Styles.NormalBtnStyle)) - Utility.SaveLayout(_windows); - GUILayout.Space(5); - if (GUILayout.Button("LOAD LAYOUT", Styles.NormalBtnStyle)) - { - Utility.LoadLayout(_windows); - _manager.Windows = _windows; + GUIStyle s = i == 0 ? Styles.EntryBackground_First : i < w.Entries.Count - 1 ? Styles.EntryBackground_Middle : Styles.EntryBackground_Last; + DrawEntry(s, w.Entries[i].Name, w.Entries[i].ValueDisplay, w.Entries[i].Unit); } - - GUILayout.Space(5); - if (GUILayout.Button("RESET", Styles.NormalBtnStyle)) - ResetLayout(); - GUILayout.EndHorizontal(); - GUILayout.BeginHorizontal(); - if (GUILayout.Button("Edit Windows", Styles.NormalBtnStyle)) - { - _showEditWindow = !_showEditWindow; - } - GUILayout.EndHorizontal(); + w.DrawWindowFooter(); - DrawSectionEnd(windowToDraw); + DrawSectionEnd(w); } private void DrawStages(int windowIndex) { - BaseWindow windowToDraw = _windows[windowIndex]; + EntryWindow windowToDraw = _windows.FindAll(w => w is EntryWindow).Cast().ToList()[windowIndex]; DrawStagesHeader(windowToDraw); @@ -404,7 +441,7 @@ private void DrawSectionHeader(string sectionName, ref bool isPopout, bool isLoc GUILayout.Space(Styles.SpacingAfterHeader); } - private void DrawStagesHeader(BaseWindow stageWindow) + private void DrawStagesHeader(EntryWindow stageWindow) { GUILayout.BeginHorizontal(); stageWindow.IsFlightPoppedOut = stageWindow.IsFlightPoppedOut ? !CloseButton(Styles.CloseBtnRect) : GUILayout.Button("⇖", Styles.PopoutBtnStyle); @@ -427,9 +464,9 @@ private void DrawStagesHeader(BaseWindow stageWindow) GUILayout.Space(Styles.SpacingAfterHeader); } - private void DrawEntry(string entryName, string value, string unit = "") + private void DrawEntry(GUIStyle horizontalStyle, string entryName, string value, string unit = "") { - GUILayout.BeginHorizontal(); + GUILayout.BeginHorizontal(horizontalStyle); GUILayout.Label(entryName, Styles.NameLabelStyle); GUILayout.FlexibleSpace(); GUILayout.Label(value, Styles.ValueLabelStyle); @@ -466,7 +503,7 @@ private void DrawStageEntry(int stageID, DeltaVStageInfo stageInfo, string twrFo GUILayout.Space(Styles.SpacingAfterEntry); } - private void DrawSectionEnd(BaseWindow window) + private void DrawSectionEnd(EntryWindow window) { if (window.IsFlightPoppedOut) { @@ -487,7 +524,7 @@ private void DrawSectionEnd(BaseWindow window) /// private void DrawEditWindow(int windowIndex) { - List editableWindows = _windows.FindAll(w => w.IsEditable); // Editable windows are all except MainGUI, Settings, Stage and StageInfoOAB + List editableWindows = _windows.FindAll(w => w is EntryWindow).Cast().ToList().FindAll(w => w.IsEditable); // Editable windows are all except MainGUI, Settings, Stage and StageInfoOAB List entriesByCategory = _manager.Entries.FindAll(e => e.Category == _selectedCategory); // All window stageInfoOabEntries belong to a category, but they can still be placed in any window _showEditWindow = !CloseButton(Styles.CloseBtnRect); @@ -496,7 +533,7 @@ private void DrawEditWindow(int windowIndex) GUILayout.BeginHorizontal(); GUILayout.Label("EDITING WINDOW", Styles.TitleLabelStyle); GUILayout.FlexibleSpace(); - if (GUILayout.Button("<", Styles.OneCharacterBtnStyle)) + if (GUILayout.Button("<", Styles.OneCharacterHighBtnStyle)) { _selectedWindowId = _selectedWindowId > 0 ? _selectedWindowId - 1 : editableWindows.Count - 1; } @@ -505,7 +542,7 @@ private void DrawEditWindow(int windowIndex) editableWindows[_selectedWindowId].Abbreviation = Utility.ValidateAbbreviation(editableWindows[_selectedWindowId].Abbreviation); GUI.SetNextControlName(Utility.InputDisableWindowName); editableWindows[_selectedWindowId].Name = GUILayout.TextField(editableWindows[_selectedWindowId].Name, Styles.WindowSelectionTextFieldStyle); - if (GUILayout.Button(">", Styles.OneCharacterBtnStyle)) + if (GUILayout.Button(">", Styles.OneCharacterHighBtnStyle)) { _selectedWindowId = _selectedWindowId < editableWindows.Count - 1 ? _selectedWindowId + 1 : 0; } @@ -559,10 +596,11 @@ private void DrawEditWindow(int windowIndex) if (GUILayout.Button("X", Styles.OneCharacterBtnStyle)) editableWindows[_selectedWindowId].RemoveEntry(index); GUILayout.EndHorizontal(); + GUILayout.Space(Styles.SpacingAfterEntry); } #endregion - GUILayout.Space(10); + GUILayout.Space(20); Styles.DrawHorizontalLine(); GUILayout.Space(10); @@ -575,14 +613,14 @@ private void DrawEditWindow(int windowIndex) GUILayout.Label("Category", Styles.NormalLabelStyle); GUILayout.FlexibleSpace(); - if (GUILayout.Button("<", Styles.OneCharacterBtnStyle)) + if (GUILayout.Button("<", Styles.OneCharacterHighBtnStyle)) { _selectedCategory = (int)_selectedCategory > 0 ? _selectedCategory - 1 : Enum.GetValues(typeof(MicroEntryCategory)).Cast().Last(); } GUILayout.Label(_selectedCategory.ToString(), Styles.NormalCenteredLabelStyle); - if (GUILayout.Button(">", Styles.OneCharacterBtnStyle)) + if (GUILayout.Button(">", Styles.OneCharacterHighBtnStyle)) { _selectedCategory = (int)_selectedCategory < (int)Enum.GetValues(typeof(MicroEntryCategory)).Cast().Last() ? _selectedCategory + 1 : @@ -618,7 +656,9 @@ private void DrawEditWindow(int windowIndex) GUILayout.Label(entry.Description, Styles.BlueLabelStyle); GUILayout.EndHorizontal(); } + GUILayout.Space(Styles.SpacingAfterEntry); } + GUILayout.Space(10); #endregion GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); @@ -630,7 +670,7 @@ private void DrawEditWindow(int windowIndex) private void DrawStageInfoOAB(int windowID) { - BaseWindow stageInfoOabWindow = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + EntryWindow stageInfoOabWindow = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); List stageInfoOabEntries = stageInfoOabWindow.Entries; GUILayout.BeginHorizontal(); @@ -743,7 +783,7 @@ private void DrawCelestialBodySelection(int id) { if (GUILayout.Button(body.DisplayName, Styles.CelestialSelectionBtnStyle)) { - StageInfo_OAB stageInfoOab = (StageInfo_OAB)_windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Stage Info (OAB)"); + StageInfo_OAB stageInfoOab = (StageInfo_OAB)_windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Stage Info (OAB)"); stageInfoOab.CelestialBodyForStage[CelestialBodySelectionStageIndex] = body.Name; // Hide the selection window @@ -762,11 +802,12 @@ private void DrawSettingsOabWindow(int id) if (CloseButton(Styles.CloseBtnSettingsOABRect)) _showGuiSettingsOAB = false; - BaseWindow stageInfoOabWindow = _windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB); + EntryWindow stageInfoOabWindow = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); List stageInfoOabEntries = stageInfoOabWindow.Entries; Torque torqueEntry = (Torque)stageInfoOabEntries.Find(e => e.Name == "Torque"); torqueEntry.IsActive = GUILayout.Toggle(torqueEntry.IsActive, "Display Torque (experimental)\nTurn on CoT & CoM for this", Styles.SectionToggleStyle); + GUILayout.Space(15); } /// @@ -802,5 +843,10 @@ private bool CloseButton(Rect rect) { return GUI.Button(rect, "X", Styles.CloseBtnStyle); } + + private bool SettingsButtonOnMainGui(Rect rect) + { + return GUI.Button(rect, Styles.SettingsIcon, Styles.SettingsMainGuiBtnStyle); + } } } \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index da90013..4fdd744 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -18,7 +18,7 @@ public class MicroEngineerMod : BaseSpaceWarpPlugin public override void OnInitialized() { - Styles.InitializeStyles(); + Styles.Initialize(this); _manager = new Manager(this); _ui = new UI(this, _manager); @@ -34,7 +34,7 @@ public override void OnInitialized() isOpen => { _ui.ShowGuiFlight = isOpen; - _manager.Windows.Find(w => w.MainWindow == MainWindow.MainGui).IsFlightActive = isOpen; + _manager.Windows.Find(w => w.GetType() == typeof(MainGuiWindow)).IsFlightActive = isOpen; GameObject.Find("BTN-MicroEngineerBtn")?.GetComponent()?.SetValue(isOpen); }); @@ -45,7 +45,7 @@ public override void OnInitialized() isOpen => { _ui.ShowGuiOAB = isOpen; - _manager.Windows.Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive = isOpen; + _manager.Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive = isOpen; GameObject.Find("BTN - MicroEngineerOAB")?.GetComponent()?.SetValue(isOpen); }); } diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs index 0914658..aa25c3f 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs @@ -1,14 +1,21 @@ -using SpaceWarp.API.UI; +using SpaceWarp.API.Assets; +using SpaceWarp.API.UI; using UnityEngine; namespace MicroMod { + // MARGIN: how much the element is offset from other elements + // PADDING: how much the text inside the element is offset from the default alignment + public static class Styles { + private static MicroEngineerMod _plugin; + public static int WindowWidth = 290; public static int WindowHeight = 1440; public static int WindowWidthStageOAB = 645; public static int WindowWidthSettingsOAB = 300; + public static int WindowWidthSettingsFlight = WindowWidth; public static GUISkin SpaceWarpUISkin; public static GUIStyle MainWindowStyle; @@ -18,8 +25,10 @@ public static class Styles public static GUIStyle CelestialSelectionStyle; public static GUIStyle SettingsOabStyle; + public static GUIStyle SettingsFlightStyle; public static GUIStyle PopoutBtnStyle; public static GUIStyle SectionToggleStyle; + public static GUIStyle NameLabelStyle; public static GUIStyle ValueLabelStyle; public static GUIStyle BlueLabelStyle; @@ -28,26 +37,42 @@ public static class Styles public static GUIStyle NormalLabelStyle; public static GUIStyle TitleLabelStyle; public static GUIStyle NormalCenteredLabelStyle; + public static GUIStyle WindowSelectionTextFieldStyle; public static GUIStyle WindowSelectionAbbrevitionTextFieldStyle; public static GUIStyle CloseBtnStyle; public static GUIStyle SettingsBtnStyle; + public static GUIStyle SettingsMainGuiBtnStyle; public static GUIStyle CloseBtnStageOABStyle; public static GUIStyle NormalBtnStyle; public static GUIStyle CelestialBodyBtnStyle; public static GUIStyle CelestialSelectionBtnStyle; public static GUIStyle OneCharacterBtnStyle; + public static GUIStyle OneCharacterHighBtnStyle; public static GUIStyle TableHeaderLabelStyle; public static GUIStyle TableHeaderCenteredLabelStyle; - public static string UnitColorHex { get => ColorUtility.ToHtmlStringRGBA(UnitLabelStyle.normal.textColor); } + public static GUIStyle EntryBackground_WhiteTheme_First; + public static GUIStyle EntryBackground_WhiteTheme_Middle; + public static GUIStyle EntryBackground_WhiteTheme_Last; + public static GUIStyle EntryBackground_GrayTheme_First; + public static GUIStyle EntryBackground_GrayTheme_Middle; + public static GUIStyle EntryBackground_GrayTheme_Last; + public static GUIStyle EntryBackground_BlackTheme_First; + public static GUIStyle EntryBackground_BlackTheme_Middle; + public static GUIStyle EntryBackground_BlackTheme_Last; + public static GUIStyle EntryBackground_First; + public static GUIStyle EntryBackground_Middle; + public static GUIStyle EntryBackground_Last; + + public static string UnitColorHex { get => ColorUtility.ToHtmlStringRGBA(_unitColor); } public static int SpacingAfterHeader = -12; public static int SpacingAfterEntry = -12; - public static int SpacingAfterSection = 5; - public static float SpacingBelowPopout = 10; + public static int SpacingAfterSection = 10; + public static float SpacingBelowPopout = 15; public static float PoppedOutX = Screen.width * 0.6f; public static float PoppedOutY = Screen.height * 0.2f; @@ -55,12 +80,48 @@ public static class Styles public static float MainGuiY = Screen.height * 0.2f; public static Rect CloseBtnRect = new Rect(Styles.WindowWidth - 23, 6, 16, 16); + public static Rect SettingsMainBtnBtnRect = new Rect(6, 6, 30, 20); + public static Rect SettingsWindowBtnBtnRect = new Rect(Styles.WindowWidth - 23, 6, 20, 20); public static Rect CloseBtnStagesOABRect = new Rect(Styles.WindowWidthStageOAB - 23, 6, 16, 16); public static Rect CloseBtnSettingsOABRect = new Rect(Styles.WindowWidthSettingsOAB - 23, 6, 16, 16); public static Rect SettingsOABRect = new Rect(Styles.WindowWidthStageOAB - 50, 6, 16, 16); public static Rect EditWindowRect = new Rect(Screen.width * 0.5f - Styles.WindowWidth / 2, Screen.height * 0.2f, Styles.WindowWidth, 0); - public static void InitializeStyles() + public static Texture2D SettingsIcon; + public static Texture2D EntryBackgroundTexture_WhiteTheme_First; + public static Texture2D EntryBackgroundTexture_WhiteTheme_Middle; + public static Texture2D EntryBackgroundTexture_WhiteTheme_Last; + public static Texture2D EntryBackgroundTexture_GrayTheme_First; + public static Texture2D EntryBackgroundTexture_GrayTheme_Middle; + public static Texture2D EntryBackgroundTexture_GrayTheme_Last; + public static Texture2D EntryBackgroundTexture_BlackTheme_First; + public static Texture2D EntryBackgroundTexture_BlackTheme_Middle; + public static Texture2D EntryBackgroundTexture_BlackTheme_Last; + + private static Color _nameColor_DarkThemes = new Color(.7f, .75f, .75f, 1); + private static Color _valueColor_DarkThemes = new Color(.6f, .7f, 1, 1); + private static Color _unitColor_DarkThemes = new Color(.7f, .75f, .75f, 1); + + private static Color _nameColor_LightThemes = new Color(.0f, .0f, .0f, 1); + private static Color _valueColor_LightThemes = new Color(.2f, .3f, 1, 1); + private static Color _unitColor_LightThemes = new Color(.0f, .0f, .0f, 1); + + private static Color _nameColor = _nameColor_DarkThemes; + private static Color _valueColor = _valueColor_DarkThemes; + private static Color _unitColor = _unitColor_DarkThemes; + + public static Theme ActiveTheme; + + public static void Initialize(MicroEngineerMod plugin) + { + _plugin = plugin; + + InitializeStyles(); + InitializeTextures(); + SetActiveTheme(Theme.Gray); + } + + private static void InitializeStyles() { SpaceWarpUISkin = Skins.ConsoleSkin; @@ -102,6 +163,13 @@ public static void InitializeStyles() fixedWidth = WindowWidthSettingsOAB }; + SettingsFlightStyle = new GUIStyle(SpaceWarpUISkin.window) + { + padding = new RectOffset(8, 8, 0, 16), + contentOffset = new Vector2(0, -22), + fixedWidth = WindowWidthSettingsFlight + }; + PopoutBtnStyle = new GUIStyle(SpaceWarpUISkin.button) { alignment = TextAnchor.MiddleCenter, @@ -115,31 +183,34 @@ public static void InitializeStyles() SectionToggleStyle = new GUIStyle(SpaceWarpUISkin.toggle) { - padding = new RectOffset(0, 18, -5, 0), - contentOffset= new Vector2(17, 8) + fixedHeight = 22, + margin = new RectOffset(0, 4, 0, 0) }; NameLabelStyle = new GUIStyle(SpaceWarpUISkin.label); - NameLabelStyle.normal.textColor = new Color(.7f, .75f, .75f, 1); + NameLabelStyle.normal.textColor = _nameColor; + NameLabelStyle.contentOffset = new Vector2(0, -1); // Background texture is hiding entry's bottom pixel, so this is needed ValueLabelStyle = new GUIStyle(SpaceWarpUISkin.label) { alignment = TextAnchor.MiddleRight }; - ValueLabelStyle.normal.textColor = new Color(.6f, .7f, 1, 1); + ValueLabelStyle.normal.textColor = _valueColor; + ValueLabelStyle.contentOffset = new Vector2(0, -1); // Background texture is hiding entry's bottom pixel, so this is needed UnitLabelStyle = new GUIStyle(SpaceWarpUISkin.label) { fixedWidth = 24, alignment = TextAnchor.MiddleLeft }; - UnitLabelStyle.normal.textColor = new Color(.7f, .75f, .75f, 1); + UnitLabelStyle.normal.textColor = _unitColor; + UnitLabelStyle.contentOffset = new Vector2(0, -1); // Background texture is hiding entry's bottom pixel, so this is needed UnitLabelStyleStageOAB = new GUIStyle(SpaceWarpUISkin.label) { alignment = TextAnchor.MiddleRight }; - UnitLabelStyleStageOAB.normal.textColor = new Color(.7f, .75f, .75f, 1); + UnitLabelStyleStageOAB.normal.textColor = _unitColor; NormalLabelStyle = new GUIStyle(SpaceWarpUISkin.label) { @@ -165,7 +236,7 @@ public static void InitializeStyles() alignment = TextAnchor.MiddleLeft, wordWrap = true }; - BlueLabelStyle.normal.textColor = new Color(.6f, .7f, 1, 1); + BlueLabelStyle.normal.textColor = _valueColor; WindowSelectionTextFieldStyle = new GUIStyle(SpaceWarpUISkin.textField) { @@ -189,6 +260,14 @@ public static void InitializeStyles() fontSize = 24 }; + SettingsMainGuiBtnStyle = new GUIStyle(SpaceWarpUISkin.button) + { + fixedWidth = 30, + fixedHeight = 20, + padding = new RectOffset(-2, -2, -2, -2) + }; + + NormalBtnStyle = new GUIStyle(SpaceWarpUISkin.button) { alignment = TextAnchor.MiddleCenter @@ -210,7 +289,16 @@ public static void InitializeStyles() OneCharacterBtnStyle = new GUIStyle(SpaceWarpUISkin.button) { fixedWidth = 20, - alignment = TextAnchor.MiddleCenter + fixedHeight = 19, + alignment = TextAnchor.MiddleCenter, + margin = new RectOffset(0, 5, 9, 0), + padding = new RectOffset(0, 0, 3, 0) + }; + + OneCharacterHighBtnStyle = new GUIStyle(SpaceWarpUISkin.button) + { + fixedWidth = 20, + alignment = TextAnchor.MiddleCenter, }; TableHeaderLabelStyle = new GUIStyle(NameLabelStyle) @@ -223,6 +311,83 @@ public static void InitializeStyles() }; } + private static void InitializeTextures() + { + SettingsIcon = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/settings-30.png"); + + EntryBackgroundTexture_WhiteTheme_First = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_white_first.png"); + EntryBackgroundTexture_WhiteTheme_Middle = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_white_middle.png"); + EntryBackgroundTexture_WhiteTheme_Last = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_white_last.png"); + + EntryBackgroundTexture_GrayTheme_First = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_darkgray_first.png"); + EntryBackgroundTexture_GrayTheme_Middle = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_darkgray_middle.png"); + EntryBackgroundTexture_GrayTheme_Last = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_darkgray_last.png"); + + EntryBackgroundTexture_BlackTheme_First = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_black_first.png"); + EntryBackgroundTexture_BlackTheme_Middle = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_black_middle.png"); + EntryBackgroundTexture_BlackTheme_Last = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_black_last.png"); + + EntryBackground_WhiteTheme_First = new GUIStyle { name = "WhiteFirst" }; + EntryBackground_WhiteTheme_First.normal.background = EntryBackgroundTexture_WhiteTheme_First; + EntryBackground_WhiteTheme_Middle = new GUIStyle { name = "WhiteMiddle" }; + EntryBackground_WhiteTheme_Middle.normal.background = EntryBackgroundTexture_WhiteTheme_Middle; + EntryBackground_WhiteTheme_Last = new GUIStyle { name = "WhiteLast" }; + EntryBackground_WhiteTheme_Last.normal.background = EntryBackgroundTexture_WhiteTheme_Last; + + EntryBackground_GrayTheme_First = new GUIStyle { name = "GrayFirst" }; + EntryBackground_GrayTheme_First.normal.background = EntryBackgroundTexture_GrayTheme_First; + EntryBackground_GrayTheme_Middle = new GUIStyle { name = "GrayMiddle" }; + EntryBackground_GrayTheme_Middle.normal.background = EntryBackgroundTexture_GrayTheme_Middle; + EntryBackground_GrayTheme_Last = new GUIStyle { name = "GrayLast" }; + EntryBackground_GrayTheme_Last.normal.background = EntryBackgroundTexture_GrayTheme_Last; + + EntryBackground_BlackTheme_First = new GUIStyle { name = "BlackFirst" }; + EntryBackground_BlackTheme_First.normal.background = EntryBackgroundTexture_BlackTheme_First; + EntryBackground_BlackTheme_Middle = new GUIStyle { name = "BlackMiddle" }; + EntryBackground_BlackTheme_Middle.normal.background = EntryBackgroundTexture_BlackTheme_Middle; + EntryBackground_BlackTheme_Last = new GUIStyle { name = "BlackLast" }; + EntryBackground_BlackTheme_Last.normal.background = EntryBackgroundTexture_BlackTheme_Last; + } + + public static void SetActiveTheme(Theme theme) + { + if (ActiveTheme == theme) return; + + switch (theme) + { + case Theme.munix: + EntryBackground_First = EntryBackground_WhiteTheme_First; + EntryBackground_Middle = EntryBackground_WhiteTheme_Middle; + EntryBackground_Last = EntryBackground_WhiteTheme_Last; + _nameColor = _nameColor_LightThemes; + _valueColor = _valueColor_LightThemes; + _unitColor = _unitColor_LightThemes; + break; + case Theme.Gray: + EntryBackground_First = EntryBackground_GrayTheme_First; + EntryBackground_Middle = EntryBackground_GrayTheme_Middle; + EntryBackground_Last = EntryBackground_GrayTheme_Last; + _nameColor = _nameColor_DarkThemes; + _valueColor = _valueColor_DarkThemes; + _unitColor = _unitColor_DarkThemes; + break; + case Theme.Black: + EntryBackground_First = EntryBackground_BlackTheme_First; + EntryBackground_Middle = EntryBackground_BlackTheme_Middle; + EntryBackground_Last = EntryBackground_BlackTheme_Last; + _nameColor = _nameColor_DarkThemes; + _valueColor = _valueColor_DarkThemes; + _unitColor = _unitColor_DarkThemes; + break; + default: + SetActiveTheme(Theme.Gray); + break; + } + + ActiveTheme = theme; + InitializeStyles(); + } + /// /// Draws a white horizontal line accross the container it's put in /// @@ -248,4 +413,11 @@ internal static void SetStylesForOldSpaceWarpSkin() }; } } + + public enum Theme + { + munix, + Gray, + Black + } } diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs index 5c0cb01..d3af764 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs @@ -18,7 +18,7 @@ public static class Utility public static VesselComponent ActiveVessel; public static ManeuverNodeData CurrentManeuver; public static string LayoutPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MicroLayout.json"); - public static int CurrentLayoutVersion = 3; + public static int CurrentLayoutVersion = 5; private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Utility"); public static GameStateConfiguration GameState; public static MessageCenter MessageCenter; @@ -169,9 +169,6 @@ internal static void SaveLayout(List windows) { try { - // Deactivate the Settings window before saving, because it doesn't make sense to save it in an active state since user cannot click the save button without having the Settings window active - windows.Find(w => w.MainWindow == MainWindow.Settings).IsFlightActive = false; - File.WriteAllText(LayoutPath, JsonConvert.SerializeObject(windows)); Logger.LogInfo("SaveLayout successful"); } @@ -188,7 +185,7 @@ internal static void LoadLayout(List windows) List deserializedWindows = JsonConvert.DeserializeObject>(File.ReadAllText(LayoutPath)); // Check if user has an old layout version. If it's older, it's not supported, so the default layout will remain active. Once the new layout is saved, it will persist. - var MainGui = deserializedWindows.Find(w => w.MainWindow == MainWindow.MainGui); + var MainGui = deserializedWindows.OfType().FirstOrDefault(); if (MainGui.LayoutVersion < Utility.CurrentLayoutVersion) { Logger.LogInfo("Loaded layout version is older than the current supported version. Layout will be reset."); @@ -198,6 +195,9 @@ internal static void LoadLayout(List windows) windows.Clear(); windows.AddRange(deserializedWindows); + var settingsWindow = windows.Find(w => w.GetType() == typeof(SettingsWIndow)) as SettingsWIndow; + settingsWindow.LoadSettings(); + Logger.LogInfo("LoadLayout successful"); } catch (FileNotFoundException ex) diff --git a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs index f5b5a6f..106e6fe 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs @@ -9,125 +9,21 @@ namespace MicroMod [JsonObject(MemberSerialization.OptIn)] internal class BaseWindow { - [JsonProperty] - internal string Name; - [JsonProperty] - internal int LayoutVersion; - [JsonProperty] - internal string Abbreviation; - [JsonProperty] - internal string Description; // not used - [JsonProperty] - internal Type WindowType = typeof(BaseWindow); - [JsonProperty] internal bool IsEditorActive; [JsonProperty] internal bool IsFlightActive; [JsonProperty] internal bool IsMapActive; // TODO: implement - - [JsonProperty] - internal bool IsEditorPoppedOut; - [JsonProperty] - internal bool IsFlightPoppedOut; - [JsonProperty] - internal bool IsMapPoppedOut; - - /// - /// Can the window be dragged or closed - /// - [JsonProperty] - internal bool IsLocked; - - /// - /// Window can be deleted if it's not one of main windows - /// - [JsonProperty] - internal bool IsDeletable { get => MainWindow == MainWindow.None; } - - /// - /// Can the window be edited (add, remove & arrange entries) - /// - [JsonProperty] - internal bool IsEditable { get => MainWindow != MainWindow.MainGui && MainWindow != MainWindow.Settings && MainWindow != MainWindow.Stage && MainWindow != MainWindow.StageInfoOAB; } - - [JsonProperty] - internal MainWindow MainWindow; + [JsonProperty] internal Rect EditorRect; [JsonProperty] internal Rect FlightRect; - [JsonProperty] - internal List Entries; - - /// - /// Moves entry upwards in the window. Does nothing if it's already first. - /// - /// Entry's current index - internal void MoveEntryUp(int entryIndex) - { - // check if entry exists and it's not first - if (entryIndex < Entries.Count && entryIndex > 0) - { - var temp = Entries[entryIndex-1]; - Entries[entryIndex - 1] = Entries[entryIndex]; - Entries[entryIndex] = temp; - } - } - - /// - /// Moves entry downwards in the window. Does nothing if it's already last. - /// - /// Entry's current index - internal void MoveEntryDown(int entryIndex) - { - // check if entry is not last - if (entryIndex < Entries.Count - 1) - { - var temp = Entries[entryIndex + 1]; - Entries[entryIndex + 1] = Entries[entryIndex]; - Entries[entryIndex] = temp; - } - } - - /// - /// Removes entry from the window - /// - /// Entry's index - internal void RemoveEntry(int entryIndex) - { - if (entryIndex < Entries.Count) - Entries.RemoveAt(entryIndex); - } - - /// - /// Adds an entry to the window to the last position - /// - /// - internal void AddEntry(BaseEntry entry) => Entries.Add(entry); - - /// - /// Grabs new data for each entry in the window - /// - internal void RefreshEntryData() - { - foreach (BaseEntry entry in Entries) - entry.RefreshData(); - } internal virtual void DrawWindowHeader() { } internal virtual void DrawWindowFooter() { } - - internal virtual void RefreshData() - { - if (Entries == null || Entries.Count == 0) - return; - - foreach (BaseEntry entry in Entries) - entry.RefreshData(); - } } /// diff --git a/MicroEngineerProject/MicroEngineer/Windows/EntryWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/EntryWindow.cs new file mode 100644 index 0000000..9231152 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Windows/EntryWindow.cs @@ -0,0 +1,109 @@ +using Newtonsoft.Json; + +namespace MicroMod +{ + internal class EntryWindow: BaseWindow + { + [JsonProperty] + internal string Name; + [JsonProperty] + internal string Abbreviation; + [JsonProperty] + internal string Description; // not used + + [JsonProperty] + internal bool IsEditorPoppedOut; + [JsonProperty] + internal bool IsFlightPoppedOut; + [JsonProperty] + internal bool IsMapPoppedOut; + + /// + /// Can the window be dragged or closed + /// + [JsonProperty] + internal bool IsLocked; + + /// + /// Window can be deleted if it's not one of main windows + /// + [JsonProperty] + internal bool IsDeletable { get => MainWindow == MainWindow.None; } + + /// + /// Can the window be edited (add, remove & arrange entries) + /// + [JsonProperty] + internal bool IsEditable { get => MainWindow != MainWindow.Stage && MainWindow != MainWindow.StageInfoOAB; } + + [JsonProperty] + internal MainWindow MainWindow; + + [JsonProperty] + internal List Entries; + + /// + /// Moves entry upwards in the window. Does nothing if it's already first. + /// + /// Entry's current index + internal void MoveEntryUp(int entryIndex) + { + // check if entry exists and it's not first + if (entryIndex < Entries.Count && entryIndex > 0) + { + var temp = Entries[entryIndex - 1]; + Entries[entryIndex - 1] = Entries[entryIndex]; + Entries[entryIndex] = temp; + } + } + + /// + /// Moves entry downwards in the window. Does nothing if it's already last. + /// + /// Entry's current index + internal void MoveEntryDown(int entryIndex) + { + // check if entry is not last + if (entryIndex < Entries.Count - 1) + { + var temp = Entries[entryIndex + 1]; + Entries[entryIndex + 1] = Entries[entryIndex]; + Entries[entryIndex] = temp; + } + } + + /// + /// Removes entry from the window + /// + /// Entry's index + internal void RemoveEntry(int entryIndex) + { + if (entryIndex < Entries.Count) + Entries.RemoveAt(entryIndex); + } + + /// + /// Adds an entry to the window to the last position + /// + /// + internal void AddEntry(BaseEntry entry) => Entries.Add(entry); + + /// + /// Grabs new data for each entry in the window + /// + internal void RefreshEntryData() + { + foreach (BaseEntry entry in Entries) + entry.RefreshData(); + } + + internal virtual void RefreshData() + { + if (Entries == null || Entries.Count == 0) + return; + + foreach (BaseEntry entry in Entries) + entry.RefreshData(); + } + } +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Windows/MainGuiWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/MainGuiWindow.cs new file mode 100644 index 0000000..e5b6c34 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Windows/MainGuiWindow.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json; + +namespace MicroMod +{ + internal class MainGuiWindow : BaseWindow + { + [JsonProperty] + internal int LayoutVersion; + } +} diff --git a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs index 430213d..e8688e9 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs @@ -6,7 +6,7 @@ namespace MicroMod { - internal class ManeuverWindow : BaseWindow + internal class ManeuverWindow : EntryWindow { private int _selectedNodeIndex = 0; private List _nodes = new(); diff --git a/MicroEngineerProject/MicroEngineer/Windows/SettingsWIndow.cs b/MicroEngineerProject/MicroEngineer/Windows/SettingsWIndow.cs new file mode 100644 index 0000000..1ce2215 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Windows/SettingsWIndow.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; + +namespace MicroMod +{ + [JsonObject(MemberSerialization.OptIn)] + internal class SettingsWIndow : BaseWindow + { + [JsonProperty] + internal Theme ActiveTheme { get; set; } + + internal void LoadSettings() + { + Styles.SetActiveTheme(ActiveTheme); + } + } +} \ No newline at end of file diff --git a/MicroEngineerProject/Other/MicroEngineer_BackgroundStyles.psd b/MicroEngineerProject/Other/MicroEngineer_BackgroundStyles.psd new file mode 100644 index 0000000000000000000000000000000000000000..6bace50f93a4a3d96bbf406faf0ec168f4dbdeaa GIT binary patch literal 35924 zcmeHP3ve69dEUc|4*+~fq)bW?2^{u+Zi(dH3v$Q1^*+t*)AM^~S`q?9~{ST$t zk%tbAh95c_4o2wRJ*C}~U6bRfah78&ljHG3rfYH+%|wzRwhLsO?WQe6g*&>7-h&G) z4-5`j`jcta;&%m{VQ+hKCBGd{P^=L8LB=0t*HCY^~)gJ49m zGr(rT=~#-3B@-5GmkA{&xLq`jE0QYJ11WSFJk3?L7t% zh>)&&W@hw6iggdOndC$|%)Cb+8v&-vk_4v9x9)%G>bD537WF!_n zk!z!E6uOwNqs!Z&w4u;kZUee=gy9%fR+PF5JCSf#G?^Y}xE>~zipRnX?tAWIiHO*v zWY>1Pv#N^o|{FIJDiI8SHdM!_d=1{z%B_33%Gun5fsodVG?PZ_Nk3 zE{Jx1j})eUPd>=@-|!J8F~&xE+|p%98Ml+$)WyDA9y%-UF1NeegfW;K3Z)3XEOZL0 zis_XwcO!!sCT}orbjuUR6+>DMdvB$%yl1|Zwq;v|N@OV12nD#*pd{-Q;F6(GBNX6L zgOaRMfJ=r#jZlC~4N9_30WKK|H9`R{H7LnC1-N7=)CdK*)Sx8m6yTDfP$LxJQiGDL zQ-Di`LXA*>OASi0P5~|%3N=CjE;T60It937DAWiAxYVE|>lEOUp->|f;8KHWlB`pJONK&? zP=HGfO0rG?E*T0nLIEx{D9JhnxMV2Q2nD#*pd{-Q;F6(GBNX6LgOaRMfJ=r#jZlC~ z4N9_30WKK|HNv`Zm1dV>vI$s!c^np6l9ifWWaZ{du*WMog;k%%R63U6?wR0H6C7mf zvC2?}8wtU}JECzQ!Le*&VjLG>86W%OX`C)6=Z?fCu|{8v!{^{)!6utN#Ei3}dmk8u zETJ;tgrRgY869D{iPSxz4~3!7goaQWCE*iA7Bqrb#Gwh4!lqDZO4f!HG1C|45@L%? zp@~?WizSFjC@&$}{e$m)HzHTO6PwUDVVAw)O^PeNhpgSqK>1x*vp>Zpq>F%y45j77 z@K|P0PV}b}{nAUnd~{3%LO=-(@9XP_){rH* z!x4)mlAH+jCSSxYB-_4pVntqGe5GDrIx>21g1ft6IF5ZQZ+-EIWwrd_Oq?V6LzD5| zVOhQO7#oIlZLn++*0+kiVrXnABlQX_V`VtvW}|~_R4}uw+R7YVoW^6B$ePMDDurx{%~yUh_b*a z6+qi$ecW@j*Mv5p{cxnEW%%;&algPlLJ~k0PA@sy* zQc?$dGa7~7&Y%R!Kp$s7W5Swp68sV|buexb}fs0oy;x|%8u)wBa_@fe%(vZ{^vR|Nok!uLUm{m#lZVG{_TZ+ zFb1gv^avJm4x>KkA7OM9a&h?tltdsta?n@epn*r7BRa z#6%p&aSWINRt2888Wblna$i6 zKS(Ynrye~igL5{)w}>PT3@GX<8cQc9QaM?MBw6h%-5vIhVC%xtU9e$hCb;B2Ho>Ox zvRTMLc*(7(Tq-Ez99(i>e9QuexBL3Fu&h7l7D>R*%^A#$<=#dOOq?5K#&WdE!fZS~ z%1&|zGW$md4@!Z$Sjx^(E;*7+KeQ(v8KRvDQ~;}F7ETQ zS0^L230DL&4Cv0g7l|y4X&hf+Ac#?wbWPHsw~@23KGGh>8t^?2Un7X$LufPD(DtJm zMDai5uOSn8HNoNjL8Rg5Q5i|0$cI6n;(vlpBU5p4aY?bMq{LKdEHzeEmzzxG)is+p zS8v{2Q)wcbcn}iH_mtUaG?$qx%E~IL%F4>B@UE;%IHgjJ0siZ#vKShFUQ5wPQ%Pwn zDgJ-pLQDDQsNK*?y%6i5!FbamN~6;oii%50jd0V;Eu@e}D-~8CN=IomI*q=_P^{OQ z+MuvftFvzM>i4{d*-Sq;?K4z;{E27!8XBvIzY%I{PoI3gzsUB9k;R|B8qWB)Jo))k z_JL21M)rR5GhE=V@8A0~_LpBc{jdKu@xQ;i+wsWXocZEkJa_TuuRZmpf4lV3ukVW< zJNxKo|LNcV`{ma=_T4{reCDyI|M^=#_`ly&B8>)Gt0QeHGU)xJ30ChW9kk#a--kwg=B~)zdjlN%Gr0+Cx4@BY z0{>%V(vmtW(QfowVwy)*ZsB_CzNJ42eeKI1{N(GGpJ}^#_)A~=?vn9M*MD4J`25lj zdDQ&7$EIGJ`Vx;$E**WX=lqwK9^lb;KgT2Erjf6H;u}2LG4=8fcy#9BsYiGJ>L`!C z`P?H5jsH0Ho%-LxDL)Mze(BGz|CmRM&)9Z;dq@2*zqK?z^~M8_{Wi>_z_ZtP960pL zcNblMhDR3;FKw~CGnW6Qe)!qT$)%Rpe`kH|+03V&zJBH_$FF_vz)z-*&R_e&>-Wu1 zbzFRX>hZ6B=lWmq==?n|@1Fn7^E_IZ;ZbyWg#VE+60M}`-4A;hjX)~U9=ORRQ3!5u z79a*kK<40^AyNu7s&1fRK|bUmUoa`uLE}0o-{2r>0ihTbQJcv08qe$ywUy8wTzQDv zCd(h9nnWGA5mH`qJFEwtH02{Qju{`HiIJ#*&;48YUPPtWKa3E}uf*f}uP#COeI#9; z_AXzWMS7PASb>4~X-cRY&;LHHk?NpoKCP8x{H7kV87QsTPMBY0uZ5zs*Fv=@uSG*i zHYlG)wk=vi;!IaQ?*31Nc72Z*=7xe2)C@Oo9hsXxNwS_Kaq>xm%ab^QCg3F{JSv4k zs#~-Skr#Emp-dNNPNa$c zi5R}IQh)#;-Bz-h-G^tF-GpT4!IvmILh4~%`*hc2aIId$q ze962yJdxo*#v8Os!8D8U3ykm^UmzDZpafdUrblDrEM|0jepI>b-cyggKx{@Q)3|F_ zz;~?;FpyFIE>?nm2v(^+j5;-lTc$w0Q8c3(bzM}L^i90G15Q2xv&}fk&!Ss| z(|M2XU+%mix|n;wb>1Ah12>Cq`B<7gVTm&t&H}GANuN-lj6GFOX80`hZVO<|K(OOL z!n}}!nZL*k<5~1gw+H$&H$-2=v0Bl$|BmGGq;FS|zTJ$kR?)W)-Yoi+1pVCw%s8Zp9ao}JP_+XB;o)^k*3oo40tM!6%41679Ow|!DxQG{m%e;W&AKp|) zm8-HHd^ zj%Xx!VEt&M^nki(M51K=d*LIu;)S;(8VO!lKN=~$pe`EK-WJj5@f$=V3Z9y%`b_iF z{44N%r}r>BP}M$Uc<0+D)OZsuMAPUM_`cKo+oFY4z|u|dlU6DG8iYSVs zwV_2r`x;LRsfK2ns%ykWS7^%8i0V!XVtsyy7_qwmu?pw}xErkb0mK4Mmt&@Wy8hMr zqB`2X!`JEe8~lM*TU~3@tYg~os-wv6bXuF5{Jh>DpuKk6jD6a^Xg2_eOTG5p6A zYOUx4`6h@@W{6X`?`)wO>v4d1g+_JxAzE;A=4h(1PD3|0;7E3b)-?KPO-q9nr=Y08 zrt?@@9M-dtyh>{unrfR3F6UNTlf{a|=RB>q(ydmvi+AZ7ZS_qKoVh?78tvO@2hP=d zb~qZW+aHDqJYT18Y;JP9U4Yn{@rSs*9O6_p#H%fogT@hI&Q3Y%^G|LN+tzH+*j!Dg zNr=>S>rPJ+qX8k8f~+1#=Ko`vwP`)pZD`kTC3A( ze;8uyg2T|%T4!s;+4@f34m(}}-axXk3r`2%IR(fEIYYz;@=0y8NWfvW&!qQk_bTm-HH(-M6zVI?ya(-n&q1}jZi ziN2SR68wu11lgM~uX7)(w~Vt_RQ zInml0XmX36gB7q^+E+soFljLXJ*g2pkkLZbNfQQReZI-yc+Bh60Vh40SkQG8B)5#}BFB)?EcS)}&7A2~*Pv?QsT~u(V$B&`ZV5%pXh5*I^W~dB#v!8t(csRP0hvE| z4%6%Ho;^2xZsDAg!<-Yt=Tj1gIVT3#ryMPNC~%l=l7QcH&jE+&7K6?? z;4n`~GH{r4c_oA6H_T!7_;(AyDLIS`oWx-y;6Ceg0~xg2CE)G_4$~_G2OMU%1Q2kT z&q^|I7#X;{kO8=ja+v<$!0d(T3kw&N9Oi=9;hvT_%muN-Jsk*oFo$_s>~IeNhZ!IV z=x`T+!wiU6T>uXAv?K#>k)u~$$ndW#VfD%o!*P;)_h9BI$gt{{tcbBAQC#tCn;& zFC(3Qs(Tb3oXOm&)w=)Z`YV6mfghY@NoR0w$*?s4gO74U+ocC*&a-due16eKC7o4E zC7sKtRw4iZ literal 0 HcmV?d00001 diff --git a/Staging/BepInEx/plugins/micro_engineer/assets/images/background_black_first.png b/Staging/BepInEx/plugins/micro_engineer/assets/images/background_black_first.png new file mode 100644 index 0000000000000000000000000000000000000000..71e4ebb40525b93de1483bfe618013de5547ba53 GIT binary patch literal 438 zcmeAS@N?(olHy`uVBq!ia0y~yV3Yu|ML5`iWSF&*Gf<$`)5S5QV$R!}wtmuq60Hx5 z+q0W{C+bdqsNTe($f~Ky#OuYKWS*m-8#`-_B6k97$;*`!E;T5r3QpAJ;IucMCz*Ea zarYV>29cWG-y;u%&v}$<_ju0b8`pmCb(`lZ-)s0gb>6kE-ysYiW)wQD*?PQj>+)^) z-dugv>l{7*W$&to@}Kjnk4q#^dq4U1!e>{~3>7%nD`nnNqCG`kzl~8mmDe<7B1}tp^xBv=M=wFEQW0T+_F;V8c&fd@y*r L`njxgN@xNAh`z|+ literal 0 HcmV?d00001 diff --git a/Staging/BepInEx/plugins/micro_engineer/assets/images/background_black_last.png b/Staging/BepInEx/plugins/micro_engineer/assets/images/background_black_last.png new file mode 100644 index 0000000000000000000000000000000000000000..b3f331e88ace1ea470c5afed50728546821731ef GIT binary patch literal 414 zcmeAS@N?(olHy`uVBq!ia0y~yV3Yu|ML5`iWSF&*Gf*Ja)5S5QV$Rz;_I}ci5^W#9 z&;EOS-Az^=j|NA^rW6s!phgzahgq%@yW}1 z_ZgQ}bT6OrXfyxo*!%BeU)B|9Gf1?DS+2eLtw$!CiKF!Z14kQ?_`v__OEWJ@Fgy+o z%RT9%mmg|$jMac`?MY2to%NZSTUT3jJzZCAUwV8c8$)uC$mCylcZW=Qrab+*@UJha z{&(NTZat-G#`YmEZJEjGFCUh#w>asyXlj4-uANra9+N^Y7t3D#&fMGPufy}eH?GfT zZC=jH!VBTmg^v%po(#-+*4Lf&FX+?#SB~{{sky;%arWo@BgGHYPrcf6W@b`#SZ(=Q z6aDH*-&Fr@I&aPXY*EEJNxL$)!@o92+Lg?kowhl1R_x>N;s>;s2)9mJBT@N&e|qKD f&`(>x$JH}FHwikJt$jii814+7u6{1-oD!MkMD4~#yU*g!AIjPO;tqt4$E&)1#!PC{xWt~$(699B+Jzf9+ literal 0 HcmV?d00001 diff --git a/Staging/BepInEx/plugins/micro_engineer/assets/images/background_darkgray_first.png b/Staging/BepInEx/plugins/micro_engineer/assets/images/background_darkgray_first.png new file mode 100644 index 0000000000000000000000000000000000000000..f6841d47556a268009ab7244ba440bbba4a24748 GIT binary patch literal 428 zcmeAS@N?(olHy`uVBq!ia0y~yV3Yu|ML5`iWSF&*Gf<$|)5S5QV$R!}hIv;UMA|?8 zm+s&DT9sQVLzGp8h1GS|gtiNAj~HZ{`nU^N^d<@yF#ReCnKH#Bb5f{?<&oK2ZH*^R zou{zra_#YJI7 zSMS%D+V&G{#s*VD=_nLR(B-Y?#DQshvQCmmB>W^x$ETPgJaV(PR5%66|hV z35$FVdQ&MBb@0MC-O AA^-pY literal 0 HcmV?d00001 diff --git a/Staging/BepInEx/plugins/micro_engineer/assets/images/background_darkgray_last.png b/Staging/BepInEx/plugins/micro_engineer/assets/images/background_darkgray_last.png new file mode 100644 index 0000000000000000000000000000000000000000..06b5f66510224ea71c09d7e21830127353001264 GIT binary patch literal 406 zcmeAS@N?(olHy`uVBq!ia0y~yV3Yu|ML5`iWSF&*Gf*Jb)5S5QV$Rz;hJMnHBJCgl z&z^httJLE|TplN!CNc?$XvAs+6?Vlm1Q)c#D6p!scehBl6to=RxV<}hKgaU^2_H)C zzh{Wv^XT&IiD_>?PZ!ot@}I=bup87wSknX8ln3j>|C1;#RoMBB$LI7pt}=ZDQDVV2j_}d2(u6tCn%EzOw2if5`g6#}HThkK7aQB&`@c`)v{$Naz;!+Ic=N|MSRT~giOv7M^X$2G zVw+dGu^->QP(y!l!{giu~vEe^gn1;x*pKtn~%w3iC z-SJYnXZg3Uw_974>b%}2-P!tCer2uf`d}+x&AFS8FjVxfx*i_+-MajLsQF>-lh5C+ a+plU78F*Ja{yH$c89ZJ6T-G@yGywo3kFuly literal 0 HcmV?d00001 diff --git a/Staging/BepInEx/plugins/micro_engineer/assets/images/background_darkgray_middle.png b/Staging/BepInEx/plugins/micro_engineer/assets/images/background_darkgray_middle.png new file mode 100644 index 0000000000000000000000000000000000000000..ab73bf245445d5c15a0681682d92c9b9be9efcc4 GIT binary patch literal 170 zcmeAS@N?(olHy`uVBq!ia0y~yV3Yu|ML5`iWSF&*Gmt9uba4!+nDh3^M&9NCkpl<5 zbGmMG@S6NL+}l-A*N=vJ1)_S`4hRW9+EiQx}{ip#{`8a7wv3Ym-z|>iXuEBdM*MY z;<`@ezJZr#+CM)d*+0i$;nbepufH?SJGys=S-H`3i6J%oUe~ z80M(?c5MB&JN@mvv%lJBzImWNTh_wn-OZ#R%*1-~UC(Q4R6m^JS zv%dbqyMO#QcZi?fzHwh(-Ugk9eVOLcpDxK?{@hv_#(E*#vq(qZR^ktTgqXwqN*}HR iqD;&OB#FShp6YYU3xxK{mGJwh?LmSrOy^`{Sj3lGaon1|z&X71 z@|B~Co)fd)-+J;Y_zN$`!+CFiS2F&8XkK%Cf90Q)OYh#kTM<^R#c<;A#fuwf>8C&0 zsKyY^!NZVF9B#OCw6Lc9l5yKHh7;G9pVyvb_-WBZq03Asj^2!nes8b$;>j1MMtO}H z^|q&1voY+nwD_a9xc*c3#RIo*|6g`%bK9z~&&$6uHYBQgE=rQn`gt`pfMfd}lh4!j zt#j}41erd+Cn(9_ytCHm>$k&;{{7o`<;db&{Z10=*^X667p|<)yBSt>Ro6WJ?CDdl zUVl^5X5MiifjLaCBIxYkF;NTCneJK z^rp;Y3GoAeyZDnt4^mdKI;Vst07*PHlmGw# literal 0 HcmV?d00001 diff --git a/Staging/BepInEx/plugins/micro_engineer/assets/images/settings-30.png b/Staging/BepInEx/plugins/micro_engineer/assets/images/settings-30.png new file mode 100644 index 0000000000000000000000000000000000000000..656d94207f335257a195bad2c597d6f85eafbcaf GIT binary patch literal 559 zcmV+~0?_@5P)cJI1f}XsXi=QGG-GHKJ zqb$aQ2Q?=73_)+=FAThe&e*#%J8MHRUDaLnre1YdD>i^ExelxV4d80l{@BQ1z&dan zm;pWloA#-6qB;xs7VyjS3E(rZ1dIoJE&$8G7hux1-}WsGd<0kpF6B6IEvY&4qrCvP zGTH+6rtCK@p{;7F$NtBuJ}>F3q(9bANNP%&w<8KJikscR!b`)S8mi(#~*`mev$$Xcn5 zEnUpMRIFSX&jQa(S3>pK6xH=0vqxsA-}*UIz3dpX-2jL3*i@Em8v&ZYOH0$XR>OG< zJjgoLd4Q+fxhj!*$F9>xs=*Wj9(G1kT{Mu3_8IO4cmde0_)G}+fZQHjna2a^w z&h-Jf0^IlE=>zup!MFol_MR>KlzXjl>#;Zx=FC?9k xRF<@w^#+$p|H4$V5Za74l7_sN%)1+sb^uSvpOqVNg=zo*002ovPDHLkV1j8u14{q^ literal 0 HcmV?d00001 From e775e7b5248999e9bd4de20fc5a27bc6456f6c91 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sun, 23 Apr 2023 21:44:31 +0200 Subject: [PATCH 30/38] Move flight StageInfo to StageWindow, add theme support --- .../MicroEngineer/Managers/Manager.cs | 2 +- .../MicroEngineer/Managers/MessageManager.cs | 1 + .../MicroEngineer/Managers/UI.cs | 161 ++++-------------- .../MicroEngineer/Utilities/Utility.cs | 2 +- .../MicroEngineer/Windows/StageWindow.cs | 137 +++++++++++++++ 5 files changed, 169 insertions(+), 134 deletions(-) create mode 100644 MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs diff --git a/MicroEngineerProject/MicroEngineer/Managers/Manager.cs b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs index 2e64b99..8fab538 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/Manager.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs @@ -205,7 +205,7 @@ internal List InitializeWindows() Entries = Entries.Where(entry => entry.Category == MicroEntryCategory.Maneuver && entry.IsDefault).ToList() }); - Windows.Add(new EntryWindow + Windows.Add(new StageWindow { Name = "Stage", Abbreviation = "STG", diff --git a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs index 08fea3f..f932b8e 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs @@ -78,6 +78,7 @@ private void GameStateEntered(MessageCenterMessage obj) { Utility.LoadLayout(_windows); _manager.Windows = _windows; + _ui.Windows = _windows; if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) _ui.ShowGuiFlight = _windows.OfType().FirstOrDefault().IsFlightActive; diff --git a/MicroEngineerProject/MicroEngineer/Managers/UI.cs b/MicroEngineerProject/MicroEngineer/Managers/UI.cs index d110ec5..28cb878 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/UI.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/UI.cs @@ -14,7 +14,7 @@ internal class UI private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.MessageManager"); - private List _windows; + internal List Windows; internal bool ShowGuiFlight; internal bool ShowGuiOAB; @@ -45,7 +45,7 @@ internal UI(MicroEngineerMod plugin, Manager manager) { _plugin = plugin; _manager = manager; - _windows = manager.Windows; + Windows = manager.Windows; } internal void OnGUI() @@ -65,7 +65,7 @@ private void OnGUI_Flight() if (!ShowGuiFlight || Utility.ActiveVessel == null) return; - MainGuiWindow mainGui = (MainGuiWindow)_windows.Find(w => w is MainGuiWindow); // window => window.MainWindow == MainWindow.MainGui); + MainGuiWindow mainGui = (MainGuiWindow)Windows.Find(w => w is MainGuiWindow); // window => window.MainWindow == MainWindow.MainGui); // Draw main GUI that contains docked windows mainGui.FlightRect = GUILayout.Window( @@ -78,7 +78,7 @@ private void OnGUI_Flight() ); mainGui.FlightRect.position = Utility.ClampToScreen(mainGui.FlightRect.position, mainGui.FlightRect.size); - List entryWindows = _windows.FindAll(w => w is EntryWindow).Cast().ToList(); + List entryWindows = Windows.FindAll(w => w is EntryWindow).Cast().ToList(); // Draw all other popped out windows foreach (var (window, index) in entryWindows @@ -116,21 +116,9 @@ private void OnGUI_Flight() } // Draw popped out Stages - int stageIndex = entryWindows.FindIndex(window => window.MainWindow == MainWindow.Stage); - if (entryWindows[stageIndex].IsFlightActive && entryWindows[stageIndex].IsFlightPoppedOut) - { - entryWindows[stageIndex].FlightRect = GUILayout.Window( - stageIndex, - entryWindows[stageIndex].FlightRect, - DrawStages, - "", - Styles.PopoutWindowStyle, - GUILayout.Height(0), - GUILayout.Width(Styles.WindowWidth) - ); - - entryWindows[stageIndex].FlightRect.position = Utility.ClampToScreen(entryWindows[stageIndex].FlightRect.position, entryWindows[stageIndex].FlightRect.size); - } + StageWindow stageWindow= entryWindows.OfType().FirstOrDefault(); + if (stageWindow.IsFlightActive && stageWindow.IsFlightPoppedOut) + stageWindow.DrawWindow(this); // Draw Edit Window if (_showEditWindow) @@ -174,12 +162,12 @@ private void DrawSettingsFlightWindow(int id) GUILayout.Space(10); GUILayout.Label("Layout control"); if (GUILayout.Button("SAVE LAYOUT", Styles.NormalBtnStyle)) - Utility.SaveLayout(_windows); + Utility.SaveLayout(Windows); GUILayout.Space(5); if (GUILayout.Button("LOAD LAYOUT", Styles.NormalBtnStyle)) { - Utility.LoadLayout(_windows); - _manager.Windows = _windows; + Utility.LoadLayout(Windows); + _manager.Windows = Windows; } if (GUILayout.Button("RESET LAYOUT", Styles.NormalBtnStyle)) ResetLayout(); @@ -189,7 +177,7 @@ private void DrawSettingsFlightWindow(int id) GUILayout.Space(-10); GUILayout.BeginHorizontal(); - var settingsWindow = _windows.Find(w => w.GetType() == typeof(SettingsWIndow)) as SettingsWIndow; + var settingsWindow = Windows.Find(w => w.GetType() == typeof(SettingsWIndow)) as SettingsWIndow; if (GUILayout.Toggle(Styles.ActiveTheme == Theme.munix, "munix", Styles.SectionToggleStyle)) { Styles.SetActiveTheme(Theme.munix); @@ -221,7 +209,7 @@ private void OnGUI_OAB() { if (!ShowGuiOAB) return; - EntryWindow stageInfoOAB = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); + EntryWindow stageInfoOAB = Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); if (stageInfoOAB.Entries.Find(e => e.Name == "Stage Info (OAB)").EntryValue == null) return; stageInfoOAB.EditorRect = GUILayout.Window( @@ -276,11 +264,11 @@ private void OnGUI_OAB() /// private void FillMainGUI(int windowID) { - List entryWindows = _windows.FindAll(w => w is EntryWindow).Cast().ToList(); + List entryWindows = Windows.FindAll(w => w is EntryWindow).Cast().ToList(); if (SettingsButtonOnMainGui(Styles.SettingsMainBtnBtnRect)) { - Rect mainGuiRect = _windows.OfType().FirstOrDefault().FlightRect; + Rect mainGuiRect = Windows.OfType().FirstOrDefault().FlightRect; settingsFlightRect = new Rect(mainGuiRect.x - Styles.WindowWidthSettingsFlight, mainGuiRect.y, Styles.WindowWidthSettingsFlight, 0); _showGuiSettingsFlight = !_showGuiSettingsFlight; } @@ -312,9 +300,9 @@ private void FillMainGUI(int windowID) GUILayout.Space(5); // Draw Stage window next - int stageIndex = entryWindows.FindIndex(window => window.MainWindow == MainWindow.Stage); - if (entryWindows[stageIndex].IsFlightActive && !entryWindows[stageIndex].IsFlightPoppedOut) - DrawStages(stageIndex); + StageWindow stageWindow = entryWindows.OfType().FirstOrDefault(); + if (stageWindow.IsFlightActive && !stageWindow.IsFlightPoppedOut) + stageWindow.DrawWindow(this); // Draw all other windows foreach (var (window, index) in entryWindows @@ -344,7 +332,6 @@ private void FillMainGUI(int windowID) DrawEntry(s, window.Entries[i].Name, window.Entries[i].ValueDisplay, window.Entries[i].Unit); } - window.DrawWindowFooter(); DrawSectionEnd(window); @@ -364,8 +351,8 @@ private void FillMainGUI(int windowID) /// private void DrawPopoutWindow(int windowIndex) { - List entryWindows = _windows.FindAll(w => w is EntryWindow).Cast().ToList(); - EntryWindow w = _windows.FindAll(w => w is EntryWindow).Cast().ToList()[windowIndex]; + List entryWindows = Windows.FindAll(w => w is EntryWindow).Cast().ToList(); + EntryWindow w = Windows.FindAll(w => w is EntryWindow).Cast().ToList()[windowIndex]; DrawSectionHeader(w.Name, ref w.IsFlightPoppedOut, w.IsLocked, ""); @@ -373,7 +360,6 @@ private void DrawPopoutWindow(int windowIndex) GUILayout.Space(10); for (int i = 0; i < w.Entries.Count; i++) - //foreach (BaseEntry entry in w.Entries) { if (w.Entries[i].HideWhenNoData && w.Entries[i].ValueDisplay == "-") continue; @@ -384,46 +370,7 @@ private void DrawPopoutWindow(int windowIndex) w.DrawWindowFooter(); DrawSectionEnd(w); - } - - private void DrawStages(int windowIndex) - { - EntryWindow windowToDraw = _windows.FindAll(w => w is EntryWindow).Cast().ToList()[windowIndex]; - - DrawStagesHeader(windowToDraw); - - List stages = (List)windowToDraw.Entries.Find(entry => entry.Name == "Stage Info").EntryValue; - - int stageCount = stages?.Count ?? 0; - if (stages != null && stageCount > 0) - { - float highestTwr = Mathf.Floor(stages.Max(stage => stage.TWRActual)); - int preDecimalDigits = Mathf.FloorToInt(Mathf.Log10(highestTwr)) + 1; - string twrFormatString = "N2"; - - if (preDecimalDigits == 3) - { - twrFormatString = "N1"; - } - else if (preDecimalDigits == 4) - { - twrFormatString = "N0"; - } - - for (int i = stages.Count - 1; i >= 0; i--) - { - - DeltaVStageInfo stageInfo = stages[i]; - if (stageInfo.DeltaVinVac > 0.0001 || stageInfo.DeltaVatASL > 0.0001) - { - int stageNum = stageCount - stageInfo.Stage; - DrawStageEntry(stageNum, stageInfo, twrFormatString); - } - } - } - - DrawSectionEnd(windowToDraw); - } + } private void DrawSectionHeader(string sectionName, ref bool isPopout, bool isLocked, string value = "") { @@ -439,30 +386,7 @@ private void DrawSectionHeader(string sectionName, ref bool isPopout, bool isLoc GUILayout.Label("", Styles.UnitLabelStyle); GUILayout.EndHorizontal(); GUILayout.Space(Styles.SpacingAfterHeader); - } - - private void DrawStagesHeader(EntryWindow stageWindow) - { - GUILayout.BeginHorizontal(); - stageWindow.IsFlightPoppedOut = stageWindow.IsFlightPoppedOut ? !CloseButton(Styles.CloseBtnRect) : GUILayout.Button("⇖", Styles.PopoutBtnStyle); - - GUILayout.Label($"{stageWindow.Name}"); - GUILayout.FlexibleSpace(); - GUILayout.Label("∆v", Styles.TableHeaderLabelStyle); - GUILayout.Space(16); - GUILayout.Label($"TWR", Styles.TableHeaderLabelStyle, GUILayout.Width(40)); - GUILayout.Space(16); - if (stageWindow.IsFlightPoppedOut) - { - GUILayout.Label($"Burn", GUILayout.Width(56)); - } - else - { - GUILayout.Label($"Burn", Styles.TableHeaderLabelStyle, GUILayout.Width(56)); - } - GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterHeader); - } + } private void DrawEntry(GUIStyle horizontalStyle, string entryName, string value, string unit = "") { @@ -474,34 +398,7 @@ private void DrawEntry(GUIStyle horizontalStyle, string entryName, string value, GUILayout.Label(unit, Styles.UnitLabelStyle); GUILayout.EndHorizontal(); GUILayout.Space(Styles.SpacingAfterEntry); - } - - private void DrawStageEntry(int stageID, DeltaVStageInfo stageInfo, string twrFormatString) - { - GUILayout.BeginHorizontal(); - GUILayout.Label($"{stageID:00.}", Styles.NameLabelStyle, GUILayout.Width(24)); - GUILayout.FlexibleSpace(); - GUILayout.Label($"{stageInfo.DeltaVActual:N0} m/s", Styles.ValueLabelStyle); - GUILayout.Space(16); - GUILayout.Label($"{stageInfo.TWRActual.ToString(twrFormatString)}", Styles.ValueLabelStyle, GUILayout.Width(40)); - GUILayout.Space(16); - string burnTime = Utility.SecondsToTimeString(stageInfo.StageBurnTime, false); - string lastUnit = "s"; - if (burnTime.Contains('h')) - { - burnTime = burnTime.Remove(burnTime.LastIndexOf("{lastUnit}", Styles.ValueLabelStyle, GUILayout.Width(56)); - GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); - } + } private void DrawSectionEnd(EntryWindow window) { @@ -524,7 +421,7 @@ private void DrawSectionEnd(EntryWindow window) /// private void DrawEditWindow(int windowIndex) { - List editableWindows = _windows.FindAll(w => w is EntryWindow).Cast().ToList().FindAll(w => w.IsEditable); // Editable windows are all except MainGUI, Settings, Stage and StageInfoOAB + List editableWindows = Windows.FindAll(w => w is EntryWindow).Cast().ToList().FindAll(w => w.IsEditable); // Editable windows are all except MainGUI, Settings, Stage and StageInfoOAB List entriesByCategory = _manager.Entries.FindAll(e => e.Category == _selectedCategory); // All window stageInfoOabEntries belong to a category, but they can still be placed in any window _showEditWindow = !CloseButton(Styles.CloseBtnRect); @@ -560,7 +457,7 @@ private void DrawEditWindow(int windowIndex) { if (GUILayout.Button("DEL WINDOW", Styles.NormalBtnStyle)) { - _windows.Remove(editableWindows[_selectedWindowId]); + Windows.Remove(editableWindows[_selectedWindowId]); editableWindows.Remove(editableWindows[_selectedWindowId]); _selectedWindowId--; } @@ -670,7 +567,7 @@ private void DrawEditWindow(int windowIndex) private void DrawStageInfoOAB(int windowID) { - EntryWindow stageInfoOabWindow = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); + EntryWindow stageInfoOabWindow = Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); List stageInfoOabEntries = stageInfoOabWindow.Entries; GUILayout.BeginHorizontal(); @@ -783,7 +680,7 @@ private void DrawCelestialBodySelection(int id) { if (GUILayout.Button(body.DisplayName, Styles.CelestialSelectionBtnStyle)) { - StageInfo_OAB stageInfoOab = (StageInfo_OAB)_windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Stage Info (OAB)"); + StageInfo_OAB stageInfoOab = (StageInfo_OAB)Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Stage Info (OAB)"); stageInfoOab.CelestialBodyForStage[CelestialBodySelectionStageIndex] = body.Name; // Hide the selection window @@ -802,7 +699,7 @@ private void DrawSettingsOabWindow(int id) if (CloseButton(Styles.CloseBtnSettingsOABRect)) _showGuiSettingsOAB = false; - EntryWindow stageInfoOabWindow = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); + EntryWindow stageInfoOabWindow = Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); List stageInfoOabEntries = stageInfoOabWindow.Entries; Torque torqueEntry = (Torque)stageInfoOabEntries.Find(e => e.Name == "Torque"); @@ -824,7 +721,7 @@ private bool SettingsButton(Rect rect) private void ResetLayout() { - _windows = _manager.InitializeWindows(); + Windows = _manager.InitializeWindows(); _selectedWindowId = 0; } @@ -839,7 +736,7 @@ private void CloseWindow() /// /// Where to position the close button /// - private bool CloseButton(Rect rect) + internal bool CloseButton(Rect rect) { return GUI.Button(rect, "X", Styles.CloseBtnStyle); } diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs index d3af764..24c2952 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs @@ -18,7 +18,7 @@ public static class Utility public static VesselComponent ActiveVessel; public static ManeuverNodeData CurrentManeuver; public static string LayoutPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MicroLayout.json"); - public static int CurrentLayoutVersion = 5; + public static int CurrentLayoutVersion = 6; private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Utility"); public static GameStateConfiguration GameState; public static MessageCenter MessageCenter; diff --git a/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs new file mode 100644 index 0000000..2281307 --- /dev/null +++ b/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs @@ -0,0 +1,137 @@ +using KSP.Sim.DeltaV; +using UnityEngine; + +namespace MicroMod +{ + internal class StageWindow : EntryWindow + { + private UI _ui; + + internal void DrawWindow(UI ui) + { + _ui = ui; + + if (this.IsFlightPoppedOut) + { + this.FlightRect = GUILayout.Window( + GUIUtility.GetControlID(FocusType.Passive), + this.FlightRect, + DrawStages, + "", + Styles.PopoutWindowStyle, + GUILayout.Width(Styles.WindowWidth), + GUILayout.Height(0) + ); + + this.FlightRect.position = Utility.ClampToScreen(this.FlightRect.position, this.FlightRect.size); + } + else + { + DrawStages(int.MinValue); + } + } + + private void DrawStages(int id) + { + DrawStagesHeader(); + + List stages = (List)this.Entries.Find(entry => entry.Name == "Stage Info").EntryValue; + + int stageCount = stages?.Count ?? 0; + if (stages != null && stageCount > 0) + { + float highestTwr = Mathf.Floor(stages.Max(stage => stage.TWRActual)); + int preDecimalDigits = Mathf.FloorToInt(Mathf.Log10(highestTwr)) + 1; + string twrFormatString = "N2"; + + if (preDecimalDigits == 3) + { + twrFormatString = "N1"; + } + else if (preDecimalDigits == 4) + { + twrFormatString = "N0"; + } + + int numberOfNonEmptyStagesToDraw = stages.Where(s => s.DeltaVinVac > 0.0001 || s.DeltaVatASL > 0.0001).Count(); + int stageBeingDrawn = 0; + for (int i = stages.Count - 1; i >= 0; i--) + { + DeltaVStageInfo stageInfo = stages[i]; + if (stageInfo.DeltaVinVac > 0.0001 || stageInfo.DeltaVatASL > 0.0001) + { + GUIStyle style = stageBeingDrawn < numberOfNonEmptyStagesToDraw - 1 ? Styles.EntryBackground_Middle : Styles.EntryBackground_Last; + int stageNum = stageCount - stageInfo.Stage; + DrawStageEntry(style, stageNum, stageInfo, twrFormatString); + } + } + } + + DrawSectionEnd(); + } + + private void DrawStagesHeader() + { + GUILayout.BeginHorizontal(); + // If window is popped out and it's not locked => show the close button. If it's not popped out => show to popup arrow + this.IsFlightPoppedOut = this.IsFlightPoppedOut && !this.IsLocked ? !_ui.CloseButton(Styles.CloseBtnRect) : !this.IsFlightPoppedOut ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : this.IsFlightPoppedOut; + + GUILayout.Label($"{this.Name}"); + GUILayout.EndHorizontal(); + //GUILayout.Space(Styles.SpacingAfterHeader); + + GUILayout.BeginHorizontal(Styles.EntryBackground_First); + GUILayout.FlexibleSpace(); + GUILayout.Label("∆v", Styles.TableHeaderLabelStyle); + GUILayout.Space(16); + GUILayout.Label($"TWR", Styles.TableHeaderLabelStyle, GUILayout.Width(40)); + GUILayout.Space(16); + GUILayout.Label($"Burn", Styles.TableHeaderLabelStyle, GUILayout.Width(56)); + GUILayout.Space(5); + GUILayout.EndHorizontal(); + GUILayout.Space(Styles.SpacingAfterEntry); + } + + private void DrawStageEntry(GUIStyle horizontalStyle, int stageID, DeltaVStageInfo stageInfo, string twrFormatString) + { + GUILayout.BeginHorizontal(horizontalStyle); + GUILayout.Label($"{stageID:00.}", Styles.NameLabelStyle, GUILayout.Width(24)); + GUILayout.FlexibleSpace(); + GUILayout.Label($"{stageInfo.DeltaVActual:N0} m/s", Styles.ValueLabelStyle); + GUILayout.Space(16); + GUILayout.Label($"{stageInfo.TWRActual.ToString(twrFormatString)}", Styles.ValueLabelStyle, GUILayout.Width(40)); + GUILayout.Space(16); + string burnTime = Utility.SecondsToTimeString(stageInfo.StageBurnTime, false); + string lastUnit = "s"; + if (burnTime.Contains('h')) + { + burnTime = burnTime.Remove(burnTime.LastIndexOf("{lastUnit}", Styles.ValueLabelStyle, GUILayout.Width(56)); + GUILayout.EndHorizontal(); + GUILayout.Space(Styles.SpacingAfterEntry); + } + + private void DrawSectionEnd() + { + if (this.IsFlightPoppedOut) + { + if (!this.IsLocked) + GUI.DragWindow(new Rect(0, 0, Styles.WindowWidth, Styles.WindowHeight)); + + GUILayout.Space(Styles.SpacingBelowPopout); + } + else + { + GUILayout.Space(Styles.SpacingAfterSection); + } + } + } +} \ No newline at end of file From 43d1a939522c99237512c0cd727b03764442a4fc Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Sun, 23 Apr 2023 23:52:51 +0200 Subject: [PATCH 31/38] Add changing of number of decimal digits Also: - rename MicroEntry to BaseEntry - move save/load/reset layout to Manager - Manager is making sure that every instance has an up-to-date version of windows and entries - reset layout now also rebuilds entries --- .../Entries/{MicroEntries.cs => BaseEntry.cs} | 13 ++- .../MicroEngineer/Entries/BodyEntries.cs | 6 +- .../MicroEngineer/Entries/FlightEntries.cs | 51 +++++++---- .../MicroEngineer/Entries/ManeuverEntries.cs | 60 ++++++++----- .../MicroEngineer/Entries/MiscEntries.cs | 21 +++-- .../Entries/OabStageInfoEntries.cs | 12 ++- .../MicroEngineer/Entries/OrbitalEntries.cs | 51 +++++++---- .../MicroEngineer/Entries/SurfaceEntries.cs | 27 ++++-- .../MicroEngineer/Entries/TargetEntries.cs | 81 ++++++++++++------ .../MicroEngineer/Entries/VesselEntries.cs | 54 ++++++++---- .../MicroEngineer/Managers/Manager.cs | 23 ++++- .../MicroEngineer/Managers/MessageManager.cs | 26 +++--- .../MicroEngineer/Managers/UI.cs | 39 +++++---- .../MicroEngineer/MicroEngineerMod.cs | 4 +- .../MicroEngineer/Utilities/Styles.cs | 7 +- .../MicroEngineer/Utilities/Utility.cs | 2 +- MicroEngineerProject/Other/Decimal digits.psd | Bin 0 -> 26350 bytes .../assets/images/decrease-decimal-19.png | Bin 0 -> 338 bytes .../assets/images/increase-decimal-19.png | Bin 0 -> 351 bytes 19 files changed, 321 insertions(+), 156 deletions(-) rename MicroEngineerProject/MicroEngineer/Entries/{MicroEntries.cs => BaseEntry.cs} (75%) create mode 100644 MicroEngineerProject/Other/Decimal digits.psd create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/decrease-decimal-19.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/increase-decimal-19.png diff --git a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs similarity index 75% rename from MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs rename to MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs index 9cce3c6..6b2ee22 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MicroEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs @@ -1,4 +1,6 @@ using Newtonsoft.Json; +using System.Xml; +using UnityEngine; namespace MicroMod { @@ -20,7 +22,14 @@ public class BaseEntry [JsonProperty] public string Unit; [JsonProperty] - public string Formatting; + public byte NumberOfDecimalDigits; + [JsonProperty("Formatting")] + private string _formatting; + public string Formatting + { + get => String.IsNullOrEmpty(_formatting) ? null : $"{{0:{_formatting}{this.NumberOfDecimalDigits}}}"; + set => _formatting = value; + } public virtual object EntryValue { get; set; } @@ -38,6 +47,8 @@ public virtual string ValueDisplay } } + + public virtual void RefreshData() { } } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs index 2d5340b..c34b147 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs @@ -33,7 +33,8 @@ public ReferenceBodyConstants_Radius() Category = MicroEntryCategory.Body; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -53,7 +54,8 @@ public ReferenceBodyConstants_StandardGravitationParameter() Category = MicroEntryCategory.Body; IsDefault = false; Unit = "μ"; - Formatting = "{0:e4}"; + NumberOfDecimalDigits = 4; + Formatting = "e"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index 01354a6..af3dd11 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -13,7 +13,8 @@ public Speed() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -33,7 +34,8 @@ public MachNumber() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = null; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -53,7 +55,8 @@ public GeeForce() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "g"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -73,7 +76,8 @@ public AngleOfAttack() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "°"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -93,7 +97,8 @@ public SideSlip() Category = MicroEntryCategory.Flight; IsDefault = false; Unit = "°"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -113,7 +118,8 @@ public Heading() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -133,7 +139,8 @@ public Pitch_HorizonRelative() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -153,7 +160,8 @@ public Roll_HorizonRelative() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -173,7 +181,8 @@ public Yaw_HorizonRelative() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -193,7 +202,8 @@ public Zenith() Category = MicroEntryCategory.Flight; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -213,7 +223,8 @@ public TotalLift() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "N"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -243,7 +254,8 @@ public TotalDrag() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "N"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -273,7 +285,8 @@ public LiftDivDrag() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = null; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -303,7 +316,8 @@ public DragCoefficient() Category = MicroEntryCategory.Flight; IsDefault = false; Unit = null; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -323,7 +337,8 @@ public ExposedArea() Category = MicroEntryCategory.Flight; IsDefault = false; Unit = null; // TODO - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -343,7 +358,8 @@ public AtmosphericDensity() Category = MicroEntryCategory.Flight; IsDefault = true; Unit = "g/L"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -363,7 +379,8 @@ public SoundSpeed() Category = MicroEntryCategory.Flight; IsDefault = false; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 3c515de..0f2f02d 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -18,7 +18,8 @@ public DeltaVRequired() Category = MicroEntryCategory.Maneuver; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -43,7 +44,8 @@ public ManeuverPrograde() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -64,7 +66,8 @@ public ManeuverNormal() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -85,7 +88,8 @@ public ManeuverRadial() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -166,7 +170,8 @@ public ProjectedAp() Category = MicroEntryCategory.Maneuver; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -189,7 +194,8 @@ public ProjectedPe() Category = MicroEntryCategory.Maneuver; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -276,7 +282,8 @@ public Maneuver_Inclination() Category = MicroEntryCategory.Maneuver; IsDefault = true; Unit = "°"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -299,7 +306,8 @@ public Maneuver_Eccentricity() Category = MicroEntryCategory.Maneuver; IsDefault = true; Unit = null; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -354,7 +362,8 @@ public Maneuver_TrueAnomaly() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "°"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -386,7 +395,8 @@ public Maneuver_MeanAnomaly() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -418,7 +428,8 @@ public Maneuver_EccentricAnomaly() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -450,7 +461,8 @@ public Maneuver_LongitudeOfAscendingNode() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -473,7 +485,8 @@ public Maneuver_ArgumentOfPeriapsis() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -496,7 +509,8 @@ public Maneuver_SemiLatusRectum() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -519,7 +533,8 @@ public Maneuver_SemiMajorAxis() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -542,7 +557,8 @@ public Maneuver_SemiMinorAxis() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -565,7 +581,8 @@ public Maneuver_OrbitalEnergy() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "kJ"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -588,7 +605,8 @@ public Maneuver_ObT() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -620,7 +638,8 @@ public Maneuver_OrbitPercent() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "%"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -643,7 +662,8 @@ public Maneuver_EndUT() Category = MicroEntryCategory.Maneuver; IsDefault = false; Unit = "s"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs index 028be8e..71f5e1a 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -28,7 +28,8 @@ public GravityForPos() Category = MicroEntryCategory.Misc; IsDefault = false; Unit = "ms2"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -48,7 +49,8 @@ public EndUT() Category = MicroEntryCategory.Misc; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -77,7 +79,8 @@ public StartUT() Category = MicroEntryCategory.Misc; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -106,7 +109,8 @@ public LaunchTime() Category = MicroEntryCategory.Misc; IsDefault = false; Unit = "s"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -135,7 +139,8 @@ public TimeSinceLaunch() Category = MicroEntryCategory.Misc; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -244,7 +249,8 @@ public UniversalTimeAtClosestApproach() Category = MicroEntryCategory.Misc; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -273,7 +279,8 @@ public UniversalTimeAtSoiEncounter() Category = MicroEntryCategory.Misc; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs index c838d97..704b564 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs @@ -19,7 +19,8 @@ public TotalBurnTime_OAB() Category = MicroEntryCategory.OAB; IsDefault = true; Unit = "s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; UseDHMSFormatting = true; } @@ -52,7 +53,8 @@ public TotalDeltaVASL_OAB() Category = MicroEntryCategory.OAB; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() { @@ -71,7 +73,8 @@ public TotalDeltaVActual_OAB() Category = MicroEntryCategory.OAB; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() { @@ -90,7 +93,8 @@ public TotalDeltaVVac_OAB() Category = MicroEntryCategory.OAB; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() { diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 2ded6a5..07474e8 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -15,7 +15,8 @@ public Apoapsis() Category = MicroEntryCategory.Orbital; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -35,7 +36,8 @@ public Periapsis() Category = MicroEntryCategory.Orbital; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -113,7 +115,8 @@ public Inclination() Category = MicroEntryCategory.Orbital; IsDefault = true; Unit = "°"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -133,7 +136,8 @@ public Eccentricity() Category = MicroEntryCategory.Orbital; IsDefault = true; Unit = null; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -182,7 +186,8 @@ public OrbitalSpeed() Category = MicroEntryCategory.Orbital; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -202,7 +207,8 @@ public TrueAnomaly() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "°"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -231,7 +237,8 @@ public MeanAnomaly() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -260,7 +267,8 @@ public EccentricAnomaly() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -289,7 +297,8 @@ public LongitudeOfAscendingNode() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -309,7 +318,8 @@ public ArgumentOfPeriapsis() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -329,7 +339,8 @@ public SemiLatusRectum() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -349,7 +360,8 @@ public SemiMajorAxis() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -369,7 +381,8 @@ public SemiMinorAxis() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -389,7 +402,8 @@ public OrbitalEnergy() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "kJ"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -409,7 +423,8 @@ public ObT() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -438,7 +453,8 @@ public OrbitPercent() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "%"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -458,7 +474,8 @@ public OrbitRadius() Category = MicroEntryCategory.Orbital; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index 5db5970..8e0d935 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -15,7 +15,8 @@ public AltitudeAgl() Category = MicroEntryCategory.Surface; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -35,7 +36,8 @@ public AltitudeAsl() Category = MicroEntryCategory.Surface; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -55,7 +57,8 @@ public AltitudeFromScenery() Category = MicroEntryCategory.Surface; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -75,7 +78,8 @@ public VerticalVelocity() Category = MicroEntryCategory.Surface; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -95,7 +99,8 @@ public HorizontalVelocity() Category = MicroEntryCategory.Surface; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -231,7 +236,8 @@ public DynamicPressure_kPa() Category = MicroEntryCategory.Surface; IsDefault = false; Unit = "kPa"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -251,7 +257,8 @@ public StaticPressure_kPa() Category = MicroEntryCategory.Surface; IsDefault = false; Unit = "kPa"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -271,7 +278,8 @@ public AtmosphericTemperature() Category = MicroEntryCategory.Surface; IsDefault = false; Unit = "K"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -291,7 +299,8 @@ public ExternalTemperature() Category = MicroEntryCategory.Surface; IsDefault = false; Unit = "K"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 1c2a872..4ce1c5a 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -34,7 +34,8 @@ public TargetApoapsis() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -54,7 +55,8 @@ public TargetPeriapsis() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -74,7 +76,8 @@ public DistanceToTarget() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -105,7 +108,8 @@ public RelativeSpeed() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -138,7 +142,8 @@ public RelativeInclination() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "°"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -171,7 +176,8 @@ public Target_AltitudeFromSeaLevel() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -191,7 +197,8 @@ public Target_Inclination() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "°"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -211,7 +218,8 @@ public Target_Eccentricity() Category = MicroEntryCategory.Target; IsDefault = false; Unit = null; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -260,7 +268,8 @@ public Target_Obtvelocity() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -280,7 +289,8 @@ public Target_TrueAnomaly() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "°"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -309,7 +319,8 @@ public Target_MeanAnomaly() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -338,7 +349,8 @@ public Target_EccentricAnomaly() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -367,7 +379,8 @@ public Target_LongitudeOfAscendingNode() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -387,7 +400,8 @@ public Target_ArgumentOfPeriapsis() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -407,7 +421,8 @@ public Target_SemiLatusRectum() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -427,7 +442,8 @@ public Target_SemiMajorAxis() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -447,7 +463,8 @@ public Target_SemiMinorAxis() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -467,7 +484,8 @@ public Target_ObT() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "s"; - Formatting = "{0:N3}"; + NumberOfDecimalDigits = 3; + Formatting = "N"; } public override void RefreshData() @@ -496,7 +514,8 @@ public Target_ReferenceBodyConstants_Radius() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -516,7 +535,8 @@ public Target_ReferenceBodyConstants_StandardGravitationParameter() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "μ"; - Formatting = "{0:e4}"; + NumberOfDecimalDigits = 4; + Formatting = "e"; } public override void RefreshData() @@ -536,7 +556,8 @@ public Target_OrbitRadius() Category = MicroEntryCategory.Target; IsDefault = false; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -556,7 +577,8 @@ public PhaseAngle() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -576,7 +598,8 @@ public TransferAngle() Category = MicroEntryCategory.Target; IsDefault = true; Unit = "°"; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -597,7 +620,8 @@ public DistanceAtCloseApproach1() IsDefault = true; HideWhenNoData = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -652,7 +676,8 @@ public RelativeSpeedAtCloseApproach1() IsDefault = true; HideWhenNoData = true; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -675,7 +700,8 @@ public DistanceAtCloseApproach2() IsDefault = false; HideWhenNoData = true; Unit = "m"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -730,7 +756,8 @@ public RelativeSpeedAtCloseApproach2() IsDefault = false; HideWhenNoData = true; Unit = "m/s"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 706f267..7558f83 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -33,7 +33,8 @@ public Mass() Category = MicroEntryCategory.Vessel; IsDefault = true; Unit = "kg"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -53,7 +54,8 @@ public TotalDeltaVActual() Category = MicroEntryCategory.Vessel; IsDefault = true; Unit = "m/s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -73,7 +75,8 @@ public TotalDeltaVASL() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "m/s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -94,7 +97,8 @@ public TotalDeltaVVac() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "m/s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -114,7 +118,8 @@ public TotalBurnTime() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -143,7 +148,8 @@ public StageThrustActual() Category = MicroEntryCategory.Vessel; IsDefault = true; Unit = "N"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -163,7 +169,8 @@ public StageThrustASL() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "N"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -183,7 +190,8 @@ public StageThrustVac() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "N"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -203,7 +211,8 @@ public StageTWRActual() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = null; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -223,7 +232,8 @@ public StageTWRASL() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = null; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -243,7 +253,8 @@ public StageTWRVac() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = null; - Formatting = "{0:N2}"; + NumberOfDecimalDigits = 2; + Formatting = "N"; } public override void RefreshData() @@ -263,7 +274,8 @@ public StageISPActual() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -283,7 +295,8 @@ public StageISPAsl() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -303,7 +316,8 @@ public StageISPVac() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "s"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -323,7 +337,8 @@ public FuelPercentage() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "%"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -343,7 +358,8 @@ public StageFuelPercentage() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "%"; - Formatting = "{0:N1}"; + NumberOfDecimalDigits = 1; + Formatting = "N"; } public override void RefreshData() @@ -383,7 +399,8 @@ public Throttle() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = "%"; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() @@ -403,7 +420,8 @@ public TotalCommandCrewCapacity() Category = MicroEntryCategory.Vessel; IsDefault = false; Unit = null; - Formatting = "{0:N0}"; + NumberOfDecimalDigits = 0; + Formatting = "N"; } public override void RefreshData() diff --git a/MicroEngineerProject/MicroEngineer/Managers/Manager.cs b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs index 8fab538..8ec5423 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/Manager.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs @@ -9,7 +9,9 @@ internal class Manager { internal List Windows; internal List Entries; - private MicroEngineerMod _plugin; + internal UI UI; + internal MessageManager MessageManager; + private MicroEngineerMod _plugin; private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Manager"); @@ -286,5 +288,24 @@ internal int CreateCustomWindow(List editableWindows) return editableWindows.Count - 1; } + + internal void ResetLayout() + { + Windows.Clear(); + Entries.Clear(); + Entries = InitializeEntries(); + Windows = InitializeWindows(); + UI.Windows = Windows; + MessageManager.Windows = Windows; + } + + internal void LoadLayout() + { + Utility.LoadLayout(Windows); + UI.Windows = Windows; + MessageManager.Windows = Windows; + } + + internal void SaveLayout() => Utility.SaveLayout(Windows); } } diff --git a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs index f932b8e..5e7d397 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs @@ -9,7 +9,7 @@ internal class MessageManager MicroEngineerMod _plugin; private Manager _manager; private UI _ui; - private List _windows; + internal List Windows; private static readonly ManualLogSource _logger = Logger.CreateLogSource("MicroEngineer.MessageManager"); @@ -18,7 +18,7 @@ internal MessageManager(MicroEngineerMod plugin, Manager manager, UI ui) _plugin = plugin; _manager = manager; _ui = ui; - _windows = _manager.Windows; + Windows = _manager.Windows; SubscribeToMessages(); } @@ -51,21 +51,21 @@ internal void SubscribeToMessages() private void OnManeuverCreatedMessage(MessageCenterMessage message) { - var maneuverWindow = _windows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; + var maneuverWindow = Windows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; maneuverWindow.OnManeuverCreatedMessage(message); } private void OnManeuverRemovedMessage(MessageCenterMessage message) { - var maneuverWindow = _windows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; + var maneuverWindow = Windows.Find(w => w.GetType() == typeof(ManeuverWindow)) as ManeuverWindow; maneuverWindow.OnManeuverRemovedMessage(message); } private void OnPartManipulationCompletedMessage(MessageCenterMessage obj) { - EntryWindow stageInfoOabWindow = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); + EntryWindow stageInfoOabWindow = Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); - Torque torque = (Torque)_windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Torque"); + Torque torque = (Torque)Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).Entries.Find(e => e.Name == "Torque"); torque.RefreshData(); } @@ -76,16 +76,16 @@ private void GameStateEntered(MessageCenterMessage obj) Utility.RefreshGameManager(); if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView) { - Utility.LoadLayout(_windows); - _manager.Windows = _windows; - _ui.Windows = _windows; + Utility.LoadLayout(Windows); + _manager.Windows = Windows; + _ui.Windows = Windows; if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) - _ui.ShowGuiFlight = _windows.OfType().FirstOrDefault().IsFlightActive; + _ui.ShowGuiFlight = Windows.OfType().FirstOrDefault().IsFlightActive; if (Utility.GameState.GameState == GameState.VehicleAssemblyBuilder) { - _ui.ShowGuiOAB = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive; + _ui.ShowGuiOAB = Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive; _ui.CelestialBodies.GetBodies(); _ui.CelestialBodySelectionStageIndex = -1; } @@ -99,7 +99,7 @@ private void GameStateLeft(MessageCenterMessage obj) Utility.RefreshGameManager(); if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView) { - Utility.SaveLayout(_windows); + Utility.SaveLayout(Windows); if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView) _ui.ShowGuiFlight = false; @@ -123,7 +123,7 @@ private void RefreshStagingDataOAB(MessageCenterMessage obj) Utility.RefreshStagesOAB(); - EntryWindow stageWindow = _windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); + EntryWindow stageWindow = Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); if (Utility.VesselDeltaVComponentOAB?.StageInfo == null) { diff --git a/MicroEngineerProject/MicroEngineer/Managers/UI.cs b/MicroEngineerProject/MicroEngineer/Managers/UI.cs index 28cb878..59d0f2d 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/UI.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/UI.cs @@ -162,15 +162,15 @@ private void DrawSettingsFlightWindow(int id) GUILayout.Space(10); GUILayout.Label("Layout control"); if (GUILayout.Button("SAVE LAYOUT", Styles.NormalBtnStyle)) - Utility.SaveLayout(Windows); + _manager.SaveLayout(); GUILayout.Space(5); if (GUILayout.Button("LOAD LAYOUT", Styles.NormalBtnStyle)) - { - Utility.LoadLayout(Windows); - _manager.Windows = Windows; - } + _manager.LoadLayout(); if (GUILayout.Button("RESET LAYOUT", Styles.NormalBtnStyle)) - ResetLayout(); + { + _manager.ResetLayout(); + _selectedWindowId = 0; + } GUILayout.Space(10); GUILayout.Label("Theme"); @@ -480,16 +480,27 @@ private void DrawEditWindow(int windowIndex) { GUILayout.BeginHorizontal(); GUILayout.Label(entry.Name, Styles.NameLabelStyle); + GUI.enabled = entry.NumberOfDecimalDigits < 5; + if (entry.Formatting != null && GUILayout.Button(Styles.IncreaseDecimalDigitsTexture, Styles.OneCharacterBtnStyle)) + { + entry.NumberOfDecimalDigits++; + } + GUI.enabled = entry.NumberOfDecimalDigits > 0; + if (entry.Formatting != null && GUILayout.Button(Styles.DecreaseDecimalDigitsTexture, Styles.OneCharacterBtnStyle)) + { + entry.NumberOfDecimalDigits--; + } + GUI.enabled = index > 0; if (GUILayout.Button("↑", Styles.OneCharacterBtnStyle)) { - if (index > 0) - editableWindows[_selectedWindowId].MoveEntryUp(index); + editableWindows[_selectedWindowId].MoveEntryUp(index); } + GUI.enabled = index < editableWindows[_selectedWindowId].Entries.Count - 1; if (GUILayout.Button("↓", Styles.OneCharacterBtnStyle)) { - if (index < editableWindows[_selectedWindowId].Entries.Count - 1) - editableWindows[_selectedWindowId].MoveEntryDown(index); + editableWindows[_selectedWindowId].MoveEntryDown(index); } + GUI.enabled = true; if (GUILayout.Button("X", Styles.OneCharacterBtnStyle)) editableWindows[_selectedWindowId].RemoveEntry(index); GUILayout.EndHorizontal(); @@ -718,13 +729,7 @@ private bool SettingsButton(Rect rect) } #endregion - - private void ResetLayout() - { - Windows = _manager.InitializeWindows(); - _selectedWindowId = 0; - } - + private void CloseWindow() { GameObject.Find("BTN-MicroEngineerBtn")?.GetComponent()?.SetValue(false); diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs index 4fdd744..aacc6f7 100644 --- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs +++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs @@ -21,8 +21,10 @@ public override void OnInitialized() Styles.Initialize(this); _manager = new Manager(this); - _ui = new UI(this, _manager); + _ui = new UI(this, _manager); _messagesManager = new MessageManager(this, _manager, _ui); + _manager.UI = _ui; + _manager.MessageManager = _messagesManager; BackwardCompatibilityInitializations(); diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs index aa25c3f..be91032 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs @@ -97,6 +97,8 @@ public static class Styles public static Texture2D EntryBackgroundTexture_BlackTheme_First; public static Texture2D EntryBackgroundTexture_BlackTheme_Middle; public static Texture2D EntryBackgroundTexture_BlackTheme_Last; + public static Texture2D IncreaseDecimalDigitsTexture; + public static Texture2D DecreaseDecimalDigitsTexture; private static Color _nameColor_DarkThemes = new Color(.7f, .75f, .75f, 1); private static Color _valueColor_DarkThemes = new Color(.6f, .7f, 1, 1); @@ -292,7 +294,7 @@ private static void InitializeStyles() fixedHeight = 19, alignment = TextAnchor.MiddleCenter, margin = new RectOffset(0, 5, 9, 0), - padding = new RectOffset(0, 0, 3, 0) + padding = new RectOffset(0, 0, 0, 0) }; OneCharacterHighBtnStyle = new GUIStyle(SpaceWarpUISkin.button) @@ -347,6 +349,9 @@ private static void InitializeTextures() EntryBackground_BlackTheme_Middle.normal.background = EntryBackgroundTexture_BlackTheme_Middle; EntryBackground_BlackTheme_Last = new GUIStyle { name = "BlackLast" }; EntryBackground_BlackTheme_Last.normal.background = EntryBackgroundTexture_BlackTheme_Last; + + IncreaseDecimalDigitsTexture = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/increase-decimal-19.png"); + DecreaseDecimalDigitsTexture = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/decrease-decimal-19.png"); } public static void SetActiveTheme(Theme theme) diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs index 24c2952..7d13b84 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs @@ -18,7 +18,7 @@ public static class Utility public static VesselComponent ActiveVessel; public static ManeuverNodeData CurrentManeuver; public static string LayoutPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MicroLayout.json"); - public static int CurrentLayoutVersion = 6; + public static int CurrentLayoutVersion = 9; private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Utility"); public static GameStateConfiguration GameState; public static MessageCenter MessageCenter; diff --git a/MicroEngineerProject/Other/Decimal digits.psd b/MicroEngineerProject/Other/Decimal digits.psd new file mode 100644 index 0000000000000000000000000000000000000000..691ad76791330776b052d81568c1f5bd0a01a3b6 GIT binary patch literal 26350 zcmeHQ32+?MnSOKVKCH`YM-(u~HV|Mmhi0UakYww$w6QE9$u^|62tD0Bqp^FshwdI( za+z9V4j1ft2@XeKu_5M;E6Kuc0tr-YaJZJ;4Iu#xWXT2$OBRa55Ec@=p8fyV#~eD` z;acxj_f+@$-~ayizxTfW-`{_C>$M`iV-v(dw9O4kJ>5%*OJnuFAL$()aj&Ae8jY7d z(z2D9Z+oM2^-PLkxA3Yb%EuF8SJS%>{bQ3S!F4rl3Xk|lQhoeXVrZMpPi$L1$!^=i zwsTFZyUROgI%bloB(E}_nWP{p9Wz}`3@1hT4xo|kYw}PLbxT)M4;FaN9~txXNiy#V zH@AA(Kq%sAYi|y;hWst9=XiqtK)cT$@daAE{y>MnwIkf-(YL1Va-ce8F4i&LKd3hc zxvr)uRZVsHd|S6}ZQk0_EXi?SpuHW`1bxAv7bLvOtf(?GUQt=0DKYf)^9m~`QffjH zJ*bz7N@=yLsRBxv#b>8NZ$$4uk>cBLNKu2WWn#$yCiuaB4ijkj!-_a-Yj4H{Kk|cC%=Y7o3=LrH{o-;QkL{8eOe6`b8D4&Ht ztBUVuRK7dt4}xKYyup^qV4x!$?(hfC_6Ixs{v0KmWPy$mFh!10nfbM}wB>5alP%OE zaf#ThB`sOW9333n5tHO3qjoc?l#pNwg{BVCa zFq#tyu7eNpTw5R*_O`I$fVVXqihA24{)m^4g`@5MmM|Y<+9*gPBe~V*sP328G#aO_ zngi7V#vkUQ{x)x0fQx!V!4Tt(g!zEiAB%)IE*uWAk$|B(r}`Y#qjCZq3nS#nVDJCb zCgxEyr>UWY0>(F+W0YW;)OAeo7w2=00wF}Jv0d9Kr!$IW)jtf^N^%sqkDP}cP4RA0D_ty8?X*o4tkQK^NMC{j$_%E)|A9Bksa z6IoN4U#C!arw=`?koW@5g2GIHwsT-@5`E@#kaaizOXnbKzw8tv#(A#WXPBoheRjSEo#1Ry>$0-0k`=B)cX zi9%pLPu-?2yAcx#D})V~6_iXF8!i(HD})V~6_iXF8!i(HD})V~6_iXF8!i(HD})V~ z6_iXF8!i(HD})V~6_iXF8!i(HD})V~6_iXF8!i(HD})V~6_iXF8!i(HD})V~6_iXF z8!i(HD})V~6_iXF8!i(HD})V~6_iXF8!i(HD})V~6_iXF8!i(HD})V~6_iXF8!i(H zD})V~6_iXF8!i(HD})V~6_iXF8!i(HD})V~6_iXF8!i(HD})V~6_iXF8!i(HD})V~ z6_iXF8!i(HD})V~6_iXF8!i(HD})V~6_iXF8!i(HE5xF3m1o!V@ggkb+X^f82wn5n zLDvAj4o6%QsI4EYNXZFN9ZjpLveH=$x3EY@`L@_Hu8PY#?v2`sHKt-_crNwEoDO{Yeqn^`EVBx6J-68vJsLna7M zRFWnsR7J{DrZnWJnqEN_^&VA5(+NRMh*Tw%mr?1ykqf@2jrd$t;q<~GJL0;W5s%VU zfC`i^L&?6BDjI`;K}KaWGagq)%uJsw_GL4on$4_>3W`~>KCVuinSrFxZ)O0;tmF65ix7b6vt(C<&yk23hT(8VcZV=VM72^V)TXX9b zIM00iaYaxme{4orGj58PPxCCStAgckuu@XDim~{ZVps*zC=4lfo2=twnwo-UC#BT9 z%}%g_#vhZ}H5Z@;y4A322<#DdK-q!j+h9GsoPfzJQI-QnP>y1LPdIzEQ=6Z+nswyXCMpR%? z885Q4nk6o!C8xl#icEsFGejf`*f;|;4>U_=H689Sm8^v$m_sH*bA)gXP0z_Rk86Il ze3hC1I_=w6%={^I93Rkp89l;5({hHkCb%41pqqoren{yd;)}(gM1W(lR;qKpbJNWx zCkQ1D@^v^GGT3hi!MUb$sLqcePjD`0=G|Ps!{T|1GM}Z4Vu7k*`V%@jx0B|w$oaKW zhgORH#-1Z0Zd$vPa&*7pTmy<=*HOpw2y%F!vW-Z&&Vz$CcFY>9vI(gs{cw(1k|0Sq z-vaRv4(K@SD%b!$&s0A5V4NA`)$4n1Iqhg312TGNku9bL^u;*nVp!iSa!P@ZVbuVX z(IMc(G_4<)1+$0rW@j08g^Xt>5$1~(SklTX8-;arFnR41(J~OKgS~`ihWm5cDv8Td zI+e#NmgtI6!^00upmuHfC+MhR(yFwU7kL?%UIK&QvQ1sMToXnPmJBE39!S3E@w;G= zciv@=f}hVBQR4ZR!eT~HCz*JjR5i;B!X!VV4l6^GBkK%jTWYZLgv+KRd0UT=h#S|! zCEDPJ3^t6sgo6dZY3lsTrg>SNM|`8f&KIwU#_3|c9B^wj{k?0=0;odPOCn-jrb;OY zA{0K?yOs;!hUaiAqttEB;a9+EpDGlmv+GQ32%-cq=hg2~TAOv~BVqRFp0R=E(4dQH zEtDtDK{()CGUiYx*gRYeooA8d#F2R+^ERoZ3)R2TH$t45cStqO5pD<8%lw*LPAW@F zOUp_t%gQQiE6OWsmoBNST(Wd|ef`q<`sKBibkh?pQ+RY#Ra8_}SJhNk*ECdDS2y6H zx_Exs z;e)?~PTanX8`#jQ@~@g*ShxpgWV?`giB!61o3&&$`EYX2@T#w_+%r6y`NfBmH$HXm z%DdmZgC?05sYRVe0p0{husH~SNe?)3iA2G}W3Gpk!yr^jT(NKb`W<0~&@j$yC# z9WRJA#7(291GHKz^#-jJmsUhvgby=h0BE>vp_daNz~5kv@Y zAQbd6;g(i!l#8~)2P8s#dyLi9qH1hZ3)6rwwlysVrKLvRNR85he0BhC_>@5kq%a6B zLwZ7;6^xJ}%Yf2yEbRjzq@*FckrC2#pujM;B`7w=%SsAvLK5)x0l>j1gS4TbcvPL@ z{89`{pSJJ$R1Gle{uD zCc!NoM5H}vmf15^1wkErSc4I0ITTT2KtMK#gTe~9E!D*#A!N-;nvgYUudw9~i{`(; z@{O{}&etc}k$DbgUyVK$rp6c+O7&A_jIl7){KABU^RIY^BCYF(PPk#uf@|Co(5Pvc z6IDH&Tm{}J2EP^(Apy7;wStFYNeF24Rmckg*9+b&3^G_61rHVlDg<&7IP#<&>f=O) z#!~{r@|>x=owR{u8^}c0=;7jk$x)oNgSEWJQ#y5R}KdgFGV znvx0=NEl<{yrLT`a!DUN9>~d;#bkI6HKFqP7HYtOCRPT|xA2BSGK?P8RB*f~CE?RG zCfj*FuuHkLW~F)d{%N(9)6Vt54Vn=+(;@VTW*$!_>c8{Qwmmu;1#GrQ*Kp8}rk6FmXwHQWMHVYR z@jN;q6WctVJi{krqUwQxP$#g7Q>O|p-DGI)<(!z0b%DrvtV`fKcGOSe(>KsriuqwN zCgr!7`yh!*(8o7=ooek_4I}hnU9$w^%h(JJx~TgC?YY~Z9G#a#?N1S%Lr{L)=v<4% zKW%hQpA??>(fRH3N9SxL))wJnA#bED==VliLOgywj`4DVAj1aRB5W(u4#?vb33oh| z)bJoRH{0-Vb1r{qm@q9UY#7`NWV~ic65i|#B z2x8<2jT=PfuRY>!U;f^k^PW24Msc6ikkbKcAU0!TjSpnJ08G-R`E>e!a>7le8W@ z>Hij(7)6aSs*2-AS`fDcVbGNn2jX-Hi9vksSz`6Q!_wouoFUEdrz;}-sRl`jar&2e zT2t`K3W)4YjPdvnxu4^G^i^Z)*H)D`;_YwM@KFCaq^ICs3h&Rzx&H6(homeubOHR` zMFqUzuBdmAn{QbT%x8!DdnRXYdHcGN>Ye_YD=wIIU3KBW!~6C>QMdo`Td!|^n9S^c zI#gM9^Oe(o_uzg1F5cXB$*)>38Lqpk^r!9@oTH7KJ#B9_?ryy3vb{eXynXPlwsY?I z`AZXt(B_w(`Q-WSq0Re`_)_1H#t+0ll34lSR~*j2xOn1k znC(aW&5!%{IUo4>hNt(Aoc7n=cek(aEW7@>dmsKN!0jtxhW4#JwriQ|p{^INx#!S9 z7#|rPSl|Es-ivkuiI~sX93PpsVDT<@DFnXwM>-2W3Rut+R@RVT-J>>`eH3JX5 zUwrk2k8SJv-h~GS+;9E)vI}qfuyM5a?wXaS@2&aCFCKpR@~4lkd-CZ1Cpq^;j$3vt zb9If~r0gE7NAymF{}#=I^#to$Pq^Id0E4I}cpi_@Lv!j^^Y>*QUgK@7;99 z)0;0U`?ov)ss4rS&pcLA`m@F>rvCDYnO7%%@J3L){?@a*4TkZcqU*O;#-<*{)4h-d=zd`UWsn{mQMLdHK7u~wLUs`OEWAVo<3U|>=P~_zxs9?S z&igD3pI;Rvna$?w0yKakcvWCB@G*%imYC6>*+UNIsRDm%qrmGeYdV(}>O>_uIx7n!KQSY!(!4)@UbDPoJglqlB^oCS|34knW7hPkf}4ILF+;lmgrsSPbk=BZn2B{ zLLtKE#9sn`27#j>_akcgH|y PX3sHFtOt153jY2Fv|=s! literal 0 HcmV?d00001 diff --git a/Staging/BepInEx/plugins/micro_engineer/assets/images/decrease-decimal-19.png b/Staging/BepInEx/plugins/micro_engineer/assets/images/decrease-decimal-19.png new file mode 100644 index 0000000000000000000000000000000000000000..749a41dff42c3e65939dfd33314e14a97a1cca5e GIT binary patch literal 338 zcmV-Y0j>UtP)XYj|DMb}Iir7QK=f6cTqexfNfpl8 z_BG(rnpzKFQ|>Lhel7#c>>YS;el`MZ#dSCC=Q&I53)a$&q*j<`!ku=UslwTkwKV5? k3)lw|V7Jo0`A1FCCo3g+_2l~Fwg3PC07*qoM6N<$g0qL1c>n+a literal 0 HcmV?d00001 diff --git a/Staging/BepInEx/plugins/micro_engineer/assets/images/increase-decimal-19.png b/Staging/BepInEx/plugins/micro_engineer/assets/images/increase-decimal-19.png new file mode 100644 index 0000000000000000000000000000000000000000..cacdc4d1fab588e8245bd5550451c876090b73e5 GIT binary patch literal 351 zcmV-l0igbgP)K`ZC}4?6~UOUf@4URVp;Q1}=>cfP3T2mU0~Hhknt& z+@ha5vA(F;mg9!+D)WVq x&kuLpu~DU2=G*qD)f%u5Bw%--fAf!;q%WHUR(*o~3S|HQ002ovPDHLkV1hvZo`?Vd literal 0 HcmV?d00001 From 6e2d65d8e0e98a08a86c727fb110684d70ebf094 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Mon, 24 Apr 2023 15:35:12 +0200 Subject: [PATCH 32/38] Add Settings button on each window - Add new textures for close button, settings button, pop out button - Clicking on each settings button opens edit window with that section/window selected - Move Pop out button to the right of the section --- .../MicroEngineer/Managers/UI.cs | 129 +++++++++--------- .../MicroEngineer/Utilities/Styles.cs | 124 +++++++++++------ .../MicroEngineer/Windows/ManeuverWindow.cs | 4 +- .../MicroEngineer/Windows/StageWindow.cs | 14 +- ...er_BackgroundStyles.psd => background.psd} | Bin MicroEngineerProject/Other/close-15.png | Bin 0 -> 196 bytes MicroEngineerProject/Other/close-15.psd | Bin 0 -> 30450 bytes .../{Decimal digits.psd => decimalDigits.psd} | Bin MicroEngineerProject/Other/popout-15.png | Bin 0 -> 348 bytes MicroEngineerProject/Other/popout-15.psd | Bin 0 -> 20160 bytes MicroEngineerProject/Other/settings-15.png | Bin 0 -> 429 bytes MicroEngineerProject/Other/settings-15.psd | Bin 0 -> 23269 bytes MicroEngineerProject/Other/settings-30.psd | Bin 0 -> 23308 bytes .../micro_engineer/assets/images/close-15.png | Bin 0 -> 196 bytes .../assets/images/popout-15.png | Bin 0 -> 348 bytes .../assets/images/settings-15.png | Bin 0 -> 429 bytes .../{settings-30.png => settings-20.png} | Bin 17 files changed, 161 insertions(+), 110 deletions(-) rename MicroEngineerProject/Other/{MicroEngineer_BackgroundStyles.psd => background.psd} (100%) create mode 100644 MicroEngineerProject/Other/close-15.png create mode 100644 MicroEngineerProject/Other/close-15.psd rename MicroEngineerProject/Other/{Decimal digits.psd => decimalDigits.psd} (100%) create mode 100644 MicroEngineerProject/Other/popout-15.png create mode 100644 MicroEngineerProject/Other/popout-15.psd create mode 100644 MicroEngineerProject/Other/settings-15.png create mode 100644 MicroEngineerProject/Other/settings-15.psd create mode 100644 MicroEngineerProject/Other/settings-30.psd create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/close-15.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/popout-15.png create mode 100644 Staging/BepInEx/plugins/micro_engineer/assets/images/settings-15.png rename Staging/BepInEx/plugins/micro_engineer/assets/images/{settings-30.png => settings-20.png} (100%) diff --git a/MicroEngineerProject/MicroEngineer/Managers/UI.cs b/MicroEngineerProject/MicroEngineer/Managers/UI.cs index 59d0f2d..e752a98 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/UI.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/UI.cs @@ -149,10 +149,11 @@ private void OnGUI_Flight() private void DrawSettingsFlightWindow(int id) { - if (CloseButton(Styles.CloseBtnRect)) - _showGuiSettingsFlight = false; - + GUILayout.BeginHorizontal(); GUILayout.Label("// SETTINGS"); + GUILayout.FlexibleSpace(); + _showGuiSettingsFlight = !CloseButton(Styles.CloseBtnStyle); + GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label("Edit window entries"); @@ -162,7 +163,10 @@ private void DrawSettingsFlightWindow(int id) GUILayout.Space(10); GUILayout.Label("Layout control"); if (GUILayout.Button("SAVE LAYOUT", Styles.NormalBtnStyle)) + { _manager.SaveLayout(); + _showGuiSettingsFlight = false; + } GUILayout.Space(5); if (GUILayout.Button("LOAD LAYOUT", Styles.NormalBtnStyle)) _manager.LoadLayout(); @@ -176,7 +180,7 @@ private void DrawSettingsFlightWindow(int id) GUILayout.Label("Theme"); GUILayout.Space(-10); - GUILayout.BeginHorizontal(); + GUILayout.BeginHorizontal(); var settingsWindow = Windows.Find(w => w.GetType() == typeof(SettingsWIndow)) as SettingsWIndow; if (GUILayout.Toggle(Styles.ActiveTheme == Theme.munix, "munix", Styles.SectionToggleStyle)) { @@ -266,22 +270,21 @@ private void FillMainGUI(int windowID) { List entryWindows = Windows.FindAll(w => w is EntryWindow).Cast().ToList(); - if (SettingsButtonOnMainGui(Styles.SettingsMainBtnBtnRect)) + GUILayout.Space(-15); + GUILayout.BeginHorizontal(); + if (GUILayout.Button(Styles.Settings20Texture, Styles.SettingsMainGuiBtnStyle)) { Rect mainGuiRect = Windows.OfType().FirstOrDefault().FlightRect; settingsFlightRect = new Rect(mainGuiRect.x - Styles.WindowWidthSettingsFlight, mainGuiRect.y, Styles.WindowWidthSettingsFlight, 0); _showGuiSettingsFlight = !_showGuiSettingsFlight; } + GUILayout.FlexibleSpace(); + if (CloseButton(Styles.CloseMainGuiBtnStyle)) + CloseWindow(); + GUILayout.EndHorizontal(); try { - if (CloseButton(Styles.CloseBtnRect)) - { - CloseWindow(); - } - - GUILayout.Space(5); - GUILayout.BeginHorizontal(); int toggleIndex = -1; @@ -297,7 +300,7 @@ private void FillMainGUI(int windowID) window.IsFlightActive = GUILayout.Toggle(window.IsFlightActive, window.Abbreviation, Styles.SectionToggleStyle); } GUILayout.EndHorizontal(); - GUILayout.Space(5); + GUILayout.Space(-5); // Draw Stage window next StageWindow stageWindow = entryWindows.OfType().FirstOrDefault(); @@ -319,10 +322,9 @@ private void FillMainGUI(int windowID) if (window.MainWindow == MainWindow.Maneuver && !Utility.ManeuverExists()) continue; - DrawSectionHeader(window.Name, ref window.IsFlightPoppedOut, window.IsLocked, ""); + DrawSectionHeader(window.Name, ref window.IsFlightPoppedOut, window.IsLocked); window.DrawWindowHeader(); - GUILayout.Space(10); for (int i = 0; i < window.Entries.Count; i++) { @@ -354,10 +356,10 @@ private void DrawPopoutWindow(int windowIndex) List entryWindows = Windows.FindAll(w => w is EntryWindow).Cast().ToList(); EntryWindow w = Windows.FindAll(w => w is EntryWindow).Cast().ToList()[windowIndex]; - DrawSectionHeader(w.Name, ref w.IsFlightPoppedOut, w.IsLocked, ""); - + GUILayout.Space(-5); + DrawSectionHeader(w.Name, ref w.IsFlightPoppedOut, w.IsLocked); + w.DrawWindowHeader(); - GUILayout.Space(10); for (int i = 0; i < w.Entries.Count; i++) { @@ -370,34 +372,43 @@ private void DrawPopoutWindow(int windowIndex) w.DrawWindowFooter(); DrawSectionEnd(w); - } + } - private void DrawSectionHeader(string sectionName, ref bool isPopout, bool isLocked, string value = "") + private void DrawSectionHeader(string sectionName, ref bool isPopout, bool isLocked) { + GUILayout.Space(10); GUILayout.BeginHorizontal(); // If window is popped out and it's not locked => show the close button. If it's not popped out => show to popup arrow - isPopout = isPopout && !isLocked ? !CloseButton(Styles.CloseBtnRect) : !isPopout ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : isPopout; + //isPopout = isPopout && !isLocked ? !CloseButton(Styles.CloseBtnRect) : !isPopout ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : isPopout; + //isPopout = isPopout && !isLocked ? !CloseButton(Styles.CloseBtnRect) : !isPopout ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : isPopout; - GUILayout.Label($"{sectionName}"); - GUILayout.FlexibleSpace(); - GUILayout.Label(value, Styles.ValueLabelStyle); - GUILayout.Space(5); - GUILayout.Label("", Styles.UnitLabelStyle); + GUILayout.Label($"{sectionName}", Styles.WindowTitleLabelStyle); + GUILayout.FlexibleSpace(); + if(GUILayout.Button(Styles.Settings15Texture, Styles.SettingsBtnStyle)) + { + _selectedWindowId = Windows. + FindAll(w => w is EntryWindow).Cast().ToList(). + FindAll(w => w.IsEditable). + FindIndex(w => w.Name == sectionName); + _showEditWindow = true; + } + isPopout = isPopout && !isLocked ? !CloseButton(Styles.CloseBtnStyle) : !isPopout ? GUILayout.Button(Styles.PopoutTexture, Styles.PopoutBtnStyle) : isPopout; GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterHeader); + + GUILayout.Space(Styles.NegativeSpacingAfterHeader); } - private void DrawEntry(GUIStyle horizontalStyle, string entryName, string value, string unit = "") + private void DrawEntry(GUIStyle backgroundTexture, string entryName, string value, string unit = "") { - GUILayout.BeginHorizontal(horizontalStyle); + GUILayout.BeginHorizontal(backgroundTexture); GUILayout.Label(entryName, Styles.NameLabelStyle); GUILayout.FlexibleSpace(); GUILayout.Label(value, Styles.ValueLabelStyle); GUILayout.Space(5); GUILayout.Label(unit, Styles.UnitLabelStyle); GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); + GUILayout.Space(Styles.NegativeSpacingAfterEntry); } private void DrawSectionEnd(EntryWindow window) @@ -424,7 +435,12 @@ private void DrawEditWindow(int windowIndex) List editableWindows = Windows.FindAll(w => w is EntryWindow).Cast().ToList().FindAll(w => w.IsEditable); // Editable windows are all except MainGUI, Settings, Stage and StageInfoOAB List entriesByCategory = _manager.Entries.FindAll(e => e.Category == _selectedCategory); // All window stageInfoOabEntries belong to a category, but they can still be placed in any window - _showEditWindow = !CloseButton(Styles.CloseBtnRect); + GUILayout.Space(-5); + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + _showEditWindow = !CloseButton(Styles.CloseBtnStyle); + GUILayout.EndHorizontal(); + GUILayout.Space(5); #region Selection of window to be edited GUILayout.BeginHorizontal(); @@ -504,7 +520,7 @@ private void DrawEditWindow(int windowIndex) if (GUILayout.Button("X", Styles.OneCharacterBtnStyle)) editableWindows[_selectedWindowId].RemoveEntry(index); GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); + GUILayout.Space(Styles.NegativeSpacingAfterEntry); } #endregion @@ -564,7 +580,7 @@ private void DrawEditWindow(int windowIndex) GUILayout.Label(entry.Description, Styles.BlueLabelStyle); GUILayout.EndHorizontal(); } - GUILayout.Space(Styles.SpacingAfterEntry); + GUILayout.Space(Styles.NegativeSpacingAfterEntry); } GUILayout.Space(10); #endregion @@ -581,16 +597,19 @@ private void DrawStageInfoOAB(int windowID) EntryWindow stageInfoOabWindow = Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); List stageInfoOabEntries = stageInfoOabWindow.Entries; - GUILayout.BeginHorizontal(); - if (SettingsButton(Styles.SettingsOABRect)) - _showGuiSettingsOAB = !_showGuiSettingsOAB; - - if (CloseButton(Styles.CloseBtnStagesOABRect)) + GUILayout.BeginHorizontal(); + GUILayout.Label($"Stage Info"); + GUILayout.FlexibleSpace(); + if (GUILayout.Button(Styles.Settings15Texture, Styles.SettingsBtnStyle)) + _showGuiSettingsOAB = !_showGuiSettingsOAB; + + if (CloseButton(Styles.CloseBtnStyle)) { + GameObject.Find("BTN-MicroEngineerOAB")?.GetComponent()?.SetValue(false); stageInfoOabWindow.IsEditorActive = false; ShowGuiOAB = false; } - GUILayout.Label($"Stage Info"); + GUILayout.EndHorizontal(); // Draw StageInfo header - Delta V fields @@ -606,7 +625,7 @@ private void DrawStageInfoOAB(int windowID) Torque torque = (Torque)stageInfoOabEntries.Find(e => e.Name == "Torque"); if (torque.IsActive) { - GUILayout.Space(Styles.SpacingAfterEntry); + GUILayout.Space(Styles.NegativeSpacingAfterEntry); GUILayout.BeginHorizontal(); GUILayout.Label("Torque", Styles.NameLabelStyle); GUILayout.FlexibleSpace(); @@ -630,7 +649,7 @@ private void DrawStageInfoOAB(int windowID) GUILayout.Space(20); GUILayout.Label("Body", Styles.TableHeaderCenteredLabelStyle, GUILayout.Width(80)); GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); + GUILayout.Space(Styles.NegativeSpacingAfterEntry); StageInfo_OAB stageInfoOab = (StageInfo_OAB)stageInfoOabWindow.Entries .Find(e => e.Name == "Stage Info (OAB)"); @@ -672,7 +691,7 @@ private void DrawStageInfoOAB(int windowID) } GUILayout.EndVertical(); GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); + GUILayout.Space(Styles.NegativeSpacingAfterEntry); } GUILayout.Space(Styles.SpacingBelowPopout); @@ -707,8 +726,10 @@ private void DrawCelestialBodySelection(int id) /// private void DrawSettingsOabWindow(int id) { - if (CloseButton(Styles.CloseBtnSettingsOABRect)) - _showGuiSettingsOAB = false; + GUILayout.BeginHorizontal(); + GUILayout.FlexibleSpace(); + _showGuiSettingsOAB = !CloseButton(Styles.CloseBtnStyle); + GUILayout.EndHorizontal(); EntryWindow stageInfoOabWindow = Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB); List stageInfoOabEntries = stageInfoOabWindow.Entries; @@ -718,16 +739,6 @@ private void DrawSettingsOabWindow(int id) GUILayout.Space(15); } - /// - /// Draws a Settings button (≡) - /// - /// - /// - private bool SettingsButton(Rect rect) - { - return GUI.Button(rect, "≡", Styles.SettingsBtnStyle); - } - #endregion private void CloseWindow() @@ -741,14 +752,10 @@ private void CloseWindow() /// /// Where to position the close button /// - internal bool CloseButton(Rect rect) - { - return GUI.Button(rect, "X", Styles.CloseBtnStyle); - } - - private bool SettingsButtonOnMainGui(Rect rect) + internal bool CloseButton(GUIStyle style)//Rect rect) { - return GUI.Button(rect, Styles.SettingsIcon, Styles.SettingsMainGuiBtnStyle); + //return GUI.Button(rect, Styles.CloseButtonTexture, Styles.CloseBtnStyle); + return GUILayout.Button(Styles.CloseButtonTexture, style); } } } \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs index be91032..e8397af 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs @@ -1,4 +1,5 @@ -using SpaceWarp.API.Assets; +using BepInEx.Logging; +using SpaceWarp.API.Assets; using SpaceWarp.API.UI; using UnityEngine; @@ -11,6 +12,8 @@ public static class Styles { private static MicroEngineerMod _plugin; + private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Styles"); + public static int WindowWidth = 290; public static int WindowHeight = 1440; public static int WindowWidthStageOAB = 645; @@ -36,11 +39,13 @@ public static class Styles public static GUIStyle UnitLabelStyleStageOAB; public static GUIStyle NormalLabelStyle; public static GUIStyle TitleLabelStyle; + public static GUIStyle WindowTitleLabelStyle; public static GUIStyle NormalCenteredLabelStyle; public static GUIStyle WindowSelectionTextFieldStyle; public static GUIStyle WindowSelectionAbbrevitionTextFieldStyle; + public static GUIStyle CloseMainGuiBtnStyle; public static GUIStyle CloseBtnStyle; public static GUIStyle SettingsBtnStyle; public static GUIStyle SettingsMainGuiBtnStyle; @@ -69,8 +74,8 @@ public static class Styles public static string UnitColorHex { get => ColorUtility.ToHtmlStringRGBA(_unitColor); } - public static int SpacingAfterHeader = -12; - public static int SpacingAfterEntry = -12; + public static int NegativeSpacingAfterHeader = -12; + public static int NegativeSpacingAfterEntry = -12; public static int SpacingAfterSection = 10; public static float SpacingBelowPopout = 15; @@ -79,15 +84,20 @@ public static class Styles public static float MainGuiX = Screen.width * 0.8f; public static float MainGuiY = Screen.height * 0.2f; - public static Rect CloseBtnRect = new Rect(Styles.WindowWidth - 23, 6, 16, 16); - public static Rect SettingsMainBtnBtnRect = new Rect(6, 6, 30, 20); - public static Rect SettingsWindowBtnBtnRect = new Rect(Styles.WindowWidth - 23, 6, 20, 20); + public static Rect CloseBtnRect = new Rect(Styles.WindowWidth - 23, 6, 16, 16); // TODO check if we need this + public static Rect SettingsMainGuiBtnRect = new Rect(6, 6, 30, 20); + public static Rect SettingsFlightBtnRect = new Rect(Styles.WindowWidth - 45, 6, 16, 16); // TODO check if we need this + public static Rect PopoutBtnRect = new Rect(Styles.WindowWidth - 23, 6, 16, 16); // TODO check if we need this + public static Rect SettingsWindowBtnRect = new Rect(Styles.WindowWidth - 23, 6, 20, 20); public static Rect CloseBtnStagesOABRect = new Rect(Styles.WindowWidthStageOAB - 23, 6, 16, 16); public static Rect CloseBtnSettingsOABRect = new Rect(Styles.WindowWidthSettingsOAB - 23, 6, 16, 16); public static Rect SettingsOABRect = new Rect(Styles.WindowWidthStageOAB - 50, 6, 16, 16); public static Rect EditWindowRect = new Rect(Screen.width * 0.5f - Styles.WindowWidth / 2, Screen.height * 0.2f, Styles.WindowWidth, 0); - public static Texture2D SettingsIcon; + public static Texture2D Settings20Texture; + public static Texture2D Settings15Texture; + public static Texture2D CloseButtonTexture; + public static Texture2D PopoutTexture; public static Texture2D EntryBackgroundTexture_WhiteTheme_First; public static Texture2D EntryBackgroundTexture_WhiteTheme_Middle; public static Texture2D EntryBackgroundTexture_WhiteTheme_Last; @@ -118,8 +128,8 @@ public static void Initialize(MicroEngineerMod plugin) { _plugin = plugin; - InitializeStyles(); InitializeTextures(); + InitializeStyles(); SetActiveTheme(Theme.Gray); } @@ -142,7 +152,7 @@ private static void InitializeStyles() EditWindowStyle = new GUIStyle(PopoutWindowStyle) { - padding = new RectOffset(8, 8, 30, 8) + padding = new RectOffset(8, 8, 10, 8) }; StageOABWindowStyle = new GUIStyle(SpaceWarpUISkin.window) @@ -172,17 +182,6 @@ private static void InitializeStyles() fixedWidth = WindowWidthSettingsFlight }; - PopoutBtnStyle = new GUIStyle(SpaceWarpUISkin.button) - { - alignment = TextAnchor.MiddleCenter, - contentOffset = new Vector2(0, 2), - fixedHeight = 15, - fixedWidth = 15, - fontSize = 28, - clipping = TextClipping.Overflow, - margin = new RectOffset(0, 0, 10, 0) - }; - SectionToggleStyle = new GUIStyle(SpaceWarpUISkin.toggle) { fixedHeight = 22, @@ -227,6 +226,12 @@ private static void InitializeStyles() contentOffset = new Vector2(0, -20), }; + WindowTitleLabelStyle = new GUIStyle(SpaceWarpUISkin.label) + { + fontStyle = FontStyle.Bold, + contentOffset = new Vector2(0, -5) + }; + NormalCenteredLabelStyle = new GUIStyle(SpaceWarpUISkin.label) { fixedWidth = 80, @@ -252,14 +257,34 @@ private static void InitializeStyles() fixedWidth = 40 }; + ///// BUTTONS ///// + + CloseMainGuiBtnStyle = new GUIStyle(SpaceWarpUISkin.button) + { + fixedWidth = 20, + fixedHeight = 20, + padding = new RectOffset(-2, -2, -2, -2) + }; + CloseBtnStyle = new GUIStyle(SpaceWarpUISkin.button) { - fontSize = 8 + fixedWidth = 25, + fixedHeight = 15, + padding = new RectOffset(-2, -2, -2, -2) }; SettingsBtnStyle = new GUIStyle(SpaceWarpUISkin.button) { - fontSize = 24 + fixedWidth = 25, + fixedHeight = 15, + padding = new RectOffset(-2, -2, -2, -2) + }; + + PopoutBtnStyle = new GUIStyle(SpaceWarpUISkin.button) + { + fixedWidth = 25, + fixedHeight = 15, + padding = new RectOffset(-2, -2, -2, -2) }; SettingsMainGuiBtnStyle = new GUIStyle(SpaceWarpUISkin.button) @@ -269,7 +294,6 @@ private static void InitializeStyles() padding = new RectOffset(-2, -2, -2, -2) }; - NormalBtnStyle = new GUIStyle(SpaceWarpUISkin.button) { alignment = TextAnchor.MiddleCenter @@ -311,23 +335,6 @@ private static void InitializeStyles() { alignment = TextAnchor.MiddleCenter }; - } - - private static void InitializeTextures() - { - SettingsIcon = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/settings-30.png"); - - EntryBackgroundTexture_WhiteTheme_First = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_white_first.png"); - EntryBackgroundTexture_WhiteTheme_Middle = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_white_middle.png"); - EntryBackgroundTexture_WhiteTheme_Last = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_white_last.png"); - - EntryBackgroundTexture_GrayTheme_First = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_darkgray_first.png"); - EntryBackgroundTexture_GrayTheme_Middle = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_darkgray_middle.png"); - EntryBackgroundTexture_GrayTheme_Last = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_darkgray_last.png"); - - EntryBackgroundTexture_BlackTheme_First = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_black_first.png"); - EntryBackgroundTexture_BlackTheme_Middle = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_black_middle.png"); - EntryBackgroundTexture_BlackTheme_Last = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/background_black_last.png"); EntryBackground_WhiteTheme_First = new GUIStyle { name = "WhiteFirst" }; EntryBackground_WhiteTheme_First.normal.background = EntryBackgroundTexture_WhiteTheme_First; @@ -349,9 +356,42 @@ private static void InitializeTextures() EntryBackground_BlackTheme_Middle.normal.background = EntryBackgroundTexture_BlackTheme_Middle; EntryBackground_BlackTheme_Last = new GUIStyle { name = "BlackLast" }; EntryBackground_BlackTheme_Last.normal.background = EntryBackgroundTexture_BlackTheme_Last; + } - IncreaseDecimalDigitsTexture = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/increase-decimal-19.png"); - DecreaseDecimalDigitsTexture = AssetManager.GetAsset($"{_plugin.SpaceWarpMetadata.ModID}/images/decrease-decimal-19.png"); + private static void InitializeTextures() + { + Settings20Texture = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/settings-20.png"); + Settings15Texture = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/settings-15.png"); + CloseButtonTexture = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/close-15.png"); + PopoutTexture = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/popout-15.png"); + + EntryBackgroundTexture_WhiteTheme_First = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/background_white_first.png"); + EntryBackgroundTexture_WhiteTheme_Middle = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/background_white_middle.png"); + EntryBackgroundTexture_WhiteTheme_Last = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/background_white_last.png"); + + EntryBackgroundTexture_GrayTheme_First = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/background_darkgray_first.png"); + EntryBackgroundTexture_GrayTheme_Middle = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/background_darkgray_middle.png"); + EntryBackgroundTexture_GrayTheme_Last = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/background_darkgray_last.png"); + + EntryBackgroundTexture_BlackTheme_First = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/background_black_first.png"); + EntryBackgroundTexture_BlackTheme_Middle = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/background_black_middle.png"); + EntryBackgroundTexture_BlackTheme_Last = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/background_black_last.png"); + + IncreaseDecimalDigitsTexture = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/increase-decimal-19.png"); + DecreaseDecimalDigitsTexture = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/decrease-decimal-19.png"); + } + + private static Texture2D LoadTexture(string path) + { + try + { + return AssetManager.GetAsset(path); + } + catch (Exception ex) + { + _logger.LogError($"Error loading texture with path: {path}. Full error: \n{ex}"); + return new Texture2D(20, 20); + } } public static void SetActiveTheme(Theme theme) diff --git a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs index e8688e9..cd95edc 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs @@ -16,7 +16,7 @@ override internal void DrawWindowHeader() if (_nodes == null || _nodes.Count <= 1) return; - GUILayout.Space(10); + GUILayout.Space(5); GUILayout.BeginHorizontal(); @@ -29,6 +29,7 @@ override internal void DrawWindowHeader() _selectedNodeIndex++; GUILayout.EndHorizontal(); + GUILayout.Space(5); } override internal void DrawWindowFooter() @@ -43,6 +44,7 @@ override internal void DrawWindowFooter() DeleteNodes(); GUILayout.EndHorizontal(); + GUILayout.Space(-10); } private void DeleteNodes() diff --git a/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs index 2281307..004a653 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs @@ -72,13 +72,15 @@ private void DrawStages(int id) private void DrawStagesHeader() { + GUILayout.Space(10); GUILayout.BeginHorizontal(); + GUILayout.Label($"{this.Name}", Styles.WindowTitleLabelStyle); + GUILayout.FlexibleSpace(); + GUILayout.Button(Styles.Settings15Texture, Styles.SettingsBtnStyle); // If window is popped out and it's not locked => show the close button. If it's not popped out => show to popup arrow - this.IsFlightPoppedOut = this.IsFlightPoppedOut && !this.IsLocked ? !_ui.CloseButton(Styles.CloseBtnRect) : !this.IsFlightPoppedOut ? GUILayout.Button("⇖", Styles.PopoutBtnStyle) : this.IsFlightPoppedOut; - - GUILayout.Label($"{this.Name}"); + this.IsFlightPoppedOut = this.IsFlightPoppedOut && !this.IsLocked ? !_ui.CloseButton(Styles.CloseBtnStyle) : !this.IsFlightPoppedOut ? GUILayout.Button(Styles.PopoutTexture, Styles.PopoutBtnStyle) : this.IsFlightPoppedOut; GUILayout.EndHorizontal(); - //GUILayout.Space(Styles.SpacingAfterHeader); + GUILayout.Space(Styles.NegativeSpacingAfterHeader); GUILayout.BeginHorizontal(Styles.EntryBackground_First); GUILayout.FlexibleSpace(); @@ -89,7 +91,7 @@ private void DrawStagesHeader() GUILayout.Label($"Burn", Styles.TableHeaderLabelStyle, GUILayout.Width(56)); GUILayout.Space(5); GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); + GUILayout.Space(Styles.NegativeSpacingAfterEntry); } private void DrawStageEntry(GUIStyle horizontalStyle, int stageID, DeltaVStageInfo stageInfo, string twrFormatString) @@ -116,7 +118,7 @@ private void DrawStageEntry(GUIStyle horizontalStyle, int stageID, DeltaVStageIn GUILayout.Label($"{burnTime}{lastUnit}", Styles.ValueLabelStyle, GUILayout.Width(56)); GUILayout.EndHorizontal(); - GUILayout.Space(Styles.SpacingAfterEntry); + GUILayout.Space(Styles.NegativeSpacingAfterEntry); } private void DrawSectionEnd() diff --git a/MicroEngineerProject/Other/MicroEngineer_BackgroundStyles.psd b/MicroEngineerProject/Other/background.psd similarity index 100% rename from MicroEngineerProject/Other/MicroEngineer_BackgroundStyles.psd rename to MicroEngineerProject/Other/background.psd diff --git a/MicroEngineerProject/Other/close-15.png b/MicroEngineerProject/Other/close-15.png new file mode 100644 index 0000000000000000000000000000000000000000..60bd1c17b4cfc2bfa831eb4c5dc96fa6488fbd46 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^{2d!3zZ4qwnl&NYiWISFz9u??a$})+|8d| wa4M@^@%Q?Kdj} zuGsZK0N>QOdJTX3V3MvUj>}v#Ag9@+($v#dk(#d6Gg)yzytg?{q}OJ}4VRZo%1uhT zPG2&?Ojl1BT%(y#ugTEHOuSO4Qt7U@V!bA963HaejAV%-S(+l2NHZmAneudz z^N7n90yV&_)n!%{6gjhlP*z->)oRL2PHt*yN@_|;GMa0Xr5PEZMwTp-i9tea8P8Z% z&0@w9?@;2>Q$SlZX1&R(H!>ouSEV-EtXXk!I3xCO)~mt9X2e*MNF9?j#)jl(l_^=8 zBuQ>Bk*UsTHCpP7w@J!I-&TQE!)9u-nGK|FT1_%-pc`n$YJqgpb~A=HDKBS}wp-qY zhIUh0tc8sLffLepQ(9`qo9N^!+G4bsHFRMkl*ElIz%~GK&s3UemDOmjF&Yioj&`qf zfgzFsUZTX|dPZw(vh*2{+*aNVzgrbupt920GKmZfBULO*t&vJHWvQ8RX+Mc9QzG$D z;*e~kqZ~|8tFo%v(IQXHl*m1`w32PB$Eelo#(Sm3E$N|yZSqW|(O@)}8?|(H%7End z*zKk&RVpjZMxEY3XIrX@^F^hF$~0+4TAEmvB=uC|A=j>+0;9%;O(>7i&=zPX3+Y^} z&68f1uc~d$#chkbi9w$YO_rq9YcthpDQakwRIx@)tHdfzs!E)Zrb`iL$W+p_3|%TM zOHmIolt zTWg*C7S*oOJ5^(-H0dg}T&|IbwVD)(SSAOk6mp$foRO}Tq$sp0Dw$U2Qtgra7S$DI zJ&eyPgNKZ(HU6C}+EH^$Rwa6D8{=DB0WpDUdR%L++cwBZYEqdkG#)3i;#>m-JM^+v zhSQMoCR3%s4VbOLg9fb~klc#vE*6{8nM{9c19}I6L%&Dz+vm|#M>BUCcO0sS)a{j6 zj5=$R%1r0gLZAD?@z9~Nb(*%i+wW9=ODkAZjeo5T($eS*sa6exLVAWu41^BG1GP@9 zP1mNSNhP|Jbe+Q0#(%aAQWTjog=^IQ54C~Yel>L}rk2)bC%dZUV*D>Pn|EX1U+X%p z9=8AM&F1KXt%pL_2;OGsbclNRn`HEKaKW1eM>?7Hq;DBm*I9`<;#SH z!W+T|mp3S}GCsIiD7+zjaCw6gE8~NUg~A)c2bVV}u`)imSSY+9d~kV#5-a0_i-p1) z!UvZ(D6uj=xL7E>A$)LogAyy_gNud28^Q;dHz=_(KDbyYydivWd4m!wA$)LogAyy_gNud28^Q;dHz=_(KDbyYydivWd4m!w^ybsYt1D4 zTF<~W3{J-$*+7$7&sZyLR+G&NOgy%ndy(GH!od9bR1t|=T*11v{ojs&nJ�@Wtu|AIdaMQ_gHRoPPAhk_zu<9A265<1hw6c8UAV-b+V-*}RT--H|@ThSG z+0AN!_>NdoX|gh|N~N;9K$2Nl|v@ zWLsl2wVQ3V#^B&rnl-s2u?BL4Y0O5`aM({)i7iym)Vkmc!4XwZrhKE-YHTnVnObL( zAXf}7f(Jj?#jn!W)_Fz*x+0)#tUTW5&Hc_%22=uf3jUmTvIo2ui3@RN3b&j|j-BJ& z?+GtBsK%^fEU>GOW;Ej+me_&Bbcbs&ssU?PAqH8%##KPmKx@!==k9Ykkqn0`n1kI; zLI`Oohn{XEOm?r6vIMi?Q6wD0hP#t`{7k|D3#=M% z>nFA2;qCpdvN^Dn5Du53oY>;BV+o9kkZABH9Ou}<$pvL_I@<}iB|`3&=!}EhLby2U zkAtqS4V( zjwx-Z6~XPFu0I#PG0^JqM!;{)DYw+Negq0s25XI~wv|+fhBg>#=w@rFrKG03%r(gR zyV$LS1L}Zp8)iw!mR)6zPXjSTt$jkMX?j`%PayR~?rx|VFU_W(EC zp+CQvjesO*u#v%72Uv|Ja2_nQ=cp<)!0>wuH%Lu}>s$DN(Cl?>#Yyi=#2JBi0Op)? znb3}YON=oHM&zK9GCgDDfcZDT6BY09A2D*2$Zs#0e*pACFm#p1Vk)mL!Y&Ac-Txx| z832bSa)sXZ>*tOx^_jS&QY7+-^M(x9n9T5Kr7A%`Ys~lpmQ;;ZD7E_Ik?OwZG#rmJAi(y(S{A5TL$#BMm^mG^dX>o z8f*=Epz%l>)j+GDGx9KIJ*~8+4rmF`LFSq&csBC}z(5pK>p`nMXe(GC$RefDG@i7H zC{fc#1Rn=ch)U=t18ud6E8&|bDzg^8NYY?ZG4RB4)ETEj5x0C|fv_EyJ4SlQ-HF6) z>xln(2x&7adXJmuPU+?um%vyJPc`mrH&49)q4kd-)aeU1ujflJP)|i@-9C@{L}PpL z_*jab)+Av-+2aodSjpQH9{DBV{MgS^hzcBCScI)w17E+enML4HXlRkRtr7p}gdWB6 zD92q@w2sD}3oRN3RtAn2G&iHwlkdLhnN}as@X+ullX+;sq{FU(h+Nu&qDCj7uzgX8 z``sSIiws2EdtQJTify;DfMM|FfY9(B=NxtqG{lo@s|#lq1UVKxc`P7hRgFkvGdDU! zc=*N#Unmqsp%~O1#iK-cLd#G(>W^|!AsUD(z+)SU?t>?I9clo7tqDDVCZlO+CYp_& zK?~7~XenBWR-?Djdb9~`MLW?aXg@lPj-wOk47!LeqhHZ=@G|_UU@DS|p?XjWR6j~a zDX46!kSe39sFBnds+M9X8}$J7Fg25!LoK8hQ!A-AsduTZ)W_5T>KJvBx3Kww$ zxzXHMu9&OfD!CQhQCuC@%$>-c!JWrl!d=bX$lb;LjC+E6iTfK*z>DOGcw%0EUI}j~ zPs1C>o5*{dw~)7jw~n`i_Zjab?=r82AI$H{@5j&Nm-0vOYxzz5Y5aNo<@~k$5BZ1r zXZXJg1cGQmZ$Y}CL@-h?R&c-Ial!L~HG(aI1A^0nD}H`{F@F90vivIiRDM>!X?_d* zUh~`RchK*Q-!=b0{~rD_|04fU{*3<=|9Sqa{6FwN=zq@tdO%n}LO^CfMSwP7e88-L zr2!iQ_63{?xGoGA_7-LdYlLHklZEqztA!s5zZCu)7#J8Am=QQ6P#-ucaDLz$fgc5) z4E!x9BB*bWGU%QlThNn1uLNxgIu`VEaBy(1;N0L*!Pej>gI5M`5B@s%T1aF_Qb=it zHsqm@MIq}#4u*Um8W5TgniqOs=!DRDp>K!o3%wK;5Y{V98Kw%G7`7J1pw(euop$+~{7>rO}4yS}_n6ybbB}LD9YlE|gJ`~Jhv;%_*VvL+TkPW4y|LHhddCfon-aGs?yGoV zydqu~KR13`{N z?^k<&nHZdylQ=GMN#dbCf!Q{^E7Qmp$quCirxc|;l(He^$JBnQbm|MKN9B?7a`~h3ZStFG>1pP))oB;fd!~;` ze=hxqB1%!IcwF&O20tS|Imj0#%e&JYDfsW$(&ymG2D^45=Kl zXvo(Gdp@~CnL$?hJ9d^&KmBX$MFBm>&_=yq8BOV;_ z$;i$l^&>Zo@*6d5)bdeR?k>FhnY+*2Bfn?bJ)hs(``+ezKfbT?eTMtqA00YcHTvx_ z{4vAFtQvDeRiRpg|T%hBXcT4PzSKWg?h*W{0u6vDtXQ)Xy}{bYfiQ zxM#*)HV-l{w@{XQEgP&+;7skYCE6aboovi*T-122X;{|&@cM?;;?;}SM6a3o271Hx#ddGqtP2EDcIZN=NG-${7q zxwVmNXRM>vjbC?peck#K8%Az8@b18Ow{7gdaqW9a@4d1qcGIHwJG?*Z1K|f#Kd^6} zu=&as)0RtHYqy@>HhSCf?IX4y+A(Cu-VXH@&iwe@-HP4o zKS}#!-5&X#wV%pAUAs4J@49{I`!?*)*uU|>fCC>K%sIIAvx3id9x6Tb$>G6=4}3oK z^P@-ZIdbBt_UQRzhGRc|(fGynvl;u&?HQ-Sz7w-}L!r&55)V@1HC2) zH~enQzuD*J#+E@XU)me&cJi(fMZ5v*41|y{_Mj2RG0Wk8iw9qtvmefA)Cp1cqxSDm z5cyo&Xk|Hszegb?gtU_&F=aoFrlKH!fByjgpn!m&@IYZ;c!$uSpwJGTA|pFQMs^Ah zB8T(l2(-OY!GVFnA;DoGAz@J=At6!t5)$P|67G!x`xX@L56(>}mx@E2aEcpF*}sDK zf6Bgt%7Iey!7+gY3XBgfqBuOhz|TKG7zoo|ts^PK;kqKj5XGao93F@7C-CQUgHj+e zoXd-ikn;0}s3POWO_m9wo?857etgdkRa@05spcsMlzs_wsxP1XQDc!uFL~?XUIkCr zXbZQ!Y)$KUaOf%er?;nW|IBv!=c3+omp<~&Gdm9b>z8F~KRkTq$}nByw0X|dZDF3B?-<)AAy zb4n9(?8k`p#1b%v!<8T#it>;aCV$j0`6B|CwGL=2nGC{|3B;oQKtco#sf3)^!6kXb z;XEi=c{%C}gg^45BFL06o~=YwXEK$Kn^jG9Vd=3{qEm(gGEy>4)B|M9l#I~07d-W- zo=gwnv@75|goHOHAp~=V&ikD|P>AqX2Qww9@V!A1e07j~!U(j0X}v_b%l8t8%_HYj8dQ&J;oZUrD<2Hf5}EOOEyUw7iHpM;gW7<@xL7!>XLQZZcoME> z>W!XZgT zfiP=94zJPnZx&1CqC{yQNQQMe(Z<&8kD8tHuOetYDe6Pw-AI#p-~W1~zn(?vRcR=L z*5g`D22B~%joVY2B2h~ux^%HbodI7>OiNXW)d~eI)}*Du$K`ZVwJIY61aXt%6E_hj z*J%*!9bm@CE#cen9nv1A!h>)3VFSR64gr|1wvIQrrfS^`h!x^kC77JC!6iFPWq@fe zFezZTj!-OCNt-PuSoG1u=k{7hN41Hru-4J$HZmlqDx(!9k6p`F6=sH*dWm@g139%f zTO6V>s4SKugHdJ0>rEhqJ0rsL=56$ox%0L>Jb#XPxmA;JGIHQKbO&#XlY<1d3bU3r zJ7>pn4uZzEoCw@8jSYoNBW*C6=-~iJtNHeJ;z18?V_^ersjD=?5*n-opl2 zNp+Y^hc8L03?v>H@Kk`o000@v6dB@S84!YOKhDLb14nMD^Io;ZK{&7fWc)C*RnuOX zS{1+}kgHflj@#Z#obk82JDbeabZzgBai!Xb`=4Nv#aLDVnd7E&gX>y~!7F*FRLfYM z)A$K6>ZHKKTn(oLR=m?;Ji?(2xZ-)IG#GgmK&j!XAge_h;H80F20SNpkQzTPGT;v% z0+RtI1+}bhIXp=ukP7Qfg;Zi9DI*$FA>UL8W8E^KQh`!{W1;|kI9D1@%*V0hsH`3A zT3#ilWQ7i7s8rR`7N@ZiGg88GtVcLNXNGnEYAfB^LS1lR6AOUf6X1m$qs!=VZh=~w zF*d-rT3I${1hD0KbUHmllZ9mb@!tQ(+{yUe3T@wrjtvwJ--zzO!FkR7 z3r~dqz7ZXv>IouIE5k>Xj8z1cC4<0lt+lSrqZ^g5kMl`ROkkPZ^)nhEa;-11eE9x7 z87J|t9f0YN!=;SQ*g8kg1$-hwmd%}MLL6)4Dg$1CbF7}@80^EkyzX4#$>P;f6Hev| zFJ>1?n0Fwjf7|QEquZbMx@CXpb<1w?x`S{H{`ebh=J0O_8g`Qd%byr>CcC z#0r@-Rjj3Dsp+&ttJTWW0a5&8YkV@9rv) z+U5R(@&EQ1?JCRd?yfrA?(VEx?rrXW$?K-UBi4a$i@k3--0`olu%9dgDxG-C8sZPj zfR8<6EyQAPI34a12;o0Dgz(YU>z0DoEeAhZ0-m&%q{be-hUB7vYbxY}J#jVMzHHq%QhA zv@axg7sn;TregK{t;K7{w%WpR%}xsDcwbRj$wW6<>0s(%ZjU$H5zAR<&==vEOFwT{ z4g|1#k_0Q33@lb56Z|v~9}Z>k6Ez_4%MHH6;e3B_rYIw6ZPuq!P8Gj)QJxX+d7ih~n3emWDi>8>Sqx{Q8R- zVVOeZvp2=IhVvhtEmch(Shjw_@n@bqpM3n_U_-$}$JY5r-i#k8Igk_oK@7UwNO16*v_WIru zi85jSGKC;`q#|8kfQ`5%R2YMXl2EMmYkk*FWB>o7PQ1v?fzxf?CRw?mlvIH*;_X}^GHkT zgQz;XU%$8B*-f_4lok#ySe-v+3gGQD9H86>b&9o7FW-@b;&x)2$};d&ItV48sU-#t+z`M>MTlu-hzv) zZSR?QC!gt0#08-cupuF=`U~NXY2uaL$@lt;al|icLDWRk4Mf%HTTlz)fI9$Ja3WgJ jO(bwS2{+LV#3PQw4RjrGz?Hb}!SR%9t-({b!wdXB{H4D=u7w%d;mj388A?$3YjXUxDyja{zjJ8 zwdr-c=XtAkt@CH?v-dgc)Fcs@1O|iWz@D_q+;GJq*0H?sB#Wz4Zv9XM+NIC<&X22aV(1XwwHbQ9h)qyPf zNR??E0~0{AWA3)z!-;#qe4N^eh5y7mz8GK#_Pf2Q32ptEKPR!l2d-*68blIhy>u_4}Oe4vj(y*o|JD0STD6t&l uaTn_z+n#g4emLmY+g0!fnFfx44S;WoVaItEx2?he0000BsEaza6r2crM`-6PS6$PYyK_h#Z5H7!hwV}~?h>d@{icW8#&%14I= zoBHQcb49f%7;I#&D9L(iZXn9?N=`^Y8QHODgsK=b1JUg$h+LDIh@=%wi1c>#b#jTG zEs@PzyApjp@$SB>BguGTYb?Gcmgw$`CsOggRPW}9bwvl8pwzGN`PAgd4y!q!2BOo3 zp{8Q7+1c5y+3qeyE5s68w}P2uESc;CjZS@DHrTmNS-;#gV%r%JbWRghLsaAl+GTS} z$ry-6u_5QO`c+h&hGe~q_OXjoim^FXjU~F`v85{UoKr_FX%cmf=VF2+6b0GPp; z>jo=x!uZG_FuFvMPsIhHhwF`R?qm~*-cCNz)7zQr>E=6=`FwA_kKNqO^I&~Z^+l#f z6t09JZJFj>ny#w8$n+jfgmlD8RXXUs+a{JUv#6;tQHPM7r+LPi{xsoC3D?(hG0ZVz zNFq%fDy!)NPK$x4JujS0<5s=j<1 zv(tjS(lj$oQLW{T=t|z0Wi?@Y0b=5u)88~%TW6u|{+Nk&?I@Vs+QG5Ib-`eos#OW! zTurE1SWaLii#bbKZ6nSoe9nc1UHqKQo94VmT*2zW<-z3&0awaiba`;OLco=>7hN7) zt`Kmg>_wLcmn#HZDSOf7!Q~18SIS;=d2qQxz?HHWT^?Mn5OAgJMVAMcD+F9Ad(q{= z7hN7)t`Kmgykc}URSt&{yDPC3_v7c(%+uht{lWqHOFb8EVM@W*w?b=*CnIjsj7QaoG?Axl}{}mhqjI zG^AT;-6?SnHHJk4>!8@QDQLUdqL3ZECJQXHF|)#irYQL-!6>PFa@TPn43P<<5e5G8 zBtoW$KnzkMDw-lqs-q1QH8U(3vgJ`IR}v*dl&MLOH&X3%=D;@y?eW*qgs&4Gl^%Cg z^>`0GO{RnVBGgQ)hHQ5NI+@cPVzQuT93rjB=?Wnm6=GLT(jCd}f^pCxMvKyjLjaBy z)5F|M!2-fWiA?SsPJ=h}P~apViSSA(w@vvMdPuLGn!JcNEG^a>*7)pR+1PRUq=aMZ zT*DF{S&BcYO9tgn%t_lO9rdPz0tY8;;2;&8xU-^SqA;P`QGsPthBvxRb_sdY%z|dK zin?U8Q=DY-Cp2!`0klA`HcnI2{cyl#0wYwE3pRXV6ik9o!-`=jMM;qhR+W$~K^Lm{ zEjE8rEKFAmnr#92=ICSO_}?;pAY<@m;Lm!~sM<(nVXIMi4c$O!y!qdzyp~W_V`UwV z83{5sZ${!8D!B}vEhG!k&JvmE5aTSA1t@c5-n0?urJC*Vgm5UADMbj+n0CHGX*@e> z(k%{sE%oh74t*Kz$2*j6q)&L5RyLVuOPjC-dNEY@Jz5?kv3wpR5&gJrwm;VhEFDWX278%6?O~dpjK1%s0W%_1f7pELQ z!&um&@8~_E;-_^QD96ejzHML(ZVP!FOF}9maS4+Cad=p5AZ?xSg*-;~!YCU=gj<3U z=K-k%$n6oJ%GRTrXPywQmM&AtauPM=l7x8}J6sQEWMy7okY6|ho2IVgq;w)5m^nKDUOaV+yJ9ShB><+ktlo%hWYAaaKl#*J*s#oawK|8yT zPN8-4Fd*1yVM~UxQ;-D>58?rX;2}Osxye*U4ob$0g$TSZbpQQuP`GA^qu|$aGJ2tQ z8LVd|Bg+Cc4)gK7VLGf)$IJ3&4!)_c_Gi1 zXyR`?C}_qK>icYVt$K5=K#!|df!l7{AKvK*pbFWo$cS~Lp{THd(1q&E+9W{=Uc?RM zXv$v1Z-!x?UZ_rI;1$>q><}QFhfdJ4Id?HXLcm!wcQvIjpzCQZ)F(bOM^)w^%y-{2 zaIYm76Q=z4@>?WC4?BN5ogu#R+aydW!ruUunet2I77}V`XlQH*H8zIYo12>3*R+O0 zt!pk`wQ9|(RTsC1=w-c3V&Ri%X>M)_x3q=BZL7oK@M?U7SDRJZ&&NRdC~0qiB+}|< zqQuwE_}iKC%P@19^5e`9cv%O@3-gzG`3d6-)YS(Y8k?G7(W(_P#OJq#ZG;IheqX>> z7p!ln^M|@Y*zOOk>qyjX|0cUCdi{;b`qhW;`Ni<%>(@*^n(OY-ZhAHy+;C*-#49H` zy?5=s58k|SuJuaO3w|}g>{LJ0C;eH zbX8sQ#>1=8gGVQyJ<+{B_lkDYk@VCWPVYInp&lIwZtQ*RIdI~>i}=yKeTHz{abbB6 zHdS0G|AU15w9R%hMBd9D8Q(BeK1QQw9Yu3LMgbz*O149~R!9!gb_BMn(@-|x)@exv zjn(JSh>#?S(;G~h@f*c9m}DkHu7W}X2{IjY!-snf!dyZ(;@EhO`La{Kj=93pfz-|< zXoCML=x9ummT?vwzEz}&9qaxS?&nF<*&7If72kTVe7v9Fnf+9}Czb4pz?pq|-X5&L z!ge=fwv9WIyM0a@t#|t?WvU5tknvl7!b(`_3lpvMg}JJ_FFwY$!6bbZ+m<{YiLf=fHrq0P(T~{bP?MagPZQ=xRP#f`g?%ahJ3i87XHu& z{xX8aX_VM`LCcCo0lzc0A8Y^K+4}=mQJeWW4Z|DjE_b;@9=*fsypeCqNdS8__GWJ_ z^w)!}Hb7mna6g|Bpew`|e*~`iG$ZgTMR%Fl2ha&~HPvu20znmah)T(zacsss=9wVu z=@qymG|nN?sJs&AbpQOtM_H{w`H>TWn~yv{@U2ItTG!rncKU>=uvNiNg zOv9I2?G=Nu&6?B z9|yX!_Sv7t^#39IG+nOwV6~-ws8d&DuTwPZYZXVVt|-D5!eYSwi}>^6T-DcXqpHLA zln%cXbAC2)G;3@EU2PMaXyz+Fc~$cPSP#ENqbqU^kBrLB_aH5Ufd=@^D;0mf3(8?Z zW^7RZ>+&Gi+VcN3h(eTLRpmblBQp zb-4H`G-AXO9-iDF@8VV@#xiu?!` zf;VcDLMvON=97Urm*XWmuvx6x>+HQ|W*^kM)*E$CeRY@S0k@+&S>zuBpMn155#42V zQwg5}dUZ1*}W%Q^&Q%|{uNp-HS zuE9D!t43Z%}9QqiD)J@CR4{z5qMG2rvY^1loaV z;2JoN>(A7slC=SKtIqCL<_o^8p2lqpz$0KC=m8Faf50=~VRqWgKS^CHuvnbbqK>Pd zO5I;qHxs)uzoCw*&Ed7E)LRVG_f|Sm~YH4aQZ)UUQyrH>1xmJ z2w2Y76E41IS0e(y0e^EpbfLfXNMdy+HmYmt>%`!Z@3`;BI8KZ?Mtx(ze)5Quni9AH X@b#Rb_H74$3eA&aP0L=@EiXC}!_%4WXhfBxmk&2#6TIdjgLGw+<4do%Z$ zo0eZug(ze{xNr#|rw_t392FbV@=MEj(IgW{Qn!SZMPWv2US>|SS*dQItx^@O)fuxQ zet7fU2&qn!6;Yd97GGvApzC!dQyIEy>d0#K)CP6BCL$+WoY|bwY%m*Wt5Vu*&>Jlo z%~=sjjY&mk0FBx52q_VBh0B3lepCZnm#s4OgYR0p}Nh@CYv=YA_7;$9*%Yy z%xpzQOB`uqoZ4iNH!IEZgt&P5os`V=CacL(Z@P;rTYOgo8Z}#~*~aKe+cau9t)~sN z(P{y`ggaIYeNtA&s@~CGgW-;v7Hd%>K;VG%j+&P07Belcq%9^Jqo#`*!4ns*09z*1 zo>9QiN~?*fHktI<_I|H$f+1A^UeW=zI-|zaWEq$#zg6A^zsnR|sI=1Aig*PCMv_dC zRGko?p-9R|P8b}o$cT@3Gh&y##YP!~qDE;|dSa!E?5%c88eLtBM^;>tZZ_C1&nPsh zZMYNjjB45fNLfgDvr$LlJYT8p%Ejp7K-KHA0kk-cPLrWZNmKzUNiwyHR?3v>B&94p zr7lsHu23eVq}L_UibPeW+@a+11Y089u61O}J@YWrC01b4o0u|_hR#lO*LJa8mAYw_ z78F!4raGOT&bCwz%a@iG6{IAjr=-XfaS85b+~nNsXw(^XCdQz&W-HBRy-uyfLs;Hu z)Hntv>s_YYCF-V6#z#h}(PC8s{H28iO&y@APF1RslhyGujXE)2rbq@f(~|2{vh-9< zd}5j=QK`_>kytA$b63C3w6k{|rg2C8Gp60tZ!=xa=wNfL0VvGC7SaR)QERaK(H zk=fEU21x)`(Nnr|U6Dym9J1|>~Ckaq^;R)e|%M+AX z882Kc6rK=XxI96LmGQ#GLg5MFh07C^SQ#%|EEJv)Ubs9#iIwrf#X{i;;f2c+lvo)r zTr3ox5MH=EL5Y>|!o@=23E_py6O>pPFI+4Xo)BKRJVA+-@xsMI;R)e|%M+AX882Kc z6rK=XxI96LmGQ#GLg5MFh07C^SQ#%|EEJv)Ubs9#iIwrf#X{i;;f2c+lvo)rTr3ox z5MH=EL5Y>|!o@=23E_py6O>pPFI+4Xo)BKRJVA+-@xsMI;R)e|%M+AX882Kc6rK=X zxI96LmGQ#GLg5MFh07C^SQ#%|EEJv)_k>IA+AT*LVT)W7?1e*QH(dtVUUwc+yxY#c zGtbw|=#18Ko7HTy0+WwLDlFD26>N?o5~W5fO&e_nT!3kOEzmPKA3$`gbj?^IUuVTS zxY%x!W=1Lvbal~~YGBzbvn#;f8dF^rZMB)pRg=|FC_xp7K_>XsAt|atG_oQaGGkLn zY-Xh)N6h5wtwx7O5|vG-x9W_Iz%Ybj$h1&p!4l`&dfnGq_zg)JGWwKlSuB7?q=%>a%r)A{NKtpf-< zN(lBG6@WKnn`EU%D%F^5s$5e$_K+OI7~^fceEscm`HZG|w9#4|S*gc;%O3f9jr30Z zN{ik~_!Z6i+)7ql+(@fos|{={gFT3jsHo6ZSe#LTX)Fv^>^2%f*V)b7Qf;-#e8+05 z)OtI=f>Gy=#TLjBsAf#&TG-)Ifg@CB)H>nw#|4$(Q@+V+H5v3Kqt>A!ah6~g-1vS@ zex*)Z?_S{RECAnFc|2CQ-`RaYC2*zS=eUw_6hq4V9hJf*XF9USn;+rvARR{}d$9Sw z#OhU&7m*YaifF~!_r8kl(T&+e_8O5YLGrpfDA7YIARNlUS+lH_S3w8! zvd+YvXWzZ-EOA`j1)N0=Cvnzj)8iQtH&y`qca0j$EhAlR#Z?p6@$g_{5SX{bFv@qu zI(7wBxH2TwT#JT?!pq7$W}h*JX=(S zt=sqIfek;U&1xD(8)*jbi30}0`{^9QV!JTr;F3~owu_X%n%3*9>1J!GrKGxSgmcRCak9Gzi|S3x)I7aT>%1cc*c)HsWJAk^ z8oEwtBU7-bk!GxS5U+8vyNdg&v}CKQ8@NGs`}xDz0#HFCO-78h$Z9gft=vMp&v9Zs zOoq2{B`Pv`-p2QZZm+*poQ%K$xFWb$LpbMj5ZXR+Nia%aew37q&>2k}2!8|I-|)uS zF=NL`g$E)0MKBT}(3NV7xvZ)fKM)|;R4c{1Yweau3WMpFllF0VOjc4MmAaLALI$bL z4BY6b3J^}z!2WrlX92BmvYIg;dmXB3z%&OBxljfi1iCw>wRU<4k+IXcnARAK5a1l_ zvsq)%V0s_WPc+(a;B!X+J-bmyHvxSd=qSC-paUAuw4nxC34@V`F^jU&>UyB#ftE1U zm2juzWg_Gw(YnzpH`)pj2(qZaWNsmSA|0R}D20y)q)AKYCOvJn$|~TS2uel+Uo0?~ zmBto?>}|$cDEPLW%Yomi)wBbFlmo#AVSvvi9#pFp}<3-i2L0E#0&97-0{yt3B~r?2vH3@$0JnR?}9z< zfrfIDc1bw%Anh zHPj~RRq73DH}w&9g!-I1OI@OVqHb`w90@0s(}xqok#o{Gd7R;#YR&|XmNSJjl{1U; zG-oMiE$3xU8)rA?6V3@vJLg-@H7?@%a>Kd(xiW4Vw}4yD9mlQXGTcYFbGS>mYq?vv zySV$g$GGj>E8O3B0$vDD%9HVi@=AE4d1~Gi-XpwuyjI?eyf)rG-Z9=;UI*__z8}9g ze=t9TU&o?xY5tKdDs z5y3gZHK9=0LpWHNB`g;zg;wEg;WFXN!gqy7h3AF8`uO_v^HKN|`;7B3`pooM;`5Tv zJ3dE!F8JIO1&X3Y8KQELM${sjFIq3!B|0QJFS;oX632?O#MR=-;u+$l;w|F$#b?A< zeSLi+eA9hL`RaV9`!4l;#rH$sv%bGcf+d3_1(NX+o8)Q9M#+1U&m~v={QP44a{b2n zS^b{&+vK;`?<>Dw{X_iY{7d~c{?q)I`?vWY_5VIV6c8Pd7w|y9)PN-cuLT?mxDqG| zj0r3VR0cj0xIFNUz*B+OfGMVz4kcCb%eA6Fe(;UGU!Eb0OT2 z$dG~%b;zS3>qFiTIUgzrjSVdgog6wh^lzaDLp#EP!;->k!kWXDhrJ!v9?lJq2`>%T zhtCh+7Jf4PMz=oQ^19L8p6s@z+tF^wTd2wLX3O4C`a= zv#ihFK3DpN_s#7)x$mOB@ASRYFQi{~KV82?{od_&SsEtIlj@~QrTe5E{d@N>>2K@5 zrvJhIHzQ&rMn}wy*c$O=q&PAyvMzE_`r1N;W$445)t?SSJ01q0ItHVj-j@bDncpyWaIgO(3E zG?+6uWw37W%E3p5@Q0)iF%DTf z=u1N{X2xdHnd>vpWkqBuv({v_XG^muWv|X|&*`6|%vqcBb#7#?CU-;bg}i}zlk;BA z`#wKDpUK~zf4v~1;NgPz3b}>D3g;9aEDA0fUDR6iRdGbIws>=K$FSsK4-R{;gkLhe zWI@TP(mti?(oLlu_od$V@O}G+ONLhsZyo;ih(RNm5xdGbW%rdmTXtq-^ho2#9p$LJ zwEWrfFDqgzrc}H+N-(No)bdf^R3=nDRJp$@q-tW-OI5#A=U30KK0SKCXxr#LH32o_ zYc|zfuPv-ySld2EKIY*upN#D}RyTI%IN`XOaT~^6yT9oE#rK~dpFDo{_>&W2Cp1s^ z=z*RO=pT4{V!%Y@#MdVAC)G}RY0~e?a^+g(HC3rayw<)?L(QX`j_zs?VukQh!BPplj9rIJso#A2$8P z8R8iYGd`UeKXc*CpC7G#bl0ptv!>5F_t>z`6Q5l6 zabeKHsSD3N zTlQ?*BI%+zi+)}_aq&k>l9sG`PW+thx%Q-p0eCvwdE1q0& zeWhmQ(dToY-?FODs=2Fftk$jmY|XGWZEIuJE?Fm7*SPMR^)>7FzmWFArVTwe%-!(E zM&riz7b{=fw<&egrk8rZG=DQ^vu*RGm&d<+_-}=O+qp%yWzE*`t#e;Nuh?F>{OY7v zPi`B&ZO?0IuWflf`t=ptL$=RpquN^9I(F3WXx}+@=aDz=dt=Y8p}V%f8TaPKxB9=e z{Oz!}=f5L^;73)V_o74}br|4~jq7yFYLL zyB}tK_|``mAHDH$+Q&OSN%^GhK=Og@pC*60{b0($wnM3hb{6>1X(7=6o6W<&v*@f3^1S z1OL9YJ*EBavxR35d|mbR>2vCH-~Pk$kKfPF`o`~@B^UZ#*mO~G@vTe6mkwXP|MK~7 z&EMX@3Az$ZLQa}L9~6Lm*a=VzVYAqn}M)5L-@$bXOgNe*eIgDll~8qGoyA0Ho)k3=Mr z1o?`6gTewNl7O)8At7NQA>D%{Mc!}#DLio@dzggzp%FDycJEu;{K z>nsdJ6p!L^cpSb^;KS!i5}`1N%j+MUz|R|{42hUBLm>!Vu;$hL$f&T&-KxYSX6BIs zVf4bPj|)w>=tD_-wVNXwN!pO1GnNwlkzV&AM=R z4`N*|bbf&(TvBHc%0cH7UfEv~w&Up5Zktu7=w)M5zW92|+?5wk(2I{>9k|J8^6iqMi53}@t9d-d!@ub;ct^Wy6nXWEhuU;bprE8mP=l(Qy#@S5ePFP)ok!&Lj#M#GL? zE1!Jg%HJn`x48FPdn+Vi(+3-tq`bQA!2Lb8of+RS_R{Fu8xzMy=X8Ef;=4cT?pjDm z-v^*PSe7y&6)aCl;i0-7Xe*o+LYYA<^e-f&@W>obPCR5t9TB(=N>NsZ1_9xNgj6tD zV#ceRi0Vm}{&C=`s9r2RnHu1b;ebp6S;*=KG7P04G#;l59@mitEUfz?oX3&)_vr}1 zs;1+5?@z2D{N1#S_$2sZn$-E-G_V4}znXISx0=J&5wM!;qKPCdE>ZAM4K#&U{9J9J zB3x~u2D!I|Lpg0w3XaRR!<=Ka7dfv&_$SV9CM|YK*ykW#XD2YS2{Rkx2s9vtvN7UD z_zGAj01X}`5eWqUWngvHlT)mM|MqxQ4i+DD55 zsUb2gI#`h)?c(CRTCdXMJa!A`b;i18M>)wi7#mFPdA-G4*CnskGmys(AP2T#sW;#{ zO5h|bwQ8FMuptL-V<4QkI?%!&Sj1nob8tj@Wed$z>kKr0o00c<(EOyU+=q!Dbv*yZJj zvlQPy_y*-<6XSR@f|dCOSkiVf@XXGw(>1%jIT4vHuy${O4+MHO21rAklZC1T8RyrL1ymCz)=;{zrD@YWbl+%!($bby6tdi;p~+3i(iYqR5e0lAh^%fP zf`|_kq(xjo6a-|GML@8~LqHL$f~?ZtnVaM`Ek*Nt%kTaE$jv8n&zy7S%$e_c8(B4NM74HWtu{j!m6I*XY*00rt!C1pmNl47 zlwH-36{Xf$G^7e>%vMCnXcb3oR#YAq$i|jc$OnonBR0SnRG2a#>L|4u@5xP}JAg$JZyt zTWkhJVnzm-Q7V*5IcUi3Qz?hKK~CBGx{P@26q0tW&1iKPEtCw~RckCxM^;o6u86tZ z?J`@LiYR+L-NtyW#jI#hTNR1%35w1N>9kB4tJ7wpUDIh5q=__>l*10?5<4wtt+6;P z_8QB5s$|6Xtr(t3Ss7Dzr~aDFomOpk6x9I)Zb&;VX|JAYB^8yV-Qu)q$)Y-FN*k^K zTPD=5DzK4ihs9QHv6!-5&%MIaD47!QlJy&7q;!^gd;d&DNBuVV+f0##Y6qFEOi)6{ zNR}&;suPu}gfx{heP99*30_8AnjLJES#(DI)b=)#s}mDc$|O}nlD7>n&5kypJL}XA zwNF;Ob-nE9v?{&DW>!10)mE#?s8!>>r>LWJ?jFTF+Dt{8s#keNt}3vYEH-eK%udQw zbjI$qRB1s$h0UTjn#gQ><&bLKcq;NTc27m+ zHX{T%waH5dw?&8BlA5G}Zk8<9YDl$QtxbjorRtO98A^2`v?-ZXCNWiXV&*X!EwlBq{ER_ZL^bjuw_MgMjI2q7)!VeJ!n;GE$&R&T0HVd zU8bTPx6Li4q`R20lgH^31TOnt#qVE7eGN(d+2D1VqP6aC#BR|$>eV(f&j3B-FN2E9 zWcxB5ZD%T6X#Xdkf`zIhZU39+08d*DZ%oo=&(_;4W|`5fHjoM{Wso^6vcHTLuI75# z_&;o`U0wGt_BWrx$3NZQ?hW++rT*47R<$*1%0TL}6`o=0VfgmgTphQ4{P2Xm4)MmN z>NV4GO{3_Z5A!IP!YPPowgZU{z@1qd?EaB`GOLodma(JYf?q;qC5{N-c{+^fho4yjFh9? z>99H-z~o|;3cI691DoJzjZ(@%l9bbo1(?S70+S8rgXpqV#s;jBZ*<@?SnRS%+D5?M zkm{nb)xdI9<|+W2xh(oB(&4n0YbI+!C_xp-hAi;WBN?hfByu1pvSL$6WM#A=N1Mqv zIViVB5{=Vnau_MvB*=xdc0t*=VXhVr#wJ*DNZMK);??4EdLN}73T#wCTZVG9Wrk}^c1AM7;HYCVMP^eWlK~vtOy_HB4Q?P@C?VM7Rsi16 z+hHqpGMUce)Z|*4v4`|E#75o2%QxMtmv7TmkD?sKeJf4)*)mtYNhj-!UuicvXnsY5 zDYueQ7uAtk*bN3-2w|_OyH`{gD(s$KfoZG^ckDJAPU>A|I#gS2v36Q*mDc3qSJBW3Ww7l;Lw;8VWE;joxZ7Rul*BJoJD3ts#H55LlAsPPtv zJp%BJ(Z^$j{gcZFR04MbKJGg`j$&z9pu1AI$7Yo0_u2#wL=|PIdLf za9Yv}(g0KqyA74a8hVZDWuRHT3hKHLOQ}_rzf4qyQW?F04Cpy z_ARn~p8Xr07t$#tE-P`aUDYC71AP&6o3GJy2~z0wATdG8b4lHtmCKeh93@ByG#*lq z4)&Wsc&xcOw9OlkM|do^c6zZdVsWRU)_+AtV}VV>@OL8xcduLmog>_+Vz05^7!MX* zRzP#yQG=BWZ1}n@;irgD+cW5fv+QAzxLS_0o?Yz_4dFTCh~_{>c+LjM$x#x*^?T5# z)!m6V57&eD#<#n?6+8mBn>b53O*jVQ#`0iiIHj|9h%H)2BFJdx@qlD{Juo|r8kFBQ zx@b2l+XfGIjc13=z@&Y&X*eGKM7w&pv<%oG@a5B)(n7Dg_y(KBX>G^iS?K+(p2%KQ zg{`|btAdRHwbNl4LQOKw zw0{Ni)Fwx@+R#obP)nLj)ntRC)Lv3uHrx|r1s--gWnqoQHZ9L&GDL9WJ^c-YW# zzK+zZopjI_;vJoxsE_ur+pCK;26~gW7r0WF{rn+}0E(ay77Al6bXcq~d9ah-QB`Du z@OuweqM^g}J$x}d_L`3B^cd`iD}vbpbmyEFns&v!Aes#kSyD3GNLg6W{mt-3#e2iY zjvFuI?}zR$gs})6U9GiS%c_d;6a>M(aT(q~?y^LuFqnQn<{F1z$xA9^GB24gq*QCQ z!K;<10OcedoXi09ETB#G4lCwkufsI8m}cQ27iI$of$oZFgNq(S>$vD#OzX@PbZ{2- z*{U<^FufD#r|X=!rJG?A+LbbHqIr> zp{N{YY~#>FFh{FFW|*(lqesvTG#kxB&!HF4a`XyXjn<(JXcKBeAE52%bF>#7L`Tsn z)QrxfA5jbX9o;4ff=>hxp+qFnn}{I>5=tVS$R>)2;Y1}dj+jIk2#RnLj}T7~^N5AS za$+U1j(CT7kJwIpK^!7Z5NC-?#IM9H7Mmqug|T|FVp$4SIxCMgj8)BgkY!*^VNGMr zVm-@R%38&Gi`B^5&f3d5%4%l)$hyWxY%x26-G?n_r?U&#ebQSN!}?>rtaf)~e2DqEd2wffeS?KvNURYdMY1rhjd0~GK+aJ~v9ul4$K03T1d`0+&;mr~3h}ekI2vfxT zh)og4B5rl**(I+F*=0_b4P6d*x!$#V*W9jT*STFcc0JnlR-`PlD6%$kL1a_p>292E z1G?Jh*tpm+ zu}{S|#a@i-8dn-OEpC0>H~j+o<@B4Q9zQd_DgKHgS}|U+K(R}47fx(3 zC9F<3l^BvZG;wC)w!~kR1C(0j3gwZcfTZH2$CI`u{gON|nM{5;`RkO>l(LkkQg)>L zk(!ojOWlxqDJ?o}Qre4Y$J4{oE7G4y-<`qD$j^8@HKzX0FaWmlc(z&RUt(oGr_ql>KUUb55TebT=iQUdZd8H#zUEyes($ z`L_Hm`PU0n1&B@0T9 zm-Z~xmaZ#p8Jafq(V;tsNrqJoTR!Z&;RA--hHooll?^R>zU-S3F(arEP35S(wEX$< z(-mdB+D-$apsoYf+S~aoi&8pw4^Q-4qpBmL~lylUM(Ltjpj9xeT z`k2Bo3&%8%Rg8Uf?A~$R#u>+L9nT*>diQ;!YYf>CH)Z)aB|`>T8-(&5N2AZGm=)_D5Z=ZjtU1nME!nFX*%M z3-uQbS%&8gmuhlq7S~)h78sWsf0-|7g1$<#h)Kj)Lqvvt{ZE9!34kFMX`AZ?%; z_DvlybGQ~pN6tQ)_vp&Uh{rUK?RdQJ)ew=o?JgWaJFss@uvnq^~%$nr;ShVpOZ9a*_^v` zb#wR3OPIHK-koQ(&+PeI;@_73t@T;`v-{_#&VTti-gDG*#}?!)cw?b-;k1S4o-cd8 zagl7%+(lPknE1jMi<1|>vP87RxukjN@TFUqMK619*`4Jz%a5+eU$ODU9xu*$@%l@; zmkz(2`|^fYdcHF6m0PbGU;TRJkd=+AVplDGjrUsJYu~RPy?WQ{>94O_({0VXHGiz7 z);7OU`Nqz5Y3tU#+2hUm>sjla>o2`E;jM#zFZ}z~4e|{uH%4rn_cnUl`SuU*OnT?o zreT|QY);?2;oX>bU)&P9Wo{$UIJL2*sivuU>$t6l-W&Sfj%|atZFxWb{k0$T`C!F| z;UCWbNc7RHk6J&T_VKk(te;%oZrFZq$HX0{J{|k%k)0!V?*DAqXS+Wy{`}KjdAmN| zowfUeFH~Q=w#xuJ7Wv!StI1b)T&uWt=6Cb&x3AB=5qaZ{ zo9Q=q-5PW2!tMGy{5wnk=>NyIyTk5&(`s&QrGIOL(X#WYZguUmgY68fO9i3Melzk&kk9MVn4d>euGnBlr1uNgl?;9Onxm}Z#Y@2zgfFHB4s^#o2 zT6;>ws!dPC7Cv9CE86jzBel!nQQwijZl3k&SI%?46~`@F{p7nZ>^$<1tFLeQ?CAMx zqxE&O7q4mj{Mh%urwtinsDEn7+NNE{FI<-*77M)P&_3~b+!We{K8Yb5@L)<*C|5aS zK^XR6d*z{)q-f1q+suUpRpDBD@-Hzw>;OMDWyfJ~;L8FR=uz^rhoLp((=}W*Q%H7Sr@(bht>40^#t9c`p^K6fs{r&2<0IiEO~2S zaYzQ!*czZ6@U_#F71YB1LPG|V)CBsAJ1Jd96t06%mX)CaKnM_@2%(pe@d_p)y3xz~ z_)%+!?hHMd=;zj9flea5bkrMkY=n}g@yJ;4l#yOC!e!rp?-3-rGaVsVM|9u+{J1=X z&%je9B&(FkGSB&SUw#Xi#ijoID~44QysmARCnaE8CMN~I<53Uz-gnKA)|+aCbpX0;^jf9X zq%q+T8nqyWVhrfD_`pnj!l0WYG^wYOwrZo9#Q$34osiCtyu9HG?T5a>hPyQ`d!MVisc}R{(emAU zpZDgOBN6&Ayw`{Dmkn+;T%0*)_Eu1*1fp+@WqZDzL;s*NTt(Rj-p+!h`OSxN(KY%H zg5F=0x(eX5c#n+EPiVrtrUxKNJ-xqj{<|lXP}T`QZV!r3 z#>vg|D?!rGNT7k9IxsA76`aAoyL>qVzQYy!B`n)`uKX`!F=_r46&-Z9tr-1k#ys}Z z&AW$NPV$APCJ)=){4^dXa2Y}o`Y5a?U?uhZMMCod(?vAll~gx1wP6oY&9~1_t-gJr zxBUON2x#EGUZHl-eI3)qW%gQN!)$d6+Hdp#TvB(512GCd54!-%anHh8U<3$1oov9-fliN4tk?`RY9-ZpU+V!Y_% zK1#OT5;G4@W3*eSc05!>F)PkA4F&{omaG*YiwkrhNvSm^5-$v5j(cIA=i-8#uZI&J zowTa7z3PyPQGcc#WPAx^@@Ck%}NCX+FeY%x?mI(*wYV5RCbuoyFlhxYG8K82iD3Kd!3zZ4qwnl&NYiWISFz9u??a$})+|8d| wa4M@^@%Q?KdD=u7w%d;mj388A?$3YjXUxDyja{zjJ8 zwdr-c=XtAkt@CH?v-dgc)Fcs@1O|iWz@D_q+;GJq*0H?sB#Wz4Zv9XM+NIC<&X22aV(1XwwHbQ9h)qyPf zNR??E0~0{AWA3)z!-;#qe4N^eh5y7mz8GK#_Pf2Q32ptEKPR!l2d-*68blIhy>u_4}Oe4vj(y*o|JD0STD6t&l uaTn_z+n#g4emLmY+g0!fnFfx44S;WoVaItEx2?he0000H`G-AXO9-iDF@8VV@#xiu?!` zf;VcDLMvON=97Urm*XWmuvx6x>+HQ|W*^kM)*E$CeRY@S0k@+&S>zuBpMn155#42V zQwg5}dUZ1*}W%Q^&Q%|{uNp-HS zuE9D!t43Z%}9QqiD)J@CR4{z5qMG2rvY^1loaV z;2JoN>(A7slC=SKtIqCL<_o^8p2lqpz$0KC=m8Faf50=~VRqWgKS^CHuvnbbqK>Pd zO5I;qHxs)uzoCw*&Ed7E)LRVG_f|Sm~YH4aQZ)UUQyrH>1xmJ z2w2Y76E41IS0e(y0e^EpbfLfXNMdy+HmYmt>%`!Z@3`;BI8KZ?Mtx(ze)5Quni9AH X Date: Mon, 24 Apr 2023 23:38:34 +0200 Subject: [PATCH 33/38] Add automatic scaling of Units used for bigger numbers --- .../MicroEngineer/Entries/BaseEntry.cs | 86 +++++++++- .../MicroEngineer/Entries/BodyEntries.cs | 12 +- .../MicroEngineer/Entries/FlightEntries.cs | 64 +++++--- .../MicroEngineer/Entries/ManeuverEntries.cs | 108 +++++++++---- .../MicroEngineer/Entries/MiscEntries.cs | 28 ++-- .../Entries/OabStageInfoEntries.cs | 26 ++- .../MicroEngineer/Entries/OrbitalEntries.cs | 92 +++++++---- .../MicroEngineer/Entries/StageInfoEntries.cs | 2 +- .../MicroEngineer/Entries/SurfaceEntries.cs | 64 +++++--- .../MicroEngineer/Entries/TargetEntries.cs | 148 ++++++++++++------ .../MicroEngineer/Entries/VesselEntries.cs | 84 ++++++---- .../MicroEngineer/Managers/UI.cs | 12 +- 12 files changed, 510 insertions(+), 216 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs b/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs index 6b2ee22..ccc0ff2 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs @@ -1,6 +1,4 @@ using Newtonsoft.Json; -using System.Xml; -using UnityEngine; namespace MicroMod { @@ -20,7 +18,15 @@ public class BaseEntry [JsonProperty] public bool HideWhenNoData; [JsonProperty] - public string Unit; + public string MiliUnit; + [JsonProperty] + public string BaseUnit; + [JsonProperty] + public string KiloUnit; + [JsonProperty] + public string MegaUnit; + [JsonProperty] + public string GigaUnit; [JsonProperty] public byte NumberOfDecimalDigits; [JsonProperty("Formatting")] @@ -43,11 +49,81 @@ public virtual string ValueDisplay if (EntryValue == null) return "-"; - return String.IsNullOrEmpty(this.Formatting) ? EntryValue.ToString() : String.Format(Formatting, EntryValue); + if (String.IsNullOrEmpty(this.Formatting)) + return EntryValue.ToString(); + + if (!double.TryParse(EntryValue.ToString(), out double d)) + return EntryValue.ToString(); // This case shouldn't exist, but just to be sure + + if (Math.Abs(d) < 1) // mili + { + return !String.IsNullOrEmpty(this.MiliUnit) ? String.Format(Formatting, d * 1000) : + String.Format(Formatting, d); + } + else if (Math.Abs(d) < 1000000) // base + { + return String.Format(Formatting, d); + } + else if (Math.Abs(d) < 1000000000) // kilo + { + return !String.IsNullOrEmpty(this.KiloUnit) ? String.Format(Formatting, d / 1000) : + String.Format(Formatting, d); + + } + else if (Math.Abs(d) < 1000000000000) // mega + { + return !String.IsNullOrEmpty(this.MegaUnit) ? String.Format(Formatting, d / 1000000) : + !String.IsNullOrEmpty(this.KiloUnit) ? String.Format(Formatting, d / 1000) : + String.Format(Formatting, d); + + } + else // giga + { + return !String.IsNullOrEmpty(this.GigaUnit) ? String.Format(Formatting, d / 1000000000) : + !String.IsNullOrEmpty(this.MegaUnit) ? String.Format(Formatting, d / 1000000) : + !String.IsNullOrEmpty(this.KiloUnit) ? String.Format(Formatting, d / 1000) : + String.Format(Formatting, d); + } } } - + public virtual string UnitDisplay + { + get + { + if (EntryValue == null) + return ""; + + if (String.IsNullOrEmpty(this.Formatting)) + return this.BaseUnit ?? ""; + + if (!double.TryParse(EntryValue.ToString(), out double d)) + return this.BaseUnit ?? ""; // This case shouldn't exist, but just to be sure + + if (d > 0.001 && d < 1) // mili + { + return this.MiliUnit ?? this.BaseUnit ?? ""; + } + else if (Math.Abs(d) < 1000000) // base + { + return this.BaseUnit ?? ""; + } + else if (Math.Abs(d) < 1000000000) // kilo + { + return this.KiloUnit ?? this.BaseUnit ?? ""; + + } + else if (Math.Abs(d) < 1000000000000) // mega + { + return this.MegaUnit ?? this.KiloUnit ?? this.BaseUnit ?? ""; + + } + else // giga + { + return this.GigaUnit ?? this.MegaUnit ?? this.KiloUnit ?? this.BaseUnit ?? ""; + } + } + } public virtual void RefreshData() { } } diff --git a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs index c34b147..b5d36df 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs @@ -12,7 +12,7 @@ public Body() Description = "Shows the body that vessel is currently at."; Category = MicroEntryCategory.Body; IsDefault = false; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -32,8 +32,12 @@ public ReferenceBodyConstants_Radius() Description = "Body's radius."; Category = MicroEntryCategory.Body; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -53,7 +57,7 @@ public ReferenceBodyConstants_StandardGravitationParameter() Description = "Product of the gravitational constant G and the mass M of the body."; Category = MicroEntryCategory.Body; IsDefault = false; - Unit = "μ"; + BaseUnit = "μ"; NumberOfDecimalDigits = 4; Formatting = "e"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index af3dd11..df462a5 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -12,8 +12,12 @@ public Speed() Description = "Shows the vessel's total velocity."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "m/s"; - NumberOfDecimalDigits = 1; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -33,7 +37,7 @@ public MachNumber() Description = "Shows the ratio of vessel's speed and local speed of sound."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -54,7 +58,7 @@ public GeeForce() Description = "Measurement of the type of force per unit mass – typically acceleration – that causes a perception of weight, with a g-force of 1 g equal to the conventional value of gravitational acceleration on Earth/Kerbin."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "g"; + BaseUnit = "g"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -75,7 +79,7 @@ public AngleOfAttack() Description = "Angle of Attack specifies the angle between the chord line of the wing and the vector representing the relative motion between the aircraft and the atmosphere."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -96,7 +100,7 @@ public SideSlip() Description = "A slip is an aerodynamic state where an aircraft is moving somewhat sideways as well as forward relative to the oncoming airflow or relative wind."; Category = MicroEntryCategory.Flight; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -117,7 +121,7 @@ public Heading() Description = "Heading of a vessel is the compass direction in which the craft's nose is pointed."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -138,7 +142,7 @@ public Pitch_HorizonRelative() Description = "Lateral axis passes through an aircraft from wingtip to wingtip. Rotation about this axis is called pitch (moving up-down)."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -159,7 +163,7 @@ public Roll_HorizonRelative() Description = "Longitudinal axis passes through the aircraft from nose to tail. Rotation about this axis is called roll (rotating left-right)."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -180,7 +184,7 @@ public Yaw_HorizonRelative() Description = "Vertical axis passes through an aircraft from top to bottom. Rotation about this axis is called yaw (moving left-right)."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -201,7 +205,7 @@ public Zenith() Description = "The zenith is an imaginary point directly above a particular location, on the celestial sphere. \"Above\" means in the vertical direction opposite to the gravity direction."; Category = MicroEntryCategory.Flight; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -222,8 +226,12 @@ public TotalLift() Description = "Shows the total lift force produced by the vessel."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "N"; - NumberOfDecimalDigits = 0; + MiliUnit = "mN"; + BaseUnit = "N"; + KiloUnit = "kN"; + MegaUnit = "MN"; + GigaUnit = "GN"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -253,8 +261,12 @@ public TotalDrag() Description = "Shows the total drag force exerted on the vessel."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "N"; - NumberOfDecimalDigits = 0; + MiliUnit = "mN"; + BaseUnit = "N"; + KiloUnit = "kN"; + MegaUnit = "MN"; + GigaUnit = "GN"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -284,7 +296,7 @@ public LiftDivDrag() Description = "Shows the ratio of total lift and drag forces."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -315,7 +327,7 @@ public DragCoefficient() Description = "Dimensionless quantity that is used to quantify the drag or resistance of an object in a fluid environment, such as air or water."; Category = MicroEntryCategory.Flight; IsDefault = false; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -336,7 +348,7 @@ public ExposedArea() Description = "The surface area that interacts with the working fluid or gas."; Category = MicroEntryCategory.Flight; IsDefault = false; - Unit = null; // TODO + BaseUnit = null; // TODO NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -357,8 +369,12 @@ public AtmosphericDensity() Description = "Shows the atmospheric density."; Category = MicroEntryCategory.Flight; IsDefault = true; - Unit = "g/L"; - NumberOfDecimalDigits = 3; + MiliUnit = "mg/L"; + BaseUnit = "g/L"; + KiloUnit = "kg/L"; + MegaUnit = "Mg/L"; + GigaUnit = "Gg/L"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -378,8 +394,12 @@ public SoundSpeed() Description = "Distance travelled per unit of time by a sound wave as it propagates through the air."; Category = MicroEntryCategory.Flight; IsDefault = false; - Unit = "m/s"; - NumberOfDecimalDigits = 1; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; + NumberOfDecimalDigits = 2; Formatting = "N"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 0f2f02d..08be5cd 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -17,7 +17,11 @@ public DeltaVRequired() Description = "Delta velocity needed to complete the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -43,7 +47,11 @@ public ManeuverPrograde() Description = "Prograde/Retrograde component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -65,7 +73,11 @@ public ManeuverNormal() Description = "Normal component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -87,7 +99,11 @@ public ManeuverRadial() Description = "Radial component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -109,7 +125,7 @@ public TimeToNode() Description = "Time until vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -139,7 +155,7 @@ public BurnTime() Description = "Length of time needed to complete the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -169,8 +185,12 @@ public ProjectedAp() Description = "Projected Apoapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -193,8 +213,12 @@ public ProjectedPe() Description = "Projected Periapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -217,7 +241,7 @@ public Maneuver_TimeToAp() Description = "Shows the Time to Apoapsis vessel will have after reaching the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -249,7 +273,7 @@ public Maneuver_TimeToPe() Description = "Shows the Time to Periapsis vessel will have after reaching the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -281,7 +305,7 @@ public Maneuver_Inclination() Description = "The inclination of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -305,7 +329,7 @@ public Maneuver_Eccentricity() Description = "The eccentricity of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -329,7 +353,7 @@ public Maneuver_Period() Description = "The period of the vessel's orbit after the burn."; Category = MicroEntryCategory.Maneuver; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -361,8 +385,8 @@ public Maneuver_TrueAnomaly() Description = "True Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "°"; - NumberOfDecimalDigits = 1; + BaseUnit = "°"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -394,7 +418,7 @@ public Maneuver_MeanAnomaly() Description = "Mean Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -427,7 +451,7 @@ public Maneuver_EccentricAnomaly() Description = "Eccentric Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -460,7 +484,7 @@ public Maneuver_LongitudeOfAscendingNode() Description = "Longitude of Ascending Node vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -484,7 +508,7 @@ public Maneuver_ArgumentOfPeriapsis() Description = "Argument of Periapsis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -508,8 +532,12 @@ public Maneuver_SemiLatusRectum() Description = "Semi Latus Rectum vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -532,8 +560,12 @@ public Maneuver_SemiMajorAxis() Description = "Semi Major Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -556,8 +588,12 @@ public Maneuver_SemiMinorAxis() Description = "Semi Minor Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -580,8 +616,12 @@ public Maneuver_OrbitalEnergy() Description = "Orbital Energy vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "kJ"; - NumberOfDecimalDigits = 0; + MiliUnit = "mJ"; + BaseUnit = "J"; + KiloUnit = "kJ"; + MegaUnit = "MJ"; + GigaUnit = "GJ"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -604,7 +644,7 @@ public Maneuver_ObT() Description = "Shows orbit time in seconds from the Periapsis when vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -637,7 +677,7 @@ public Maneuver_OrbitPercent() Description = "Orbit percent vessel will have passed after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "%"; + BaseUnit = "%"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -661,7 +701,7 @@ public Maneuver_EndUT() Description = "Universal Time when vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -694,7 +734,7 @@ public Maneuver_UniversalTimeAtClosestApproach() Description = "Universal Time at the point of closest approach."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -726,7 +766,7 @@ public Maneuver_UniversalTimeAtSoiEncounter() Description = "Universal Time at the point of transition to another Sphere Of Influence."; Category = MicroEntryCategory.Maneuver; IsDefault = false; - Unit = null; + BaseUnit = null; Formatting = null; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs index 71f5e1a..e519e33 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -13,9 +13,9 @@ public Separator() Description = "It's a separator!"; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "---"; + BaseUnit = "---"; Formatting = null; - EntryValue = "---------------"; + EntryValue = "--------------"; } } @@ -27,7 +27,7 @@ public GravityForPos() Description = "Local gravity vessel is experiencing."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "ms2"; + BaseUnit = "ms2"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -48,7 +48,7 @@ public EndUT() Description = "Universal Time."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -78,7 +78,7 @@ public StartUT() Description = "Time passed since vessel was launched."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -108,8 +108,8 @@ public LaunchTime() Description = "Universal Time when vessel was launched."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "s"; - NumberOfDecimalDigits = 3; + BaseUnit = "s"; + NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -138,7 +138,7 @@ public TimeSinceLaunch() Description = "Time since the vessel launched."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -168,7 +168,7 @@ public AutopilotStatus_IsEnabled() Description = "Is autopilot enabled or disabled."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -188,7 +188,7 @@ public AutopilotStatus_Mode() Description = "Mode vessel's autopilot is using: stability assist, prograde, retrograde, normal, etc."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -208,7 +208,7 @@ public AltimeterMode() Description = "Mode vessel's altimeter is using: Sea Level or Ground Level."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -228,7 +228,7 @@ public SpeedMode() Description = "Mode vessel's velocity meter is using: Orbit, Surface or Target."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -248,7 +248,7 @@ public UniversalTimeAtClosestApproach() Description = "Universal Time at closest approach."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -278,7 +278,7 @@ public UniversalTimeAtSoiEncounter() Description = "Universal Time at the point of transfer to another sphere of influence."; Category = MicroEntryCategory.Misc; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs index 704b564..ccb1e70 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs @@ -18,7 +18,7 @@ public TotalBurnTime_OAB() Description = "Shows the total length of burn the vessel can mantain."; Category = MicroEntryCategory.OAB; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 1; Formatting = "N"; UseDHMSFormatting = true; @@ -52,7 +52,11 @@ public TotalDeltaVASL_OAB() Description = "Shows the vessel's total delta velocity At Sea Level."; Category = MicroEntryCategory.OAB; IsDefault = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -72,7 +76,11 @@ public TotalDeltaVActual_OAB() Description = "Shows the vessel's actual total delta velocity (not used in OAB)."; Category = MicroEntryCategory.OAB; IsDefault = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -92,7 +100,11 @@ public TotalDeltaVVac_OAB() Description = "Shows the vessel's total delta velocity in Vacuum."; Category = MicroEntryCategory.OAB; IsDefault = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -118,7 +130,7 @@ public Torque() Description = "Thrust torque that is generated by not having Thrust Vector and Center of Mass aligned. Turn on the Center of Thrust and Center of Mass VAB indicators to get an accurate value."; Category = MicroEntryCategory.OAB; IsDefault = true; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -149,7 +161,7 @@ public override void RefreshData() Vector3d torque = Vector3d.Cross(force, (Vector3d)leverArm); this.EntryValue = torque.magnitude; - this.Unit = (double)EntryValue >= 1.0 ? "kNm" : "Nm"; + this.BaseUnit = (double)EntryValue >= 1.0 ? "kNm" : "Nm"; } public override string ValueDisplay @@ -180,7 +192,7 @@ public StageInfo_OAB() Description = "Holds a list of stage info parameters."; Category = MicroEntryCategory.OAB; IsDefault = true; - Unit = null; + BaseUnit = null; Formatting = null; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 07474e8..0867eed 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -14,8 +14,12 @@ public Apoapsis() Description = "Vessel's apoapsis height relative to the sea level. Apoapsis is the highest point of an orbit."; Category = MicroEntryCategory.Orbital; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -35,8 +39,12 @@ public Periapsis() Description = "Vessel's periapsis height relative to the sea level. Periapsis is the lowest point of an orbit."; Category = MicroEntryCategory.Orbital; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -56,7 +64,7 @@ public TimeToApoapsis() Description = "Shows the time until the vessel reaches apoapsis, the highest point of the orbit."; Category = MicroEntryCategory.Orbital; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -85,7 +93,7 @@ public TimeToPeriapsis() Description = "Shows the time until the vessel reaches periapsis, the lowest point of the orbit."; Category = MicroEntryCategory.Orbital; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -114,7 +122,7 @@ public Inclination() Description = "Shows the vessel's orbital inclination relative to the equator."; Category = MicroEntryCategory.Orbital; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -135,7 +143,7 @@ public Eccentricity() Description = "Shows the vessel's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; Category = MicroEntryCategory.Orbital; IsDefault = true; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -156,7 +164,7 @@ public Period() Description = "Shows the amount of time it will take to complete a full orbit."; Category = MicroEntryCategory.Orbital; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -185,7 +193,11 @@ public OrbitalSpeed() Description = "Shows the vessel's orbital speed"; Category = MicroEntryCategory.Orbital; IsDefault = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -206,8 +218,8 @@ public TrueAnomaly() Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "°"; - NumberOfDecimalDigits = 1; + BaseUnit = "°"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -236,7 +248,7 @@ public MeanAnomaly() Description = "Parameter used to describe the position of an object in its orbit around the celestial body."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -266,7 +278,7 @@ public EccentricAnomaly() Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the vessel is."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -296,7 +308,7 @@ public LongitudeOfAscendingNode() Description = "Longitude of Ascending Node is an angle from a specified reference direction, called the origin of longitude, to the direction of the ascending node, as measured in a specified reference plane."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -317,7 +329,7 @@ public ArgumentOfPeriapsis() Description = "Angle from the line of the ascending node on the equatorial plane to the point of periapsis passage."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -338,8 +350,12 @@ public SemiLatusRectum() Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -359,8 +375,12 @@ public SemiMajorAxis() Description = "Shows the distance from the center of an orbit to the farthest edge."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -380,8 +400,12 @@ public SemiMinorAxis() Description = "Shows the distance from the center of an orbit to the nearest edge."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -401,8 +425,12 @@ public OrbitalEnergy() Description = "Constant sum of two orbiting bodies' mutual potential energy and their total kinetic energy divided by the reduced mass."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "kJ"; - NumberOfDecimalDigits = 0; + MiliUnit = "mJ"; + BaseUnit = "J"; + KiloUnit = "kJ"; + MegaUnit = "MJ"; + GigaUnit = "GJ"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -422,8 +450,8 @@ public ObT() Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "s"; - NumberOfDecimalDigits = 0; + BaseUnit = "s"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -452,7 +480,7 @@ public OrbitPercent() Description = "Percent of the orbit completed."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "%"; + BaseUnit = "%"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -473,8 +501,12 @@ public OrbitRadius() Description = "Length from the center of the ellipse to the object."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -494,7 +526,7 @@ public SoiTransition() Description = "Shows the amount of time it will take to transition to another Sphere Of Influence."; Category = MicroEntryCategory.Orbital; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs index f599eb0..0d34bc1 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs @@ -12,7 +12,7 @@ public StageInfo() Description = "Stage Info object, not implemented yet."; // TODO Stage Info display and description Category = MicroEntryCategory.Stage; IsDefault = true; - Unit = null; + BaseUnit = null; Formatting = null; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index 8e0d935..fd1036c 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -14,8 +14,12 @@ public AltitudeAgl() Description = "Shows the vessel's altitude above ground Level."; Category = MicroEntryCategory.Surface; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -35,8 +39,12 @@ public AltitudeAsl() Description = "Shows the vessel's altitude above sea level."; Category = MicroEntryCategory.Surface; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -56,8 +64,12 @@ public AltitudeFromScenery() Description = "Shows the vessel's altitude above scenery."; Category = MicroEntryCategory.Surface; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -77,7 +89,11 @@ public VerticalVelocity() Description = "Shows the vessel's vertical velocity (up/down)."; Category = MicroEntryCategory.Surface; IsDefault = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -98,7 +114,11 @@ public HorizontalVelocity() Description = "Shows the vessel's horizontal velocity across a celestial body's surface."; Category = MicroEntryCategory.Surface; IsDefault = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -119,7 +139,7 @@ public Situation() Description = "Shows the vessel's current situation: Landed, Flying, Orbiting, etc."; Category = MicroEntryCategory.Surface; IsDefault = true; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -148,7 +168,7 @@ public Biome() Description = "Shows the biome currently below the vessel."; Category = MicroEntryCategory.Surface; IsDefault = true; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -183,7 +203,7 @@ public Latitude() public override void RefreshData() { EntryValue = Utility.ActiveVessel.Latitude; - Unit = Utility.ActiveVessel.Latitude < 0 ? "S" : "N"; + BaseUnit = Utility.ActiveVessel.Latitude < 0 ? "S" : "N"; } public override string ValueDisplay @@ -212,7 +232,7 @@ public Longitude() public override void RefreshData() { EntryValue = Utility.ActiveVessel.Longitude; - Unit = Utility.ActiveVessel.Longitude < 0 ? "W" : "E"; + BaseUnit = Utility.ActiveVessel.Longitude < 0 ? "W" : "E"; } public override string ValueDisplay @@ -235,7 +255,11 @@ public DynamicPressure_kPa() Description = "Dynamic Pressure (q) is a defined property of a moving flow of gas. It describes how much pressure the airflow is having on the vessel."; Category = MicroEntryCategory.Surface; IsDefault = false; - Unit = "kPa"; + MiliUnit = "Pa"; + BaseUnit = "kPa"; + KiloUnit = "MPa"; + MegaUnit = "GPa"; + GigaUnit = null; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -256,7 +280,11 @@ public StaticPressure_kPa() Description = "Static pressure is a term used to define the amount of pressure exerted by a fluid that is not moving - ambient pressure."; Category = MicroEntryCategory.Surface; IsDefault = false; - Unit = "kPa"; + MiliUnit = "Pa"; + BaseUnit = "kPa"; + KiloUnit = "MPa"; + MegaUnit = "GPa"; + GigaUnit = null; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -277,8 +305,8 @@ public AtmosphericTemperature() Description = "Temperature measured outside the vessel. The sensor which detects SAT must be carefully sited to ensure that airflow over it does not affect the indicated temperature."; Category = MicroEntryCategory.Surface; IsDefault = false; - Unit = "K"; - NumberOfDecimalDigits = 0; + BaseUnit = "K"; + NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -298,8 +326,8 @@ public ExternalTemperature() Description = "Measured by means of a sensor positioned in the airflow, kinetic heating will result, raising the temperature measured above the Static ambient temperature."; Category = MicroEntryCategory.Surface; IsDefault = false; - Unit = "K"; - NumberOfDecimalDigits = 0; + BaseUnit = "K"; + NumberOfDecimalDigits = 1; Formatting = "N"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 4ce1c5a..e3145e7 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -13,7 +13,7 @@ public Target_Name() Description = "Target's name."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -33,8 +33,12 @@ public TargetApoapsis() Description = "Shows the target's apoapsis height relative to the sea level."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -54,8 +58,12 @@ public TargetPeriapsis() Description = "Shows the target's periapsis height relative to the sea level."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -71,12 +79,16 @@ public class DistanceToTarget : TargetEntry { public DistanceToTarget() { - Name = "Distance to Target"; + Name = "Distance to Tgt"; Description = "Shows the current distance between the vessel and the target."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -107,7 +119,11 @@ public RelativeSpeed() Description = "Shows the relative velocity between the vessel and the target."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -141,7 +157,7 @@ public RelativeInclination() Description = "Shows the relative inclination between the vessel and the target."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -175,8 +191,12 @@ public Target_AltitudeFromSeaLevel() Description = "Shows the target's altitude above sea level."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -196,7 +216,7 @@ public Target_Inclination() Description = "Shows the target's orbital inclination relative to the equator."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -217,7 +237,7 @@ public Target_Eccentricity() Description = "Shows the target's orbital eccentricity which is a measure of how much an elliptical orbit is 'squashed'."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -238,7 +258,7 @@ public Target_Period() Description = "Shows the amount of time it will take the target to complete a full orbit."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -267,7 +287,11 @@ public Target_Obtvelocity() Description = "Shows the target's orbital speed."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -288,8 +312,8 @@ public Target_TrueAnomaly() Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "°"; - NumberOfDecimalDigits = 1; + BaseUnit = "°"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -318,7 +342,7 @@ public Target_MeanAnomaly() Description = "Parameter used to describe the position of the target in its orbit around the celestial body."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -348,7 +372,7 @@ public Target_EccentricAnomaly() Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the target is."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -378,7 +402,7 @@ public Target_LongitudeOfAscendingNode() Description = "Shows the target's Longitude Of Ascending Node."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -399,7 +423,7 @@ public Target_ArgumentOfPeriapsis() Description = "Angle from the line of the ascending node on the equatorial plane to the point of periapsis passage."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -420,8 +444,12 @@ public Target_SemiLatusRectum() Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -441,8 +469,12 @@ public Target_SemiMajorAxis() Description = "Shows the distance from the center of an orbit to the farthest edge."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -462,8 +494,12 @@ public Target_SemiMinorAxis() Description = "Shows the distance from the center of an orbit to the nearest edge."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -483,7 +519,7 @@ public Target_ObT() Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 3; Formatting = "N"; } @@ -513,8 +549,12 @@ public Target_ReferenceBodyConstants_Radius() Description = "Radius of the body that target is orbiting."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -534,7 +574,7 @@ public Target_ReferenceBodyConstants_StandardGravitationParameter() Description = "Product of the gravitational constant G and the mass M of the body target is orbiting."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "μ"; + BaseUnit = "μ"; NumberOfDecimalDigits = 4; Formatting = "e"; } @@ -555,8 +595,12 @@ public Target_OrbitRadius() Description = "Length from the center of the ellipse to the object."; Category = MicroEntryCategory.Target; IsDefault = false; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -576,7 +620,7 @@ public PhaseAngle() Description = "Angle between your vessel, the reference body and the target. How much \"ahead\" or \"behind\" in phase you are with the target."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -597,7 +641,7 @@ public TransferAngle() Description = "Phase angle needed for an optimal Hohmann transfer orbit. Use a circular orbit for a more accurate value."; Category = MicroEntryCategory.Target; IsDefault = true; - Unit = "°"; + BaseUnit = "°"; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -619,8 +663,12 @@ public DistanceAtCloseApproach1() Category = MicroEntryCategory.Target; IsDefault = true; HideWhenNoData = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -643,7 +691,7 @@ public TimeToCloseApproach1() Category = MicroEntryCategory.Target; IsDefault = true; HideWhenNoData = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -675,7 +723,11 @@ public RelativeSpeedAtCloseApproach1() Category = MicroEntryCategory.Target; IsDefault = true; HideWhenNoData = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -699,8 +751,12 @@ public DistanceAtCloseApproach2() Category = MicroEntryCategory.Target; IsDefault = false; HideWhenNoData = true; - Unit = "m"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm"; + BaseUnit = "m"; + KiloUnit = "km"; + MegaUnit = "Mm"; + GigaUnit = "Gm"; + NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -723,7 +779,7 @@ public TimeToCloseApproach2() Category = MicroEntryCategory.Target; IsDefault = false; HideWhenNoData = true; - Unit = "s"; + BaseUnit = "s"; Formatting = null; } @@ -755,7 +811,11 @@ public RelativeSpeedAtCloseApproach2() Category = MicroEntryCategory.Target; IsDefault = false; HideWhenNoData = true; - Unit = "m/s"; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; NumberOfDecimalDigits = 1; Formatting = "N"; } diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 7558f83..9331b4e 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -12,7 +12,7 @@ public VesselName() Description = "Name of the current vessel."; Category = MicroEntryCategory.Vessel; IsDefault = true; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -32,8 +32,12 @@ public Mass() Description = "Total mass of the vessel."; Category = MicroEntryCategory.Vessel; IsDefault = true; - Unit = "kg"; - NumberOfDecimalDigits = 0; + MiliUnit = "g"; + BaseUnit = "kg"; + KiloUnit = "T"; + MegaUnit = "kT"; + GigaUnit = "MT"; + NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -53,8 +57,12 @@ public TotalDeltaVActual() Description = "Vessel's total delta velocity."; Category = MicroEntryCategory.Vessel; IsDefault = true; - Unit = "m/s"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; + NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -74,8 +82,12 @@ public TotalDeltaVASL() Description = "Total delta velocity of the vessel At Sea Level."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "m/s"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; + NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -96,8 +108,12 @@ public TotalDeltaVVac() Description = "Total delta velocity of the vessel in vacuum."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "m/s"; - NumberOfDecimalDigits = 0; + MiliUnit = "mm/s"; + BaseUnit = "m/s"; + KiloUnit = "km/s"; + MegaUnit = "Mm/s"; + GigaUnit = "Gm/s"; + NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -117,7 +133,7 @@ public TotalBurnTime() Description = "Burn Time vessel can sustain with 100% thrust."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -147,14 +163,18 @@ public StageThrustActual() Description = "Vessel's actual thrust."; Category = MicroEntryCategory.Vessel; IsDefault = true; - Unit = "N"; - NumberOfDecimalDigits = 0; + MiliUnit = "N"; + BaseUnit = "kN"; + KiloUnit = "MN"; + MegaUnit = "GN"; + GigaUnit = null; + NumberOfDecimalDigits = 1; Formatting = "N"; } public override void RefreshData() { - EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustActual * 1000; + EntryValue = Utility.ActiveVessel.VesselDeltaV?.StageInfo.FirstOrDefault()?.ThrustActual; } public override string ValueDisplay => base.ValueDisplay; @@ -168,8 +188,12 @@ public StageThrustASL() Description = "Vessel's thrust At Sea Level."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "N"; - NumberOfDecimalDigits = 0; + MiliUnit = "N"; + BaseUnit = "kN"; + KiloUnit = "MN"; + MegaUnit = "GN"; + GigaUnit = null; + NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -189,8 +213,12 @@ public StageThrustVac() Description = "Vessel's thrust in vacuum."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "N"; - NumberOfDecimalDigits = 0; + MiliUnit = "N"; + BaseUnit = "kN"; + KiloUnit = "MN"; + MegaUnit = "GN"; + GigaUnit = null; + NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -210,7 +238,7 @@ public StageTWRActual() Description = "Vessel's Thrust to Weight Ratio."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -231,7 +259,7 @@ public StageTWRASL() Description = "Vessel's Thrust to Weight Ratio At Sea Level."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -252,7 +280,7 @@ public StageTWRVac() Description = "Vessel's Thrust to Weight Ratio in vacuum."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 2; Formatting = "N"; } @@ -273,7 +301,7 @@ public StageISPActual() Description = "Specific impulse (ISP) is a measure of how efficiently a reaction mass engine creates thrust."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -294,7 +322,7 @@ public StageISPAsl() Description = "Specific impulse At Sea Level."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -315,7 +343,7 @@ public StageISPVac() Description = "Specific impulse in vacuum."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "s"; + BaseUnit = "s"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -336,7 +364,7 @@ public FuelPercentage() Description = "Vessel's fuel percentage left."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "%"; + BaseUnit = "%"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -357,7 +385,7 @@ public StageFuelPercentage() Description = "Stage fuel percentage left."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "%"; + BaseUnit = "%"; NumberOfDecimalDigits = 1; Formatting = "N"; } @@ -378,7 +406,7 @@ public PartsCount() Description = "Number of parts vessel is constructed of."; Category = MicroEntryCategory.Vessel; IsDefault = true; - Unit = null; + BaseUnit = null; Formatting = null; } @@ -398,7 +426,7 @@ public Throttle() Description = "Vessel's current throttle in %."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = "%"; + BaseUnit = "%"; NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -419,7 +447,7 @@ public TotalCommandCrewCapacity() Description = "Crew capacity of all parts."; Category = MicroEntryCategory.Vessel; IsDefault = false; - Unit = null; + BaseUnit = null; NumberOfDecimalDigits = 0; Formatting = "N"; } diff --git a/MicroEngineerProject/MicroEngineer/Managers/UI.cs b/MicroEngineerProject/MicroEngineer/Managers/UI.cs index e752a98..95892c0 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/UI.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/UI.cs @@ -1,6 +1,5 @@ using BepInEx.Logging; using KSP.Game; -using KSP.Sim.DeltaV; using KSP.Sim.impl; using KSP.UI.Binding; using UnityEngine; @@ -200,11 +199,6 @@ private void DrawSettingsFlightWindow(int id) settingsWindow.ActiveTheme = Theme.Black; } GUILayout.EndHorizontal(); - - GUILayout.Space(10); - GUILayout.Label("Other"); - GUILayout.Space(-10); - GUILayout.Toggle(true, "use large units for large values", Styles.SectionToggleStyle); GUI.DragWindow(new Rect(0, 0, Screen.width, Screen.height)); } @@ -331,7 +325,7 @@ private void FillMainGUI(int windowID) if (window.Entries[i].HideWhenNoData && window.Entries[i].ValueDisplay == "-") continue; GUIStyle s = i == 0 ? Styles.EntryBackground_First : i < window.Entries.Count - 1 ? Styles.EntryBackground_Middle : Styles.EntryBackground_Last; - DrawEntry(s, window.Entries[i].Name, window.Entries[i].ValueDisplay, window.Entries[i].Unit); + DrawEntry(s, window.Entries[i].Name, window.Entries[i].ValueDisplay, window.Entries[i].UnitDisplay); } window.DrawWindowFooter(); @@ -366,7 +360,7 @@ private void DrawPopoutWindow(int windowIndex) if (w.Entries[i].HideWhenNoData && w.Entries[i].ValueDisplay == "-") continue; GUIStyle s = i == 0 ? Styles.EntryBackground_First : i < w.Entries.Count - 1 ? Styles.EntryBackground_Middle : Styles.EntryBackground_Last; - DrawEntry(s, w.Entries[i].Name, w.Entries[i].ValueDisplay, w.Entries[i].Unit); + DrawEntry(s, w.Entries[i].Name, w.Entries[i].ValueDisplay, w.Entries[i].UnitDisplay); } w.DrawWindowFooter(); @@ -631,7 +625,7 @@ private void DrawStageInfoOAB(int windowID) GUILayout.FlexibleSpace(); GUILayout.Label(torque.ValueDisplay, Styles.ValueLabelStyle); GUILayout.Space(5); - GUILayout.Label(torque.Unit, Styles.UnitLabelStyle); + GUILayout.Label(torque.UnitDisplay, Styles.UnitLabelStyle); GUILayout.EndHorizontal(); } From a2c336d47c76eb494dda0f7bf07893088cc290ae Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Tue, 25 Apr 2023 01:39:38 +0200 Subject: [PATCH 34/38] Add themes to edit window, OAB stage info hardcode gray theme --- .../MicroEngineer/Managers/MessageManager.cs | 1 + .../MicroEngineer/Managers/UI.cs | 57 ++++++++++--------- .../MicroEngineer/Windows/StageWindow.cs | 2 +- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs index 5e7d397..f9661c8 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs @@ -88,6 +88,7 @@ private void GameStateEntered(MessageCenterMessage obj) _ui.ShowGuiOAB = Windows.FindAll(w => w is EntryWindow).Cast().ToList().Find(w => w.MainWindow == MainWindow.StageInfoOAB).IsEditorActive; _ui.CelestialBodies.GetBodies(); _ui.CelestialBodySelectionStageIndex = -1; + Styles.SetActiveTheme(Theme.Gray); // TODO implement other themes in OAB } } } diff --git a/MicroEngineerProject/MicroEngineer/Managers/UI.cs b/MicroEngineerProject/MicroEngineer/Managers/UI.cs index 95892c0..4e32584 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/UI.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/UI.cs @@ -486,35 +486,38 @@ private void DrawEditWindow(int windowIndex) GUILayout.EndHorizontal(); var entries = editableWindows[_selectedWindowId].Entries.ToList(); - foreach (var (entry, index) in entries.Select((entry, index) => (entry, index))) + for (int i = 0; i < entries.Count; i++) { - GUILayout.BeginHorizontal(); - GUILayout.Label(entry.Name, Styles.NameLabelStyle); - GUI.enabled = entry.NumberOfDecimalDigits < 5; - if (entry.Formatting != null && GUILayout.Button(Styles.IncreaseDecimalDigitsTexture, Styles.OneCharacterBtnStyle)) + GUIStyle backgroundStyle = i == 0 ? Styles.EntryBackground_First : i < entries.Count - 1 ? Styles.EntryBackground_Middle : Styles.EntryBackground_Last; + + GUILayout.BeginHorizontal(backgroundStyle); + + GUILayout.Label(entries[i].Name, Styles.NameLabelStyle); + GUI.enabled = entries[i].NumberOfDecimalDigits < 5; + if (entries[i].Formatting != null && GUILayout.Button(Styles.IncreaseDecimalDigitsTexture, Styles.OneCharacterBtnStyle)) { - entry.NumberOfDecimalDigits++; + entries[i].NumberOfDecimalDigits++; } - GUI.enabled = entry.NumberOfDecimalDigits > 0; - if (entry.Formatting != null && GUILayout.Button(Styles.DecreaseDecimalDigitsTexture, Styles.OneCharacterBtnStyle)) + GUI.enabled = entries[i].NumberOfDecimalDigits > 0; + if (entries[i].Formatting != null && GUILayout.Button(Styles.DecreaseDecimalDigitsTexture, Styles.OneCharacterBtnStyle)) { - entry.NumberOfDecimalDigits--; + entries[i].NumberOfDecimalDigits--; } - GUI.enabled = index > 0; + GUI.enabled = i > 0; if (GUILayout.Button("↑", Styles.OneCharacterBtnStyle)) { - editableWindows[_selectedWindowId].MoveEntryUp(index); + editableWindows[_selectedWindowId].MoveEntryUp(i); } - GUI.enabled = index < editableWindows[_selectedWindowId].Entries.Count - 1; + GUI.enabled = i < editableWindows[_selectedWindowId].Entries.Count - 1; if (GUILayout.Button("↓", Styles.OneCharacterBtnStyle)) { - editableWindows[_selectedWindowId].MoveEntryDown(index); + editableWindows[_selectedWindowId].MoveEntryDown(i); } GUI.enabled = true; if (GUILayout.Button("X", Styles.OneCharacterBtnStyle)) - editableWindows[_selectedWindowId].RemoveEntry(index); + editableWindows[_selectedWindowId].RemoveEntry(i); GUILayout.EndHorizontal(); - GUILayout.Space(Styles.NegativeSpacingAfterEntry); + GUILayout.Space(-4); } #endregion @@ -546,35 +549,37 @@ private void DrawEditWindow(int windowIndex) } GUILayout.EndHorizontal(); - foreach (var (entry, index) in entriesByCategory.Select((entry, index) => (entry, index))) + for (int i = 0; i < entriesByCategory.Count; i++) { - GUILayout.BeginHorizontal(); - GUILayout.Label(entry.Name, Styles.NameLabelStyle); + GUIStyle backgroundStyle = i == 0 ? Styles.EntryBackground_First : i < entriesByCategory.Count - 1 ? Styles.EntryBackground_Middle : Styles.EntryBackground_Last; + + GUILayout.BeginHorizontal(backgroundStyle); + GUILayout.Label(entriesByCategory[i].Name, Styles.NameLabelStyle); if (GUILayout.Button("?", Styles.OneCharacterBtnStyle)) { if (!_showTooltip.condition) - _showTooltip = (true, index); + _showTooltip = (true, i); else { - if (_showTooltip.index != index) - _showTooltip = (true, index); + if (_showTooltip.index != i) + _showTooltip = (true, i); else - _showTooltip = (false, index); + _showTooltip = (false, i); } } if (GUILayout.Button("+", Styles.OneCharacterBtnStyle)) { - editableWindows[_selectedWindowId].AddEntry(entry); + editableWindows[_selectedWindowId].AddEntry(entriesByCategory[i]); } GUILayout.EndHorizontal(); - if (_showTooltip.condition && _showTooltip.index == index) + if (_showTooltip.condition && _showTooltip.index == i) { GUILayout.BeginHorizontal(); - GUILayout.Label(entry.Description, Styles.BlueLabelStyle); + GUILayout.Label(entriesByCategory[i].Description, Styles.BlueLabelStyle); GUILayout.EndHorizontal(); } - GUILayout.Space(Styles.NegativeSpacingAfterEntry); + GUILayout.Space(Styles.NegativeSpacingAfterEntry + 7); } GUILayout.Space(10); #endregion diff --git a/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs index 004a653..4d6cb09 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/StageWindow.cs @@ -60,7 +60,7 @@ private void DrawStages(int id) DeltaVStageInfo stageInfo = stages[i]; if (stageInfo.DeltaVinVac > 0.0001 || stageInfo.DeltaVatASL > 0.0001) { - GUIStyle style = stageBeingDrawn < numberOfNonEmptyStagesToDraw - 1 ? Styles.EntryBackground_Middle : Styles.EntryBackground_Last; + GUIStyle style = stageBeingDrawn++ < numberOfNonEmptyStagesToDraw - 1 ? Styles.EntryBackground_Middle : Styles.EntryBackground_Last; int stageNum = stageCount - stageInfo.Stage; DrawStageEntry(style, stageNum, stageInfo, twrFormatString); } From 78957e9b95a02fae57e08a52bb9dbe09bb3f0864 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Wed, 26 Apr 2023 00:22:58 +0200 Subject: [PATCH 35/38] Final tweaks --- MicroEngineerProject/MicroEngineer.sln | 8 ++++---- .../MicroEngineer/Entries/OrbitalEntries.cs | 2 +- .../MicroEngineer/Entries/SurfaceEntries.cs | 2 +- .../MicroEngineer/Entries/TargetEntries.cs | 4 ++-- .../MicroEngineer/Entries/VesselEntries.cs | 4 ++-- MicroEngineerProject/MicroEngineer/Utilities/Styles.cs | 6 ++++-- Staging/BepInEx/plugins/micro_engineer/swinfo.json | 3 ++- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer.sln b/MicroEngineerProject/MicroEngineer.sln index 1333d5b..4d3a884 100644 --- a/MicroEngineerProject/MicroEngineer.sln +++ b/MicroEngineerProject/MicroEngineer.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31605.320 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33530.505 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MicroEngineer", "MicroEngineer.csproj", "{2CD77478-E170-4D5C-91CA-0ABB24A30E5A}" EndProject @@ -11,8 +11,8 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Debug|Any CPU.ActiveCfg = Release|Any CPU + {2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Debug|Any CPU.Build.0 = Release|Any CPU {2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Release|Any CPU.ActiveCfg = Release|Any CPU {2CD77478-E170-4D5C-91CA-0ABB24A30E5A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 0867eed..73a566a 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -346,7 +346,7 @@ public class SemiLatusRectum : OrbitalEntry { public SemiLatusRectum() { - Name = "Semi Latus Rectum"; + Name = "Semi Latus Rect"; Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Orbital; IsDefault = false; diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index fd1036c..04e0d60 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -35,7 +35,7 @@ public class AltitudeAsl : SurfaceEntry { public AltitudeAsl() { - Name = "Altitude (Sea Lvl)"; + Name = "Altitude (Sea)"; Description = "Shows the vessel's altitude above sea level."; Category = MicroEntryCategory.Surface; IsDefault = true; diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index e3145e7..b44b3f4 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -88,7 +88,7 @@ public DistanceToTarget() KiloUnit = "km"; MegaUnit = "Mm"; GigaUnit = "Gm"; - NumberOfDecimalDigits = 2; + NumberOfDecimalDigits = 0; Formatting = "N"; } @@ -440,7 +440,7 @@ public class Target_SemiLatusRectum : TargetEntry { public Target_SemiLatusRectum() { - Name = "Semi Latus Rectum"; + Name = "Semi Latus Rect"; Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Target; IsDefault = false; diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 9331b4e..cd705f8 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -78,7 +78,7 @@ public class TotalDeltaVASL : VesselEntry { public TotalDeltaVASL() { - Name = "Total ∆v ASL"; + Name = "Total ∆v (ASL)"; Description = "Total delta velocity of the vessel At Sea Level."; Category = MicroEntryCategory.Vessel; IsDefault = false; @@ -237,7 +237,7 @@ public StageTWRActual() Name = "TWR"; Description = "Vessel's Thrust to Weight Ratio."; Category = MicroEntryCategory.Vessel; - IsDefault = false; + IsDefault = true; BaseUnit = null; NumberOfDecimalDigits = 2; Formatting = "N"; diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs index e8397af..d05b001 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs @@ -81,7 +81,7 @@ public static class Styles public static float PoppedOutX = Screen.width * 0.6f; public static float PoppedOutY = Screen.height * 0.2f; - public static float MainGuiX = Screen.width * 0.8f; + public static float MainGuiX = Screen.width * 0.7f; public static float MainGuiY = Screen.height * 0.2f; public static Rect CloseBtnRect = new Rect(Styles.WindowWidth - 23, 6, 16, 16); // TODO check if we need this @@ -201,7 +201,7 @@ private static void InitializeStyles() UnitLabelStyle = new GUIStyle(SpaceWarpUISkin.label) { - fixedWidth = 24, + fixedWidth = 35, alignment = TextAnchor.MiddleLeft }; UnitLabelStyle.normal.textColor = _unitColor; @@ -360,6 +360,8 @@ private static void InitializeStyles() private static void InitializeTextures() { + // Icons from https://icons8.com + Settings20Texture = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/settings-20.png"); Settings15Texture = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/settings-15.png"); CloseButtonTexture = LoadTexture($"{_plugin.SpaceWarpMetadata.ModID}/images/close-15.png"); diff --git a/Staging/BepInEx/plugins/micro_engineer/swinfo.json b/Staging/BepInEx/plugins/micro_engineer/swinfo.json index 5a87043..24c59de 100644 --- a/Staging/BepInEx/plugins/micro_engineer/swinfo.json +++ b/Staging/BepInEx/plugins/micro_engineer/swinfo.json @@ -4,7 +4,8 @@ "name": "Micro Engineer", "description": "Get in-flight and VAB information about your current vessel", "source": "https://github.com/Micrologist/MicroEngineer", - "version": "0.8.0", + "version": "1.0.0", + "version_check": "https://raw.githubusercontent.com/Falki-git/MicroEngineer/main/Staging/BepInEx/plugins/micro_engineer/swinfo.json", "dependencies": [ { "id": "SpaceWarp", From 53da7bcfbf2dea35db87c4cee1b00e75215479ad Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Wed, 26 Apr 2023 01:35:15 +0200 Subject: [PATCH 36/38] Update icon.png --- .../micro_engineer/assets/images/icon.png | Bin 11665 -> 656 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Staging/BepInEx/plugins/micro_engineer/assets/images/icon.png b/Staging/BepInEx/plugins/micro_engineer/assets/images/icon.png index 4136552dfc5ad9aeac858652f9a5014996a7458c..f39df0ca6de8a99c9cb9a2c75855f22b417116ce 100644 GIT binary patch delta 647 zcmV;20(kwATaX1IiBL{Q4GJ0x0000DNk~Le0000U0000U2nGNE06Q?QqLVHg7k>gm zNklR;Qw)cRvWQh zi9;;+)ea}X2Vevk)EE5W(XGZIegkX)x5m+42mM`#^fE}sSOC5P=fFk?-D5+1@TwXG zhJpT&cB_WC7L=M#c^}v@>v2<~V@Cc>bj|t~P;q?8OIkd%Z8AU~&;Xjip?}unjWN7Y z*`exOiH+J;rqb;;g#O)IdC=ni|E}>pCx)SP9pJE317lBxGGag?Oy;Gyxnp{9u zLsoJ~?|>Yzp!GSZzw^3h$xC`g`;K3WdP_NJlE{5o`~~JZgfOi-7R?|jflW_@s;;90 z=cHazhy2bBB`^T|H1acGT7QPci%F%K8X(t=)YyGDc1Na!zL*X-;WHisu8o6vXaAFi zRkCv3*;{l<&DOcJSHZTgBS~#p3^_V>)?S2d5Solt;Jt6+^n|!8=pO2ICBFbZb_n&g z4Ru)Zf^m?KnOucPqyp`|0i;CIsc_|VAA9TpJDvuTj@v-O5@)sDxm+#tUPCGOIHb># z%IrzSrl>x$kxt!8mNN0RdY h80-nO!zK2I>=C{s9E!`>p_Tvu002ovPDHLkV1ibJA(j9D literal 11665 zcmeHM2{@GN+aE%flqG9qjFhD@J2P{TovB6|6pGBsSZ2n|$k1XfvV|-~i>m6@%_)$=`8>Ao$uw@AtXh=bBv(_O{ZJ zs*)fONSa`0MFK|Ush^A(a4#F^s|JCjHiS62@JZw#Fo(-#F#YIYelUj)rVE%15J=En z>E@bVTvqb2Q)gI)qh)ju3paucY!j3{7tS6+tv^lob#kH_Ey~lvjRm(f-XL@r0@Z zp9QdP!NcwOi7oB-Hmobn*n1%P?#Gv-#=54jo8ceZn+=cIhHN=leZR2n+WQx`w@7a@ zMjeE>&ULJQmBZSNOysyX%AMeY3mz%%-n3JEg@7YQmvoj&^ zMx)nSQ9ZZ2c3afE-78d#1w2!4fc(_t|kx$IP1NDqLt)fz!hveSdzLQ$pF{9wPG;M3h zysV=!S00CpFtFXd7L5a|l^#CP11&v&eI7kEd~Pp>?t-fn9Iqk4Xg}rflK^9I<5)l@XR)W)nzDe#3r1~Au$SFz#s!OHEO$w7U~GPh<2-l} zU!Hh?cTYlRDf^6e%e~-{$la!*@_xO&5eqcylX4TqvM;q+Ygoo3w2$orRxX;T1*2XLqXl`V?uVX8PaR_!3%ii)336XnA+@ zaLI?oAy0>fD{mZ!l}dRy7I%(~rfwV@@wnhR!iJ>QO2oDF!inqZ`aL#=h26YguC3!+ zDX`yq(yI0lSz6n5>$)_-yu}qnX8y$0p!}n@4ZP47i-N14XHDGTEh(uUJiY#$dhqd; zDtZ^FD5-{mIP=$infY_h9N2R4i2lIoI<85+lWfxI$LkV~BcN?*1zE9$+Wl+mr8*xg z^>ZbyxfcT)_3n1%^LVwkg-tnu3R_E~APnNjY5o3(`p$cXh}wGscq6qJ@hqnJ?pWpU zK&AHVaeL)m6``8(tfG(3$|frYHbu4F^FAk;r?p@l5}#;18V3&%#*_~aC4GE6n71vZp zFB3$soMd;NLFp8DjfHKWy%b_-`TR>{7CG?V#7tYHg3iS@-2YmKeJfO9_ZQ7^hvY#lVP+cF3mz;Qdsl%h8{uG8#yZ6W{ zSoe(vrNQGIje7IU7~YQv)AFGG^7Yn9(oftaFl#|VF`h4L@KNj^hFDIQ7R!8Gb!A-@ zNF&Dma(s8m1~2vfP1bj0?w8<4Wp5I6jnBNfu7WlwxUIO|toQ^^q()$|dWY44BNk3| za@AfhSug#vjRb}(TUydrrEGRd4c+>B6e}{n!(}TQ9%|_uDX(i^>bicftlbTz!4&CK zgSLoEAbKn%A(!!G34aE z3z9K+n0f13IoTs3DtzIhHQYrdq&w+RGEo?kE+!xj^h1)fqYSo}Eb4bWEj6aCG5=(3 z!?pSp%VNRJ?y|k%ePoSeIXI$wG8OzF=SA@b?~#n;jNVXi-kheivwZ?sM8AQ#S(5ku zK+s+j4QYKlT?gio@s`}Mq;oONg9C?)z;kUJTfIuU=1qR^qrQ;ssMH*g-y5iQ$;5Z1 z>hl%8lJ_U&8Ch%RE;u-m^SnIs`mXubbComj@C|(RK$-ijG|mx_4AbenLT@~eld}*Q z_2RRQuP>LAG0+r!3OcnZS#d9x81a4RtxJ6?$nNM+u#(wNliO?@dcML ze6cx?v&zhNXkDb-s*v1JRmE*Z*Xvf_2kn6hzksWFO4sM?9*T8{MyoHcdbkoabYlsK znJsLFe+EDIUi#674^i**ANZCf8=1YT)m2v8AzqLy(vNS_5#(ffz7*f<=D5SAMEh9X zDhsc@l>r3XFjTF0jl+|p(rdEhgA)#`=cTx)?)R}(qhr^5Emx4U*aq;q& z;TMy3AD2jGFU7xLxOh(P+au!sYG;azk%fbEit?2;h+EF@<>v+&!gBj zs&xd`-#c=m{bWUSr(DRR^3(RBblH>e^DVTF^psTreQqMy@s#9PmB2YS){;&7{d^Oh zb=)fN@SXj{0C! zST3sosh^Yea*s>D*|HWO_CzTvP)`ios_ImSQA=c zmL+VJq2Efj7T)EuD8e=QX2_Cltu>GYQ~Jq(Q3-hc>n?HaWRM7XXnA8^vVUU-q=j)7Cdt*_4W{LH&cw-gQMqLLmtWTY3PqxEnRJ;@JVr$4OgJ0v1dcfDrp zS)8z3qd@zK!pmmN;HIc#D^Zh1#n8NbG;U~nf4mnN>sy_HQ7B1e6aoT#em!d7fDIA*@eWPl2~^XgN<{&^?w;HYOs6j~?{- zIHC7mA6C@{!8gR&d)tO)uYa?K03sEx65egDd@Gf3$1IEzd$CtIQ}jeyt&@W*-_u=^ z)%;`kBU$UNWv@*WPvyMnJxy75=2Y1xr7fy{@ePajNEaPca4>m6B8jp4Rm)Vljd}Re zVt=pfCM}2eNegy6YE`YURU!x~O&gJ@q#P4*VJvg(JmD&(3wEP2rABm@PJBo6HT*uu zofL32eK>XuFJ09jerg~_Hk=Ru_ed$48zs0LJrrbd=HUf?vW!$KF+Jx|s?>5z>~ity zR#{Dz^`uv3YQ*3byKXO$xO{ap96GMdz(o5*(9%RJl9QxNK2tVA7j_ zyx}#u-sKO++&k(LTWC)F10;2n9^SlgVrZg!J(=$lhYLN#Yggvy?S?N`cYZvvFNJ`r zRFTI&$ZjuF@0CAn3UjI9N0Zk0Gi~p(MwI5#$Bxg%>&KfKIXyHbzH5{jRI`42LO0@6 zu7;uY{H8}^+cHC0!fU(?#jeHV^0v(Dv2N>n7R$~Z9KY7&wU$qpf4E1d>ZHa?kA?1c zyMvd-mW;@$$K`G^+@EOG#@@2NGF{aB0lM!DXYn@_e6H9RAAKh4O+ zJG~37pPZAP!Q%=EVVEG0&<>`hr31mza^^D|__*G`E%^t#3l0l+P99ll?WXn=d_O4% z?>f2zyHa1V&Vs35@z|5wu7qaVkv6J{c1A?*ZYYY3D=(Q}5&?b-3J44!@ss6Rh>}o> zG3T_#q{(DU&492)d9zcwm#_oovfVNY#o(Ntm`7jq0^y~yDSHc-q2gQxH#<#Uk?vXt zrw8>MQXok#owF74+_+sjP7o>B+}cRBm7mCwYmu>C=$yAzbKu1J;J9+Pl)&a!T$F{ENpIX3gbrSC>WjQz`4hTxEfDo`x}sHYzo~#;LichMIeyz3IT^q^`-N{6uK9aWda$gJ_i9aX(o{M z7$Tg=v7~!5?LxS8#}IobYKSitM}w>|l{6OM0RVqGp9~iG`>}Xeqa4;7Z7W>OrR^teqTm41w{j(kTeFIMn=(~2pR?s zM1#aZDR71%6bnZqs0hht0)wX;7f+^sa>65Trhg(7SocXq^(M2t=)fEPxus_0%>Pg> zBNUE-Vo(uKG6iJ>Mbl7pDAovpfznY_2AYPYVhqXT=`?;u=dl_5ATpP3?geBDWCOI& zbT(j}&n)Zy+CIpeK1CrMiGsqBP$bp~iNvEZcq9@6`}@B3eG>!UWcu(3S-=Ng5O7v|GO`s9ob$vet8A^NPkf+vmerxalLW`kl?VJOCO`EP0%h)> z`nzl{pFp&pJ1|FRjv7SbmT3zJB&S8NGIw&35K@*Kc=ie4`~5ou-x>JVG9WZN^2yKF zY`M_qYqtDr^WVbz+PdG;&yGX*w+#O+^50#7nS^FDFe9HmevSFxi!&Q{_WY|A__L1w z?E2XO&z^rZf!Pbb#_ZShv+@4y{F@W_vkw32^hG+D@C7%g+wthzbt>cWp znROyF5C83Pb|8P$|2MbLY{#>iovr_)f&Jcf-<-hj1^#c@{ow>=Gd+9$e?Ebk0RO4L zXZ-)+3d{if)8jw33(bD{e=iZUEB>#q!0%1`yWMvN{=YJyw9L~^MC<+5sr(4m_Esep Ho)P~8!TybO From 23edf00607a2d8ab31b49189222514c01c20d6cc Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Wed, 26 Apr 2023 21:05:29 +0200 Subject: [PATCH 37/38] Lectoring --- .../MicroEngineer/Entries/BodyEntries.cs | 4 +-- .../MicroEngineer/Entries/FlightEntries.cs | 12 +++---- .../MicroEngineer/Entries/ManeuverEntries.cs | 30 ++++++++--------- .../MicroEngineer/Entries/MiscEntries.cs | 14 ++++---- .../Entries/OabStageInfoEntries.cs | 4 +-- .../MicroEngineer/Entries/OrbitalEntries.cs | 24 +++++++------- .../MicroEngineer/Entries/SurfaceEntries.cs | 14 ++++---- .../MicroEngineer/Entries/TargetEntries.cs | 32 +++++++++---------- .../MicroEngineer/Entries/VesselEntries.cs | 16 +++++----- 9 files changed, 75 insertions(+), 75 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs index b5d36df..ad0357e 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs @@ -28,7 +28,7 @@ public class ReferenceBodyConstants_Radius : BodyEntry { public ReferenceBodyConstants_Radius() { - Name = "Body Radius"; + Name = "Body radius"; Description = "Body's radius."; Category = MicroEntryCategory.Body; IsDefault = false; @@ -53,7 +53,7 @@ public class ReferenceBodyConstants_StandardGravitationParameter : BodyEntry { public ReferenceBodyConstants_StandardGravitationParameter() { - Name = "Std. Grav. Param."; + Name = "Std. grav. param."; Description = "Product of the gravitational constant G and the mass M of the body."; Category = MicroEntryCategory.Body; IsDefault = false; diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index df462a5..2567158 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -33,7 +33,7 @@ public class MachNumber : FlightEntry { public MachNumber() { - Name = "Mach Number"; + Name = "Mach number"; Description = "Shows the ratio of vessel's speed and local speed of sound."; Category = MicroEntryCategory.Flight; IsDefault = true; @@ -222,7 +222,7 @@ public class TotalLift : FlightEntry { public TotalLift() { - Name = "Total Lift"; + Name = "Total lift"; Description = "Shows the total lift force produced by the vessel."; Category = MicroEntryCategory.Flight; IsDefault = true; @@ -257,7 +257,7 @@ public class TotalDrag : FlightEntry { public TotalDrag() { - Name = "Total Drag"; + Name = "Total drag"; Description = "Shows the total drag force exerted on the vessel."; Category = MicroEntryCategory.Flight; IsDefault = true; @@ -323,7 +323,7 @@ public class DragCoefficient : FlightEntry { public DragCoefficient() { - Name = "Drag Coefficient"; + Name = "Drag coefficient"; Description = "Dimensionless quantity that is used to quantify the drag or resistance of an object in a fluid environment, such as air or water."; Category = MicroEntryCategory.Flight; IsDefault = false; @@ -344,7 +344,7 @@ public class ExposedArea : FlightEntry { public ExposedArea() { - Name = "Exposed Area"; + Name = "Exposed area"; Description = "The surface area that interacts with the working fluid or gas."; Category = MicroEntryCategory.Flight; IsDefault = false; @@ -365,7 +365,7 @@ public class AtmosphericDensity : FlightEntry { public AtmosphericDensity() { - Name = "Atm. Density"; + Name = "Atm. density"; Description = "Shows the atmospheric density."; Category = MicroEntryCategory.Flight; IsDefault = true; diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 08be5cd..24c0483 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -43,7 +43,7 @@ public class ManeuverPrograde : ManeuverEntry { public ManeuverPrograde() { - Name = "∆v Prograde"; + Name = "∆v prograde"; Description = "Prograde/Retrograde component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -69,7 +69,7 @@ public class ManeuverNormal : ManeuverEntry { public ManeuverNormal() { - Name = "∆v Normal"; + Name = "∆v normal"; Description = "Normal component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -95,7 +95,7 @@ public class ManeuverRadial : ManeuverEntry { public ManeuverRadial() { - Name = "∆v Radial"; + Name = "∆v radial"; Description = "Radial component of the total change in velocity."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -121,7 +121,7 @@ public class TimeToNode : ManeuverEntry { public TimeToNode() { - Name = "Time to Node"; + Name = "Time to node"; Description = "Time until vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = true; @@ -151,7 +151,7 @@ public class BurnTime : ManeuverEntry { public BurnTime() { - Name = "Burn Time"; + Name = "Burn time"; Description = "Length of time needed to complete the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = true; @@ -381,7 +381,7 @@ public class Maneuver_TrueAnomaly : ManeuverEntry { public Maneuver_TrueAnomaly() { - Name = "True Anomaly"; + Name = "True anomaly"; Description = "True Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -414,7 +414,7 @@ public class Maneuver_MeanAnomaly : ManeuverEntry { public Maneuver_MeanAnomaly() { - Name = "Mean Anomaly"; + Name = "Mean anomaly"; Description = "Mean Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -447,7 +447,7 @@ public class Maneuver_EccentricAnomaly : ManeuverEntry { public Maneuver_EccentricAnomaly() { - Name = "Eccentric Anomaly"; + Name = "Eccentric anomaly"; Description = "Eccentric Anomaly vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -528,7 +528,7 @@ public class Maneuver_SemiLatusRectum : ManeuverEntry { public Maneuver_SemiLatusRectum() { - Name = "Semi Latus Rectum"; + Name = "Semi latus rect"; Description = "Semi Latus Rectum vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -556,7 +556,7 @@ public class Maneuver_SemiMajorAxis : ManeuverEntry { public Maneuver_SemiMajorAxis() { - Name = "Semi Major Axis"; + Name = "Semi major axis"; Description = "Semi Major Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -584,7 +584,7 @@ public class Maneuver_SemiMinorAxis : ManeuverEntry { public Maneuver_SemiMinorAxis() { - Name = "Semi Minor Axis"; + Name = "Semi minor axis"; Description = "Semi Minor Axis vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -612,7 +612,7 @@ public class Maneuver_OrbitalEnergy : ManeuverEntry { public Maneuver_OrbitalEnergy() { - Name = "Orbital Energy"; + Name = "Orbital energy"; Description = "Orbital Energy vessel will have after completing the maneuver."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -640,7 +640,7 @@ public class Maneuver_ObT : ManeuverEntry { public Maneuver_ObT() { - Name = "Orbit Time"; + Name = "Orbit time"; Description = "Shows orbit time in seconds from the Periapsis when vessel reaches the maneuver node."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -730,7 +730,7 @@ public class Maneuver_UniversalTimeAtClosestApproach : ManeuverEntry { public Maneuver_UniversalTimeAtClosestApproach() { - Name = "UT Close.App."; + Name = "UT close.app."; Description = "Universal Time at the point of closest approach."; Category = MicroEntryCategory.Maneuver; IsDefault = false; @@ -762,7 +762,7 @@ public class Maneuver_UniversalTimeAtSoiEncounter : ManeuverEntry { public Maneuver_UniversalTimeAtSoiEncounter() { - Name = "UT SOI Enc."; + Name = "UT SOI enc."; Description = "Universal Time at the point of transition to another Sphere Of Influence."; Category = MicroEntryCategory.Maneuver; IsDefault = false; diff --git a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs index e519e33..7bc6ce5 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/MiscEntries.cs @@ -23,7 +23,7 @@ public class GravityForPos : MiscEntry { public GravityForPos() { - Name = "Local Gravity"; + Name = "Local gravity"; Description = "Local gravity vessel is experiencing."; Category = MicroEntryCategory.Misc; IsDefault = false; @@ -104,7 +104,7 @@ public class LaunchTime : MiscEntry { public LaunchTime() { - Name = "Launch Time"; + Name = "Launch time"; Description = "Universal Time when vessel was launched."; Category = MicroEntryCategory.Misc; IsDefault = false; @@ -184,7 +184,7 @@ public class AutopilotStatus_Mode : MiscEntry { public AutopilotStatus_Mode() { - Name = "Autopilot Mode"; + Name = "Autopilot mode"; Description = "Mode vessel's autopilot is using: stability assist, prograde, retrograde, normal, etc."; Category = MicroEntryCategory.Misc; IsDefault = false; @@ -204,7 +204,7 @@ public class AltimeterMode : MiscEntry { public AltimeterMode() { - Name = "Altimeter Mode"; + Name = "Altimeter mode"; Description = "Mode vessel's altimeter is using: Sea Level or Ground Level."; Category = MicroEntryCategory.Misc; IsDefault = false; @@ -224,7 +224,7 @@ public class SpeedMode : MiscEntry { public SpeedMode() { - Name = "Speed Mode"; + Name = "Speed mode"; Description = "Mode vessel's velocity meter is using: Orbit, Surface or Target."; Category = MicroEntryCategory.Misc; IsDefault = false; @@ -244,7 +244,7 @@ public class UniversalTimeAtClosestApproach : MiscEntry { public UniversalTimeAtClosestApproach() { - Name = "UT Close.App."; + Name = "UT close.app."; Description = "Universal Time at closest approach."; Category = MicroEntryCategory.Misc; IsDefault = false; @@ -274,7 +274,7 @@ public class UniversalTimeAtSoiEncounter : MiscEntry { public UniversalTimeAtSoiEncounter() { - Name = "UT SOI Enc."; + Name = "UT SOI enc."; Description = "Universal Time at the point of transfer to another sphere of influence."; Category = MicroEntryCategory.Misc; IsDefault = false; diff --git a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs index ccb1e70..5eb17a0 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs @@ -14,7 +14,7 @@ public class TotalBurnTime_OAB : OabStageInfoEntry public TotalBurnTime_OAB() { - Name = "Total Burn Time (OAB)"; + Name = "Total burn time (OAB)"; Description = "Shows the total length of burn the vessel can mantain."; Category = MicroEntryCategory.OAB; IsDefault = true; @@ -72,7 +72,7 @@ public class TotalDeltaVActual_OAB : OabStageInfoEntry { public TotalDeltaVActual_OAB() { - Name = "Total ∆v Actual (OAB)"; + Name = "Total ∆v actual (OAB)"; Description = "Shows the vessel's actual total delta velocity (not used in OAB)."; Category = MicroEntryCategory.OAB; IsDefault = true; diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index 73a566a..c794710 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -189,7 +189,7 @@ public class OrbitalSpeed : OrbitalEntry { public OrbitalSpeed() { - Name = "Orbital Speed"; + Name = "Orbital speed"; Description = "Shows the vessel's orbital speed"; Category = MicroEntryCategory.Orbital; IsDefault = true; @@ -214,7 +214,7 @@ public class TrueAnomaly : OrbitalEntry { public TrueAnomaly() { - Name = "True Anomaly"; + Name = "True anomaly"; Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -244,7 +244,7 @@ public class MeanAnomaly : OrbitalEntry { public MeanAnomaly() { - Name = "Mean Anomaly"; + Name = "Mean anomaly"; Description = "Parameter used to describe the position of an object in its orbit around the celestial body."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -274,7 +274,7 @@ public class EccentricAnomaly : OrbitalEntry { public EccentricAnomaly() { - Name = "Eccentric Anomaly"; + Name = "Eccentric anomaly"; Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the vessel is."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -346,7 +346,7 @@ public class SemiLatusRectum : OrbitalEntry { public SemiLatusRectum() { - Name = "Semi Latus Rect"; + Name = "Semi latus rect"; Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -371,7 +371,7 @@ public class SemiMajorAxis : OrbitalEntry { public SemiMajorAxis() { - Name = "Semi Major Axis"; + Name = "Semi major axis"; Description = "Shows the distance from the center of an orbit to the farthest edge."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -396,7 +396,7 @@ public class SemiMinorAxis : OrbitalEntry { public SemiMinorAxis() { - Name = "Semi Minor Axis"; + Name = "Semi minor axis"; Description = "Shows the distance from the center of an orbit to the nearest edge."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -421,7 +421,7 @@ public class OrbitalEnergy : OrbitalEntry { public OrbitalEnergy() { - Name = "Orbital Energy"; + Name = "Orbital energy"; Description = "Constant sum of two orbiting bodies' mutual potential energy and their total kinetic energy divided by the reduced mass."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -446,7 +446,7 @@ public class ObT : OrbitalEntry { public ObT() { - Name = "Orbit Time"; + Name = "Orbit time"; Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -476,7 +476,7 @@ public class OrbitPercent : OrbitalEntry { public OrbitPercent() { - Name = "Orbit Percent"; + Name = "Orbit percent"; Description = "Percent of the orbit completed."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -497,7 +497,7 @@ public class OrbitRadius : OrbitalEntry { public OrbitRadius() { - Name = "Orbit Radius"; + Name = "Orbit radius"; Description = "Length from the center of the ellipse to the object."; Category = MicroEntryCategory.Orbital; IsDefault = false; @@ -522,7 +522,7 @@ public class SoiTransition : OrbitalEntry { public SoiTransition() { - Name = "SOI Trans."; + Name = "SOI trans."; Description = "Shows the amount of time it will take to transition to another Sphere Of Influence."; Category = MicroEntryCategory.Orbital; IsDefault = false; diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index 04e0d60..9d0440c 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -10,7 +10,7 @@ public class AltitudeAgl : SurfaceEntry { public AltitudeAgl() { - Name = "Altitude (Ground)"; + Name = "Altitude (ground)"; Description = "Shows the vessel's altitude above ground Level."; Category = MicroEntryCategory.Surface; IsDefault = true; @@ -35,7 +35,7 @@ public class AltitudeAsl : SurfaceEntry { public AltitudeAsl() { - Name = "Altitude (Sea)"; + Name = "Altitude (sea)"; Description = "Shows the vessel's altitude above sea level."; Category = MicroEntryCategory.Surface; IsDefault = true; @@ -60,7 +60,7 @@ public class AltitudeFromScenery : SurfaceEntry { public AltitudeFromScenery() { - Name = "Altitude (Scenery)"; + Name = "Altitude (scenery)"; Description = "Shows the vessel's altitude above scenery."; Category = MicroEntryCategory.Surface; IsDefault = false; @@ -85,7 +85,7 @@ public class VerticalVelocity : SurfaceEntry { public VerticalVelocity() { - Name = "Vertical Vel."; + Name = "Vertical vel."; Description = "Shows the vessel's vertical velocity (up/down)."; Category = MicroEntryCategory.Surface; IsDefault = true; @@ -110,7 +110,7 @@ public class HorizontalVelocity : SurfaceEntry { public HorizontalVelocity() { - Name = "Horizontal Vel."; + Name = "Horizontal vel."; Description = "Shows the vessel's horizontal velocity across a celestial body's surface."; Category = MicroEntryCategory.Surface; IsDefault = true; @@ -251,7 +251,7 @@ public class DynamicPressure_kPa : SurfaceEntry { public DynamicPressure_kPa() { - Name = "Dynamic Pressure"; + Name = "Dynamic pressure"; Description = "Dynamic Pressure (q) is a defined property of a moving flow of gas. It describes how much pressure the airflow is having on the vessel."; Category = MicroEntryCategory.Surface; IsDefault = false; @@ -276,7 +276,7 @@ public class StaticPressure_kPa : SurfaceEntry { public StaticPressure_kPa() { - Name = "Static Pressure"; + Name = "Static pressure"; Description = "Static pressure is a term used to define the amount of pressure exerted by a fluid that is not moving - ambient pressure."; Category = MicroEntryCategory.Surface; IsDefault = false; diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index b44b3f4..6963f01 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -115,7 +115,7 @@ public class RelativeSpeed : TargetEntry { public RelativeSpeed() { - Name = "Rel. Speed"; + Name = "Rel. speed"; Description = "Shows the relative velocity between the vessel and the target."; Category = MicroEntryCategory.Target; IsDefault = true; @@ -153,7 +153,7 @@ public class RelativeInclination : TargetEntry { public RelativeInclination() { - Name = "Rel. Inclination"; + Name = "Rel. inclination"; Description = "Shows the relative inclination between the vessel and the target."; Category = MicroEntryCategory.Target; IsDefault = true; @@ -187,7 +187,7 @@ public class Target_AltitudeFromSeaLevel : TargetEntry { public Target_AltitudeFromSeaLevel() { - Name = "Altitude (Sea)"; + Name = "Altitude (sea)"; Description = "Shows the target's altitude above sea level."; Category = MicroEntryCategory.Target; IsDefault = true; @@ -283,7 +283,7 @@ public class Target_Obtvelocity : TargetEntry { public Target_Obtvelocity() { - Name = "Orbital Speed"; + Name = "Orbital speed"; Description = "Shows the target's orbital speed."; Category = MicroEntryCategory.Target; IsDefault = true; @@ -308,7 +308,7 @@ public class Target_TrueAnomaly : TargetEntry { public Target_TrueAnomaly() { - Name = "True Anomaly"; + Name = "True anomaly"; Description = "Angle between the direction of periapsis and the current position of the object, as seen from the main focus of the ellipse."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -338,7 +338,7 @@ public class Target_MeanAnomaly : TargetEntry { public Target_MeanAnomaly() { - Name = "Mean Anomaly"; + Name = "Mean anomaly"; Description = "Parameter used to describe the position of the target in its orbit around the celestial body."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -368,7 +368,7 @@ public class Target_EccentricAnomaly : TargetEntry { public Target_EccentricAnomaly() { - Name = "Eccentric Anomaly"; + Name = "Eccentric anomaly"; Description = "Angle at the center of the orbital ellipse from the semi major axis to the line that passes through the center of the ellipse and the point on the auxiliary circle that is the intersection of the line perpendicular to the semi major axis and passes through the point in the orbit where the target is."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -440,7 +440,7 @@ public class Target_SemiLatusRectum : TargetEntry { public Target_SemiLatusRectum() { - Name = "Semi Latus Rect"; + Name = "Semi latus rect"; Description = "Half the length of the chord through one focus, perpendicular to the major axis."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -465,7 +465,7 @@ public class Target_SemiMajorAxis : TargetEntry { public Target_SemiMajorAxis() { - Name = "Semi Major Axis"; + Name = "Semi major axis"; Description = "Shows the distance from the center of an orbit to the farthest edge."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -490,7 +490,7 @@ public class Target_SemiMinorAxis : TargetEntry { public Target_SemiMinorAxis() { - Name = "Semi Minor Axis"; + Name = "Semi minor axis"; Description = "Shows the distance from the center of an orbit to the nearest edge."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -515,7 +515,7 @@ public class Target_ObT : TargetEntry { public Target_ObT() { - Name = "Orbit Time"; + Name = "Orbit time"; Description = "Shows orbit time in seconds from the Periapsis."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -545,7 +545,7 @@ public class Target_ReferenceBodyConstants_Radius : TargetEntry { public Target_ReferenceBodyConstants_Radius() { - Name = "Body Radius"; + Name = "Body radius"; Description = "Radius of the body that target is orbiting."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -570,7 +570,7 @@ public class Target_ReferenceBodyConstants_StandardGravitationParameter : Target { public Target_ReferenceBodyConstants_StandardGravitationParameter() { - Name = "Std. Grav. Param."; + Name = "Std. grav. param."; Description = "Product of the gravitational constant G and the mass M of the body target is orbiting."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -591,7 +591,7 @@ public class Target_OrbitRadius : TargetEntry { public Target_OrbitRadius() { - Name = "Orbit Radius"; + Name = "Orbit radius"; Description = "Length from the center of the ellipse to the object."; Category = MicroEntryCategory.Target; IsDefault = false; @@ -616,7 +616,7 @@ public class PhaseAngle : TargetEntry { public PhaseAngle() { - Name = "Phase Angle"; + Name = "Phase angle"; Description = "Angle between your vessel, the reference body and the target. How much \"ahead\" or \"behind\" in phase you are with the target."; Category = MicroEntryCategory.Target; IsDefault = true; @@ -637,7 +637,7 @@ public class TransferAngle : TargetEntry { public TransferAngle() { - Name = "Transfer Angle"; + Name = "Transfer angle"; Description = "Phase angle needed for an optimal Hohmann transfer orbit. Use a circular orbit for a more accurate value."; Category = MicroEntryCategory.Target; IsDefault = true; diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index cd705f8..5c83e3a 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -78,7 +78,7 @@ public class TotalDeltaVASL : VesselEntry { public TotalDeltaVASL() { - Name = "Total ∆v (ASL)"; + Name = "Total ∆v ASL"; Description = "Total delta velocity of the vessel At Sea Level."; Category = MicroEntryCategory.Vessel; IsDefault = false; @@ -129,7 +129,7 @@ public class TotalBurnTime : VesselEntry { public TotalBurnTime() { - Name = "Total Burn Time"; + Name = "Total burn time"; Description = "Burn Time vessel can sustain with 100% thrust."; Category = MicroEntryCategory.Vessel; IsDefault = false; @@ -209,7 +209,7 @@ public class StageThrustVac : VesselEntry { public StageThrustVac() { - Name = "Thrust (Vacuum)"; + Name = "Thrust (vacuum)"; Description = "Vessel's thrust in vacuum."; Category = MicroEntryCategory.Vessel; IsDefault = false; @@ -276,7 +276,7 @@ public class StageTWRVac : VesselEntry { public StageTWRVac() { - Name = "TWR (Vacuum)"; + Name = "TWR (vacuum)"; Description = "Vessel's Thrust to Weight Ratio in vacuum."; Category = MicroEntryCategory.Vessel; IsDefault = false; @@ -339,7 +339,7 @@ public class StageISPVac : VesselEntry { public StageISPVac() { - Name = "ISP (Vacuum)"; + Name = "ISP (vacuum)"; Description = "Specific impulse in vacuum."; Category = MicroEntryCategory.Vessel; IsDefault = false; @@ -360,7 +360,7 @@ public class FuelPercentage : VesselEntry { public FuelPercentage() { - Name = "Vessel Fuel"; + Name = "Vessel fuel"; Description = "Vessel's fuel percentage left."; Category = MicroEntryCategory.Vessel; IsDefault = false; @@ -381,7 +381,7 @@ public class StageFuelPercentage : VesselEntry { public StageFuelPercentage() { - Name = "Stage Fuel"; + Name = "Stage fuel"; Description = "Stage fuel percentage left."; Category = MicroEntryCategory.Vessel; IsDefault = false; @@ -443,7 +443,7 @@ public class TotalCommandCrewCapacity : VesselEntry { public TotalCommandCrewCapacity() { - Name = "Command Crew Capacity"; + Name = "Command crew capacity"; Description = "Crew capacity of all parts."; Category = MicroEntryCategory.Vessel; IsDefault = false; From 4c5de68cec920daa1671acac780871eff7d8c312 Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Wed, 26 Apr 2023 22:34:09 +0200 Subject: [PATCH 38/38] Nothing important --- MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs | 2 +- MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs | 2 +- MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs | 2 +- MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs | 2 +- .../MicroEngineer/Entries/OabStageInfoEntries.cs | 2 +- MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs | 2 +- .../MicroEngineer/Entries/StageInfoEntries.cs | 2 +- MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs | 2 +- MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs | 2 +- MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs | 2 +- MicroEngineerProject/MicroEngineer/Managers/Manager.cs | 2 +- .../MicroEngineer/Managers/MicroCelestialBodies.cs | 2 +- MicroEngineerProject/MicroEngineer/Managers/UI.cs | 2 +- MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs | 2 +- MicroEngineerProject/MicroEngineer/Utilities/Styles.cs | 2 +- MicroEngineerProject/MicroEngineer/Utilities/Utility.cs | 4 ++-- MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs | 2 +- MicroEngineerProject/MicroEngineer/Windows/MainGuiWindow.cs | 2 +- MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs | 2 +- 19 files changed, 20 insertions(+), 20 deletions(-) diff --git a/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs b/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs index ccc0ff2..9e1f3d8 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs @@ -127,4 +127,4 @@ public virtual string UnitDisplay public virtual void RefreshData() { } } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs index ad0357e..37fbab7 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/BodyEntries.cs @@ -69,4 +69,4 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs index 2567158..da143df 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs @@ -410,4 +410,4 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs index 24c0483..657a0e6 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/ManeuverEntries.cs @@ -789,4 +789,4 @@ public override string ValueDisplay } } } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs index 5eb17a0..f0c342d 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs @@ -298,4 +298,4 @@ private double GetISPAtAltitude(double altitude, CelestialBodyComponent cel) internal double GetTWRAtSeaLevel(CelestialBodyComponent cel) => this.GetTWRAtAltitude(0, cel); internal double GetDeltaVelAtSeaLevel(CelestialBodyComponent cel) => GetDeltaVelAlt(0, cel); } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs index c794710..37c1cbb 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs @@ -546,4 +546,4 @@ public override string ValueDisplay } } } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs index 0d34bc1..c3c3b45 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/StageInfoEntries.cs @@ -23,4 +23,4 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs index 9d0440c..22169e1 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs @@ -338,4 +338,4 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs index 6963f01..a1f144a 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs @@ -829,4 +829,4 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs index 5c83e3a..09f08c8 100644 --- a/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs +++ b/MicroEngineerProject/MicroEngineer/Entries/VesselEntries.cs @@ -459,4 +459,4 @@ public override void RefreshData() public override string ValueDisplay => base.ValueDisplay; } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Managers/Manager.cs b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs index 8ec5423..77bfd24 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/Manager.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/Manager.cs @@ -308,4 +308,4 @@ internal void LoadLayout() internal void SaveLayout() => Utility.SaveLayout(Windows); } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs b/MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs index afb5c24..72d3006 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs @@ -139,4 +139,4 @@ internal class CelestialBody internal bool IsHomeWorld; internal CelestialBodyComponent CelestialBodyComponent; } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Managers/UI.cs b/MicroEngineerProject/MicroEngineer/Managers/UI.cs index 4e32584..f15787e 100644 --- a/MicroEngineerProject/MicroEngineer/Managers/UI.cs +++ b/MicroEngineerProject/MicroEngineer/Managers/UI.cs @@ -11,7 +11,7 @@ internal class UI private MicroEngineerMod _plugin; private Manager _manager; - private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.MessageManager"); + private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.UI"); internal List Windows; diff --git a/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs b/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs index e31e2b4..1550d1d 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/AeroForces.cs @@ -131,4 +131,4 @@ public static double SideSlip } } } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs index d05b001..50e8bb5 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Styles.cs @@ -467,4 +467,4 @@ public enum Theme Gray, Black } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs index 7d13b84..a505775 100644 --- a/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs +++ b/MicroEngineerProject/MicroEngineer/Utilities/Utility.cs @@ -18,7 +18,7 @@ public static class Utility public static VesselComponent ActiveVessel; public static ManeuverNodeData CurrentManeuver; public static string LayoutPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "MicroLayout.json"); - public static int CurrentLayoutVersion = 9; + public static int CurrentLayoutVersion = 10; private static ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.Utility"); public static GameStateConfiguration GameState; public static MessageCenter MessageCenter; @@ -326,4 +326,4 @@ internal static bool IsModOlderThan(string modId, int major, int minor, int patc return false; } } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs index 106e6fe..34b5bcd 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/BaseWindow.cs @@ -60,4 +60,4 @@ public enum MainWindow Settings, StageInfoOAB } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Windows/MainGuiWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/MainGuiWindow.cs index e5b6c34..345e92c 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/MainGuiWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/MainGuiWindow.cs @@ -7,4 +7,4 @@ internal class MainGuiWindow : BaseWindow [JsonProperty] internal int LayoutVersion; } -} +} \ No newline at end of file diff --git a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs index cd95edc..f8ac4ca 100644 --- a/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs +++ b/MicroEngineerProject/MicroEngineer/Windows/ManeuverWindow.cs @@ -100,4 +100,4 @@ internal void OnManeuverRemovedMessage(MessageCenterMessage message) _selectedNodeIndex = 0; } } -} +} \ No newline at end of file