Added Transfer and Rendezvous. Added their tools to Tools.
[VOID.git] / VOID_Rendezvous.cs
blob:a/VOID_Rendezvous.cs -> blob:b/VOID_Rendezvous.cs
--- a/VOID_Rendezvous.cs
+++ b/VOID_Rendezvous.cs
@@ -20,6 +20,8 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 using KSP;
 using System;
+using System.Collections.Generic;
+using System.Linq;
 using UnityEngine;
 
 namespace VOID
@@ -32,11 +34,14 @@
 		[AVOID_SaveValue("toggleExtendedOrbital")]
 		protected VOID_SaveValue<bool> toggleExtendedOrbital = false;
 
-		protected Vessel selectedVessel;
+		protected VOID_VesselRegister RegisterModule;
 
 		public VOID_Rendezvous()
 		{
 			this._Name = "Rendezvous Information";
+
+			this.WindowPos.x = 845;
+			this.WindowPos.y = 85;
 		}
 
 		public override void ModuleWindow(int _)
@@ -44,6 +49,8 @@
 			Vessel rendezvessel = new Vessel();
 			CelestialBody rendezbody = new CelestialBody();
 
+			this.RegisterModule = VOID_Core.Instance.Modules.Where(m => typeof(VOID_VesselRegister).IsAssignableFrom(m.GetType())).FirstOrDefault() as VOID_VesselRegister;
+
 			GUILayout.BeginVertical();
 
 			//display both
@@ -79,16 +86,16 @@
 			}
 
 			//Show Vessel Register vessel info
-			if (untoggleRegisterInfo == false)
+			if (untoggleRegisterInfo == false && this.RegisterModule != default(IVOID_Module))
 			{
 				GUILayout.Label("Vessel Register:", VOID_Core.Instance.LabelStyles["center_bold"]);
-				if (selectedVessel != null)
-				{
-					rendezvessel = selectedVessel;
+				if (this.RegisterModule.selectedVessel != null)
+				{
+					rendezvessel = this.RegisterModule.selectedVessel;
 					display_rendezvous_info(rendezvessel, null);
 
 					//show set/unset buttons
-					if (FlightGlobals.fetch.VesselTarget == null || (FlightGlobals.fetch.VesselTarget != null && FlightGlobals.fetch.VesselTarget.GetVessel() != selectedVessel))
+					if (FlightGlobals.fetch.VesselTarget == null || (FlightGlobals.fetch.VesselTarget != null && FlightGlobals.fetch.VesselTarget.GetVessel() != this.RegisterModule.selectedVessel))
 					{
 						//no Tgt set or Tgt is not this vessel
 						//show a Set button
@@ -107,7 +114,7 @@
 				}
 			}
 
-			untoggleRegisterInfo = GUILayout.Toggle(untoggleRegisterInfo, "Hide Vessel Register Info");
+			untoggleRegisterInfo.value = GUILayout.Toggle(untoggleRegisterInfo, "Hide Vessel Register Info");
 
 			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 			GUILayout.Label(" ", GUILayout.ExpandWidth(true));
@@ -131,7 +138,7 @@
 				{
 					// Toadicus edit: added local sidereal longitude.
 					// Toadicus edit: added local sidereal longitude.
-					double LSL = vessel.longitude + vessel.orbit.referenceBody.rotationAngle;
+					double LSL = v.longitude + v.orbit.referenceBody.rotationAngle;
 					LSL = Tools.FixDegreeDomain (LSL);
 
 					//display orbital info for orbiting/flying/suborbital/escaping vessels only
@@ -223,7 +230,7 @@
 						// Toadicus edit: added local sidereal longitude.
 						GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 						GUILayout.Label("Local Sidereal Longitude:");
-						GUILayout.Label(LSL.ToString("F3") + "°", VOID_Core.Instance.LabelStyles["txt_right"]);
+						GUILayout.Label(LSL.ToString("F3") + "°", VOID_Core.Instance.LabelStyles["right"]);
 						GUILayout.EndHorizontal();
 					}
 				}