Exemplo n.º 1
0
        private void WindowLayout_AddPane_ClosestApproach()
        {
            GUILayout.BeginVertical();
            GUILayout.Label(strAlarmEventName + " Details...", KACResources.styleAddSectionHeading);

            if (KACWorkerGameState.CurrentVessel == null)
            {
                GUILayout.Label("No Active Vessel");
            }
            else
            {
                if (!(KACWorkerGameState.CurrentVesselTarget is Vessel) && !(KACWorkerGameState.CurrentVesselTarget is ModuleDockingNode))
                {
                    GUILayout.Label("No valid Vessel Target Selected", GUILayout.ExpandWidth(true));
                }
                else
                {
                    //GUILayout.Label("Adjust Lookahead amounts...", KACResources.styleAddSectionHeading);

                    GUILayout.BeginVertical(KACResources.styleAddFieldAreas);

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Orbits to Search:", KACResources.styleAddHeading, GUILayout.Width(110));
                    GUILayout.Label(((int)Math.Round((Decimal)fltOrbits, 0)).ToString(), KACResources.styleAddXferName, GUILayout.Width(25));
                    fltOrbits = GUILayout.HorizontalSlider(fltOrbits, 1, 20);
                    fltOrbits = (float)Math.Floor((Decimal)fltOrbits);
                    GUILayout.EndHorizontal();

                    intOrbits = (int)fltOrbits;
                    int    intClosestOrbitPass = 0;
                    double dblClosestDistance  = Double.MaxValue;
                    double dblClosestUT        = 0;

                    double dblOrbitTestClosest   = Double.MaxValue;
                    double dblOrbitTestClosestUT = 0;
                    for (int intOrbitToTest = 1; intOrbitToTest <= intOrbits; intOrbitToTest++)
                    {
                        dblOrbitTestClosestUT = KACUtils.timeOfClosestApproach(KACWorkerGameState.CurrentVessel.orbit,
                                                                               KACWorkerGameState.CurrentVesselTarget.GetOrbit(),
                                                                               KACWorkerGameState.CurrentTime.UT,
                                                                               intOrbitToTest,
                                                                               out dblOrbitTestClosest
                                                                               );
                        if (dblOrbitTestClosest < dblClosestDistance)
                        {
                            dblClosestDistance  = dblOrbitTestClosest;
                            dblClosestUT        = dblOrbitTestClosestUT;
                            intClosestOrbitPass = intOrbitToTest;
                        }
                    }


                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Distance:", KACResources.styleAddHeading, GUILayout.Width(70));
                    String strDistance = string.Format("{0:#}m", dblClosestDistance);
                    if (dblClosestDistance > 999)
                    {
                        strDistance = string.Format("{0:#.0}km", dblClosestDistance / 1000);
                    }
                    GUILayout.Label(strDistance, KACResources.styleAddXferName, GUILayout.Width(90));
                    GUILayout.Label("On Orbit:", KACResources.styleAddHeading);
                    GUILayout.Label(intClosestOrbitPass.ToString(), KACResources.styleAddXferName);
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();


                    String  strMarginConversion = "";
                    KACTime eventTime           = new KACTime(dblClosestUT);
                    KACTime eventInterval       = new KACTime(dblClosestUT - KACWorkerGameState.CurrentTime.UT);

                    KACTime eventAlarm;
                    KACTime eventAlarmInterval;
                    try
                    {
                        eventAlarm         = new KACTime(eventTime.UT - timeMargin.UT);
                        eventAlarmInterval = new KACTime(eventTime.UT - KACWorkerGameState.CurrentTime.UT - timeMargin.UT);
                    }
                    catch (Exception)
                    {
                        eventAlarm          = null;
                        eventAlarmInterval  = null;
                        strMarginConversion = "Unable to Add the Margin Minutes";
                    }

                    if ((eventTime.UT > KACWorkerGameState.CurrentTime.UT) && strMarginConversion == "")
                    {
                        if (DrawAddAlarm(eventTime, eventInterval, eventAlarmInterval))
                        {
                            KACAlarm newAlarm = new KACAlarm(KACWorkerGameState.CurrentVessel.id.ToString(), strAlarmName, strAlarmNotes,
                                                             eventAlarm.UT, timeMargin.UT, AddType,
                                                             (AddAction == KACAlarm.AlarmAction.KillWarp), (AddAction == KACAlarm.AlarmAction.PauseGame));
                            newAlarm.TargetObject = KACWorkerGameState.CurrentVesselTarget;
                            newAlarm.ManNodes     = KACWorkerGameState.CurrentVessel.patchedConicSolver.maneuverNodes;

                            Settings.Alarms.Add(newAlarm);
                            Settings.Save();
                            _ShowAddPane = false;
                        }
                    }
                    else
                    {
                        strMarginConversion = "No Future Closest Approach found";
                    }

                    if (strMarginConversion != "")
                    {
                        GUILayout.Label(strMarginConversion, GUILayout.ExpandWidth(true));
                    }
                }
            }

            GUILayout.EndVertical();
        }
Exemplo n.º 2
0
        private void WindowLayout_AddPane_TargetDistance()
        {
            intAddDistanceHeight = 272;
            GUILayout.BeginVertical();
            GUILayout.Label(strAlarmEventName + " Details...", KACResources.styleAddSectionHeading);

            //What are the possible targets??
            List <ITargetable> iTargets = new List <ITargetable>();

            if (!(KACWorkerGameState.CurrentVesselTarget == null))
            {
                iTargets.Add(KACWorkerGameState.CurrentVesselTarget);   //VesselTarget
            }
            iTargets.Add(KACWorkerGameState.CurrentVessel.mainBody);    //Body we are orbiting
            if (KACWorkerGameState.SOIPointExists)
            {
                iTargets.Add(KACWorkerGameState.CurrentVessel.orbit.nextPatch.referenceBody);   //Body we will orbit next
            }

            if (intSelectediTarget > iTargets.Count - 1)
            {
                intSelectediTarget = 0;
            }

            intAddDistanceHeight += (iTargets.Count * 30);

            //Now give the user the choice
            GUILayout.BeginHorizontal();
            GUILayout.Label("Select Target:", KACResources.styleAddXferName);
            if (DrawRadioListVertical(ref intSelectediTarget, iTargets.Select(x => x.GetName()).ToArray()))
            {
                DebugLogFormatted("Distance Target is:{0}", iTargets[intSelectediTarget].GetName());
            }
            GUILayout.EndHorizontal();

            //Set the tgt Object
            tgtSelectedDistance = iTargets[intSelectediTarget];
            string strDistanceName = "Distance";

            if (tgtSelectedDistance is CelestialBody)
            {
                strDistanceName = "Altitude";
            }

            //Ask for the target distance/altitude
            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("Target {0} (m):", strDistanceName), KACResources.styleAddXferName);
            dblTargetDistance = Convert.ToInt32(GUILayout.TextField(dblTargetDistance.ToString(), KACResources.styleAddField));
            GUILayout.EndHorizontal();

            //If the body has an atmosphere then add an option to set the Altitude straight to that
            if (tgtSelectedDistance is CelestialBody)
            {
                if ((tgtSelectedDistance as CelestialBody).atmosphere)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(string.Format("Atmosphere: {0}", (tgtSelectedDistance as CelestialBody).maxAtmosphereAltitude));
                    if (GUILayout.Button("Set to Edge"))
                    {
                        dblTargetDistance = (tgtSelectedDistance as CelestialBody).maxAtmosphereAltitude;
                    }
                    GUILayout.EndHorizontal();
                    intAddDistanceHeight += 26;
                }
            }

            //For a vessel give some options for orbits to look forwards
            GUILayout.BeginVertical(KACResources.styleAddFieldAreas);
            if (!(tgtSelectedDistance is CelestialBody))
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Orbits to Search:", KACResources.styleAddHeading, GUILayout.Width(110));
                GUILayout.Label(((int)Math.Round((Decimal)fltOrbits_Distance, 0)).ToString(), KACResources.styleAddXferName, GUILayout.Width(25));
                fltOrbits_Distance = GUILayout.HorizontalSlider(fltOrbits_Distance, 1, 20);
                fltOrbits_Distance = (float)Math.Floor((Decimal)fltOrbits_Distance);
                GUILayout.EndHorizontal();
                intAddDistanceHeight += 18;
            }

            //What VesselOrbit do we care about
            Orbit VesselOrbitToCompare = KACWorkerGameState.CurrentVessel.GetOrbit();

            if ((KACWorkerGameState.SOIPointExists) && ((tgtSelectedDistance as CelestialBody) == KACWorkerGameState.CurrentVessel.orbit.nextPatch.referenceBody))
            {
                VesselOrbitToCompare = KACWorkerGameState.CurrentVessel.orbit.nextPatch;
            }
            //Get the startUT of the orbit
            Double VesselOrbitStartUT = KACWorkerGameState.CurrentVessel.GetOrbit().StartUT;

            //Set up some variables
            intOrbits_Distance = (int)fltOrbits_Distance;
            int    intDistanceOrbitPass = 0;
            double dblClosestDistance   = Double.MaxValue;
            double dblDistanceUT        = 0;

            double dblOrbitTestDistance   = Double.MaxValue;
            double dblOrbitTestDistanceUT = 0;

            //If its an Altitude alarm then do this
            if (tgtSelectedDistance is CelestialBody)
            {
                dblOrbitTestDistanceUT = KACUtils.timeOfTargetAltitude(VesselOrbitToCompare,
                                                                       VesselOrbitStartUT,
                                                                       out dblOrbitTestDistance,
                                                                       dblTargetDistance
                                                                       );

                dblClosestDistance = dblOrbitTestDistance;
                dblDistanceUT      = dblOrbitTestDistanceUT;
            }
            else
            {
                //Else Iterate through the orbits to find the target separation
                for (int intOrbitToTest = 1; intOrbitToTest <= intOrbits_Distance; intOrbitToTest++)
                {
                    dblOrbitTestDistanceUT = KACUtils.timeOfTargetDistance(VesselOrbitToCompare,
                                                                           tgtSelectedDistance.GetOrbit(),
                                                                           KACWorkerGameState.CurrentTime.UT,
                                                                           intOrbitToTest,
                                                                           out dblOrbitTestDistance,
                                                                           dblTargetDistance
                                                                           );

                    if (dblOrbitTestDistance < dblClosestDistance)
                    {
                        dblClosestDistance   = dblOrbitTestDistance;
                        dblDistanceUT        = dblOrbitTestDistanceUT;
                        intDistanceOrbitPass = intOrbitToTest;
                    }
                }
            }

            //Now display what we got
            GUILayout.BeginHorizontal();
            GUILayout.Label(String.Format("{0}:", strDistanceName), KACResources.styleAddHeading, GUILayout.Width(70));
            String strDistance = string.Format("{0:#}m", dblClosestDistance);

            if (dblClosestDistance > 999)
            {
                strDistance = string.Format("{0:#.0}km", dblClosestDistance / 1000);
            }
            GUILayout.Label(strDistance, KACResources.styleAddXferName, GUILayout.Width(90));
            if (!(tgtSelectedDistance is CelestialBody))
            {
                GUILayout.Label("On Orbit:", KACResources.styleAddHeading);
                GUILayout.Label(intDistanceOrbitPass.ToString(), KACResources.styleAddXferName);
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            //Now do the stuff to draw the alarm button
            String  strMarginConversion = "";
            KACTime eventTime           = new KACTime(dblDistanceUT);
            KACTime eventInterval       = new KACTime(dblDistanceUT - KACWorkerGameState.CurrentTime.UT);

            KACTime eventAlarm;
            KACTime eventAlarmInterval;

            try
            {
                eventAlarm         = new KACTime(eventTime.UT - timeMargin.UT);
                eventAlarmInterval = new KACTime(eventTime.UT - KACWorkerGameState.CurrentTime.UT - timeMargin.UT);
            }
            catch (Exception)
            {
                eventAlarm          = null;
                eventAlarmInterval  = null;
                strMarginConversion = "Unable to Add the Margin Minutes";
            }

            if ((eventTime.UT > KACWorkerGameState.CurrentTime.UT) && strMarginConversion == "")
            {
                if (DrawAddAlarm(eventTime, eventInterval, eventAlarmInterval))
                {
                    KACAlarm newAlarm = new KACAlarm(KACWorkerGameState.CurrentVessel.id.ToString(), strAlarmName, strAlarmNotes,
                                                     eventAlarm.UT, timeMargin.UT, AddType,
                                                     (AddAction == KACAlarm.AlarmAction.KillWarp), (AddAction == KACAlarm.AlarmAction.PauseGame));
                    newAlarm.TargetObject = KACWorkerGameState.CurrentVesselTarget;
                    newAlarm.ManNodes     = KACWorkerGameState.CurrentVessel.patchedConicSolver.maneuverNodes;

                    Settings.Alarms.Add(newAlarm);
                    Settings.Save();
                    _ShowAddPane = false;
                }
            }
            else
            {
                strMarginConversion = "No Target Distance Approach found";
            }

            if (strMarginConversion != "")
            {
                GUILayout.Label(strMarginConversion, GUILayout.ExpandWidth(true));
            }

            GUILayout.EndVertical();
        }
Exemplo n.º 3
0
        private void WindowLayout_SettingsSpecifics1()
        {
            //Sperer of Influence Stuff
            GUILayout.Label("Sphere Of Influence Alarms", KACResources.styleAddSectionHeading);
            GUILayout.BeginVertical(KACResources.styleAddFieldAreas, GUILayout.Height(intSOIBoxheight));

            if (DrawCheckbox(ref Settings.AlarmSOIRecalc, new GUIContent("Auto Recalc of Manual SOI Alarms", strAlarmDescXfer)))
            {
                Settings.Save();
                //if it was turned on then force a recalc regardless of the gap
                if (Settings.AlarmSOIRecalc)
                {
                    RecalcSOIAlarmTimes(true);
                }
            }

            if (DrawCheckbox(ref Settings.AlarmAddSOIAuto, new GUIContent("Detect and Add Alarms for SOI Changes", strAlarmDescSOI)))
            {
                Settings.Save();
            }
            if (!Settings.AlarmAddSOIAuto)
            {
                Settings.AlarmCatchSOIChange = false;
            }
            if (Settings.AlarmAddSOIAuto)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                if (DrawCheckbox(ref Settings.AlarmAddSOIAuto_ExcludeEVA, new GUIContent("Exclude EVA Kerbals from Auto Alarm", "If an EVA'd Kerbal is on an SOI Path dont create an alarm for this scenario")))
                {
                    Settings.Save();
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                if (DrawCheckbox(ref Settings.AlarmCatchSOIChange, new GUIContent("Throw alarm on background SOI Change", "This will throw an alarm whenever the name of the body a ship is orbiting changes.\r\n\r\nIt wont slow time as this approaches, just a big hammer in case we never looked at the flight path before it happened")))
                {
                    Settings.Save();
                }
                GUILayout.EndHorizontal();
                GUILayout.Label("SOI Alarm Settings", KACResources.styleAddSectionHeading);
                if (DrawAlarmActionChoice(ref Settings.AlarmOnSOIChange_Action, "On Alarm:", 90))
                {
                    Settings.Save();
                }
                if (DrawTimeEntry(ref timeAutoSOIMargin, KACTimeStringArray.TimeEntryPrecisionEnum.Hours, "Alarm Margin:", 100))
                {
                    //convert it and save it in the settings
                    Settings.AlarmAutoSOIMargin = timeAutoSOIMargin.UT;
                    Settings.Save();
                }
            }
            GUILayout.EndVertical();

            //Transfer Alarm Stuff
            GUILayout.Label("Transfer Alarms", KACResources.styleAddSectionHeading);
            GUILayout.BeginVertical(KACResources.styleAddFieldAreas);
            if (DrawCheckbox(ref Settings.AlarmXferRecalc, new GUIContent("Auto Recalc of Transfer points", strAlarmDescXfer)))
            {
                Settings.Save();
                //if it was turned on then force a recalc regardless of the gap
                if (Settings.AlarmXferRecalc)
                {
                    RecalcTransferAlarmTimes(true);
                }
            }
            GUILayout.EndVertical();

            //Node Alarm Stuff
            GUILayout.Label("Orbital Node Alarms (Ap, Pe, AN, DN)", KACResources.styleAddSectionHeading);
            GUILayout.BeginVertical(KACResources.styleAddFieldAreas);
            if (DrawCheckbox(ref Settings.AlarmNodeRecalc, new GUIContent("Auto Recalc of Node points", strAlarmDescNode)))
            {
                Settings.Save();
                //if it was turned on then force a recalc regardless of the gap
                if (Settings.AlarmNodeRecalc)
                {
                    RecalcNodeAlarmTimes(true);
                }
            }
            GUILayout.EndVertical();
        }
Exemplo n.º 4
0
        private void WindowLayout_SettingsAbout()
        {
            //Update Check Area
            GUILayout.Label("Version Check", KACResources.styleAddSectionHeading);

            GUILayout.BeginVertical(KACResources.styleAddFieldAreas, GUILayout.Height(intUpdateBoxheight));
            GUILayout.BeginHorizontal();
            if (DrawCheckbox(ref Settings.DailyVersionCheck, "Check Version Daily"))
            {
                Settings.Save();
            }

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Check Version Now", KACResources.styleButton))
            {
                Settings.VersionCheck(true);
                //Hide the flag as we already have the window open;
                Settings.VersionAttentionFlag = false;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label("Last Check Attempt:", KACResources.styleAddHeading);
            GUILayout.Label("Last Version from Web:", KACResources.styleAddHeading);
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            GUILayout.Label(Settings.VersionCheckDate_AttemptString, KACResources.styleContent);

            if (Settings.VersionCheckRunning)
            {
                Int32 intDots = Convert.ToInt32(Math.Truncate(DateTime.Now.Millisecond / 250d)) + 1;
                GUILayout.Label(String.Format("{0} Checking", new String('.', intDots)), KACResources.styleVersionHighlight);
            }
            else
            {
                if (Settings.VersionAvailable)
                {
                    GUILayout.Label(String.Format("{0} @ {1}", Settings.VersionWeb, Settings.VersionCheckDate_SuccessString), KACResources.styleVersionHighlight);
                }
                else
                {
                    GUILayout.Label(String.Format("{0} @ {1}", Settings.VersionWeb, Settings.VersionCheckDate_SuccessString), KACResources.styleContent);
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (Settings.VersionAvailable)
            {
                GUILayout.Label("Updated Version Available", KACResources.styleVersionHighlight);
            }
            GUILayout.EndVertical();

            //Update Check Area
            GUILayout.Label("About", KACResources.styleAddSectionHeading);

            GUILayout.BeginVertical(KACResources.styleAddFieldAreas);
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            //GUILayout.Label("Written by:", KACResources.styleAddHeading);
            GUILayout.Label("Documentation and Links:", KACResources.styleAddHeading);
            GUILayout.Label("Spaceport Page:", KACResources.styleAddHeading);
            GUILayout.Label("Forum Page:", KACResources.styleAddHeading);
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            //GUILayout.Label("Trigger Au",KACResources.styleContent);
            if (GUILayout.Button("Click Here", KACResources.styleContent))
            {
                Application.OpenURL("https://sites.google.com/site/kerbalalarmclock/");
            }
            if (GUILayout.Button("Click Here", KACResources.styleContent))
            {
                Application.OpenURL("http://kerbalspaceport.com/kerbal-alarm-clock-2/");
            }
            if (GUILayout.Button("Click Here", KACResources.styleContent))
            {
                Application.OpenURL("http://forum.kerbalspaceprogram.com/showthread.php/24786-Kerbal-Alarm-Clock");
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
Exemplo n.º 5
0
        private void WindowLayout_SettingsGlobal()
        {
            //Preferences
            GUILayout.Label("Plugin Preferences", KACResources.styleAddSectionHeading);
            GUILayout.BeginVertical(KACResources.styleAddFieldAreas);

            //two columns
            GUILayout.BeginHorizontal();
            if (DrawTextBox(ref Settings.AlarmListMaxAlarms, KACResources.styleAddField, GUILayout.Width(45)))
            {
                Settings.Save();
            }
            GUILayout.Label("Max alarms before scrolling the list", KACResources.styleAddHeading);
            GUILayout.EndHorizontal();

            if (DrawCheckbox(ref Settings.HideOnPause, "Hide Alarm Clock when game is paused"))
            {
                Settings.Save();
            }

            if (DrawCheckbox(ref Settings.ShowTooltips, "Show Tooltips on Mouse Hover"))
            {
                Settings.Save();
            }

            int intTimeFormat = (int)Settings.TimeFormat;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Time Format:", KACResources.styleAddHeading, GUILayout.Width(90));
            if (DrawRadioList(ref intTimeFormat, new String[] { "UT", "KSP Time", "Normal Time" }))
            {
                Settings.TimeFormat = (KACTime.PrintTimeFormat)intTimeFormat;
                Settings.SaveConfig();
            }
            GUILayout.EndHorizontal();

            if (DrawCheckbox(ref Settings.AllowJumpFromViewOnly, "Allow Ship Jump in Space Center and Tracking Station"))
            {
                Settings.Save();
            }

            if (DrawCheckbox(ref Settings.AllowJumpToAsteroid, "Allow Ship Jump to Asteroids"))
            {
                Settings.Save();
            }

            //if (DrawCheckbox(ref Settings.TimeAsUT, "Display Times as UT (instead of Date/Time)"))
            //    Settings.Save();

            GUILayout.EndVertical();

            GUIContent Saveheader = new GUIContent("Save File Backups", "This option will save your persistent and quicksave files prior to switching ships using the KAC Jump buttons");

            GUILayout.Label(Saveheader, KACResources.styleAddSectionHeading);
            GUILayout.BeginVertical(KACResources.styleAddFieldAreas, GUILayout.Height(64));
            if (DrawCheckbox(ref Settings.BackupSaves, "Backup Saves on Ship Jump"))
            {
                Settings.Save();
            }

            if (DrawCheckbox(ref Settings.CancelFlightModeJumpOnBackupFailure, "Cancel Jump if Backup Fails (Flight Mode Only)"))
            {
                Settings.Save();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Backups to Keep:", KACResources.styleAddHeading, GUILayout.Width(110));
            GUILayout.Label(Settings.BackupSavesToKeep.ToString(), KACResources.styleAddXferName, GUILayout.Width(25));
            Settings.BackupSavesToKeep = (int)Math.Floor(GUILayout.HorizontalSlider((float)Settings.BackupSavesToKeep, 3, 50));
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();


            GUILayout.Label("Time Warp/Math Checks", KACResources.styleAddSectionHeading);
            GUILayout.BeginVertical(KACResources.styleAddFieldAreas);

            GUILayout.BeginHorizontal();

            GUILayout.Label("Checks per Sec:", KACResources.styleAddHeading, GUILayout.Width(100));
            if (DrawButtonList(ref intChecksPerSecChoice, contChecksPerSecChoices))
            {
                switch (intChecksPerSecChoice)
                {
                case 0: Settings.BehaviourChecksPerSec = 10; break;

                case 1: Settings.BehaviourChecksPerSec = 20; break;

                case 2: Settings.BehaviourChecksPerSec = 50; break;

                case 3: Settings.BehaviourChecksPerSec = 100; break;

                default: Settings.BehaviourChecksPerSec = Settings.BehaviourChecksPerSec_Custom; break;
                }
                parentBehaviour.SetupRepeatingFunction_BehaviourUpdate(Settings.BehaviourChecksPerSec);
                Settings.SaveConfig();
            }

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUILayout.Label("Alarm Defaults", KACResources.styleAddSectionHeading);
            GUILayout.BeginVertical(KACResources.styleAddFieldAreas, GUILayout.Height(intAlarmDefaultsBoxheight));

            //Alarm position
            GUILayout.BeginHorizontal();
            GUILayout.Label("Alarm Position:", KACResources.styleAddHeading, GUILayout.Width(90));
            if (DrawRadioList(ref Settings.AlarmPosition, "Left", "Center", "Right"))
            {
                Settings.Save();
            }
            GUILayout.EndHorizontal();

            //Default Alarm Action
            if (DrawAlarmActionChoice(ref Settings.AlarmDefaultAction, "Default Action:", 90))
            {
                Settings.Save();
            }

            if (DrawTimeEntry(ref timeDefaultMargin, KACTimeStringArray.TimeEntryPrecisionEnum.Hours, "Default Margin:", 100))
            {
                //convert it and save it in the settings
                Settings.AlarmDefaultMargin = timeDefaultMargin.UT;
                Settings.Save();
            }
            if (DrawCheckbox(ref Settings.AlarmDeleteOnClose, "Delete Alarm On Close"))
            {
                Settings.Save();
            }

            GUILayout.EndVertical();
        }