public static void display_transfer_angles_PLANET2MOON(CelestialBody body, Vessel vessel) { double dv1 = VOID_Tools.Younata_DeltaVToGetToOtherBody( (vessel.mainBody.gravParameter / 1000000000), (vessel.orbit.semiMajorAxis / 1000), (body.orbit.semiMajorAxis / 1000) ); double trans_phase_angle = VOID_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( VOID_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(); }
public override void DrawGUI(object sender) { if (this.core == null) { return; } VOID_Styles.labelHud.normal.textColor = textColors [ColorIndex]; GUI.skin = this.core.Skin; if (HighLogic.LoadedSceneIsEditor || (TimeWarp.WarpMode == TimeWarp.Modes.LOW) || (TimeWarp.CurrentRate <= TimeWarp.MaxPhysicsRate) ) { SimManager.RequestSimulation(); } HUDWindow window; for (int idx = 0; idx < this.Windows.Count; idx++) { window = this.Windows[idx]; window.WindowPos = GUILayout.Window( this.core.WindowID, window.WindowPos, VOID_Tools.GetWindowHandler(window.WindowFunction), GUIContent.none, GUIStyle.none ); } }
public override void ModuleWindow(int id) { GUILayout.BeginVertical(); GUILayout.Label( string.Format("System time: {0}", DateTime.Now.ToString("HH:mm:ss")), GUILayout.ExpandWidth(true) ); GUILayout.Label( string.Format("Kerbin time: {0}", VOID_Tools.FormatDate(Planetarium.GetUniversalTime())), GUILayout.ExpandWidth(true) ); GUIStyle activeLabelStyle = VOID_Styles.labelRed; string activeLabelText = "Inactive"; if (loggingActive) { activeLabelText = "Active"; activeLabelStyle = VOID_Styles.labelGreen; } this.loggingActive = Layout.Toggle( loggingActive, string.Format("Data logging: {0}", activeLabelText), null, activeLabelStyle ); this.waitForLaunch.value = Layout.Toggle( this.waitForLaunch, "Wait for launch" ); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Interval: ", GUILayout.ExpandWidth(false)); logIntervalStr = GUILayout.TextField(logIntervalStr, GUILayout.ExpandWidth(true)); GUILayout.Label("s", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); float newLogInterval; if (float.TryParse(logIntervalStr, out newLogInterval)) { logInterval.value = newLogInterval; this.logIntervalStr = this.logInterval.value.ToString("#.0##"); } GUILayout.EndVertical(); base.ModuleWindow(id); }
public override void DrawGUI(object sender) { if (this.core == null) { return; } VOID_Styles.labelHud.normal.textColor = textColors [ColorIndex]; GUI.skin = this.core.Skin; if (HighLogic.LoadedSceneIsEditor || (TimeWarp.WarpMode == TimeWarp.Modes.LOW) || (TimeWarp.CurrentRate <= TimeWarp.MaxPhysicsRate) ) { SimManager.Instance.RequestSimulation(); } if (!tSet) { tSet = true; t = new Texture2D(1, 1); t.SetPixel(0, 0, new Color(0, 0, 0, 0)); t.Apply(); transparentSkin = UnityEngine.Object.Instantiate(GUI.skin); transparentSkin.window.normal.background = t; transparentSkin.window.onNormal.background = t; GUI.skin = transparentSkin; } //if (GUI.skin.name != "KSPSkin") // GUI.skin = transparentSkin; HUDWindow window; for (int idx = 0; idx < this.Windows.Count; idx++) { window = this.Windows[idx]; if (GUI.skin.name != "KSPSkin") { window.WindowPos = GUILayout.Window( this.core.WindowID, window.WindowPos, VOID_Tools.GetWindowHandler(window.WindowFunction), "" ); } else { window.WindowPos = ClickThruBlocker.GUILayoutWindow( this.core.WindowID, window.WindowPos, VOID_Tools.GetWindowHandler(window.WindowFunction), "" ); } } }
public override void DrawGUI(object sender) { if (this.core == null) { return; } GUI.skin = this.core.Skin; Rect _Pos = this.WindowPos; _Pos = ClickThruBlocker.GUILayoutWindow( this.core.WindowID, _Pos, VOID_Tools.GetWindowHandler(this.ModuleWindow), this.Name, GUILayout.Width(this.defWidth), GUILayout.Height(this.defHeight) ); bool cursorInWindow = _Pos.Contains(Mouse.screenPos); if (cursorInWindow) { this.setUILock(); } else { this.removeUILock(); } if (HighLogic.LoadedSceneIsEditor) { _Pos = WindowTools.ClampRectToEditorPad(_Pos); } else { _Pos = WindowTools.ClampRectToScreen(_Pos); } if (_Pos != this.WindowPos) { this.WindowPos = _Pos; this.core.configDirty = true; } }
private void display_rendezvous_info(Vessel v, CelestialBody cb) { if (cb == null && v != null) { //Display vessel rendezvous info GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label(v.vesselName, VOID_Styles.labelCenterBold, 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) { // Toadicus edit: added local sidereal longitude. // Toadicus edit: added local sidereal longitude. double LSL = v.longitude + v.orbit.referenceBody.rotationAngle; LSL = VOID_Tools.FixDegreeDomain(LSL); //display orbital info for orbiting/flying/suborbital/escaping vessels only GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Ap/Pe:"); GUILayout.Label(SIFormatProvider.ToSI(v.orbit.ApA, 3) + "m / " + SIFormatProvider.ToSI(v.orbit.PeA, 3) + "m", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Altitude:"); GUILayout.Label(SIFormatProvider.ToSI(v.orbit.altitude, 3) + "m", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Inclination:"); GUILayout.Label(v.orbit.inclination.ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (Vessel.mainBody == v.mainBody) { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Relative inclination:"); GUILayout.Label(Vector3.Angle(Vessel.orbit.GetOrbitNormal(), v.orbit.GetOrbitNormal()).ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); } //if (debugging) Debug.Log("[CHATR] v -> v relative incl OK"); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Velocity:"); GUILayout.Label(SIFormatProvider.ToSI(v.orbit.vel.magnitude, 3) + "m/s", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Relative velocity:"); GUILayout.Label(SIFormatProvider.ToSI(v.orbit.vel.magnitude - Vessel.orbit.vel.magnitude, 3) + "m/s", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Distance:"); GUILayout.Label(SIFormatProvider.ToSI((Vessel.CoM - v.CoM).magnitude, 3) + "m", 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_Styles.labelRight); GUILayout.EndHorizontal(); toggleExtendedOrbital.value = Layout.Toggle(toggleExtendedOrbital, "Extended info"); if (toggleExtendedOrbital) { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Period:"); GUILayout.Label(VOID_Tools.FormatInterval(v.orbit.period), GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Semi-major axis:"); GUILayout.Label((v.orbit.semiMajorAxis / 1000).ToString("##,#") + "km", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Eccentricity:"); GUILayout.Label(v.orbit.eccentricity.ToString("F4"), GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); // Toadicus edit: convert mean anomaly into degrees. GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Mean anomaly:"); GUILayout.Label((v.orbit.meanAnomaly * 180d / Math.PI).ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("True anomaly:"); GUILayout.Label(v.orbit.trueAnomaly.ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); // Toadicus edit: convert eccentric anomaly into degrees. GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Eccentric anomaly:"); GUILayout.Label((v.orbit.eccentricAnomaly * 180d / Math.PI).ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Long. ascending node:"); GUILayout.Label(v.orbit.LAN.ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Arg. of periapsis:"); GUILayout.Label(v.orbit.argumentOfPeriapsis.ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); } } else { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Latitude:"); GUILayout.Label(VOID_Tools.GetLatitudeString(Vessel), GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Longitude:"); GUILayout.Label(VOID_Tools.GetLongitudeString(Vessel), GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Distance:"); GUILayout.Label(SIFormatProvider.ToSI((Vessel.CoM - v.CoM).magnitude, 3) + "m", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); } } else if (cb != null && v == null) { //Display CelstialBody rendezvous info GUILayout.Label(cb.bodyName, VOID_Styles.labelCenterBold); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Ap/Pe:"); GUILayout.Label(SIFormatProvider.ToSI(cb.orbit.ApA, 3) + "m / " + SIFormatProvider.ToSI(cb.orbit.PeA, 3) + "m", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); //if (debugging) Debug.Log("[VOID] Ap/Pe OK"); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Inclination:"); GUILayout.Label(cb.orbit.inclination.ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); //if (debugging) Debug.Log("[VOID] Inclination OK"); if (cb.referenceBody == Vessel.mainBody) { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Relative inclination:"); GUILayout.Label(Vector3.Angle(Vessel.orbit.GetOrbitNormal(), cb.orbit.GetOrbitNormal()).ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); //if (debugging) Debug.Log("[VOID] cb Relative inclination OK"); } GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label("Distance:"); GUILayout.Label(SIFormatProvider.ToSI((Vessel.mainBody.position - cb.position).magnitude, 3) + "m", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); //if (debugging) Debug.Log("[VOID] Distance OK"); //SUN2PLANET: if (Vessel.mainBody.bodyName == "Sun" && cb.referenceBody == Vessel.mainBody) { 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) { 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) { 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) { VOID_Tools.display_transfer_angles_MOON2MOON(cb, Vessel); //if (debugging) Debug.Log("[VOID] MOON2MOON OK"); } //else GUILayout.Label("Transfer angle information\nunavailable for this target"); } }
public static void display_transfer_angles_MOON2MOON(CelestialBody body, Vessel vessel) { double dv1 = VOID_Tools.Younata_DeltaVToGetToOtherBody( (vessel.mainBody.referenceBody.gravParameter / 1000000000), (vessel.mainBody.orbit.semiMajorAxis / 1000), (body.orbit.semiMajorAxis / 1000) ); double dv2 = VOID_Tools.Younata_DeltaVToExitSOI( (vessel.mainBody.gravParameter / 1000000000), (vessel.orbit.semiMajorAxis / 1000), (vessel.mainBody.sphereOfInfluence / 1000), Math.Abs(dv1) ); double trans_ejection_angle = VOID_Tools.Younata_TransferBurnPoint( (vessel.orbit.semiMajorAxis / 1000), dv2, (Math.PI / 2.0), (vessel.mainBody.gravParameter / 1000000000) ); double curr_phase_angle = VOID_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 = VOID_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 = VOID_Tools.Nivvy_CalcTransferPhaseAngle( vessel.mainBody.orbit.semiMajorAxis, body.orbit.semiMajorAxis, vessel.mainBody.referenceBody.gravParameter ) % 360; double adj_phase_angle = VOID_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 = VOID_Tools.adjust_transfer_ejection_angle(trans_ejection_angle, trans_phase_angle); double adj_curr_ejection_angle = VOID_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(); }
public int Compare(CelestialBody bodyA, CelestialBody bodyB) { Logging.PostDebugMessage(this, "got bodyA: {0} & bodyB: {1}", bodyA, bodyB); if (bodyA == null && bodyB == null) { Logging.PostDebugMessage(this, "both bodies are null, returning 0"); return(0); } if (bodyA == null) { Logging.PostDebugMessage(this, "bodyA is null, returning -1"); return(-1); } if (bodyB == null) { Logging.PostDebugMessage(this, "bodyB is null, returning 1"); return(1); } Logging.PostDebugMessage(this, "bodies are not null, carrying on"); if (object.ReferenceEquals(bodyA, bodyB)) { Logging.PostDebugMessage(this, "bodies are equal, returning 0"); return(0); } Logging.PostDebugMessage(this, "bodies are not equal, carrying on"); if (bodyA.orbitDriver == null) { Logging.PostDebugMessage(this, "bodyA.orbit is null (bodyA is the sun, returning 1"); return(1); } if (bodyB.orbitDriver == null) { Logging.PostDebugMessage(this, "bodyB.orbit is null (bodyB is the sun, returning -1"); return(-1); } Logging.PostDebugMessage(this, "orbits are not null, carrying on"); if (bodyA.orbit.referenceBody == bodyB.orbit.referenceBody) { Logging.PostDebugMessage(this, "bodies share a parent, comparing SMAs"); return(-bodyA.orbit.semiMajorAxis.CompareTo(bodyB.orbit.semiMajorAxis)); } Logging.PostDebugMessage(this, "orbits do not share a parent, carrying on"); if (bodyA.hasAncestor(bodyB)) { Logging.PostDebugMessage(this, "bodyA is a moon or sub-moon of bodyB, returning -1"); return(-1); } if (bodyB.hasAncestor(bodyA)) { Logging.PostDebugMessage(this, "bodyA is a moon or sub-moon of bodyB, returning 1"); return(1); } Logging.PostDebugMessage(this, "bodies do not have an obvious relationship, searching for one"); if (VOID_Tools.NearestRelatedParents(ref bodyA, ref bodyB)) { Logging.PostDebugMessage(this, "good relation {0} and {1}, comparing", bodyA.bodyName, bodyB.bodyName); return(this.Compare(bodyA, bodyB)); } Logging.PostDebugMessage(this, "bad relation {0} and {1}, giving up", bodyA.bodyName, bodyB.bodyName); return(0); }
public override void ModuleWindow(int id) { if (this.selectedBody == null) { this.selectedBody = core.HomeBody; } if ( !HighLogic.LoadedSceneIsFlight || (TimeWarp.WarpMode == TimeWarp.Modes.LOW) || (TimeWarp.CurrentRate <= TimeWarp.MaxPhysicsRate) ) { KerbalEngineer.VesselSimulator.SimManager.Instance.RequestSimulation(); } if (!this.stylesApplied) { this.stageTable.ApplyCellStyle(VOID_Styles.labelCenter); this.stageTable.ApplyHeaderStyle(VOID_Styles.labelCenterBold); } this.stageTable.ClearColumns(); if (core.Stages == null || core.Stages.Length == 0) { GUILayout.BeginVertical(); GUILayout.Label("No stage data!", GUILayout.Width(200)); GUILayout.EndVertical(); return; } if (HighLogic.LoadedSceneIsEditor && this.selectedBody.atmosphere && this.useSeaLevel) { SimManager.Atmosphere = this.selectedBody.GetPressure(0) * PhysicsGlobals.KpaToAtmospheres; } else { SimManager.Atmosphere = 0d; } Stage stage; for (int idx = 0; idx < core.Stages.Length; idx++) { stage = core.Stages[idx]; if (stage.deltaV == 0 && stage.mass == 0) { continue; } this.stageNumberCol.Add(stage.number); this.stageDeltaVCol.Add(stage.deltaV); this.stageTotalDVCol.Add(stage.totalDeltaV); this.stageInvertDVCol.Add(stage.inverseTotalDeltaV); this.stageMassCol.Add(stage.mass); this.stageTotalMassCol.Add(stage.totalMass); this.stageThrustCol.Add(stage.thrust * 1000f); this.stageTWRCol.Add(stage.thrustToWeight / (this.selectedBody ?? core.HomeBody).GeeASL); this.stageTimeCol.Add(VOID_Tools.FormatInterval(stage.time)); } this.stageTable.Render(); if (core.SortedBodyList != null) { GUILayout.BeginHorizontal(); if (GUILayout.Button("◄")) { this.bodyIdx.value--; } this.showBodyList = GUILayout.Toggle( this.showBodyList, (this.selectedBody ?? core.HomeBody).bodyName, GUI.skin.button ); Rect bodyButtonPos = GUILayoutUtility.GetLastRect(); if (Event.current.type == EventType.Repaint) { this.bodyListPos.width = bodyButtonPos.width; this.bodyListPos.x = bodyButtonPos.xMin + this.WindowPos.xMin; this.bodyListPos.y = bodyButtonPos.yMax + this.WindowPos.yMin; } if (GUILayout.Button("►")) { this.bodyIdx.value++; } this.bodyIdx.value %= core.SortedBodyList.Count; if (this.bodyIdx < 0) { this.bodyIdx.value += core.SortedBodyList.Count; } if (this.lastIdx != this.bodyIdx) { this.lastIdx = this.bodyIdx; this.selectedBody = core.SortedBodyList[this.bodyIdx]; } if (HighLogic.LoadedSceneIsEditor) { if ( GUILayout.Button( this.showAdvanced ? "▲" : "▼", GUILayout.ExpandWidth(false) ) ) { this.showAdvanced = !this.showAdvanced; } } GUILayout.EndHorizontal(); } if (this.showAdvanced && HighLogic.LoadedSceneIsEditor) { GUILayout.BeginHorizontal(); this.useSeaLevel.value = Layout.Toggle(this.useSeaLevel, this.seaLevelToggle, false); GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); if ( GUILayout.Button("Engineering data powered by <i>VesselSimulator from KER</i>.", VOID_Styles.labelLink) ) { Application.OpenURL("http://forum.kerbalspaceprogram.com/threads/18230"); } GUILayout.EndHorizontal(); base.ModuleWindow(id); }
public override void ModuleWindow(int id) { if (this.core.AllVesselTypes.Length < 1) { return; } if (selectedBodyIdx >= this.core.SortedBodyList.Count) { selectedBodyIdx.value %= this.core.SortedBodyList.Count; } if (selectedBodyIdx < 0) { selectedBodyIdx.value += this.core.SortedBodyList.Count; } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); if (GUILayout.Button("<")) { selectedBodyIdx.value--; if (selectedBodyIdx < 0) { selectedBodyIdx.value = this.core.SortedBodyList.Count - 1; } } GUILayout.Label(this.core.SortedBodyList[selectedBodyIdx].bodyName, VOID_Styles.labelCenterBold, GUILayout.ExpandWidth(true)); if (GUILayout.Button(">")) { selectedBodyIdx.value++; if (selectedBodyIdx > this.core.SortedBodyList.Count - 1) { selectedBodyIdx.value = 0; } } GUILayout.EndHorizontal(); seletedBody = this.core.SortedBodyList[selectedBodyIdx]; GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); if (GUILayout.Button("<")) { selectedVesselTypeIdx.value--; if (selectedVesselTypeIdx < 0) { selectedVesselTypeIdx.value = this.core.AllVesselTypes.Length - 1; } } GUILayout.Label(this.core.AllVesselTypes[selectedVesselTypeIdx].ToString(), VOID_Styles.labelCenterBold, GUILayout.ExpandWidth(true)); if (GUILayout.Button(">")) { selectedVesselTypeIdx.value++; if (selectedVesselTypeIdx > this.core.AllVesselTypes.Length - 1) { selectedVesselTypeIdx.value = 0; } } GUILayout.EndHorizontal(); selectedVesselType = this.core.AllVesselTypes[selectedVesselTypeIdx]; GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); if (GUILayout.Button("Landed", GUILayout.ExpandWidth(true))) { vesselSituation = "Landed"; } if (GUILayout.Button("Orbiting", GUILayout.ExpandWidth(true))) { vesselSituation = "Orbiting"; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Label( VOID_Tools.UppercaseFirst(vesselSituation) + " " + selectedVesselType.ToString() + "s @ " + seletedBody.bodyName, VOID_Styles.labelCenter, GUILayout.ExpandWidth(true)); GUILayout.EndHorizontal(); selectorScrollPos = GUILayout.BeginScrollView(selectorScrollPos, false, false); Vessel v; for (int idx = 0; idx < FlightGlobals.Vessels.Count; idx++) { v = FlightGlobals.Vessels[idx]; if (v != Vessel && v.vesselType == selectedVesselType && v.mainBody == seletedBody) { if ((vesselSituation == "Landed" && (v.situation == Vessel.Situations.LANDED || v.situation == Vessel.Situations.PRELAUNCH || v.situation == Vessel.Situations.SPLASHED)) || (vesselSituation == "Orbiting" && (v.situation == Vessel.Situations.ESCAPING || v.situation == Vessel.Situations.FLYING || v.situation == Vessel.Situations.ORBITING || v.situation == Vessel.Situations.SUB_ORBITAL)) ) { if (GUILayout.Button(v.vesselName, GUILayout.ExpandWidth(true))) { if (_selectedVessel != v) { _selectedVessel = v; //set clicked vessel as selected_vessel this.Active = true; //turn bool on to open the window if closed } else { _selectedVessel = null; } } } } } GUILayout.EndScrollView(); GUILayout.EndVertical(); base.ModuleWindow(id); }
protected void rightHUDWindow(int id) { using (PooledStringBuilder rightHUD = PooledStringBuilder.Get()) { VOID_Styles.labelHud.alignment = TextAnchor.UpperLeft; if (this.core.powerAvailable) { rightHUD.AppendFormat( "Burn Δv (Rem/Tot): {0} / {1}\n", VOID_Data.currManeuverDVRemaining.ValueUnitString("f2"), VOID_Data.currManeuverDeltaV.ValueUnitString("f2") ); if (VOID_Data.upcomingManeuverNodes > 1) { rightHUD.AppendFormat("Next Burn Δv: {0}\n", VOID_Data.nextManeuverDeltaV.ValueUnitString("f2") ); } rightHUD.AppendFormat("Burn Time (Rem/Total): {0} / {1}\n", VOID_Tools.FormatInterval(VOID_Data.currentNodeBurnRemaining.Value), VOID_Tools.FormatInterval(VOID_Data.currentNodeBurnDuration.Value) ); if (VOID_Data.burnTimeDoneAtNode.Value != string.Empty) { rightHUD.AppendFormat("{0} (done @ node)\n", VOID_Data.burnTimeDoneAtNode.Value ); rightHUD.AppendFormat("{0} (½ done @ node)", VOID_Data.burnTimeHalfDoneAtNode.Value ); } else { rightHUD.Append("Node is past"); } } else { VOID_Styles.labelHud.normal.textColor = Color.red; rightHUD.Append(string.Intern("-- POWER LOST --")); } GUILayout.Label( rightHUD.ToString(), VOID_Styles.labelHud, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) ); if (!this.positionsLocked) { GUI.DragWindow(); } GUI.BringWindowToBack(id); } }
public override void ModuleWindow(int id) { CelestialBody body; GUILayout.BeginVertical(); if (Vessel.mainBody.name == "Sun") //Vessel is orbiting the Sun { for (int idx = 0; idx < Vessel.mainBody.orbitingBodies.Count; idx++) { body = Vessel.mainBody.orbitingBodies[idx]; GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); if (GUILayout.Button(body.bodyName)) { //add or remove this body to this list of bodies to display more info on if (selectedBodies.Contains(body)) { selectedBodies.Remove(body); } else { selectedBodies.Add(body); } } GUILayout.Label("Inclined " + body.orbit.inclination.ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (selectedBodies.Contains(body)) { VOID_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 } } } else if (Vessel.mainBody.referenceBody.name == "Sun") //Vessel is orbiting a planet { for (int idx = 0; idx < Vessel.mainBody.referenceBody.orbitingBodies.Count; idx++) { body = Vessel.mainBody.referenceBody.orbitingBodies[idx]; if (body.name != Vessel.mainBody.name) // show other planets { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); if (GUILayout.Button(body.bodyName)) { //add or remove this body to this list of bodies to display more info on if (selectedBodies.Contains(body)) { selectedBodies.Remove(body); } else { selectedBodies.Add(body); } } GUILayout.Label("Inclined " + body.orbit.inclination.ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (selectedBodies.Contains(body)) { VOID_Tools.display_transfer_angles_PLANET2PLANET(body, Vessel); tad_targeting(body); //display Set/Unset Target button } } } for (int moonIdx = 0; moonIdx < Vessel.mainBody.orbitingBodies.Count; moonIdx++) { body = Vessel.mainBody.orbitingBodies[moonIdx]; GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); if (GUILayout.Button(body.bodyName)) { //add or remove this body to this list of bodies to display more info on if (selectedBodies.Contains(body)) { selectedBodies.Remove(body); } else { selectedBodies.Add(body); } } GUILayout.Label("Inclined " + body.orbit.inclination.ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (selectedBodies.Contains(body)) { VOID_Tools.display_transfer_angles_PLANET2MOON(body, Vessel); tad_targeting(body); //display Set/Unset Target button } } } else if (Vessel.mainBody.referenceBody.referenceBody.name == "Sun") // Vessel is orbiting a moon { for (int idx = 0; idx < Vessel.mainBody.referenceBody.orbitingBodies.Count; idx++) { body = Vessel.mainBody.referenceBody.orbitingBodies[idx]; if (body.name != Vessel.mainBody.name) // show other moons { GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); if (GUILayout.Button(body.bodyName)) { //add or remove this body to this list of bodies to display more info on if (selectedBodies.Contains(body)) { selectedBodies.Remove(body); } else { selectedBodies.Add(body); } } GUILayout.Label("Inclined " + body.orbit.inclination.ToString("F3") + "°", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (selectedBodies.Contains(body)) { VOID_Tools.display_transfer_angles_MOON2MOON(body, Vessel); tad_targeting(body); //display Set/Unset Target button } } } } GUILayout.EndVertical(); base.ModuleWindow(id); }
private void body_OP_show_orbital_info(CelestialBody body) { if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label((body.orbit.ApA / 1000).ToString("##,#") + "km", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label(VOID_Tools.FormatInterval(body.orbit.timeToAp), VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label((body.orbit.PeA / 1000).ToString("##,#") + "km", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label(VOID_Tools.FormatInterval(body.orbit.timeToPe), VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label((body.orbit.semiMajorAxis / 1000).ToString("##,#") + "km", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label(body.orbit.eccentricity.ToString("F4") + "", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label(VOID_Tools.FormatInterval(body.orbit.period), VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label(VOID_Tools.FormatInterval(body.rotationPeriod), VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label((body.orbit.orbitalSpeed / 1000).ToString("F2") + "km/s", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } // Toadicus edit: convert mean anomaly into degrees. if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label((body.orbit.meanAnomaly * 180d / Math.PI).ToString("F3") + "°", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label(body.orbit.trueAnomaly.ToString("F3") + "°", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } // Toadicus edit: convert eccentric anomaly into degrees. if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label((body.orbit.eccentricAnomaly * 180d / Math.PI).ToString("F3") + "°", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label(body.orbit.inclination.ToString("F3") + "°", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label(body.orbit.LAN.ToString("F3") + "°", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { GUILayout.Label(body.orbit.argumentOfPeriapsis.ToString("F3") + "°", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } if (body.bodyName == "Sun") { GUILayout.Label("N/A", VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } else { string body_tidally_locked = "No"; if (body.tidallyLocked) { body_tidally_locked = "Yes"; } GUILayout.Label(body_tidally_locked, VOID_Styles.labelRight, GUILayout.ExpandWidth(true)); } }