Major changes to the way VOID_Core was implemented to allow a more-extensible core framework for use in multiple scenes.
[VOID.git] / VOID_EditorHUD.cs
blob:a/VOID_EditorHUD.cs -> blob:b/VOID_EditorHUD.cs
--- a/VOID_EditorHUD.cs
+++ b/VOID_EditorHUD.cs
@@ -30,7 +30,6 @@
 using KSP;
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Text;
 using ToadicusTools;
 using UnityEngine;
@@ -58,9 +57,12 @@
 			{
 				if (this._vesselOverlays == null)
 				{
-					this._vesselOverlays = (EditorVesselOverlays)Resources
-						.FindObjectsOfTypeAll(typeof(EditorVesselOverlays))
-						.FirstOrDefault();
+					UnityEngine.Object[] overlayObjs = Resources.FindObjectsOfTypeAll(typeof(EditorVesselOverlays));
+
+					if (overlayObjs.Length > 0)
+					{
+						this._vesselOverlays = (EditorVesselOverlays)overlayObjs[0];
+					}
 				}
 
 				return this._vesselOverlays;
@@ -98,9 +100,9 @@
 		 * */
 		public VOID_EditorHUD() : base()
 		{
-			this._Name = "Heads-Up Display";
-
-			this.toggleActive = true;
+			this.Name = "Heads-Up Display";
+
+			this.Active = true;
 
 			this.snapToLeft.value = true;
 
@@ -116,7 +118,7 @@
 
 		public void ehudWindowFunc(int id)
 		{
-			StringBuilder hudString = new StringBuilder();
+			StringBuilder hudString = Tools.GetStringBuilder();
 
 			if (this.core.LastStage == null)
 			{
@@ -190,6 +192,8 @@
 			}
 
 			GUI.BringWindowToBack(id);
+
+			Tools.PutStringBuilder(hudString);
 		}
 
 		public override void DrawGUI()
@@ -240,7 +244,7 @@
 
 			this.ehudWindow.WindowPos = hudPos;
 
-			this.snapToLeft = Mathf.Abs(this.ehudWindow.WindowPos.xMin - hudLeft) < 15f;
+			this.snapToLeft.value = Mathf.Abs(this.ehudWindow.WindowPos.xMin - hudLeft) < 15f;
 		}
 	}
 }