diff --git a/MicroEngineerProject/MicroEngineer.csproj b/MicroEngineerProject/MicroEngineer.csproj
index 35af288..5eae1eb 100644
--- a/MicroEngineerProject/MicroEngineer.csproj
+++ b/MicroEngineerProject/MicroEngineer.csproj
@@ -9,31 +9,10 @@
-
-
-
-
-
-
- external_dlls\UitkForKsp2.dll
-
-
- external_dlls\UitkForKsp2.Controls.dll
-
-
- external_dlls\UnityEngine.IMGUIModule.dll
-
-
- external_dlls\UnityEngine.InputLegacyModule.dll
-
-
- external_dlls\UnityEngine.TextRenderingModule.dll
-
-
- external_dlls\UnityEngine.UIElementsModule.dll
-
+
+
-
+
\ No newline at end of file
diff --git a/MicroEngineerProject/MicroEngineer.sln b/MicroEngineerProject/MicroEngineer.sln
index 4d3a884..1394d9c 100644
--- a/MicroEngineerProject/MicroEngineer.sln
+++ b/MicroEngineerProject/MicroEngineer.sln
@@ -11,8 +11,8 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {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}.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}.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/BaseEntry.cs b/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs
index 72d755e..85f2151 100644
--- a/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs
+++ b/MicroEngineerProject/MicroEngineer/Entries/BaseEntry.cs
@@ -1,5 +1,4 @@
-using BepInEx.Logging;
-using Newtonsoft.Json;
+using Newtonsoft.Json;
namespace MicroMod
{
@@ -31,6 +30,8 @@ public class BaseEntry
[JsonProperty]
public string GigaUnit;
[JsonProperty]
+ public AltUnit AltUnit;
+ [JsonProperty]
public byte NumberOfDecimalDigits;
[JsonProperty("Formatting")]
private string _formatting;
@@ -101,6 +102,12 @@ public virtual string ValueDisplay
if (!double.TryParse(EntryValue.ToString(), out double d))
return EntryValue.ToString(); // This case shouldn't exist, but just to be sure
+ if (AltUnit != null && AltUnit.IsActive)
+ {
+ return !string.IsNullOrEmpty(Formatting) ? String.Format(Formatting, d * AltUnit.Factor) :
+ (d * AltUnit.Factor).ToString();
+ }
+
if (Math.Abs(d) < 1) // mili
{
return !String.IsNullOrEmpty(this.MiliUnit) ? String.Format(Formatting, d * 1000) :
@@ -146,6 +153,9 @@ public virtual string UnitDisplay
if (!double.TryParse(EntryValue.ToString(), out double d))
return this.BaseUnit ?? ""; // This case shouldn't exist, but just to be sure
+ if (AltUnit != null && AltUnit.IsActive)
+ return AltUnit.Unit;
+
if (d > 0.001 && d < 1) // mili
{
return this.MiliUnit ?? this.BaseUnit ?? "";
@@ -172,5 +182,15 @@ public virtual string UnitDisplay
}
public virtual void RefreshData() { }
- }
+ }
+
+ public class AltUnit
+ {
+ [JsonProperty]
+ public bool IsActive;
+ [JsonProperty]
+ public string Unit;
+ [JsonProperty]
+ public float Factor;
+ }
}
\ No newline at end of file
diff --git a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs
index 0d76542..25d9a32 100644
--- a/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs
+++ b/MicroEngineerProject/MicroEngineer/Entries/FlightEntries.cs
@@ -18,6 +18,12 @@ public Speed()
GigaUnit = "Gm/s";
NumberOfDecimalDigits = 2;
Formatting = "N";
+ AltUnit = new AltUnit()
+ {
+ IsActive = false,
+ Unit = "km/h",
+ Factor = (60f * 60f) / 1000f
+ };
}
public override void RefreshData()
@@ -400,6 +406,12 @@ public SoundSpeed()
GigaUnit = "Gm/s";
NumberOfDecimalDigits = 2;
Formatting = "N";
+ AltUnit = new AltUnit()
+ {
+ IsActive = false,
+ Unit = "km/h",
+ Factor = (60f * 60f) / 1000f
+ };
}
public override void RefreshData()
diff --git a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs
index 1846891..2474f9e 100644
--- a/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs
+++ b/MicroEngineerProject/MicroEngineer/Entries/OabStageInfoEntries.cs
@@ -1,5 +1,4 @@
-using BepInEx.Logging;
-using KSP.Game;
+using KSP.Game;
using KSP.Sim.DeltaV;
using KSP.Sim.impl;
@@ -16,7 +15,7 @@ public TotalBurnTime_OAB()
{
Name = "Total burn time (OAB)";
Description = "Shows the total length of burn the vessel can mantain.";
- EntryType = EntryType.Time;
+ EntryType = EntryType.Time;
Category = MicroEntryCategory.OAB;
IsDefault = true;
BaseUnit = "s";
@@ -105,7 +104,7 @@ public override void RefreshData()
///
/// Calculates torque from the Center of Thrust and Center of Mass
- ///
+ ///
public class Torque : OabStageInfoEntry
{
public Torque()
@@ -188,7 +187,7 @@ public override void RefreshData()
if (Utility.VesselDeltaVComponentOAB?.StageInfo == null) return;
- for (int i = 0; i < Utility.VesselDeltaVComponentOAB.StageInfo.Count; i++)
+ for (int i = 0; i < Utility.VesselDeltaVComponentOAB.StageInfo.Count; i++)
{
var retrieved = Utility.VesselDeltaVComponentOAB.StageInfo[i];
var stage = new DeltaVStageInfo_OAB()
diff --git a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs
index 648201b..0720d71 100644
--- a/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs
+++ b/MicroEngineerProject/MicroEngineer/Entries/OrbitalEntries.cs
@@ -170,6 +170,12 @@ public OrbitalSpeed()
GigaUnit = "Gm/s";
NumberOfDecimalDigits = 1;
Formatting = "N";
+ AltUnit = new AltUnit()
+ {
+ IsActive = false,
+ Unit = "km/h",
+ Factor = (60f * 60f) / 1000f
+ };
}
public override void RefreshData()
diff --git a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs
index 89b8f95..bcad33b 100644
--- a/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs
+++ b/MicroEngineerProject/MicroEngineer/Entries/SurfaceEntries.cs
@@ -99,6 +99,12 @@ public VerticalVelocity()
GigaUnit = "Gm/s";
NumberOfDecimalDigits = 1;
Formatting = "N";
+ AltUnit = new AltUnit()
+ {
+ IsActive = false,
+ Unit = "km/h",
+ Factor = (60f * 60f) / 1000f
+ };
}
public override void RefreshData()
@@ -124,6 +130,12 @@ public HorizontalVelocity()
GigaUnit = "Gm/s";
NumberOfDecimalDigits = 1;
Formatting = "N";
+ AltUnit = new AltUnit()
+ {
+ IsActive = false,
+ Unit = "km/h",
+ Factor = (60f * 60f) / 1000f
+ };
}
public override void RefreshData()
diff --git a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs
index 58ffac0..67fef68 100644
--- a/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs
+++ b/MicroEngineerProject/MicroEngineer/Entries/TargetEntries.cs
@@ -126,6 +126,12 @@ public RelativeSpeed()
GigaUnit = "Gm/s";
NumberOfDecimalDigits = 1;
Formatting = "N";
+ AltUnit = new AltUnit()
+ {
+ IsActive = false,
+ Unit = "km/h",
+ Factor = (60f * 60f) / 1000f
+ };
}
public override void RefreshData()
@@ -284,6 +290,12 @@ public Target_Obtvelocity()
GigaUnit = "Gm/s";
NumberOfDecimalDigits = 1;
Formatting = "N";
+ AltUnit = new AltUnit()
+ {
+ IsActive = false,
+ Unit = "km/h",
+ Factor = (60f * 60f) / 1000f
+ };
}
public override void RefreshData()
@@ -700,6 +712,12 @@ public RelativeSpeedAtCloseApproach1()
GigaUnit = "Gm/s";
NumberOfDecimalDigits = 1;
Formatting = "N";
+ AltUnit = new AltUnit()
+ {
+ IsActive = false,
+ Unit = "km/h",
+ Factor = (60f * 60f) / 1000f
+ };
}
public override void RefreshData()
@@ -778,6 +796,12 @@ public RelativeSpeedAtCloseApproach2()
GigaUnit = "Gm/s";
NumberOfDecimalDigits = 1;
Formatting = "N";
+ AltUnit = new AltUnit()
+ {
+ IsActive = false,
+ Unit = "km/h",
+ Factor = (60f * 60f) / 1000f
+ };
}
public override void RefreshData()
diff --git a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs
index dc329e4..bcee2f5 100644
--- a/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs
+++ b/MicroEngineerProject/MicroEngineer/Managers/MessageManager.cs
@@ -92,14 +92,13 @@ private void GameStateEntered(MessageCenterMessage obj)
}
private void GameStateLeft(MessageCenterMessage obj)
- {
+ {
Utility.RefreshGameManager();
var maingui = Manager.Instance.Windows.OfType().FirstOrDefault();
var stageOab = Manager.Instance.Windows.OfType().FirstOrDefault();
if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.VehicleAssemblyBuilder || Utility.GameState.GameState == GameState.Map3DView)
{
- _logger.LogDebug($"Initiating Save from GameStateLeft.");
Utility.SaveLayout();
if (Utility.GameState.GameState == GameState.FlightView || Utility.GameState.GameState == GameState.Map3DView)
diff --git a/MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs b/MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs
index 9ea3112..0139359 100644
--- a/MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs
+++ b/MicroEngineerProject/MicroEngineer/Managers/MicroCelestialBodies.cs
@@ -24,7 +24,6 @@ public static MicroCelestialBodies Instance
public MicroCelestialBodies()
{
- _logger.LogDebug("Instantiating singleton.");
InitializeBodies();
}
@@ -104,7 +103,7 @@ private void TryReorderBodies()
///
private List InstantiateCelestialBodies (CelestialBodyComponent cel, int level)
{
- List instantiatedBodies = new();
+ List instantiatedBodies = new();
instantiatedBodies.Add(InstantiateCelestialBody(cel, level));
foreach (CelestialBodyComponent body in cel.orbitingBodies)
diff --git a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs
index 08ba07e..3b4d96d 100644
--- a/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs
+++ b/MicroEngineerProject/MicroEngineer/MicroEngineerMod.cs
@@ -6,15 +6,13 @@
using SpaceWarp.API.UI.Appbar;
using MicroEngineer.UI;
using KSP.Game;
-using BepInEx.Logging;
namespace MicroMod
{
- [BepInPlugin("com.micrologist.microengineer", "MicroEngineer", "1.2.0")]
+ [BepInPlugin("com.micrologist.microengineer", "MicroEngineer", "1.3.0")]
[BepInDependency(SpaceWarpPlugin.ModGuid, SpaceWarpPlugin.ModVer)]
public class MicroEngineerMod : BaseSpaceWarpPlugin
{
- private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineerMod");
public static MicroEngineerMod Instance { get; set; }
public string GUID;
@@ -36,7 +34,6 @@ public override void OnInitialized()
if (isOpen)
Manager.Instance.Windows.Find(w => w.GetType() == typeof(MainGuiWindow)).IsFlightActive = isOpen;
FlightSceneController.Instance.ShowGui = isOpen;
- _logger.LogDebug($"Initiating Save from Appbar.RegisterAppButton.");
Utility.SaveLayout();
});
@@ -49,7 +46,6 @@ public override void OnInitialized()
if (isOpen)
Manager.Instance.Windows.Find(w => w.GetType() == typeof(StageInfoOabWindow)).IsEditorActive = isOpen;
OABSceneController.Instance.ShowGui = isOpen;
- _logger.LogDebug($"Initiating Save from Appbar.RegisterOABAppButton.");
Utility.SaveLayout();
});
}
@@ -66,7 +62,7 @@ public void Update()
bool guiState = FlightSceneController.Instance.ShowGui;
FlightSceneController.Instance.ShowGui = !guiState;
Manager.Instance.Windows.Find(w => w.GetType() == typeof(MainGuiWindow)).IsFlightActive = !guiState;
- }
+ }
else if (Utility.GameState.GameState == GameState.VehicleAssemblyBuilder)
{
bool guiState = OABSceneController.Instance.ShowGui;
diff --git a/MicroEngineerProject/MicroEngineer/UI/Controllers/EditWindowsController.cs b/MicroEngineerProject/MicroEngineer/UI/Controllers/EditWindowsController.cs
index bc98fc6..fb70973 100644
--- a/MicroEngineerProject/MicroEngineer/UI/Controllers/EditWindowsController.cs
+++ b/MicroEngineerProject/MicroEngineer/UI/Controllers/EditWindowsController.cs
@@ -1,5 +1,4 @@
-using BepInEx.Logging;
-using MicroMod;
+using MicroMod;
using UnityEngine;
using UnityEngine.UIElements;
@@ -7,8 +6,6 @@ namespace MicroEngineer.UI
{
public class EditWindowsController : MonoBehaviour
{
- private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.EditWindowsController");
-
private EditWindowsItemControl _selectedAvailableEntry;
private EditWindowsItemControl _selectedInstalledEntry;
private List _editableWindows;
@@ -22,7 +19,7 @@ public class EditWindowsController : MonoBehaviour
public Button CloseButton { get; set; }
public ScrollView AvailableScrollView { get; set; }
public ScrollView InstalledScrollView { get; set; }
- public DropdownField CategoryDropdown { get; set; }
+ public DropdownField CategoryDropdown { get; set; }
public TextField SelectedWindow { get; set; }
public Button PreviousWindow { get; set; }
public Button NextWindow { get; set; }
@@ -47,7 +44,6 @@ private System.Collections.IEnumerator StartInitialization()
// wait for 1 frame until SelectedWindowId is set in FlightSceneController
yield return null;
- _logger.LogDebug("Entering OnEnable.");
EditWindows = GetComponent();
Root = EditWindows.rootVisualElement;
@@ -94,7 +90,7 @@ private void BuildCategoryDropdown()
{
CategoryDropdown.choices = Enum.GetNames(typeof(MicroEntryCategory)).Where(e => e != MicroEntryCategory.OAB.ToString()).ToList();
CategoryDropdown.RegisterValueChangedCallback(BuildAvailableEntries);
- }
+ }
private void BuildAvailableEntries(ChangeEvent _)
{
@@ -159,7 +155,7 @@ public void UnselectAvailable(EditWindowsItemControl control)
AddEntry.SetEnabled(false);
}
- ////////////////////// INSTALLED (RIGHT SCROLLVIEW) //////////////////////
+ ////////////////////// INSTALLED (RIGHT SCROLLVIEW) //////////////////////
public void ResetSelectedWindow()
{
@@ -374,7 +370,6 @@ private void CheckIfDecimalButtonsShouldBeEnabled(BaseEntry entry, Button increa
private void RebuildFlightUI()
{
- _logger.LogDebug($"Initiating Save from RebuildFlightUI.");
Utility.SaveLayout();
FlightSceneController.Instance.RebuildUI();
}
diff --git a/MicroEngineerProject/MicroEngineer/UI/Controllers/EntryWindowController.cs b/MicroEngineerProject/MicroEngineer/UI/Controllers/EntryWindowController.cs
index 402f6a3..b4a7a11 100644
--- a/MicroEngineerProject/MicroEngineer/UI/Controllers/EntryWindowController.cs
+++ b/MicroEngineerProject/MicroEngineer/UI/Controllers/EntryWindowController.cs
@@ -1,5 +1,4 @@
-using BepInEx.Logging;
-using MicroMod;
+using MicroMod;
using UnityEngine;
using UnityEngine.UIElements;
@@ -7,8 +6,6 @@ namespace MicroEngineer.UI
{
public class EntryWindowController : MonoBehaviour
{
- private static readonly ManualLogSource _logger = BepInEx.Logging.Logger.CreateLogSource("MicroEngineer.EntryWindowController");
-
public EntryWindow EntryWindow { get; set; }
public VisualElement WindowRoot { get; set; }
public VisualElement Root { get; set; }
@@ -38,8 +35,6 @@ public EntryWindowController(EntryWindow w, VisualElement windowRoot)
public void Initialize()
{
- _logger.LogDebug($"Creating window: {EntryWindow.Name}.");
-
Root = Uxmls.Instance.EntryWindow.CloneTree();
BuildTitle();
@@ -72,7 +67,6 @@ public void UpdateWindowPosition(PointerUpEvent evt)
return;
EntryWindow.FlightRect.position = WindowRoot[0].transform.position;
- _logger.LogDebug($"Initiating Save from UpdateWindowPosition.");
Utility.SaveLayout();
}
@@ -85,7 +79,7 @@ private void BuildTitle()
NameLabel = Root.Q