Changed up the window modules to inherit the generic stuff. Adding more and more modules. CBInfoBrowser in progress.
[VOID.git] / VOID_Transfer.cs
blob:a/VOID_Transfer.cs -> blob:b/VOID_Transfer.cs
--- a/VOID_Transfer.cs
+++ b/VOID_Transfer.cs
@@ -21,20 +21,22 @@
 using KSP;
 using System;
 using System.Collections.Generic;
+using System.Linq;
 using UnityEngine;
 
 namespace VOID
 {
 	public class VOID_Transfer : VOID_WindowModule
 	{
-		[AVOID_SaveValue("toggleExtended")]
-		protected VOID_SaveValue<bool> toggleExtended = false;
-
 		protected List<CelestialBody> selectedBodies = new List<CelestialBody>();
 
 		public VOID_Transfer()
 		{
 			this._Name = "Transfer Angle Information";
+
+			this.WindowPos.x = 475;
+			this.WindowPos.y = 85;
+			this.defWidth = 315;
 		}
 
 		public override void ModuleWindow(int _)
@@ -57,7 +59,7 @@
 
 					if (selectedBodies.Contains(body))
 					{
-						display_transfer_angles_SUN2PLANET(body);  //show phase angles for each selected body
+						Tools.display_transfer_angles_SUN2PLANET(body, vessel);  //show phase angles for each selected body
 						tad_targeting(body);    //display Set/Unset Target button for each selected body
 					}
 			    }
@@ -80,7 +82,7 @@
 
 			            if (selectedBodies.Contains(body))
 			            {
-			                display_transfer_angles_PLANET2PLANET(body);
+			                Tools.display_transfer_angles_PLANET2PLANET(body, vessel);
 			                tad_targeting(body);    //display Set/Unset Target button
 			            }
 			        }
@@ -99,7 +101,7 @@
 
 			        if (selectedBodies.Contains(body))
 			        {
-			            display_transfer_angles_PLANET2MOON(body);
+			            Tools.display_transfer_angles_PLANET2MOON(body, vessel);
 			            tad_targeting(body);    //display Set/Unset Target button
 			        }
 			    }
@@ -122,7 +124,7 @@
 
 						if (selectedBodies.Contains(body))
 						{
-							display_transfer_angles_MOON2MOON(body);
+							Tools.display_transfer_angles_MOON2MOON(body, vessel);
 							tad_targeting(body);    //display Set/Unset Target button
 						}
 					}
@@ -165,104 +167,6 @@
 		        }
 		    }
 		}
-
-		private void display_transfer_angles_SUN2PLANET(CelestialBody body)
-		{
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Phase angle (curr/trans):");
-			GUILayout.Label(Tools.mrenigma03_calcphase(vessel, body).ToString("F3") + "° / " + Tools.Nivvy_CalcTransferPhaseAngle(vessel.orbit.semiMajorAxis, body.orbit.semiMajorAxis, vessel.mainBody.gravParameter).ToString("F3") + "°", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Transfer velocity:");
-			GUILayout.Label((Tools.Younata_DeltaVToGetToOtherBody((vessel.mainBody.gravParameter / 1000000000), (vessel.orbit.semiMajorAxis / 1000), (body.orbit.semiMajorAxis / 1000)) * 1000).ToString("F2") + "m/s", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-		}
-
-		private void display_transfer_angles_PLANET2PLANET(CelestialBody body)
-		{
-			double dv1 = Tools.Younata_DeltaVToGetToOtherBody((vessel.mainBody.referenceBody.gravParameter / 1000000000), (vessel.mainBody.orbit.semiMajorAxis / 1000), (body.orbit.semiMajorAxis / 1000));
-			double dv2 = Tools.Younata_DeltaVToExitSOI((vessel.mainBody.gravParameter / 1000000000), (vessel.orbit.semiMajorAxis / 1000), (vessel.mainBody.sphereOfInfluence / 1000), Math.Abs(dv1));
-
-			double trans_ejection_angle = Tools.Younata_TransferBurnPoint((vessel.orbit.semiMajorAxis / 1000), dv2, (Math.PI / 2.0), (vessel.mainBody.gravParameter / 1000000000));
-			double curr_ejection_angle = Tools.Adammada_CurrentEjectionAngle(FlightGlobals.ActiveVessel.longitude, FlightGlobals.ActiveVessel.orbit.referenceBody.rotationAngle, FlightGlobals.ActiveVessel.orbit.referenceBody.orbit.LAN, FlightGlobals.ActiveVessel.orbit.referenceBody.orbit.orbitPercent);
-
-			double trans_phase_angle = Tools.Nivvy_CalcTransferPhaseAngle(vessel.mainBody.orbit.semiMajorAxis, body.orbit.semiMajorAxis, vessel.mainBody.referenceBody.gravParameter) % 360;
-			double curr_phase_angle = Tools.Adammada_CurrrentPhaseAngle(body.orbit.LAN, body.orbit.orbitPercent, FlightGlobals.ActiveVessel.orbit.referenceBody.orbit.LAN, FlightGlobals.ActiveVessel.orbit.referenceBody.orbit.orbitPercent);
-
-			double adj_phase_angle = Tools.adjustCurrPhaseAngle(trans_phase_angle, curr_phase_angle);
-			double adj_trans_ejection_angle = Tools.adjust_transfer_ejection_angle(trans_ejection_angle, trans_phase_angle);
-			double adj_curr_ejection_angle = Tools.adjust_current_ejection_angle(curr_ejection_angle);
-
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Phase angle (curr/trans):");
-			GUILayout.Label(adj_phase_angle.ToString("F3") + "° / " + trans_phase_angle.ToString("F3") + "°", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Ejection angle (curr/trans):");
-			GUILayout.Label(adj_curr_ejection_angle.ToString("F3") + "° / " + adj_trans_ejection_angle.ToString("F3") + "°", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Transfer velocity:");
-			GUILayout.Label((dv2 * 1000).ToString("F2") + "m/s", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-		}
-
-		private void display_transfer_angles_PLANET2MOON(CelestialBody body)
-		{
-			double dv1 = Tools.Younata_DeltaVToGetToOtherBody((vessel.mainBody.gravParameter / 1000000000), (vessel.orbit.semiMajorAxis / 1000), (body.orbit.semiMajorAxis / 1000));
-			
-			double trans_phase_angle = Tools.Nivvy_CalcTransferPhaseAngle(vessel.orbit.semiMajorAxis, body.orbit.semiMajorAxis, vessel.mainBody.gravParameter);
-
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Phase angle (curr/trans):");
-			GUILayout.Label(Tools.mrenigma03_calcphase(vessel, body).ToString("F3") + "° / " + trans_phase_angle.ToString("F3") + "°", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Transfer velocity:");
-			GUILayout.Label((dv1 * 1000).ToString("F2") + "m/s", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-		}
-
-		private void display_transfer_angles_MOON2MOON(CelestialBody body)
-		{
-			double dv1 = Tools.Younata_DeltaVToGetToOtherBody((vessel.mainBody.referenceBody.gravParameter / 1000000000), (vessel.mainBody.orbit.semiMajorAxis / 1000), (body.orbit.semiMajorAxis / 1000));
-			double dv2 = Tools.Younata_DeltaVToExitSOI((vessel.mainBody.gravParameter / 1000000000), (vessel.orbit.semiMajorAxis / 1000), (vessel.mainBody.sphereOfInfluence / 1000), Math.Abs(dv1));
-			double trans_ejection_angle = Tools.Younata_TransferBurnPoint((vessel.orbit.semiMajorAxis / 1000), dv2, (Math.PI / 2.0), (vessel.mainBody.gravParameter / 1000000000));
-
-			double curr_phase_angle = Tools.Adammada_CurrrentPhaseAngle(body.orbit.LAN, body.orbit.orbitPercent, FlightGlobals.ActiveVessel.orbit.referenceBody.orbit.LAN, FlightGlobals.ActiveVessel.orbit.referenceBody.orbit.orbitPercent);
-			double curr_ejection_angle = Tools.Adammada_CurrentEjectionAngle(FlightGlobals.ActiveVessel.longitude, FlightGlobals.ActiveVessel.orbit.referenceBody.rotationAngle, FlightGlobals.ActiveVessel.orbit.referenceBody.orbit.LAN, FlightGlobals.ActiveVessel.orbit.referenceBody.orbit.orbitPercent);
-
-			double trans_phase_angle = Tools.Nivvy_CalcTransferPhaseAngle(vessel.mainBody.orbit.semiMajorAxis, body.orbit.semiMajorAxis, vessel.mainBody.referenceBody.gravParameter) % 360;
-
-			double adj_phase_angle = Tools.adjustCurrPhaseAngle(trans_phase_angle, curr_phase_angle);
-			//double adj_ejection_angle = adjustCurrEjectionAngle(trans_phase_angle, curr_ejection_angle);
-
-			//new stuff
-			//
-			double adj_trans_ejection_angle = Tools.adjust_transfer_ejection_angle(trans_ejection_angle, trans_phase_angle);
-			double adj_curr_ejection_angle = Tools.adjust_current_ejection_angle(curr_ejection_angle);
-			//
-			//
-
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Phase angle (curr/trans):");
-			GUILayout.Label(adj_phase_angle.ToString("F3") + "° / " + trans_phase_angle.ToString("F3") + "°", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Ejection angle (curr/trans):");
-			GUILayout.Label(adj_curr_ejection_angle.ToString("F3") + "° / " + adj_trans_ejection_angle.ToString("F3") + "°", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-
-			GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
-			GUILayout.Label("Transfer velocity:");
-			GUILayout.Label((dv2 * 1000).ToString("F2") + "m/s", GUILayout.ExpandWidth(false));
-			GUILayout.EndHorizontal();
-		}
 	}
 }