Got the EditorHUD working, and it's not even that ugly! Need to finalize what we want, and get a config window available.
[VOID.git] / VOIDFlightMaster.cs
blob:a/VOIDFlightMaster.cs -> blob:b/VOIDFlightMaster.cs
--- a/VOIDFlightMaster.cs
+++ b/VOIDFlightMaster.cs
@@ -46,16 +46,17 @@
 
 		public void Awake()
 		{
-			Tools.PostDebugMessage ("VOIDLightMaster: Waking up.");
+			Tools.PostDebugMessage ("VOIDFlightMaster: Waking up.");
 			this.Core = (VOID_Core)VOID_Core.Instance;
-			this.Core.StartGUI ();
+			this.Core.ResetGUI ();
 			Tools.PostDebugMessage ("VOIDFlightMaster: Awake.");
 		}
 
 		public void Update()
 		{
-			if (!HighLogic.LoadedSceneIsEditor)
+			if (!HighLogic.LoadedSceneIsFlight && this.Core != null)
 			{
+				this.Core.SaveConfig ();
 				this.Core = null;
 				VOID_Core.Reset();
 				return;
@@ -70,7 +71,8 @@
 
 			if (this.Core.vessel != null)
 			{
-				SimManager.Instance.Gravity = VOID_Core.Instance.vessel.mainBody.gravParameter / Math.Pow(VOID_Core.Instance.vessel.mainBody.Radius, 2);
+				SimManager.Instance.Gravity = VOID_Core.Instance.vessel.mainBody.gravParameter /
+					Math.Pow(VOID_Core.Instance.vessel.mainBody.Radius, 2);
 				SimManager.Instance.TryStartSimulation();
 			}
 
@@ -91,6 +93,16 @@
 
 			this.Core.FixedUpdate ();
 		}
+
+		public void OnGUI()
+		{
+			if (this.Core == null)
+			{
+				return;
+			}
+
+			this.Core.OnGUI();
+		}
     }
 
 	[KSPAddon(KSPAddon.Startup.EditorAny, false)]
@@ -102,14 +114,15 @@
 		{
 			Tools.PostDebugMessage ("VOIDEditorMaster: Waking up.");
 			this.Core = VOID_EditorCore.Instance;
-			this.Core.StartGUI ();
+			this.Core.ResetGUI ();
 			Tools.PostDebugMessage ("VOIDEditorMaster: Awake.");
 		}
 
 		public void Update()
 		{
-			if (!HighLogic.LoadedSceneIsEditor)
+			if (!HighLogic.LoadedSceneIsEditor && this.Core != null)
 			{
+				this.Core.SaveConfig ();
 				this.Core = null;
 				VOID_EditorCore.Reset();
 				return;
@@ -139,6 +152,16 @@
 
 			this.Core.FixedUpdate ();
 		}
+
+		public void OnGUI()
+		{
+			if (this.Core == null)
+			{
+				return;
+			}
+
+			this.Core.OnGUI();
+		}
 	}
 }