VOID_Core: Wrapped some of the flight-specific things in HighLogic.LoadedSceneIs
[VOID.git] / VOID_EditorCore.cs
blob:a/VOID_EditorCore.cs -> blob:b/VOID_EditorCore.cs
--- a/VOID_EditorCore.cs
+++ b/VOID_EditorCore.cs
@@ -79,22 +79,11 @@
 				this.LoadModulesOfType<IVOID_EditorModule>();
 			}
 
-			Rect _iconPos = new Rect(this.VOIDIconPos);
-			Vector2 _iconCtr = new Vector2 ();
-			_iconCtr.x = ((Rect)this.mainWindowPos).center.x;
+			Rect _iconPos = Tools.DockToWindow (this.VOIDIconPos, this.mainWindowPos);
 
-			if (this.mainWindowPos.value.center.y < Screen.height / 2)
-			{
-				_iconCtr.y = ((Rect)this.mainWindowPos).yMin - 15;
-			}
-			else
-			{
-				_iconCtr.y = ((Rect)this.mainWindowPos).yMax + 15;
-			}
+			_iconPos = Tools.ClampRectToScreen (_iconPos, (int)_iconPos.width, (int)_iconPos.height);
 
-			_iconPos.center = _iconCtr;
-
-			if (this.VOIDIconPos != _iconPos)
+			if (_iconPos != this.VOIDIconPos)
 			{
 				this.VOIDIconPos = _iconPos;
 			}
@@ -121,21 +110,23 @@
 				}
 			}
 
-			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();
 			}
 
 			if (EditorLogic.SortedShipList.Count > 0)
 			{
-				SimManager.Instance.Gravity = 9.08665;
+				SimManager.Instance.Gravity = VOID_Data.KerbinGee;
 				SimManager.Instance.TryStartSimulation();
 			}
+
+			this.CheckAndSave ();
 		}
 
 		public new void FixedUpdate() {}