VOID_EditorHUD: Moved the HUD to the top left, and made it move with the parts and actions panels... in theory.
VOID_EditorHUD: Moved the HUD to the top left, and made it move with the parts and actions panels... in theory.

file:a/Tools.cs -> file:b/Tools.cs
--- a/Tools.cs
+++ b/Tools.cs
@@ -723,6 +723,99 @@
 		{
 			return ClampV2ToScreen (vec, 15);
 		}
+
+		// UNDONE: This seems messy.  Can we clean it up?
+		public static Rect DockToWindow(Rect icon, Rect window)
+		{
+			// We can't set the x and y of the center point directly, so build a new vector.
+			Vector2 center = new Vector2 ();
+
+			// If we are near the top or bottom of the screen...
+			if (window.yMax > Screen.height - icon.height ||
+			    window.yMin < icon.height
+			    )
+			{
+				// If we are in a corner...
+				if (window.xMax > Screen.width - icon.width ||
+				    window.xMin < icon.width
+				    )
+				{
+					// If it is a top corner, put the icon below the window.
+					if (window.yMax < Screen.height / 2)
+					{
+						center.y = window.yMax + icon.height / 2;
+					}
+					// If it is a bottom corner, put the icon above the window.
+					else
+					{
+						center.y = window.yMin - icon.height / 2;
+					}
+				}
+				// If we are not in a corner...
+				else
+				{
+					// If we are along the top edge, align the icon's top edge with the top edge of the window
+					if (window.yMax > Screen.height / 2)
+					{
+						center.y = window.yMax - icon.height / 2;
+					}
+					// If we are along the bottom edge, align the icon's bottom edge with the bottom edge of the window
+					else
+					{
+						center.y = window.yMin + icon.height / 2;
+					}
+				}
+
+				// At the top or bottom, if we are towards the right, put the icon to the right of the window
+				if (window.center.x < Screen.width / 2)
+				{
+					center.x = window.xMin - icon.width / 2;
+				}
+				// At the top or bottom, if we are towards the left, put the icon to the left of the window
+				else
+				{
+					center.x = window.xMax + icon.width / 2;
+				}
+
+			}
+			// If we are not along the top or bottom of the screen...
+			else
+			{
+				// By default, center the icon above the window
+				center.y = window.yMin - icon.height / 2;
+				center.x = window.center.x;
+
+				// If we are along a side...
+				if (window.xMax > Screen.width - icon.width ||
+				    window.xMin < icon.width
+				    )
+				{
+					// UNDONE: I'm not sure I like the feel of this part.
+					// If we are along a side towards the bottom, put the icon below the window
+					if (window.center.y > Screen.height / 2)
+					{
+						center.y = window.yMax + icon.height / 2;
+					}
+
+					// Along the left side, align the left edge of the icon with the left edge of the window.
+					if (window.xMax > Screen.width - icon.width)
+					{
+						center.x = window.xMax - icon.width / 2;
+					}
+					// Along the right side, align the right edge of the icon with the right edge of the window.
+					else if (window.xMin < icon.width)
+					{
+						center.x = window.xMin + icon.width / 2;
+					}
+				}
+			}
+
+			// Assign the vector to the center of the rect.
+			icon.center = center;
+
+			// Return the icon's position.
+			return icon;
+		}
 				
 		private static ScreenMessage debugmsg = new ScreenMessage("", 2f, ScreenMessageStyle.UPPER_RIGHT);
 

--- a/VOIDFlightMaster.cs
+++ b/VOIDFlightMaster.cs
@@ -55,8 +55,9 @@
 
 		public void Update()
 		{
-			if (!HighLogic.LoadedSceneIsEditor)
+			if (!HighLogic.LoadedSceneIsFlight && this.Core != null)
 			{
+				this.Core.SaveConfig ();
 				this.Core = null;
 				VOID_Core.Reset();
 				return;
@@ -120,8 +121,9 @@
 
 		public void Update()
 		{
-			if (!HighLogic.LoadedSceneIsEditor)
+			if (!HighLogic.LoadedSceneIsEditor && this.Core != null)
 			{
+				this.Core.SaveConfig ();
 				this.Core = null;
 				VOID_EditorCore.Reset();
 				return;

--- a/VOID_Core.cs
+++ b/VOID_Core.cs
@@ -68,7 +68,7 @@
 		 * Fields
 		 * */
 		protected string VoidName = "VOID";
-		protected string VoidVersion = "0.9.9";
+		protected string VoidVersion = "0.9.10";
 
 		protected bool _factoryReset = false;
 
@@ -130,8 +130,9 @@
 
 		public float saveTimer = 0;
 
-		protected string defaultSkin = "KSP window 2";
-		protected VOID_SaveValue<int> _skinIdx = int.MinValue;
+		[AVOID_SaveValue("defaultSkin")]
+		protected VOID_SaveValue<string> defaultSkin = "KSP window 2";
+		protected int _skinIdx = int.MinValue;
 		protected List<GUISkin> skin_list;
 		protected string[] forbiddenSkins =
 		{
@@ -246,6 +247,13 @@
 				));
 			foreach (var voidType in types)
 			{
+				if (!HighLogic.LoadedSceneIsEditor &&
+				    typeof(IVOID_EditorModule).IsAssignableFrom(voidType)
+				    )
+				{
+					continue;
+				}
+
 				Tools.PostDebugMessage (string.Format (
 					"{0}: found Type {1}",
 					this.GetType ().Name,
@@ -430,8 +438,25 @@
 		{
 			this.saveTimer += Time.deltaTime;
 
+			Tools.PostDebugMessage (string.Format (
+				"{0}: Checking if time to save; saveTimer: {1}",
+				this.GetType ().Name,
+				this.saveTimer
+			));
+
 			if (this.saveTimer > 2f)
 			{
+				Tools.PostDebugMessage (string.Format (
+					"{0}: Time to save, checking if configDirty: {1}",
+					this.GetType ().Name,
+					this.configDirty
+					));
+
+				if (!this.configDirty)
+				{
+					return;
+				}
+
 				this.SaveConfig ();
 				this.saveTimer = 0;
 			}
@@ -503,7 +528,12 @@
 			{
 				this._skinIdx--;
 				if (this._skinIdx < 0) this._skinIdx = skin_list.Count - 1;
-				Tools.PostDebugMessage("[VOID] new this._skin = " + this._skinIdx + " :: skin_list.Count = " + skin_list.Count);
+				Tools.PostDebugMessage (string.Format (
+					"{0}: new this._skinIdx = {1} :: skin_list.Count = {2}",
+					this.GetType().Name,
+					this._skinIdx,
+					this.skin_list.Count
+				));
 			}
 
 			string skin_name = skin_list[this._skinIdx].name;
@@ -517,7 +547,17 @@
 			{
 				this._skinIdx++;
 				if (this._skinIdx >= skin_list.Count) this._skinIdx = 0;
-				Tools.PostDebugMessage("[VOID] new this._skin = " + this._skinIdx + " :: skin_list.Count = " + skin_list.Count);
+				Tools.PostDebugMessage (string.Format (
+					"{0}: new this._skinIdx = {1} :: skin_list.Count = {2}",
+					this.GetType().Name,
+					this._skinIdx,
+					this.skin_list.Count
+					));
+			}
+
+			if (this.Skin.name != this.defaultSkin)
+			{
+				this.defaultSkin = this.Skin.name;
 			}
 
 			GUILayout.EndHorizontal();
@@ -666,11 +706,6 @@
 
 		public void SaveConfig()
 		{
-			if (!this.configDirty)
-			{
-				return;
-			}
-
 			var config = KSP.IO.PluginConfiguration.CreateForType<VOID_Core> ();
 			config.load ();
 

--- a/VOID_EditorCore.cs
+++ b/VOID_EditorCore.cs
@@ -79,71 +79,9 @@
 				this.LoadModulesOfType<IVOID_EditorModule>();
 			}
 
-			Rect _mainPos = new Rect (this.mainWindowPos);
+			Rect _iconPos = Tools.DockToWindow (this.VOIDIconPos, this.mainWindowPos);
 
-			Rect _iconPos = new Rect(this.VOIDIconPos);
-			Vector2 _iconCtr = new Vector2 ();
-
-			// HACK: This is really messy.  Clean it up.
-			if (_mainPos.yMax > Screen.height - 30 ||
-			    _mainPos.yMin < 30
-			    )
-			{
-				if (_mainPos.xMax > Screen.width - 30 ||
-				    _mainPos.xMin < 30
-				    )
-				{
-					if (_mainPos.yMax < Screen.height / 2)
-					{
-						_iconCtr.y = _mainPos.yMax + 15;
-					}
-					else
-					{
-						_iconCtr.y = _mainPos.yMin - 15;
-					}
-				}
-				else
-				{
-					if (_mainPos.yMax > Screen.height / 2)
-					{
-						_iconCtr.y = _mainPos.yMax - 15;
-					}
-					else
-					{
-						_iconCtr.y = _mainPos.yMin + 15;
-					}
-				}
-
-				if (_mainPos.center.x < Screen.width / 2)
-				{
-					_iconCtr.x = _mainPos.xMin - 15;
-				}
-				else
-				{
-					_iconCtr.x = _mainPos.xMax + 15;
-				}
-
-			}
-			else
-			{
-				if (_mainPos.xMax > Screen.width - 30)
-				{
-					_iconCtr.x = _mainPos.xMax - 15;
-				}
-				else if (_mainPos.xMin < 30)
-				{
-					_iconCtr.x = _mainPos.xMin + 15;
-				}
-				else
-				{
-					_iconCtr.x = _mainPos.center.x;
-				}
-
-				_iconCtr.y = _mainPos.yMin - 15;
-			}
-
-			_iconCtr = Tools.ClampV2ToScreen (_iconCtr, 15);
-			_iconPos.center = _iconCtr;
+			_iconPos = Tools.ClampRectToScreen (_iconPos, (int)_iconPos.width, (int)_iconPos.height);
 
 			if (_iconPos != this.VOIDIconPos)
 			{
@@ -170,8 +108,6 @@
 				{
 					module.StopGUI();
 				}
-
-				this.CheckAndSave ();
 			}
 
 			if (EditorLogic.startPod == null || !HighLogic.LoadedSceneIsEditor)
@@ -189,6 +125,8 @@
 				SimManager.Instance.Gravity = 9.08665;
 				SimManager.Instance.TryStartSimulation();
 			}
+
+			this.CheckAndSave ();
 		}
 
 		public new void FixedUpdate() {}

--- a/VOID_EditorHUD.cs
+++ b/VOID_EditorHUD.cs
@@ -81,7 +81,7 @@
 			this.textColors.Add(Color.magenta);
 
 			this.labelStyle = new GUIStyle ();
-			this.labelStyle.alignment = TextAnchor.UpperRight;
+			// this.labelStyle.alignment = TextAnchor.UpperRight;
 			this.labelStyle.normal.textColor = this.textColors [this.ColorIndex];
 
 			Tools.PostDebugMessage (this.GetType().Name + ": Constructed.");
@@ -96,12 +96,29 @@
 				return;
 			}
 
+			float hudLeft;
+
+			if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Parts)
+			{
+				hudLeft = EditorPanels.Instance.partsPanelWidth + 10;
+			}
+			else if (EditorLogic.fetch.editorScreen == EditorLogic.EditorScreen.Actions)
+			{
+				hudLeft = EditorPanels.Instance.actionsPanelWidth + 10;
+			}
+			else
+			{
+				return;
+			}
+
+			Rect hudPos = new Rect (hudLeft, 48, 300, 32);
+
 			// GUI.skin = AssetBase.GetGUISkin("KSP window 2");
 
 			labelStyle.normal.textColor = textColors [ColorIndex];
 
 			GUI.Label (
-				new Rect (Screen.width - 310, 80, 300f, 32f),
+				hudPos,
 				"Total Mass: " + SimManager.Instance.LastStage.totalMass.ToString("F3") + "t" +
 				" Part Count: " + EditorLogic.SortedShipList.Count +
 				"\nTotal Delta-V: " + Tools.MuMech_ToSI(SimManager.Instance.LastStage.totalDeltaV) + "m/s" +

--- a/VOID_SaveValue.cs
+++ b/VOID_SaveValue.cs
@@ -77,10 +77,17 @@
 			VOID_SaveValue<T> r = new VOID_SaveValue<T>();
 			r.value = v;
 			r.type = v.GetType();
+
 			if (VOID_Core.Initialized)
 			{
 				VOID_Core.Instance.configDirty = true;
 			}
+
+			if (VOID_EditorCore.Initialized)
+			{
+				VOID_EditorCore.Instance.configDirty = true;
+			}
+
 			return r;
 		}