Relicensed to Modified BSD.
[VOID.git] / VOID_Rendezvous.cs
blob:a/VOID_Rendezvous.cs -> blob:b/VOID_Rendezvous.cs
--- a/VOID_Rendezvous.cs
+++ b/VOID_Rendezvous.cs
@@ -58,13 +58,16 @@
 			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;
+			if (this.RegisterModule == null)
+			{
+				this.RegisterModule = this.core.Modules.Where(m => typeof(VOID_VesselRegister).IsAssignableFrom(m.GetType())).FirstOrDefault() as VOID_VesselRegister;
+			}
 
 			GUILayout.BeginVertical();
 
 			//display both
 			//Show Target Info
-			GUILayout.Label("Target:", VOID_Core.Instance.LabelStyles["center_bold"]);
+			GUILayout.Label("Target:", this.core.LabelStyles["center_bold"]);
 			if (FlightGlobals.fetch.VesselTarget != null)
 			{
 				//a KSP Target (body or vessel) is selected
@@ -91,13 +94,13 @@
 			else
 			{
 				//no KSP Target selected
-				GUILayout.Label("No Target Selected", VOID_Core.Instance.LabelStyles["center_bold"]);
+				GUILayout.Label("No Target Selected", this.core.LabelStyles["center_bold"]);
 			}
 
 			//Show Vessel Register vessel info
 			if (untoggleRegisterInfo == false && this.RegisterModule != default(IVOID_Module))
 			{
-				GUILayout.Label("Vessel Register:", VOID_Core.Instance.LabelStyles["center_bold"]);
+				GUILayout.Label("Vessel Register:", this.core.LabelStyles["center_bold"]);
 				if (this.RegisterModule.selectedVessel != null)
 				{
 					rendezvessel = this.RegisterModule.selectedVessel;
@@ -119,7 +122,7 @@
 				{
 					//vesreg Vessel is null
 					//targ = null;
-					GUILayout.Label("No Vessel Selected", VOID_Core.Instance.LabelStyles["center_bold"]);
+					GUILayout.Label("No Vessel Selected", this.core.LabelStyles["center_bold"]);
 				}
 			}
 
@@ -127,7 +130,7 @@
 
 			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 			GUILayout.Label(" ", GUILayout.ExpandWidth(true));
-			if (GUILayout.Button("Close", GUILayout.ExpandWidth(false))) this._Active = false;
+			if (GUILayout.Button("Close", GUILayout.ExpandWidth(false))) this.toggleActive = false;
 			GUILayout.EndHorizontal();
 
 			GUILayout.EndVertical();
@@ -140,7 +143,7 @@
 			{
 				//Display vessel rendezvous info
 				GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-				GUILayout.Label(v.vesselName, VOID_Core.Instance.LabelStyles["center_bold"], GUILayout.ExpandWidth(true));
+				GUILayout.Label(v.vesselName, this.core.LabelStyles["center_bold"], GUILayout.ExpandWidth(true));
 				GUILayout.EndHorizontal();
 
 				if (v.situation == Vessel.Situations.ESCAPING || v.situation == Vessel.Situations.FLYING || v.situation == Vessel.Situations.ORBITING || v.situation == Vessel.Situations.SUB_ORBITAL)
@@ -148,7 +151,7 @@
 					// Toadicus edit: added local sidereal longitude.
 					// Toadicus edit: added local sidereal longitude.
 					double LSL = v.longitude + v.orbit.referenceBody.rotationAngle;
-					LSL = Tools.FixDegreeDomain (LSL);
+					LSL = VOID_Tools.FixDegreeDomain (LSL);
 
 					//display orbital info for orbiting/flying/suborbital/escaping vessels only
 					GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
@@ -190,13 +193,19 @@
 					GUILayout.Label(Tools.MuMech_ToSI((vessel.findWorldCenterOfMass() - v.findWorldCenterOfMass()).magnitude) + "m", GUILayout.ExpandWidth(false));
 					GUILayout.EndHorizontal();
 
-					//target_vessel_extended_orbital_info = GUILayout.Toggle(target_vessel_extended_orbital_info, "Extended info");
+					// Toadicus edit: added local sidereal longitude.
+					GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
+					GUILayout.Label("Local Sidereal Longitude:");
+					GUILayout.Label(LSL.ToString("F3") + "°", this.core.LabelStyles["right"]);
+					GUILayout.EndHorizontal();
+
+					toggleExtendedOrbital.value = GUILayout.Toggle(toggleExtendedOrbital, "Extended info");
 
 					if (toggleExtendedOrbital)
 					{
 						GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 						GUILayout.Label("Period:");
-						GUILayout.Label(Tools.ConvertInterval(v.orbit.period), GUILayout.ExpandWidth(false));
+						GUILayout.Label(VOID_Tools.ConvertInterval(v.orbit.period), GUILayout.ExpandWidth(false));
 						GUILayout.EndHorizontal();
 
 						GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
@@ -235,24 +244,18 @@
 						GUILayout.Label("Arg. of periapsis:");
 						GUILayout.Label(v.orbit.argumentOfPeriapsis.ToString("F3") + "°", GUILayout.ExpandWidth(false));
 						GUILayout.EndHorizontal();
-
-						// 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["right"]);
-						GUILayout.EndHorizontal();
 					}
 				}
 				else
 				{
 					GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 					GUILayout.Label("Latitude:");
-					GUILayout.Label(Tools.GetLatitudeString(vessel), GUILayout.ExpandWidth(false));
+					GUILayout.Label(VOID_Tools.GetLatitudeString(vessel), GUILayout.ExpandWidth(false));
 					GUILayout.EndHorizontal();
 
 					GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 					GUILayout.Label("Longitude:");
-					GUILayout.Label(Tools.GetLongitudeString(vessel), GUILayout.ExpandWidth(false));
+					GUILayout.Label(VOID_Tools.GetLongitudeString(vessel), GUILayout.ExpandWidth(false));
 					GUILayout.EndHorizontal();
 
 					GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
@@ -264,7 +267,7 @@
 			else if (cb != null && v == null)
 			{
 				//Display CelstialBody rendezvous info
-				GUILayout.Label(cb.bodyName, VOID_Core.Instance.LabelStyles["center_bold"]);
+				GUILayout.Label(cb.bodyName, this.core.LabelStyles["center_bold"]);
 
 				GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
 				GUILayout.Label("Ap/Pe:");
@@ -297,28 +300,28 @@
 				//SUN2PLANET:
 				if (vessel.mainBody.bodyName == "Sun" && cb.referenceBody == vessel.mainBody)
 				{
-					Tools.display_transfer_angles_SUN2PLANET(cb, vessel);
+					VOID_Tools.display_transfer_angles_SUN2PLANET(cb, vessel);
 					//if (debugging) Debug.Log("[VOID] SUN2PLANET OK");
 				}
 
 				//PLANET2PLANET
 				else if (vessel.mainBody.referenceBody.bodyName == "Sun" && cb.referenceBody == vessel.mainBody.referenceBody)
 				{
-					Tools.display_transfer_angles_PLANET2PLANET(cb, vessel);
+					VOID_Tools.display_transfer_angles_PLANET2PLANET(cb, vessel);
 					//if (debugging) Debug.Log("[VOID] PLANET2PLANET OK");
 				}
 
 				//PLANET2MOON
 				else if (vessel.mainBody.referenceBody.bodyName == "Sun" && cb.referenceBody == vessel.mainBody)
 				{
-					Tools.display_transfer_angles_PLANET2MOON(cb, vessel);
+					VOID_Tools.display_transfer_angles_PLANET2MOON(cb, vessel);
 					//if (debugging) Debug.Log("[VOID] PLANET2MOON OK");
 				}
 
 				//MOON2MOON
 				else if (vessel.mainBody.referenceBody.referenceBody.bodyName == "Sun" && cb.referenceBody == vessel.mainBody.referenceBody)
 				{
-					Tools.display_transfer_angles_MOON2MOON(cb, vessel);
+					VOID_Tools.display_transfer_angles_MOON2MOON(cb, vessel);
 					//if (debugging) Debug.Log("[VOID] MOON2MOON OK");
 				}