//String is "VesselID|Name|Notes|AlarmTime.UT|AlarmMarginSecs|Type|Enabled|HaltWarp|PauseGame|ActionedAt|Manuever|Xfer|Target|Options|<ENDLINE>"); public String SerializeString3() { //"VesselID, Name, Notes, AlarmTime.UT, AlarmMarginSecs, Type, Enabled, HaltWarp, PauseGame, Manuever/Xfer" String strReturn = ""; strReturn += VesselID + "|"; strReturn += KACUtils.PipeSepVariables(Name, Notes, AlarmTime.UT, AlarmMarginSecs, TypeOfAlarm, Enabled, HaltWarp, PauseGame, ActionedAt); strReturn += "|"; if (ManNodes != null) { strReturn += ManNodeSerializeList(ManNodes); } strReturn += "|"; if (XferTargetBodyName != null && XferTargetBodyName != "") { strReturn += "" + XferOriginBodyName; strReturn += "," + XferTargetBodyName; } strReturn += "|"; if (TargetObject != null) { strReturn += KACAlarm.TargetSerialize(TargetObject); } strReturn += "|"; //Extra Options go here if we need it later strReturn += "|"; return(strReturn); }
private int DrawAlarmActionButtons(KACAlarm tmpAlarm, out int NoOfDoubleLineButtons) { int intReturnNoOfButtons = 0; NoOfDoubleLineButtons = 0; ////is it the current vessel? //if ((!ViewAlarmsOnly) && (KACWorkerGameState.CurrentVessel != null) && (FindVesselForAlarm(tmpAlarm).id.ToString() == KACWorkerGameState.CurrentVessel.id.ToString())) if ((KACWorkerGameState.CurrentGUIScene == GameScenes.FLIGHT) && (KACWorkerGameState.CurrentVessel != null) && (FindVesselForAlarm(tmpAlarm).id.ToString() == KACWorkerGameState.CurrentVessel.id.ToString())) { //There is a node and the alarm + Margin is not expired if ((tmpAlarm.ManNodes != null) && tmpAlarm.ManNodes.Count > 0) //if ((tmpAlarm.ManNodes != null) && ((tmpAlarm.Remaining.UT + tmpAlarm.AlarmMarginSecs) > 0)) { //Check if theres a Maneuver node and if so put a label saying that it already exists //only display this node button if its the active ship //Add this sae functionality to the alarm triggered window //Add a jump to ship button if not the active ship //As well as to the String strRestoretext = "Restore Maneuver Node(s)"; if (KACWorkerGameState.CurrentVessel.patchedConicSolver.maneuverNodes.Count > 0) { strRestoretext = "Replace Maneuver Node(s)"; //if the count and UT's are the same then go from there if (!KACAlarm.CompareManNodeListSimple(KACWorkerGameState.CurrentVessel.patchedConicSolver.maneuverNodes, tmpAlarm.ManNodes)) { strRestoretext += "\r\nNOTE: There is already a Node on the flight path"; } else { strRestoretext += "\r\nNOTE: These nodes appear to be already set on the flight path"; } NoOfDoubleLineButtons++; } if ((tmpAlarm.Remaining.UT + tmpAlarm.AlarmMarginSecs) < 0) { strRestoretext += "\r\nWARNING: The stored Nodes are in the past"; NoOfDoubleLineButtons++; } intReturnNoOfButtons++; if (GUILayout.Button(strRestoretext, KACResources.styleButton)) { LogFormatted("Attempting to add Node"); KACWorkerGameState.CurrentVessel.patchedConicSolver.maneuverNodes.Clear(); RestoreManeuverNodeList(tmpAlarm.ManNodes); } } //There is a stored Target, that hasnt passed //if ((tmpAlarm.TargetObject != null) && ((tmpAlarm.Remaining.UT + tmpAlarm.AlarmMarginSecs) > 0)) if ((tmpAlarm.TargetObject != null)) { String strRestoretext = "Restore Target"; if (KACWorkerGameState.CurrentVesselTarget != null) { strRestoretext = "Replace Target"; if (KACWorkerGameState.CurrentVesselTarget != tmpAlarm.TargetObject) { strRestoretext += "\r\nNOTE: There is already a target and this will change"; } else { strRestoretext += "\r\nNOTE: This already appears to be the target"; } NoOfDoubleLineButtons++; } intReturnNoOfButtons++; if (GUILayout.Button(strRestoretext, KACResources.styleButton)) { if (tmpAlarm.TargetObject is Vessel) { FlightGlobals.fetch.SetVesselTarget(tmpAlarm.TargetObject as Vessel); } else if (tmpAlarm.TargetObject is CelestialBody) { FlightGlobals.fetch.SetVesselTarget(tmpAlarm.TargetObject as CelestialBody); } } } } else { //not current vessel //There is a node and the alarm + Margin is not expired //if (tmpAlarm.ManNodes != null && tmpAlarm.Remaining.UT + tmpAlarm.AlarmMarginSecs > 0) if (tmpAlarm.ManNodes != null && tmpAlarm.ManNodes.Count > 0) { String strRestoretext = "Jump To Ship and Restore Maneuver Node"; if (tmpAlarm.TypeOfAlarm == KACAlarm.AlarmTypeEnum.Crew) { strRestoretext = strRestoretext.Replace("Ship", "Kerbal"); } if ((tmpAlarm.Remaining.UT + tmpAlarm.AlarmMarginSecs) < 0) { strRestoretext += "\r\nWARNING: The stored Nodes are in the past"; NoOfDoubleLineButtons++; } intReturnNoOfButtons++; if (GUILayout.Button(strRestoretext, KACResources.styleButton)) { Vessel tmpVessel = FindVesselForAlarm(tmpAlarm); if (JumpToVessel(tmpVessel)) { //Set the Node in memory to restore once the ship change has completed settings.LoadManNode = KACAlarm.ManNodeSerializeList(tmpAlarm.ManNodes); settings.Save(); } } } //There is a target and the alarm has not expired //if (tmpAlarm.TargetObject != null && tmpAlarm.Remaining.UT + tmpAlarm.AlarmMarginSecs > 0) if (tmpAlarm.TargetObject != null) { intReturnNoOfButtons++; String strButtonT = "Jump To Ship and Restore Target"; if (tmpAlarm.TypeOfAlarm == KACAlarm.AlarmTypeEnum.Crew) { strButtonT = strButtonT.Replace("Ship", "Kerbal"); } if (GUILayout.Button(strButtonT, KACResources.styleButton)) { Vessel tmpVessel = FindVesselForAlarm(tmpAlarm); if (JumpToVessel(tmpVessel)) { //Set the Target in persistant file to restore once the ship change has completed... settings.LoadVesselTarget = KACAlarm.TargetSerialize(tmpAlarm.TargetObject); settings.Save(); } } } intReturnNoOfButtons++; //Or just jump to ship - regardless of alarm time String strButton = "Jump To Ship"; if (tmpAlarm.TypeOfAlarm == KACAlarm.AlarmTypeEnum.Crew) { strButton = strButton.Replace("Ship", "Kerbal"); } if (GUILayout.Button(strButton, KACResources.styleButton)) { Vessel tmpVessel = FindVesselForAlarm(tmpAlarm); // tmpVessel.MakeActive(); JumpToVessel(tmpVessel); } ////////////////////////////////////////////////////////////////////////////////// // Focus Vessel Code - reflecting to get SetVessel Focus in TS ////////////////////////////////////////////////////////////////////////////////// if (KACWorkerGameState.CurrentGUIScene == GameScenes.TRACKSTATION) { Vessel vTarget = FlightGlobals.Vessels.FirstOrDefault(v => v.id.ToString().ToLower() == tmpAlarm.VesselID); if (vTarget != null) { intReturnNoOfButtons++; if (GUILayout.Button("Set Vessel Active", KACResources.styleButton)) { SetVesselActiveInTS(vTarget); //FlightGlobals.Vessels.ForEach(v => // { // v.DetachPatchedConicsSolver(); // v.orbitRenderer.isFocused = false; // }); //vTarget.orbitRenderer.isFocused = true; //vTarget.AttachPatchedConicsSolver(); //FlightGlobals.SetActiveVessel(vTarget); //SpaceTracking.GoToAndFocusVessel(vTarget); //st.mainCamera.SetTarget(getVesselIdx(vTarget)); } } //} } } return(intReturnNoOfButtons); }