Revert ".csproj changes for laptop development."
Revert ".csproj changes for laptop development."

This reverts commit 637d9fafe902376c462cc8df4344ed99771137e6.

file:a/Tools.cs -> file:b/Tools.cs
--- a/Tools.cs
+++ b/Tools.cs
@@ -686,6 +686,43 @@
 			GUILayout.Label((dv2 * 1000).ToString("F2") + "m/s", GUILayout.ExpandWidth(false));
 			GUILayout.EndHorizontal();
 		}
+
+		// This implementation is adapted from FARGUIUtils.ClampToScreen
+		public static Rect ClampRectToScreen(Rect window, int xMargin, int yMargin)
+		{
+			window.x = Mathf.Clamp (window.x, xMargin - window.width, Screen.width - xMargin);
+			window.y = Mathf.Clamp (window.y, yMargin - window.height, Screen.height - yMargin);
+
+			return window;
+		}
+
+		public static Rect ClampRectToScreen(Rect window, int Margin)
+		{
+			return ClampRectToScreen(window, Margin, Margin);
+		}
+
+		public static Rect ClampRectToScreen(Rect window)
+		{
+			return ClampRectToScreen (window, 30);
+		}
+
+		public static Vector2 ClampV2ToScreen(Vector2 vec, uint xMargin, uint yMargin)
+		{
+			vec.x = Mathf.Clamp (vec.x, xMargin, Screen.width - xMargin);
+			vec.y = Mathf.Clamp (vec.y, yMargin, Screen.height - yMargin);
+
+			return vec;
+		}
+
+		public static Vector2 ClampV2ToScreen(Vector2 vec, uint Margin)
+		{
+			return ClampV2ToScreen(vec, Margin, Margin);
+		}
+
+		public static Vector2 ClampV2ToScreen(Vector2 vec)
+		{
+			return ClampV2ToScreen (vec, 15);
+		}
 				
 		private static ScreenMessage debugmsg = new ScreenMessage("", 2f, ScreenMessageStyle.UPPER_RIGHT);
 

--- a/VOID.csproj
+++ b/VOID.csproj
@@ -22,7 +22,7 @@
     <ConsolePause>false</ConsolePause>
     <CustomCommands>
       <CustomCommands>
-        <Command type="AfterBuild" command="xcopy /Y ${ProjectDir}\bin\Debug\*.dll ..\..\..\Games\KSP_win\GameData\VOID\Plugins\" workingdir="${ProjectDir}" externalConsole="True" />
+        <Command type="AfterBuild" command="/usr/bin/cp -fv ${ProjectDir}/bin/Debug/VOID.dll /mnt/games/ssd/KSP_linux/GameData/VOID/Plugins/" />
       </CustomCommands>
     </CustomCommands>
   </PropertyGroup>
@@ -35,7 +35,7 @@
     <DefineConstants>TRACE</DefineConstants>
     <CustomCommands>
       <CustomCommands>
-        <Command type="AfterBuild" command="xcopy /Y ${ProjectDir}\bin\Release\*.dll ..\..\..\Games\KSP_win\GameData\VOID\Plugins\" workingdir="${ProjectDir}" externalConsole="True" />
+        <Command type="AfterBuild" command="/usr/bin/cp -fv ${ProjectDir}/bin/Release/VOID.dll /mnt/games/ssd/KSP_linux/GameData/VOID/Plugins/" />
       </CustomCommands>
     </CustomCommands>
   </PropertyGroup>
@@ -61,13 +61,16 @@
   </ItemGroup>
   <ItemGroup>
     <Reference Include="Assembly-CSharp">
-      <HintPath>..\..\..\Games\KSP_win\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
+      <HintPath>..\..\..\..\..\mnt\games-ssd\KSP_linux\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
+      <Private>False</Private>
     </Reference>
     <Reference Include="UnityEngine">
-      <HintPath>..\..\..\Games\KSP_win\KSP_Data\Managed\UnityEngine.dll</HintPath>
+      <HintPath>..\..\..\..\..\mnt\games-ssd\KSP_linux\KSP_Data\Managed\UnityEngine.dll</HintPath>
+      <Private>False</Private>
     </Reference>
     <Reference Include="System">
-      <HintPath>..\..\..\Games\KSP_win\KSP_Data\Managed\System.dll</HintPath>
+      <HintPath>..\..\..\..\..\mnt\games-ssd\KSP_linux\KSP_Data\Managed\System.dll</HintPath>
+      <Private>False</Private>
     </Reference>
   </ItemGroup>
   <ItemGroup>

--- a/VOIDFlightMaster.cs
+++ b/VOIDFlightMaster.cs
@@ -46,8 +46,9 @@
 
 		public void Awake()
 		{
-			Tools.PostDebugMessage ("VOIDLightMaster: Waking up.");
+			Tools.PostDebugMessage ("VOIDFlightMaster: Waking up.");
 			this.Core = (VOID_Core)VOID_Core.Instance;
+			this.Core.StopGUI ();
 			this.Core.StartGUI ();
 			Tools.PostDebugMessage ("VOIDFlightMaster: Awake.");
 		}
@@ -112,6 +113,7 @@
 		{
 			Tools.PostDebugMessage ("VOIDEditorMaster: Waking up.");
 			this.Core = VOID_EditorCore.Instance;
+			this.Core.StopGUI ();
 			this.Core.StartGUI ();
 			Tools.PostDebugMessage ("VOIDEditorMaster: Awake.");
 		}

--- a/VOID_Core.cs
+++ b/VOID_Core.cs
@@ -287,19 +287,22 @@
 			));
 		}
 
+		protected void Preload_BeforeUpdate()
+		{
+			if (!this.bodiesLoaded)
+			{
+				this.LoadAllBodies();
+			}
+
+			if (!this.vesselTypesLoaded)
+			{
+				this.LoadVesselTypes();
+			}
+		}
+
 		public void Update()
 		{
-			this.saveTimer += Time.deltaTime;
-
-			if (!this.bodiesLoaded)
-			{
-				this.LoadAllBodies();
-			}
-
-			if (!this.vesselTypesLoaded)
-			{
-				this.LoadVesselTypes();
-			}
+			this.Preload_BeforeUpdate ();
 
 			if (!this.guiRunning)
 			{
@@ -332,11 +335,7 @@
 				}
 			}
 
-			if (this.saveTimer > 2f)
-			{
-				this.SaveConfig ();
-				this.saveTimer = 0;
-			}
+			this.CheckAndSave ();
 		}
 
 		public void FixedUpdate()
@@ -425,6 +424,17 @@
 		{
 			this._allVesselTypes = Enum.GetValues(typeof(VesselType)).OfType<VesselType>().ToList();
 			this.vesselTypesLoaded = true;
+		}
+
+		protected void CheckAndSave()
+		{
+			this.saveTimer += Time.deltaTime;
+
+			if (this.saveTimer > 2f)
+			{
+				this.SaveConfig ();
+				this.saveTimer = 0;
+			}
 		}
 
 		public void VOIDMainWindow(int _)
@@ -614,6 +624,8 @@
 					GUILayout.Height (50)
 				);
 
+				_mainWindowPos = Tools.ClampRectToScreen (_mainWindowPos);
+
 				if (_mainWindowPos != this.mainWindowPos)
 				{
 					this.mainWindowPos = _mainWindowPos;
@@ -633,6 +645,8 @@
 					GUILayout.Height (50)
 				);
 
+				_configWindowPos = Tools.ClampRectToScreen (_configWindowPos);
+
 				if (_configWindowPos != this.configWindowPos)
 				{
 					this.configWindowPos = _configWindowPos;

--- a/VOID_EditorCore.cs
+++ b/VOID_EditorCore.cs
@@ -79,22 +79,73 @@
 				this.LoadModulesOfType<IVOID_EditorModule>();
 			}
 
+			Rect _mainPos = new Rect (this.mainWindowPos);
+
 			Rect _iconPos = new Rect(this.VOIDIconPos);
 			Vector2 _iconCtr = new Vector2 ();
-			_iconCtr.x = ((Rect)this.mainWindowPos).center.x;
 
-			if (this.mainWindowPos.value.center.y < Screen.height / 2)
+			// HACK: This is really messy.  Clean it up.
+			if (_mainPos.yMax > Screen.height - 30 ||
+			    _mainPos.yMin < 30
+			    )
 			{
-				_iconCtr.y = ((Rect)this.mainWindowPos).yMin - 15;
+				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
 			{
-				_iconCtr.y = ((Rect)this.mainWindowPos).yMax + 15;
+				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;
 
-			if (this.VOIDIconPos != _iconPos)
+			if (_iconPos != this.VOIDIconPos)
 			{
 				this.VOIDIconPos = _iconPos;
 			}
@@ -119,14 +170,16 @@
 				{
 					module.StopGUI();
 				}
+
+				this.CheckAndSave ();
 			}
 
-			if (EditorLogic.startPod == null)
+			if (EditorLogic.startPod == null || !HighLogic.LoadedSceneIsEditor)
 			{
 				this.StopGUI();
 				return;
 			}
-			else if (!this.guiRunning)
+			else if (!this.guiRunning && HighLogic.LoadedSceneIsEditor)
 			{
 				this.StartGUI();
 			}

--- a/VOID_Module.cs
+++ b/VOID_Module.cs
@@ -208,6 +208,8 @@
 				GUILayout.Height(this.defHeight)
 			);
 
+			_Pos = Tools.ClampRectToScreen (_Pos);
+
 			if (_Pos != this.WindowPos)
 			{
 				this.WindowPos = _Pos;