Changes throughout to separate VOID_Tools from ToadicusTools.Tools. Good idea?
[VOID.git] / VOID_VesselRegister.cs
blob:a/VOID_VesselRegister.cs -> blob:b/VOID_VesselRegister.cs
--- a/VOID_VesselRegister.cs
+++ b/VOID_VesselRegister.cs
@@ -37,16 +37,16 @@
 	public class VOID_VesselRegister : VOID_WindowModule
 	{
 		[AVOID_SaveValue("selectedBodyIdx")]
-		protected VOID_SaveValue<int> selectedBodyIdx = 0;
+		protected VOID_SaveValue<int> selectedBodyIdx;
 		protected CelestialBody seletedBody;
 
 		[AVOID_SaveValue("selectedVesselTypeIdx")]
-		protected VOID_SaveValue<int> selectedVesselTypeIdx = 0;
+		protected VOID_SaveValue<int> selectedVesselTypeIdx;
 		protected VesselType selectedVesselType;
 
-		protected string vesselSituation = "Orbiting";
+		protected string vesselSituation;
 
-		protected Vector2 selectorScrollPos = new Vector2();
+		protected Vector2 selectorScrollPos;
 
 		protected Vessel _selectedVessel;
 
@@ -58,18 +58,25 @@
 			}
 		}
 
-		public VOID_VesselRegister()
+		public VOID_VesselRegister() : base()
 		{
-			this._Name = "Vessel Register";
+			this.Name = "Vessel Register";
 
 			this.WindowPos.x = 845;
 			this.WindowPos.y = 275;
 			this.defHeight = 375;
+
+			this.selectedBodyIdx = (VOID_SaveValue<int>)0;
+			this.selectedVesselTypeIdx = (VOID_SaveValue<int>)0;
+
+			this.vesselSituation = "Orbiting";
+
+			this.selectorScrollPos = new Vector2();
 		}
 
-		public override void ModuleWindow(int _)
+		public override void ModuleWindow(int id)
 		{
-			if (!VOID_Core.Instance.allVesselTypes.Any())
+			if (!this.core.AllVesselTypes.Any())
 			{
 				return;
 			}
@@ -79,34 +86,46 @@
 			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 			if (GUILayout.Button("<"))
 			{
-				selectedBodyIdx--;
-				if (selectedBodyIdx < 0) selectedBodyIdx = VOID_Core.Instance.allBodies.Count - 1;
+				selectedBodyIdx.value--;
+				if (selectedBodyIdx < 0)
+				{
+					selectedBodyIdx.value = this.core.AllBodies.Count - 1;
+				}
 			}
-			GUILayout.Label(VOID_Core.Instance.allBodies[selectedBodyIdx].bodyName, VOID_Core.Instance.LabelStyles["center_bold"], GUILayout.ExpandWidth(true));
+			GUILayout.Label(this.core.AllBodies[selectedBodyIdx].bodyName, VOID_Styles.labelCenterBold, GUILayout.ExpandWidth(true));
 			if (GUILayout.Button(">"))
 			{
-				selectedBodyIdx++;
-				if (selectedBodyIdx > VOID_Core.Instance.allBodies.Count - 1) selectedBodyIdx = 0;
+				selectedBodyIdx.value++;
+				if (selectedBodyIdx > this.core.AllBodies.Count - 1)
+				{
+					selectedBodyIdx.value = 0;
+				}
 			}
 			GUILayout.EndHorizontal();
 
-			seletedBody = VOID_Core.Instance.allBodies[selectedBodyIdx];
+			seletedBody = this.core.AllBodies[selectedBodyIdx];
 
 			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 			if (GUILayout.Button("<"))
 			{
-				selectedVesselTypeIdx--;
-				if (selectedVesselTypeIdx < 0) selectedVesselTypeIdx = VOID_Core.Instance.allVesselTypes.Count - 1;
+				selectedVesselTypeIdx.value--;
+				if (selectedVesselTypeIdx < 0)
+				{
+					selectedVesselTypeIdx.value = this.core.AllVesselTypes.Length - 1;
+				}
 			}
-			GUILayout.Label(VOID_Core.Instance.allVesselTypes[selectedVesselTypeIdx].ToString(), VOID_Core.Instance.LabelStyles["center_bold"], GUILayout.ExpandWidth(true));
+			GUILayout.Label(this.core.AllVesselTypes[selectedVesselTypeIdx].ToString(), VOID_Styles.labelCenterBold, GUILayout.ExpandWidth(true));
 			if (GUILayout.Button(">"))
 			{
-				selectedVesselTypeIdx++;
-				if (selectedVesselTypeIdx > VOID_Core.Instance.allVesselTypes.Count - 1) selectedVesselTypeIdx = 0;
+				selectedVesselTypeIdx.value++;
+				if (selectedVesselTypeIdx > this.core.AllVesselTypes.Length - 1)
+				{
+					selectedVesselTypeIdx.value = 0;
+				}
 			}
 			GUILayout.EndHorizontal();
 
-			selectedVesselType = VOID_Core.Instance.allVesselTypes[selectedVesselTypeIdx];
+			selectedVesselType = this.core.AllVesselTypes[selectedVesselTypeIdx];
 
 			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 			if (GUILayout.Button("Landed", GUILayout.ExpandWidth(true))) vesselSituation = "Landed";
@@ -116,7 +135,7 @@
 			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 			GUILayout.Label(
 				VOID_Tools.UppercaseFirst(vesselSituation) + " " + selectedVesselType.ToString() + "s  @ " + seletedBody.bodyName,
-				VOID_Core.Instance.LabelStyles["center"],
+				VOID_Styles.labelCenter,
 				GUILayout.ExpandWidth(true));
 			GUILayout.EndHorizontal();
 
@@ -124,7 +143,7 @@
 
 			foreach (Vessel v in FlightGlobals.Vessels)
 			{
-				if (v != vessel && v.vesselType == selectedVesselType && v.mainBody == seletedBody)
+				if (v != Vessel && v.vesselType == selectedVesselType && v.mainBody == seletedBody)
 				{
 					if ((vesselSituation == "Landed" &&
 					     (v.situation == Vessel.Situations.LANDED ||
@@ -142,7 +161,7 @@
 							if (_selectedVessel != v)
 							{
 								_selectedVessel = v; //set clicked vessel as selected_vessel
-								this._Active.value = true;    //turn bool on to open the window if closed
+								this.Active = true;    //turn bool on to open the window if closed
 							}
 							else
 							{
@@ -157,7 +176,7 @@
 
 			GUILayout.EndVertical();
 
-			GUI.DragWindow();
+			base.ModuleWindow(id);
 		}
 	}
 }