public void FillAlarmWindow(int windowID) { KACAlarm tmpAlarm = Settings.Alarms.GetByWindowID(windowID); GUILayout.BeginVertical(); GUILayout.BeginVertical(GUI.skin.textArea); GUILayout.BeginHorizontal(); GUILayout.Label("Alarm Time:", KACResources.styleAlarmMessageTime); if (tmpAlarm.TypeOfAlarm != KACAlarm.AlarmType.EarthTime) { GUILayout.Label(KACTime.PrintDate(tmpAlarm.AlarmTime, Settings.TimeFormat), KACResources.styleAlarmMessageTime); } else { GUILayout.Label(EarthTimeDecode(tmpAlarm.AlarmTime.UT).ToLongTimeString(), KACResources.styleAlarmMessageTime); } if (tmpAlarm.TypeOfAlarm != KACAlarm.AlarmType.Raw && tmpAlarm.TypeOfAlarm != KACAlarm.AlarmType.EarthTime && tmpAlarm.TypeOfAlarm != KACAlarm.AlarmType.Crew) { GUILayout.Label("(m: " + KACTime.PrintInterval(new KACTime(tmpAlarm.AlarmMarginSecs), 3, Settings.TimeFormat) + ")", KACResources.styleAlarmMessageTime); } GUILayout.EndHorizontal(); GUILayout.Label(tmpAlarm.Notes, KACResources.styleAlarmMessage); GUILayout.BeginHorizontal(); DrawCheckbox(ref tmpAlarm.DeleteOnClose, "Delete On Close", 0); if (tmpAlarm.PauseGame) { if (FlightDriver.Pause) { GUILayout.Label("Game paused", KACResources.styleAlarmMessageActionPause); } else { GUILayout.Label("Alarm paused game, but has been unpaused", KACResources.styleAlarmMessageActionPause); } } else if (tmpAlarm.HaltWarp) { GUILayout.Label("Time Warp Halted", KACResources.styleAlarmMessageAction); } GUILayout.EndHorizontal(); if (tmpAlarm.TypeOfAlarm == KACAlarm.AlarmType.Crew) { DrawStoredCrewMissing(tmpAlarm.VesselID); } else { DrawStoredVesselIDMissing(tmpAlarm.VesselID); } GUILayout.EndVertical(); int intNoOfActionButtons = 0; int intNoOfActionButtonsDoubleLine = 0; //if the alarm has a vessel ID/Kerbal associated if (CheckVesselOrCrewForJump(tmpAlarm.VesselID, tmpAlarm.TypeOfAlarm)) { //option to allow jumping from SC and TS if (Settings.AllowJumpFromViewOnly) { intNoOfActionButtons = DrawAlarmActionButtons(tmpAlarm, out intNoOfActionButtonsDoubleLine); } } //Work out the text String strText = "Close Alarm"; if (tmpAlarm.PauseGame) { if (FlightDriver.Pause) { strText = "Close Alarm and Unpause"; } } //Now draw the button if (GUILayout.Button(strText, KACResources.styleButton)) { tmpAlarm.AlarmWindowClosed = true; tmpAlarm.ActionedAt = KACWorkerGameState.CurrentTime.UT; if (tmpAlarm.PauseGame) { FlightDriver.SetPause(false); } if (tmpAlarm.DeleteOnClose) { Settings.Alarms.Remove(tmpAlarm); } Settings.SaveAlarms(); } GUILayout.EndVertical(); int intLines = tmpAlarm.Notes.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Length; if (intLines == 0) { intLines = 1; } tmpAlarm.AlarmWindowHeight = 148 + intLines * 16 + intNoOfActionButtons * 32 + intNoOfActionButtonsDoubleLine * 14; SetTooltipText(); GUI.DragWindow(); }
public void FillEarthAlarmWindow(int WindowID) { GUILayout.BeginVertical(); intHeight_AddWindowCommon = 64; WindowLayout_CommonFields2(ref strAlarmName, ref blnAlarmAttachToVessel, ref AddAction, ref timeMargin, AddType, intHeight_AddWindowCommon); GUILayout.Label("Enter Time for reminder...", KACResources.styleAddSectionHeading); GUILayout.BeginVertical(KACResources.styleAddFieldAreas); GUILayout.BeginHorizontal(); GUILayout.Label("Time for Alarm (24 hour):", KACResources.styleAddHeading); GUILayout.FlexibleSpace(); if (DrawTimeField(ref strAlarmEarthHour, "", 40, 0)) { if (strAlarmEarthHour.Length > 2) { strAlarmEarthHour = strAlarmEarthHour.Substring(strAlarmEarthHour.Length - 2, 2); } } GUILayout.Label(":", KACResources.styleAlarmMessageTime, GUILayout.Width(3)); //strAlarmEarthMin = GUILayout.TextField(strAlarmEarthMin, KACResources.styleAddField, GUILayout.Width(40)); if (DrawTimeField(ref strAlarmEarthMin, "", 40, 0)) { if (strAlarmEarthMin.Length > 2) { strAlarmEarthMin = strAlarmEarthMin.Substring(strAlarmEarthMin.Length - 2, 2); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); try { DateTime dteWorking; dteWorking = DateTime.ParseExact(strAlarmEarthHour + ":" + strAlarmEarthMin, "H:m", null); TimeSpan tmAlarm = (dteWorking.TimeOfDay - DateTime.Now.TimeOfDay); if (tmAlarm.TotalSeconds < 0) { tmAlarm = tmAlarm.Add(new TimeSpan(24, 0, 0)); } KACTime TimeToAlarm = new KACTime(tmAlarm.TotalSeconds); //Bit at the bottom to add an alarm int intLineHeight = 18; GUILayout.BeginHorizontal(KACResources.styleAddAlarmArea); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Date:", KACResources.styleAddHeading, GUILayout.Height(intLineHeight), GUILayout.Width(40), GUILayout.MaxWidth(40)); GUILayout.Label(dteWorking.ToLongTimeString(), KACResources.styleContentEarth, GUILayout.Height(intLineHeight)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Time to Alarm:", KACResources.styleAddHeading, GUILayout.Height(intLineHeight), GUILayout.Width(100), GUILayout.MaxWidth(100)); GUILayout.Label(KACTime.PrintInterval(TimeToAlarm, KACTime.PrintTimeFormat.DateTimeString), KACResources.styleContentEarth, GUILayout.Height(intLineHeight)); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Space(10); int intButtonHeight = 36; if (GUILayout.Button("Add Alarm", KACResources.styleButton, GUILayout.Width(90), GUILayout.Height(intButtonHeight))) { Settings.Alarms.Add( new KACAlarm(null, strAlarmName, strAlarmNotes, EarthTimeEncode(DateTime.Now + tmAlarm), 0, KACAlarm.AlarmType.EarthTime, (AddAction == KACAlarm.AlarmAction.KillWarp), (AddAction == KACAlarm.AlarmAction.PauseGame)) ); Settings.SaveAlarms(); _ShowEarthAlarm = false; } GUILayout.EndHorizontal(); } catch (Exception) { GUILayout.Label("Unable to determine Earth Time", GUILayout.ExpandWidth(true)); } GUILayout.EndVertical(); SetTooltipText(); }