Got the close button working; now converting from a cached anonymous method to an inherited method. TODO: VOID_ConfigModule.
[VOID.git] / VOID_StageInfo.cs
blob:a/VOID_StageInfo.cs -> blob:b/VOID_StageInfo.cs
--- a/VOID_StageInfo.cs
+++ b/VOID_StageInfo.cs
@@ -35,7 +35,7 @@
 
 		private bool showColumnSelection;
 
-		private CelestialBody selectedBody;
+		private CelestialBody _selectedBody;
 		[AVOID_SaveValue("bodyIdx")]
 		private VOID_SaveValue<int> bodyIdx;
 		private int lastIdx;
@@ -46,11 +46,24 @@
 		private VOID_SaveValue<bool> useSeaLevel;
 		private GUIContent seaLevelToggle;
 
+		private CelestialBody selectedBody
+		{
+			get
+			{
+				return this._selectedBody;
+			}
+			set
+			{
+				this._selectedBody = value;
+				KerbalEngineer.Helpers.CelestialBodies.SelectedBody = value;
+			}
+		}
+
 		public VOID_StageInfo() : base()
 		{
 			this.Name = "Stage Information";
 			this.defWidth = 20f;
-			this.bodyIdx = 4;
+			this.bodyIdx = (VOID_SaveValue<int>)4;
 
 			this.stylesApplied = false;
 			this.showBodyList = false;
@@ -96,7 +109,7 @@
 
 			this.showAdvanced = false;
 
-			this.useSeaLevel = false;
+			this.useSeaLevel = (VOID_SaveValue<bool>)false;
 
 			seaLevelToggle = new GUIContent(
 				"Use Sea Level",
@@ -110,7 +123,7 @@
 
 			if (this.showBodyList)
 			{
-				GUILayout.Window(core.windowID, this.bodyListPos, this.BodyPickerWindow, string.Empty);
+				GUILayout.Window(core.WindowID, this.bodyListPos, this.BodyPickerWindow, string.Empty);
 			}
 		}
 
@@ -151,7 +164,7 @@
 
 			if (HighLogic.LoadedSceneIsEditor && this.selectedBody.atmosphere && this.useSeaLevel)
 			{
-				SimManager.Atmosphere = this.selectedBody.atmosphereMultiplier * 101.325d;
+				SimManager.Atmosphere = this.selectedBody.GetPressure(0) * PhysicsGlobals.KpaToAtmospheres;
 			}
 			else
 			{
@@ -182,13 +195,13 @@
 
 			this.stageTable.Render();
 
-			if (core.sortedBodyList != null)
+			if (core.SortedBodyList != null)
 			{
 				GUILayout.BeginHorizontal();
 
 				if (GUILayout.Button("◄"))
 				{
-					this.bodyIdx--;
+					this.bodyIdx.value--;
 				}
 
 				this.showBodyList = GUILayout.Toggle(
@@ -208,20 +221,20 @@
 
 				if (GUILayout.Button("►"))
 				{
-					this.bodyIdx++;
-				}
-
-				this.bodyIdx %= core.sortedBodyList.Count;
+					this.bodyIdx.value++;
+				}
+
+				this.bodyIdx.value %= core.SortedBodyList.Count;
 
 				if (this.bodyIdx < 0)
 				{
-					this.bodyIdx += core.sortedBodyList.Count;
+					this.bodyIdx.value += core.SortedBodyList.Count;
 				}
 
 				if (this.lastIdx != this.bodyIdx)
 				{
 					this.lastIdx = this.bodyIdx;
-					this.selectedBody = core.sortedBodyList[this.bodyIdx];
+					this.selectedBody = core.SortedBodyList[this.bodyIdx];
 				}
 
 				if (HighLogic.LoadedSceneIsEditor)
@@ -275,12 +288,12 @@
 
 		private void BodyPickerWindow(int _)
 		{
-			foreach (CelestialBody body in core.sortedBodyList)
+			foreach (CelestialBody body in core.SortedBodyList)
 			{
 				if (GUILayout.Button(body.bodyName, VOID_Styles.labelDefault))
 				{
 					Debug.Log("Picked new body focus: " + body.bodyName);
-					this.bodyIdx = core.sortedBodyList.IndexOf(body);
+					this.bodyIdx.value = core.SortedBodyList.IndexOf(body);
 					this.showBodyList = false;
 				}
 			}