示例#1
0
        internal void DeleteInstance()
        {
            if (selectedObjectPrevious == selectedInstance)
            {
                selectedObjectPrevious = null;
            }


            if (selectedInstance.hasLauchSites)
            {
                LaunchSiteManager.DeleteLaunchSite(selectedInstance.launchSite);
            }


            KerbalKonstructs.instance.DeleteInstance(selectedInstance);
            selectedInstance = null;
            return;
        }
        void BuildLaunchsites()
        {
            launchsiteItems.Clear();
            int index = 0;

            for (int i = 0, count = LaunchSiteManager.allLaunchSites.Length; i < count; i++)
            {
                var site = LaunchSiteManager.allLaunchSites[i];
                if (launchsiteFilter.showFavOnly && (site.favouriteSite != "Yes"))
                {
                    continue;
                }

                if (launchsiteFilter.category != site.sitecategory && !launchsiteFilter.showAllcategorys)
                {
                    continue;
                }

                if (LaunchSiteManager.CheckLaunchSiteIsValid(site) == false)
                {
                    continue;
                }
                if ((!launchsiteFilter.showOpen && site.isOpen) || (!launchsiteFilter.showClosed && !site.isOpen))
                {
                    continue;
                }
                // Don't show hidden closed Bases
                if (site.LaunchSiteIsHidden && (!site.isOpen))
                {
                    //Log.Normal("Ignoring hidden base: " + site.LaunchSiteName);
                    continue;
                }
                if (site == selectedSite)
                {
                    index = launchsiteItems.Count;
                }
                launchsiteItems.Add(new LaunchsiteItem(site));
            }
            UIKit.UpdateListContent(launchsiteItems);
            launchsiteItems.Select(index);
        }
        void OpenSite()
        {
            float  openCost     = selectedSite.OpenCost / 2;
            double currentfunds = Funding.Instance.Funds;

            if (openCost > currentfunds)
            {
                MiscUtils.HUDMessage(KKLocalization.InsuficientFundsToOpenSite, 10, 3);
            }
            else
            {
                LaunchSiteManager.OpenLaunchSite(selectedSite);
                if (MiscUtils.isCareerGame())
                {
                    Funding.Instance.AddFunds(-openCost, TransactionReasons.Cheating);
                }
                string message = Localizer.Format(KKLocalization.SiteOpened, selectedSite.LaunchSiteName);
                MiscUtils.HUDMessage(message, 10, 2);

                launchsiteItems.Update(selectedSite);
                UpdateLaunchsite();
            }
        }
        void drawBaseManagerWindow(int windowID)
        {
            string     Base;
            string     Base2;
            float      Range;
            LaunchSite lNearest;
            LaunchSite lBase;
            LaunchSite lBase2;
            string     smessage = "";

            BoxNoBorder = new GUIStyle(GUI.skin.box);
            BoxNoBorder.normal.background = null;
            BoxNoBorder.normal.textColor  = Color.white;

            LabelInfo = new GUIStyle(GUI.skin.label);
            LabelInfo.normal.background = null;
            LabelInfo.normal.textColor  = Color.white;
            LabelInfo.fontSize          = 13;
            LabelInfo.fontStyle         = FontStyle.Bold;
            LabelInfo.padding.left      = 3;
            LabelInfo.padding.top       = 0;
            LabelInfo.padding.bottom    = 0;

            DeadButton = new GUIStyle(GUI.skin.button);
            DeadButton.normal.background  = null;
            DeadButton.hover.background   = null;
            DeadButton.active.background  = null;
            DeadButton.focused.background = null;
            DeadButton.normal.textColor   = Color.white;
            DeadButton.hover.textColor    = Color.white;
            DeadButton.active.textColor   = Color.white;
            DeadButton.focused.textColor  = Color.white;
            DeadButton.fontSize           = 14;
            DeadButton.fontStyle          = FontStyle.Bold;

            DeadButtonRed = new GUIStyle(GUI.skin.button);
            DeadButtonRed.normal.background  = null;
            DeadButtonRed.hover.background   = null;
            DeadButtonRed.active.background  = null;
            DeadButtonRed.focused.background = null;
            DeadButtonRed.normal.textColor   = Color.red;
            DeadButtonRed.hover.textColor    = Color.yellow;
            DeadButtonRed.active.textColor   = Color.red;
            DeadButtonRed.focused.textColor  = Color.red;
            DeadButtonRed.fontSize           = 12;
            DeadButtonRed.fontStyle          = FontStyle.Bold;

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", DeadButton, GUILayout.Height(16));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Inflight Base Boss", DeadButton, GUILayout.Height(16));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(16)))
                {
                    bShowFacilities = false;
                    KerbalKonstructs.instance.showFlightManager = false;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(5);
            GUILayout.Box("Flight Tools", BoxNoBorder);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(2);
                GUILayout.Label("ATC ", LabelInfo);

                if (KerbalKonstructs.instance.enableATC)
                {
                    tToggle = tIconOpen;
                }
                else
                {
                    tToggle = tIconClosed;
                }

                if (GUILayout.Button(tToggle, GUILayout.Height(18), GUILayout.Width(18)))
                {
                    KerbalKonstructs.instance.updateCache();

                    if (KerbalKonstructs.instance.enableATC)
                    {
                        KerbalKonstructs.instance.enableATC = false;
                    }
                    else
                    {
                        KerbalKonstructs.instance.enableATC = true;
                    }
                }

                KerbalKonstructs.instance.showATC = (KerbalKonstructs.instance.enableATC);

                GUILayout.FlexibleSpace();
                GUILayout.Label("NGS ", LabelInfo);

                if (KerbalKonstructs.instance.enableNGS)
                {
                    tToggle2 = tIconOpen;
                }
                else
                {
                    tToggle2 = tIconClosed;
                }

                if (GUILayout.Button(tToggle2, GUILayout.Height(18), GUILayout.Width(18)))
                {
                    if (KerbalKonstructs.instance.enableNGS)
                    {
                        KerbalKonstructs.instance.enableNGS = false;
                    }
                    else
                    {
                        KerbalKonstructs.instance.enableNGS = true;
                    }
                }

                KerbalKonstructs.instance.showNGS = (KerbalKonstructs.instance.enableNGS);

                GUILayout.FlexibleSpace();
                GUILayout.Label("Downlink ", LabelInfo);

                if (KerbalKonstructs.instance.enableDownlink)
                {
                    tToggle2 = tIconOpen;
                }
                else
                {
                    tToggle2 = tIconClosed;
                }

                if (GUILayout.Button(tToggle2, GUILayout.Height(18), GUILayout.Width(18)))
                {
                    if (KerbalKonstructs.instance.enableDownlink)
                    {
                        KerbalKonstructs.instance.enableDownlink = false;
                    }
                    else
                    {
                        KerbalKonstructs.instance.enableDownlink = true;
                    }
                }

                KerbalKonstructs.instance.showDownlink = (KerbalKonstructs.instance.enableDownlink);

                GUILayout.Space(2);
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);

            GUILayout.Box("Active Beacons", BoxNoBorder);

            if (MiscUtils.isCareerGame())
            {
                GUILayout.BeginHorizontal();
                {
                    string snearestopen = "";
                    LaunchSiteManager.getNearestOpenBase(FlightGlobals.ActiveVessel.GetTransform().position, out Base, out Range, out lNearest);
                    if (FlightGlobals.ActiveVessel.altitude > 75000)
                    {
                        GUILayout.Label("No base's beacon in range at this altitude.", LabelInfo);
                    }
                    else
                    if (Base == "")
                    {
                        GUILayout.Label("No open base found.", LabelInfo);
                    }
                    else
                    {
                        if (Range < 10000)
                        {
                            snearestopen = Base + " at " + Range.ToString("#0.0") + " m";
                        }
                        else
                        {
                            snearestopen = Base + " at " + (Range / 1000).ToString("#0.0") + " km";
                        }

                        GUILayout.Space(5);
                        GUILayout.Label("Nearest Open: ", LabelInfo);
                        GUILayout.Label(snearestopen, LabelInfo, GUILayout.Width(150));

                        if (KerbalKonstructs.instance.enableNGS)
                        {
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("NGS", GUILayout.Height(21)))
                            {
                                NavGuidanceSystem.setTargetSite(lNearest);
                                smessage = "NGS set to " + Base;
                                MiscUtils.HUDMessage(smessage, 10, 2);
                            }
                        }
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(2);
            }

            GUILayout.BeginHorizontal();
            {
                string sNearestbase = "";
                LaunchSiteManager.getNearestBase(FlightGlobals.ActiveVessel.GetTransform().position, out Base, out Base2, out Range, out lBase, out lBase2);

                if (FlightGlobals.ActiveVessel.altitude > 75000)
                {
                    GUILayout.Label("No base's beacon in range at this altitude.", LabelInfo);
                }
                else
                if (Base == "")
                {
                    GUILayout.Label("No nearest base found.", LabelInfo);
                }
                else
                {
                    if (Range < 10000)
                    {
                        sNearestbase = Base + " at " + Range.ToString("#0.0") + " m";
                    }
                    else
                    {
                        sNearestbase = Base + " at " + (Range / 1000).ToString("#0.0") + " km";
                    }

                    GUILayout.Space(5);
                    GUILayout.Label("Nearest Base: ", LabelInfo);
                    GUILayout.Label(sNearestbase, LabelInfo, GUILayout.Width(150));

                    if (KerbalKonstructs.instance.enableNGS)
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("NGS", GUILayout.Height(21)))
                        {
                            NavGuidanceSystem.setTargetSite(lBase);

                            smessage = "NGS set to " + Base;
                            MiscUtils.HUDMessage(smessage, 10, 2);
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);
            GUILayout.Box("Base Status", BoxNoBorder);

            if (MiscUtils.isCareerGame())
            {
                bool bLanded = (FlightGlobals.ActiveVessel.Landed);

                if (Range < 2000)
                {
                    string sClosed;
                    float  fOpenCost;
                    LaunchSiteManager.getSiteOpenCloseState(Base, out sClosed, out fOpenCost);
                    fOpenCost = fOpenCost / 2f;

                    if (bLanded && sClosed == "Closed")
                    {
                        GUILayout.Space(2);
                        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                        GUILayout.Space(2);
                        if (GUILayout.Button("Open Base for " + fOpenCost + " funds", GUILayout.Height(23)))
                        {
                            double currentfunds = Funding.Instance.Funds;

                            if (fOpenCost > currentfunds)
                            {
                                MiscUtils.HUDMessage("Insufficient funds to open this site!", 10, 0);
                            }
                            else
                            {
                                Funding.Instance.AddFunds(-fOpenCost, TransactionReasons.Cheating);

                                LaunchSiteManager.setSiteOpenCloseState(Base, "Open");
                                smessage = Base + " opened";
                                MiscUtils.HUDMessage(smessage, 10, 2);
                            }
                        }
                    }

                    if (bLanded && sClosed == "Open")
                    {
                        GUI.enabled = false;
                        GUILayout.Button("Base is Open", GUILayout.Height(23));
                        GUI.enabled = true;
                    }

                    if (bLanded && (sClosed == "OpenLocked" || sClosed == "ClosedLocked"))
                    {
                        GUI.enabled = false;
                        GUILayout.Button("Base cannot be opened or closed", GUILayout.Height(23));
                        GUI.enabled = true;
                    }

                    GUILayout.Space(2);
                    GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                    GUILayout.Space(2);
                }
                else
                {
                    GUILayout.Label("Bases can only be opened or closed at the base when within 2km of the base.", LabelInfo);
                }

                if (Range > 100000)
                {
                    if (bLanded)
                    {
                        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                        GUILayout.Space(2);
                        GUILayout.Label("This feature is WIP.", LabelInfo);
                        GUI.enabled = false;
                        if (GUILayout.Button("Found a New Base", GUILayout.Height(23)))
                        {
                            foundingBase = true;
                        }
                        GUI.enabled = true;
                        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                        GUILayout.Space(2);
                    }
                }
                else
                {
                    GUILayout.Label("This feature is WIP.", LabelInfo);
                    GUILayout.Label("New bases cannot be built within 100 km of an existing base.", LabelInfo);
                }
            }

            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);
            GUILayout.Box("Operational Facilities", BoxNoBorder);

            bool bAreFacilities = false;

            if (FlightGlobals.ActiveVessel.Landed)
            {
                if (GUILayout.Button("Show/Hide", GUILayout.Height(23)))
                {
                    if (bShowFacilities)
                    {
                        bShowFacilities = false;
                    }
                    else
                    {
                        foreach (StaticObject soStaticobj in KerbalKonstructs.instance.getStaticDB().getAllStatics())
                        {
                            if ((string)soStaticobj.model.getSetting("DefaultFacilityType") == "None")
                            {
                                continue;
                            }

                            if (soStaticobj.pqsCity.sphere == FlightGlobals.currentMainBody.pqsController)
                            {
                                var dist2 = Vector3.Distance(FlightGlobals.ActiveVessel.GetTransform().position, soStaticobj.gameObject.transform.position);
                                if (dist2 > 5000f)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                continue;
                            }

                            PersistenceUtils.loadStaticPersistence(soStaticobj);
                        }

                        bShowFacilities = true;
                    }
                }

                if (bShowFacilities)
                {
                    scrollPos = GUILayout.BeginScrollView(scrollPos);
                    foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics())
                    {
                        bool isLocal = true;
                        if (obj.pqsCity.sphere == FlightGlobals.currentMainBody.pqsController)
                        {
                            var dist = Vector3.Distance(FlightGlobals.ActiveVessel.GetTransform().position, obj.gameObject.transform.position);
                            isLocal = dist < 5000f;
                        }
                        else
                        {
                            isLocal = false;
                        }

                        if ((string)obj.model.getSetting("DefaultFacilityType") == "None")
                        {
                            isLocal = false;
                        }

                        if (isLocal)
                        {
                            bAreFacilities = true;
                            GUILayout.BeginHorizontal();
                            {
                                bIsOpen = ((string)obj.getSetting("OpenCloseState") == "Open");

                                if (!bIsOpen)
                                {
                                    iFundsOpen2 = (float)obj.model.getSetting("cost");
                                    if (iFundsOpen2 == 0)
                                    {
                                        bIsOpen = true;
                                    }
                                }

                                if (GUILayout.Button((string)obj.model.getSetting("title"), GUILayout.Height(23)))
                                {
                                    selectedObject = obj;
                                    KerbalKonstructs.instance.selectObject(obj, false, true, false);
                                    PersistenceUtils.loadStaticPersistence(obj);
                                    FacilityManager.setSelectedFacility(obj);
                                    KerbalKonstructs.instance.showFacilityManager = true;
                                }

                                if (bIsOpen)
                                {
                                    GUILayout.Label(tIconOpen, GUILayout.Height(23), GUILayout.Width(23));
                                }

                                if (!bIsOpen)
                                {
                                    GUILayout.Label(tIconClosed, GUILayout.Height(23), GUILayout.Width(23));
                                }
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                    GUILayout.EndScrollView();
                }
                else
                {
                    GUILayout.Label("Click the button above to display a list of nearby operational facilities.", LabelInfo);

                    if (KerbalKonstructs.instance.DebugMode)
                    {
                        GUILayout.Box("Debug Mode ActiveVessel Report");
                        GUILayout.Label("Name " + FlightGlobals.ActiveVessel.vesselName);
                        GUILayout.Label("Acceleration " + FlightGlobals.ActiveVessel.acceleration.ToString());
                        GUILayout.Label("Angular Momentum " + FlightGlobals.ActiveVessel.angularMomentum.ToString("#0.000"));
                        GUILayout.Label("Angular Velocity " + FlightGlobals.ActiveVessel.angularVelocity.ToString("#0.000"));
                        //GUILayout.Label("Centrifugal Acc " + FlightGlobals.ActiveVessel.CentrifugalAcc.ToString());
                        GUILayout.Label("Horiz Srf Speed " + FlightGlobals.ActiveVessel.horizontalSrfSpeed.ToString("#0.00"));
                        GUILayout.Label("Indicated Air Speed " + FlightGlobals.ActiveVessel.indicatedAirSpeed.ToString("#0.00"));
                        GUILayout.Label("Mach " + FlightGlobals.ActiveVessel.mach.ToString("#0.00"));
                        GUILayout.Label("Orbit Speed " + FlightGlobals.ActiveVessel.obt_speed.ToString("#0.00"));
                        GUILayout.Label("Orbit Velocity " + FlightGlobals.ActiveVessel.obt_velocity.ToString());
                        GUILayout.Label("Perturbation " + FlightGlobals.ActiveVessel.perturbation.ToString());
                        GUILayout.Label("rb_velocity " + FlightGlobals.ActiveVessel.rb_velocity.ToString("#0.000"));
                        GUILayout.Label("Specific Acc " + FlightGlobals.ActiveVessel.specificAcceleration.ToString("#0.00"));
                        GUILayout.Label("speed " + FlightGlobals.ActiveVessel.speed.ToString("#0.00"));
                        GUILayout.Label("srf_velocity " + FlightGlobals.ActiveVessel.srf_velocity.ToString());
                        GUILayout.Label("srfspeed " + FlightGlobals.ActiveVessel.srfSpeed.ToString("#0.00"));
                    }
                }
            }
            else
            {
                GUILayout.Label("Nearby facilities can only be shown when landed.", LabelInfo);
                bShowFacilities = false;
            }

            if (bAreFacilities == false)
            {
                //GUILayout.Label("There are no nearby operational facilities.", LabelInfo);
            }

            GUILayout.FlexibleSpace();
            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);
            GUILayout.Box("Other Features", BoxNoBorder);
            if (GUILayout.Button("Start Air Racing!", GUILayout.Height(23)))
            {
                KerbalKonstructs.instance.showRacingApp = true;
                AirRacing.runningRace                       = true;
                KerbalKonstructs.instance.showNGS           = false;
                KerbalKonstructs.instance.showFlightManager = false;
            }
            if (GUILayout.Button("Basic Orbital Data", GUILayout.Height(23)))
            {
                KerbalKonstructs.instance.showRacingApp = true;
                AirRacing.runningRace                       = false;
                AirRacing.basicorbitalhud                   = true;
                KerbalKonstructs.instance.showNGS           = false;
                KerbalKonstructs.instance.showFlightManager = false;
            }
            GUILayout.Space(5);

            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
示例#5
0
        public static void getClosestSpaceCenter(Vector3 position, out SpaceCenter ClosestCenter, out float ClosestDistance,
                                                 out float RecoveryFactor, out float RecoveryRange, out string BaseName)
        {
            CustomSpaceCenter closest = null;

            float smallestDist = Vector3.Distance(KSC.gameObject.transform.position, position);
            // Debug.Log("KK: Distance to KSC is " + smallestDist);

            bool isCareer = false;

            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                if (!KerbalKonstructs.instance.disableCareerStrategyLayer)
                {
                    isCareer = true;
                    PersistenceFile <LaunchSite> .LoadList(LaunchSiteManager.AllLaunchSites, "LAUNCHSITES", "KK");
                }
            }

            string sOpenCloseState  = "Closed";
            string sBaseName        = "";
            float  fMyBaseRecovFact = 0f;
            float  fMyBaseRecovRang = 0f;

            foreach (CustomSpaceCenter csc in spaceCenters)
            {
                if (isCareer)
                {
                    string OpenCloseState;
                    float  OpenCost;
                    // ASH Get openclosestate of launchsite with same name as space centre
                    LaunchSiteManager.getSiteOpenCloseState(csc.SpaceCenterName, out OpenCloseState, out OpenCost);
                    sOpenCloseState = OpenCloseState;
                }

                StaticObject myBase = csc.getStaticObject();
                if ((float)myBase.getSetting("RecoveryFactor") == 0)
                {
                    continue;
                }

                float dist = Vector3.Distance(position, csc.getStaticObject().gameObject.transform.position);

                if (dist < smallestDist)
                {
                    bool bBaseIsOpen = true;
                    if (sOpenCloseState == "Closed" || sOpenCloseState == "ClosedLocked" || sOpenCloseState == "OpenLocked")
                    {
                        bBaseIsOpen = false;
                    }

                    if (isCareer && !bBaseIsOpen)
                    {
                    }
                    else
                    {
                        closest          = csc;
                        smallestDist     = dist;
                        fMyBaseRecovFact = (float)myBase.getSetting("RecoveryFactor");
                        fMyBaseRecovRang = (float)myBase.getSetting("RecoveryRange");
                        sBaseName        = (string)myBase.getSetting("LaunchSiteName");
                        // Debug.Log("KK: closest updated to " + closest.SpaceCenterName + ", distance " + smallestDist);
                    }
                }
            }

            SpaceCenter sc;

            if (closest == null)
            {
                sc = null;
            }
            else
            {
                // Debug.Log("KK: closest is " + closest.SpaceCenterName);
                sc = closest.getSpaceCenter();
            }

            // Debug.Log("KK: smallestDist is " + smallestDist);
            // Debug.Log("KK: returning closest space centre: " + sc.name);


            if (smallestDist < 1)
            {
                smallestDist = 0;
            }
            if (sc == null)
            {
                sc = KSC;
                fMyBaseRecovFact = 100;
                sBaseName        = "KSC";
            }

            ClosestCenter   = sc;
            ClosestDistance = smallestDist;
            RecoveryFactor  = fMyBaseRecovFact;
            RecoveryRange   = fMyBaseRecovRang;
            BaseName        = sBaseName;
        }
        void UpdateUI()
        {
            landingGuide.SetIsOnWithoutNotify(LandingGuideUI.instance.IsOpen());
            navGuidance.SetIsOnWithoutNotify(NavGuidanceSystem.instance.IsOpen());

            var Range = float.PositiveInfinity;

            //FIXME atmo scaling? other worlds? ...
            if (FlightGlobals.ActiveVessel.altitude > 75000)
            {
                center = null;
                noBasesBeacon.SetActive(true);
                noNearestBase.SetActive(false);
                nearestBaseGroup.SetActive(false);
            }
            else
            {
                center = StaticDatabase.GetClosestLaunchCenter();;
                if (center == null)
                {
                    noBasesBeacon.SetActive(false);
                    noNearestBase.SetActive(true);
                    nearestBaseGroup.SetActive(false);
                }
                else
                {
                    noBasesBeacon.SetActive(false);
                    noNearestBase.SetActive(false);
                    nearestBaseGroup.SetActive(true);

                    Vector3 vPosition = FlightGlobals.ActiveVessel.GetTransform().position;
                    ngsSite = LaunchSiteManager.getNearestBase(center, vPosition);
                    Range   = Vector3.Distance(center.gameObject.transform.position, vPosition);
                    string info;
                    if (Range < 10000)
                    {
                        info = center.Group + " at " + Range.ToString("#0.0") + " m";
                    }
                    else
                    {
                        info = center.Group + " at " + (Range / 1000).ToString("#0.0") + " km";
                    }
                    nearestBase.Info(info);
                    bool ngs = NavGuidanceSystem.instance.IsOpen();
                    ngsFiller.SetActive(!ngs);
                    setNGSTarget.SetActive(ngs);
                }
            }

            if (!MiscUtils.isCareerGame())
            {
                careerGroup.SetActive(false);
            }
            else
            {
                careerGroup.SetActive(true);

                if (!FlightGlobals.ActiveVessel.Landed || Range > 5000)
                {
                    //FIXME a bouncy landing will be laggy
                    if (launchsiteItems.Count > 0)
                    {
                        launchsiteItems.Clear();
                        UIKit.UpdateListContent(launchsiteItems);
                    }
                    basesCanBeOpened.SetActive(true);
                    openSite.SetActive(false);
                    siteIsOpen.SetActive(false);
                    siteCannoteBeOpened.SetActive(false);
                }
                else
                {
                    basesCanBeOpened.SetActive(false);
                    if (launchsiteItems.Count != center.launchsites.Count)
                    {
                        BuildLaunchsites();
                    }
                    UpdateLaunchsite();
                }

                //if (Range > 100000)
                //{
                //    if (bLanded)
                //    {
                //        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                //        GUILayout.Space(2);
                //        GUILayout.Label("This feature is WIP.", LabelInfo);
                //        GUI.enabled = false;
                //        if (GUILayout.Button("Found a New Base", GUILayout.Height(23)))
                //        {
                //            foundingBase = true;
                //        }
                //        GUI.enabled = true;
                //        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                //        GUILayout.Space(2);
                //    }
                //}
                //else
                //{
                //    GUILayout.Label("This feature is WIP.", LabelInfo);
                //}
            }

            UpdateFaclilitiesGroup();
        }
示例#7
0
        public void drawBaseManagerWindow(int windowID)
        {
            if (!layoutIsInitialized)
            {
                InitializeLayout();
                layoutIsInitialized = true;
            }

            string sButtonName = "";

            sButtonName = selectedSite.LaunchSiteName;
            if (selectedSite.LaunchSiteName == "Runway")
            {
                sButtonName = "KSC Runway";
            }
            if (selectedSite.LaunchSiteName == "LaunchPad")
            {
                sButtonName = "KSC LaunchPad";
            }

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Base Manager", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (HighLogic.LoadedScene != GameScenes.EDITOR)
                {
                    if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21)))
                    {
                        InputLockManager.RemoveControlLock("KKEditorLock");
                        selectedSite = null;
                        this.Close();
                        return;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            if (selectedSite.LaunchSiteName == "Runway")
            {
                GUILayout.Box("KSC Runway", Yellowtext);
            }
            else
            if (selectedSite.LaunchSiteName == "LaunchPad")
            {
                GUILayout.Box("KSC LaunchPad", Yellowtext);
            }
            else
            {
                GUILayout.Box("" + selectedSite.LaunchSiteName, Yellowtext);
            }

            if (!foldedIn)
            {
                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(2);
                    GUILayout.Box(tVerticalSep, BoxNoBorder, GUILayout.Width(4), GUILayout.Height(135));
                    GUILayout.FlexibleSpace();
                    GUILayout.Box(selectedSite.logo, BoxNoBorder, GUILayout.Height(135), GUILayout.Width(135));
                    GUILayout.FlexibleSpace();
                    GUILayout.Box(tVerticalSep, BoxNoBorder, GUILayout.Width(4), GUILayout.Height(135));
                    GUILayout.Space(2);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(3);

                descriptionScrollPosition = GUILayout.BeginScrollView(descriptionScrollPosition, GUILayout.Height(120));
                {
                    GUI.enabled = false;
                    GUILayout.Label(selectedSite.LaunchSiteDescription, LabelWhite);
                    GUI.enabled = true;
                }
                GUILayout.EndScrollView();
            }

            GUILayout.Space(1);

            isFavourite = (selectedSite.favouriteSite == "Yes");

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = (!displayStats);
                if (GUILayout.Button("Stats", GUILayout.Height(23)))
                {
                    displayLog   = false;
                    displayStats = true;
                }
                GUI.enabled = true;

                GUI.enabled = (!displayLog);
                if (GUILayout.Button("Log", GUILayout.Height(23)))
                {
                    displayLog   = true;
                    displayStats = false;
                }
                GUI.enabled = true;

                if (isFavourite)
                {
                    tFaveTemp = tIsFave;
                }
                else
                {
                    tFaveTemp = tMakeFavourite;
                }

                if (GUILayout.Button(tFaveTemp, GUILayout.Height(23), GUILayout.Width(23)))
                {
                    if (isFavourite)
                    {
                        selectedSite.favouriteSite = "No";
                    }
                    else
                    {
                        selectedSite.favouriteSite = "Yes";
                    }
                }

                if (foldedIn)
                {
                    tFolded = tFoldOut;
                }
                if (!foldedIn)
                {
                    tFolded = tFoldIn;
                }

                if (GUILayout.Button(tFolded, GUILayout.Height(23), GUILayout.Width(23)))
                {
                    if (foldedIn)
                    {
                        foldedIn = false;
                    }
                    else
                    {
                        foldedIn = true;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);

            if (displayStats)
            {
                GUILayout.Label("Altitude: " + selectedSite.refAlt.ToString("#0.0") + " m", LabelInfo);
                GUILayout.Label("Longitude: " + selectedSite.refLon.ToString("#0.000"), LabelInfo);
                GUILayout.Label("Latitude: " + selectedSite.refLat.ToString("#0.000"), LabelInfo);
                GUILayout.Space(3);
                GUILayout.Label("Length: " + selectedSite.LaunchSiteLength.ToString("#0" + " m"), LabelInfo);
                GUILayout.Label("Width: " + selectedSite.LaunchSiteWidth.ToString("#0" + " m"), LabelInfo);

                GUILayout.FlexibleSpace();
            }

            if (MiscUtils.isCareerGame())
            {
                if (displayLog)
                {
                    logScrollPosition = GUILayout.BeginScrollView(logScrollPosition, GUILayout.Height(120));
                    {
                        Char     csep        = '|';
                        string[] sLogEntries = selectedSite.MissionLog.Split(csep);
                        foreach (string sEntry in sLogEntries)
                        {
                            GUILayout.Label(sEntry, LabelInfo);
                        }
                    }
                    GUILayout.EndScrollView();

                    GUILayout.FlexibleSpace();
                }

                GUI.enabled = !selectedSite.isOpen;
                if (selectedSite.OpenCost > 0)
                {
                    if (!KerbalKonstructs.instance.disableRemoteBaseOpening)
                    {
                        if (GUILayout.Button("Open Base for \n" + selectedSite.OpenCost + " funds", GUILayout.Height(38)))
                        {
                            double currentfunds = Funding.Instance.Funds;

                            if (selectedSite.OpenCost > currentfunds)
                            {
                                MiscUtils.HUDMessage("Insufficient funds to open this base!", 10,
                                                     3);
                            }
                            else
                            {
                                selectedSite.SetOpen();
                                LaunchSiteManager.OpenLaunchSite(selectedSite);
                                Funding.Instance.AddFunds(-selectedSite.OpenCost, TransactionReasons.Cheating);
                            }
                        }
                    }
                }
                GUI.enabled = true;

                GUI.enabled = selectedSite.isOpen;
                if (selectedSite.CloseValue > 0)
                {
                    if (GUILayout.Button("Close Base for \n" + selectedSite.CloseValue + " funds", GUILayout.Height(38)))
                    {
                        Funding.Instance.AddFunds(selectedSite.CloseValue, TransactionReasons.Cheating);
                        LaunchSiteManager.CloseLaunchSite(selectedSite);
                        selectedSite.SetClosed();
                    }
                }
                GUI.enabled = true;

                GUILayout.FlexibleSpace();

                if (HighLogic.LoadedScene == GameScenes.EDITOR)
                {
                    GUILayout.BeginHorizontal();
                    {
                        if (selectedSite.LaunchSiteName == EditorLogic.fetch.launchSiteName)
                        {
                            tStatusLaunchsite = tSetLaunchsite;
                        }
                        else
                        if (selectedSite.isOpen)
                        {
                            tStatusLaunchsite = tOpenedLaunchsite;
                        }
                        else
                        {
                            tStatusLaunchsite = tClosedLaunchsite;
                        }

                        GUILayout.Label(tStatusLaunchsite, GUILayout.Height(32), GUILayout.Width(32));

                        GUI.enabled = (selectedSite.isOpen) && !(selectedSite.LaunchSiteName == EditorLogic.fetch.launchSiteName);
                        if (GUILayout.Button("Set as \nLaunchsite", GUILayout.Height(38)))
                        {
                            LaunchSiteManager.setLaunchSite(selectedSite);
                            string smessage = sButtonName + " has been set as the launchsite";
                            MiscUtils.HUDMessage(smessage, 10, 0);
                        }
                        GUI.enabled = true;
                    }
                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.Space(3);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(1);

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
示例#8
0
        void prepNGS()
        {
            if (lTargetSite != null)
            {
                sTargetSiteName = lTargetSite.LaunchSiteName;

                fRangeToTarget = LaunchSiteManager.getDistanceToBase(FlightGlobals.ActiveVessel.GetTransform().position, lTargetSite);
                if (fRangeToTarget > fOldRange)
                {
                    bClosing = false;
                }
                if (fRangeToTarget < fOldRange)
                {
                    bClosing = true;
                }

                var basepos = KerbalKonstructs.instance.GetCurrentBody().transform.InverseTransformPoint(lTargetSite.staticInstance.gameObject.transform.position);

                //disBaseLat = dBaseLat * 180 / Math.PI;
                //disBaseLon = dBaseLon * 180 / Math.PI;
                disBaseLat = KKMath.GetLatitudeInDeg(basepos);
                disBaseLon = KKMath.GetLongitudeInDeg(basepos);
                var dBaseLat = disBaseLat * KKMath.deg2rad;
                var dBaseLon = disBaseLon * KKMath.deg2rad;

                fOldRange = fRangeToTarget;

                if (bClosing)
                {
                    tTextureMiddle = UIMain.tIconOpen;
                }
                else
                {
                    tTextureMiddle = UIMain.tIconClosed;
                }

                Vector3 vcraftpos = FlightGlobals.ActiveVessel.GetTransform().position;
                vCrft = vcraftpos;
                Vector3 vsitepos = lTargetSite.staticInstance.transform.position;
                vSPos = vsitepos;
                Vector3 vHeading = FlightGlobals.ActiveVessel.transform.up;
                vHead = vHeading;

                disLat = FlightGlobals.ActiveVessel.latitude;
                var dLat = disLat / 180 * Math.PI;
                disLon = FlightGlobals.ActiveVessel.longitude;
                var dLon = disLon / 180 * Math.PI;

                var y = Math.Sin(dBaseLon - dLon) * Math.Cos(dBaseLat);
                var x = (Math.Cos(dLat) * Math.Sin(dBaseLat)) - (Math.Sin(dLat) * Math.Cos(dBaseLat) * Math.Cos(dBaseLon - dLon));
                var requiredHeading = Math.Atan2(y, x) * 180 / Math.PI;
                dreqheading = (requiredHeading + 360) % 360;

                var diff = (360 + 180 + requiredHeading - FlightGlobals.ship_heading) % 360 - 180;
                dshipheading = (FlightGlobals.ship_heading + 360) % 360;

                if (diff > 5)
                {
                    iCorrection = 2;
                }
                else if (diff < -5)
                {
                    iCorrection = 1;
                }
                else
                {
                    iCorrection = 0;
                }

                if (bClosing)
                {
                    tTextureLeft  = UIMain.tLeftOff;
                    tTextureRight = UIMain.tRightOff;
                }
                else
                {
                    tTextureLeft  = UIMain.tLeftOn;
                    tTextureRight = UIMain.tRightOn;
                }

                if (iCorrection == 1)
                {
                    tTextureLeft  = UIMain.tLeftOn;
                    tTextureRight = UIMain.tRightOff;
                }
                if (iCorrection == 2)
                {
                    tTextureLeft  = UIMain.tLeftOff;
                    tTextureRight = UIMain.tRightOn;
                }
            }
            else
            {
                tTextureMiddle = UIMain.tIconClosed;
                tTextureLeft   = UIMain.tLeftOff;
                tTextureRight  = UIMain.tRightOff;
            }
        }
示例#9
0
        public void drawSelectorWindow(int id)
        {
            ButtonKK = new GUIStyle(GUI.skin.button);
            ButtonKK.padding.left  = 0;
            ButtonKK.padding.right = 0;

            DeadButton = new GUIStyle(GUI.skin.button);
            DeadButton.normal.background  = null;
            DeadButton.hover.background   = null;
            DeadButton.active.background  = null;
            DeadButton.focused.background = null;
            DeadButton.normal.textColor   = Color.white;
            DeadButton.hover.textColor    = Color.white;
            DeadButton.active.textColor   = Color.white;
            DeadButton.focused.textColor  = Color.white;
            DeadButton.fontSize           = 14;
            DeadButton.fontStyle          = FontStyle.Bold;

            DeadButtonRed = new GUIStyle(GUI.skin.button);
            DeadButtonRed.normal.background  = null;
            DeadButtonRed.hover.background   = null;
            DeadButtonRed.active.background  = null;
            DeadButtonRed.focused.background = null;
            DeadButtonRed.normal.textColor   = Color.red;
            DeadButtonRed.hover.textColor    = Color.yellow;
            DeadButtonRed.active.textColor   = Color.red;
            DeadButtonRed.focused.textColor  = Color.red;
            DeadButtonRed.fontSize           = 12;
            DeadButtonRed.fontStyle          = FontStyle.Bold;

            BoxNoBorder = new GUIStyle(GUI.skin.box);
            BoxNoBorder.normal.background = null;
            BoxNoBorder.normal.textColor  = Color.white;

            KKToolTip = new GUIStyle(GUI.skin.box);
            KKToolTip.normal.textColor = Color.white;
            KKToolTip.fontSize         = 11;
            KKToolTip.fontStyle        = FontStyle.Normal;

            string smessage = "";

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Launchsite Selector", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21)))
                {
                    InputLockManager.RemoveControlLock("KKEditorLock");
                    InputLockManager.RemoveControlLock("KKEditorLock2");
                    this.Close();
                    return;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(UIMain.tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(5);

                if (MiscUtils.isCareerGame())
                {
                    if (bOpenOn)
                    {
                        tHolder = UIMain.tOpenBasesOn;
                    }
                    else
                    {
                        tHolder = UIMain.tOpenBasesOff;
                    }

                    if (GUILayout.Button(new GUIContent(tHolder, "Open"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        if (bOpenOn)
                        {
                            bOpenOn   = false;
                            bClosedOn = true;
                        }
                        else
                        {
                            bOpenOn = true;
                        }
                    }

                    if (bClosedOn)
                    {
                        tHolder = UIMain.tClosedBasesOn;
                    }
                    else
                    {
                        tHolder = UIMain.tClosedBasesOff;
                    }

                    if (GUILayout.Button(new GUIContent(tHolder, "Closed"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        if (bClosedOn)
                        {
                            bClosedOn = false;
                            bOpenOn   = true;
                        }
                        else
                        {
                            bClosedOn = true;
                        }
                    }

                    GUILayout.FlexibleSpace();
                }

                if (bFavesOnly)
                {
                    tHolder = tFavesOn;
                }
                else
                {
                    tHolder = tFavesOff;
                }

                if (GUILayout.Button(new GUIContent(tHolder, "Only Favourites"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    if (bFavesOnly)
                    {
                        bFavesOnly = false;
                    }
                    else
                    {
                        bFavesOnly = true;
                    }
                }

                GUILayout.FlexibleSpace();

                if (editorType == SiteType.SPH)
                {
                    GUI.enabled = false;
                }

                if (bRocketpadsOn)
                {
                    tHolder = UIMain.tLaunchpadsOn;
                }
                else
                {
                    tHolder = UIMain.tLaunchpadsOff;
                }

                if (GUILayout.Button(new GUIContent(tHolder, "Rocketpads"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    bRocketpadsOn = true;
                    bHelipadsOn   = false;
                    bRunwaysOn    = false;
                    bOtherOn      = false;
                    waterLaunchOn = false;

                    sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() :
                            LaunchSiteManager.getLaunchSites(editorType, true, "RocketPad");
                }

                GUI.enabled = true;
                GUILayout.Space(2);

                if (editorType == SiteType.VAB)
                {
                    GUI.enabled = false;
                }

                if (bRunwaysOn)
                {
                    tHolder = UIMain.tRunwaysOn;
                }
                else
                {
                    tHolder = UIMain.tRunwaysOff;
                }

                if (GUILayout.Button(new GUIContent(tHolder, "Runways"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    bRunwaysOn    = true;
                    bHelipadsOn   = false;
                    bRocketpadsOn = false;
                    bOtherOn      = false;
                    waterLaunchOn = false;

                    sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() :
                            LaunchSiteManager.getLaunchSites(editorType, true, "Runway");
                }

                GUI.enabled = true;
                GUILayout.Space(2);

                if (editorType == SiteType.VAB)
                {
                    GUI.enabled = false;
                }

                if (bHelipadsOn)
                {
                    tHolder = UIMain.tHelipadsOn;
                }
                else
                {
                    tHolder = UIMain.tHelipadsOff;
                }

                if (GUILayout.Button(new GUIContent(tHolder, "Helipads"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    bRocketpadsOn = false;
                    bHelipadsOn   = true;
                    bRunwaysOn    = false;
                    bOtherOn      = false;
                    waterLaunchOn = false;

                    sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() :
                            LaunchSiteManager.getLaunchSites(editorType, true, "Helipad");
                }

                GUI.enabled = true;
                GUILayout.Space(2);

                if (editorType == SiteType.VAB)
                {
                    GUI.enabled = false;
                }

                if (waterLaunchOn)
                {
                    tHolder = UIMain.tWaterOn;
                }
                else
                {
                    tHolder = UIMain.tWaterOff;
                }

                if (GUILayout.Button(new GUIContent(tHolder, "WalterLaunch"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    bRocketpadsOn = false;
                    bHelipadsOn   = false;
                    bRunwaysOn    = false;
                    bOtherOn      = false;
                    waterLaunchOn = true;

                    sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() :
                            LaunchSiteManager.getLaunchSites(editorType, true, "Waterlaunch");
                }

                GUI.enabled = true;
                GUILayout.Space(2);

                if (bOtherOn)
                {
                    tHolder = UIMain.tOtherOn;
                }
                else
                {
                    tHolder = UIMain.tOtherOff;
                }

                if (GUILayout.Button(new GUIContent(tHolder, "Other"), ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    bRocketpadsOn = false;
                    bHelipadsOn   = false;
                    bRunwaysOn    = false;
                    bOtherOn      = true;
                    waterLaunchOn = false;

                    sites = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() :
                            LaunchSiteManager.getLaunchSites(editorType, true, "Other");
                }

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("ALL", GUILayout.Width(32), GUILayout.Height(32)))
                {
                    bRocketpadsOn = true;
                    bHelipadsOn   = true;
                    bRunwaysOn    = true;
                    bOtherOn      = true;
                    waterLaunchOn = true;
                    sites         = (editorType == SiteType.Any) ? LaunchSiteManager.getLaunchSites() :
                                    LaunchSiteManager.getLaunchSites(editorType, true, "ALL");
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            sitesScrollPosition = GUILayout.BeginScrollView(sitesScrollPosition);
            {
                if (sites == null)
                {
                    sites = (editorType == SiteType.Any) ?
                            LaunchSiteManager.getLaunchSites() : LaunchSiteManager.getLaunchSites(editorType, true, "ALL");
                }

                sites.Sort(delegate(LaunchSite a, LaunchSite b)
                {
                    return((a.LaunchSiteName).CompareTo(b.LaunchSiteName));
                });

                foreach (LaunchSite site in sites)
                {
                    if (bFavesOnly)
                    {
                        if (site.favouriteSite != "Yes")
                        {
                            continue;
                        }
                    }

                    if (MiscUtils.isCareerGame())
                    {
                        if (!bOpenOn)
                        {
                            if (site.isOpen)
                            {
                                continue;
                            }
                        }

                        if (!bClosedOn)
                        {
                            if (!site.isOpen)
                            {
                                continue;
                            }
                        }

                        // Don't show hidden closed Bases
                        if (site.LaunchSiteIsHidden && (!site.isOpen))
                        {
                            continue;
                        }

                        GUILayout.BeginHorizontal();
                        if (site.isOpen)
                        {
                            GUILayout.Label(UIMain.tIconOpen, GUILayout.Height(30), GUILayout.Width(30));
                        }
                        else
                        {
                            GUILayout.Label(UIMain.tIconClosed, GUILayout.Height(30), GUILayout.Width(30));
                        }
                    }

                    GUI.enabled = !(selectedSite == site);

                    string sButtonName = "";
                    sButtonName = site.LaunchSiteName;
                    if (site.LaunchSiteName == "Runway")
                    {
                        sButtonName = "KSC Runway";
                    }
                    if (site.LaunchSiteName == "LaunchPad")
                    {
                        sButtonName = "KSC LaunchPad";
                    }

                    if (GUILayout.Button(sButtonName, GUILayout.Height(30)))
                    {
                        selectedSite = site;

                        if (!MiscUtils.isCareerGame())
                        {
                            LaunchSiteManager.setLaunchSite(site);
                            smessage = "Launchsite set to " + sButtonName;
                            MiscUtils.HUDMessage(smessage, 10, 2);
                        }
                    }
                    GUI.enabled = true;

                    if (MiscUtils.isCareerGame())
                    {
                        if (site.isOpen)
                        {
                            GUILayout.Label(UIMain.tIconOpen, GUILayout.Height(30), GUILayout.Width(30));
                        }
                        else
                        {
                            GUILayout.Label(UIMain.tIconClosed, GUILayout.Height(30), GUILayout.Width(30));
                        }

                        GUILayout.EndHorizontal();
                    }
                }
            }
            GUILayout.EndScrollView();

            GUILayout.Space(5);

            sCurrentSite = LaunchSiteManager.getCurrentLaunchSite();

            if (sCurrentSite != null)
            {
                if (sCurrentSite == "Runway")
                {
                    GUILayout.Box("Current Launchsite: KSC Runway");
                }
                else
                if (sCurrentSite == "LaunchPad")
                {
                    GUILayout.Box("Current Launchsite: KSC LaunchPad");
                }
                else
                {
                    GUILayout.Box("Current Launchsite: " + sCurrentSite);
                }
            }

            GUI.enabled = (selectedSite != null && !(selectedSite.LaunchSiteName == sCurrentSite) && LaunchSiteManager.getIsSiteOpen(selectedSite.LaunchSiteName));
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Set as Launchsite", GUILayout.Height(46)))
            {
                LaunchSiteManager.setLaunchSite(selectedSite);
                MiscUtils.HUDMessage(selectedSite.LaunchSiteName + " has been set as the launchsite", 10, 0);
            }

            GUILayout.EndHorizontal();
            GUI.enabled = true;

            GUILayout.BeginHorizontal();
            {
                if (editorType == SiteType.SPH)
                {
                    GUI.enabled = (KerbalKonstructs.instance.defaultSPHlaunchsite != sCurrentSite);
                }

                if (editorType == SiteType.VAB)
                {
                    GUI.enabled = (KerbalKonstructs.instance.defaultVABlaunchsite != sCurrentSite);
                }

                if (GUILayout.Button("Set as Default", GUILayout.Height(23)))
                {
                    if (sCurrentSite != null)
                    {
                        if (editorType == SiteType.SPH)
                        {
                            KerbalKonstructs.instance.defaultSPHlaunchsite = sCurrentSite;
                        }

                        if (editorType == SiteType.VAB)
                        {
                            KerbalKonstructs.instance.defaultVABlaunchsite = sCurrentSite;
                        }
                    }
                }
                GUI.enabled = true;

                LaunchSite DefaultSite = null;

                if (GUILayout.Button("Use Default", GUILayout.Height(23)))
                {
                    if (editorType == SiteType.SPH)
                    {
                        foreach (LaunchSite site in sites)
                        {
                            if (site.LaunchSiteName == KerbalKonstructs.instance.defaultSPHlaunchsite)
                            {
                                DefaultSite = site;
                            }
                        }

                        if (DefaultSite != null)
                        {
                            if (MiscUtils.isCareerGame())
                            {
                                if (!DefaultSite.isOpen)
                                {
                                    smessage = "Default site is closed.";
                                    MiscUtils.HUDMessage(smessage, 10, 0);
                                }
                                else
                                {
                                    LaunchSiteManager.setLaunchSite(DefaultSite);
                                }
                            }
                            else
                            {
                                LaunchSiteManager.setLaunchSite(DefaultSite);
                            }
                        }
                    }

                    if (editorType == SiteType.VAB)
                    {
                        foreach (LaunchSite site in sites)
                        {
                            if (site.LaunchSiteName == KerbalKonstructs.instance.defaultVABlaunchsite)
                            {
                                DefaultSite = site;
                            }
                        }

                        if (DefaultSite != null)
                        {
                            if (MiscUtils.isCareerGame())
                            {
                                if (!DefaultSite.isOpen)
                                {
                                    smessage = "Default site is closed.";
                                    MiscUtils.HUDMessage(smessage, 10, 0);
                                }
                                else
                                {
                                    LaunchSiteManager.setLaunchSite(DefaultSite);
                                }
                            }
                            else
                            {
                                LaunchSiteManager.setLaunchSite(DefaultSite);
                            }
                        }
                    }

                    if (DefaultSite != null)
                    {
                        smessage = DefaultSite.LaunchSiteName + " has been set as the launchsite";
                        MiscUtils.HUDMessage(smessage, 10, 0);
                    }
                    else
                    {
                        smessage = "KK could not determine the default launchsite.";
                        MiscUtils.HUDMessage(smessage, 10, 0);
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.Box(UIMain.tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            GUI.enabled = true;

            if (selectedSite != null)
            {
                BaseManager.setSelectedSite(selectedSite);
                BaseManager.instance.Open();
            }
            else
            {
                if (LaunchSiteManager.getLaunchSites().Count > 0)
                {
                    selectedSite = LaunchSiteManager.getLaunchSites(editorType)[0];
                    LaunchSiteManager.setLaunchSite(selectedSite);
                    BaseManager.setSelectedSite(selectedSite);
                    BaseManager.instance.Open();
                }
                else
                {
                    Log.UserError("ERROR Launch Selector cannot find KSC Runway or Launch Pad! PANIC! Runaway! Hide!");
                }
            }

            if (GUI.tooltip != "")
            {
                var labelSize = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(GUI.tooltip));
                GUI.Box(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y + 20, labelSize.x + 5, labelSize.y + 6), GUI.tooltip, KKToolTip);
            }

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
示例#10
0
        internal void SaveSettings()
        {
            bool addToDB = false;

            if (!selectedObject.hasLauchSites)
            {
                Log.Normal("Creating LaunchSite");
                KKLaunchSite lsite = new KKLaunchSite();
                selectedObject.launchSite = lsite;
                Log.Normal("created; lsite = " + lsite + "; launch site = " + selectedObject.launchSite);
                selectedObject.hasLauchSites   = true;
                lsite.staticInstance           = selectedObject;
                selectedObject.launchSite.body = selectedObject.CelestialBody;
                addToDB = true;
            }

            string             oldName     = selectedObject.launchSite.LaunchSiteName;
            LaunchSiteCategory oldCategory = category;
            bool oldState = selectedObject.launchSite.ILSIsActive;

            selectedObject.launchSite.LaunchSiteName        = siteName;
            selectedObject.launchSite.LaunchSiteLength      = float.Parse(stLength);
            selectedObject.launchSite.LaunchSiteWidth       = float.Parse(stWidth);
            selectedObject.launchSite.LaunchSiteType        = siteType;
            selectedObject.launchSite.LaunchPadTransform    = siteTrans;
            selectedObject.launchSite.LaunchSiteDescription = siteDesc;
            selectedObject.launchSite.OpenCost              = float.Parse(stOpenCost);
            selectedObject.launchSite.CloseValue            = float.Parse(stCloseValue);
            selectedObject.launchSite.LaunchSiteIsHidden    = bool.Parse(siteHidden);
            selectedObject.launchSite.ILSIsActive           = bool.Parse(ILSActive);
            selectedObject.launchSite.LaunchSiteAuthor      = siteAuthor;
            selectedObject.launchSite.refLat                = (float)selectedObject.RefLatitude;
            selectedObject.launchSite.refLon                = (float)selectedObject.RefLongitude;
            selectedObject.launchSite.refAlt                = selectedObject.RadiusOffset;
            selectedObject.launchSite.sitecategory          = category;
            selectedObject.launchSite.InitialCameraRotation = float.Parse(initialCameraRotation);

            if (ILSConfig.DetectNavUtils())
            {
                Log.Normal("NavUtils detected");
                Log.Debug("object: " + selectedObject);
                Log.Debug("launchsite: " + selectedObject.launchSite);
                Log.Debug("body: " + selectedObject.launchSite.body);

                bool regenerateILSConfig = false;
                Log.Debug("old name: " + oldName);
                Log.Debug("new name: " + selectedObject.launchSite.LaunchSiteName);
                if (oldName != null && !oldName.Equals(siteName))
                {
                    ILSConfig.RenameSite(selectedObject.launchSite.LaunchSiteName, siteName);
                    regenerateILSConfig = true;
                }

                Log.Debug("old category: " + oldCategory);
                if ((oldCategory != category))
                {
                    ILSConfig.HandleCategoryChange(selectedObject);
                    regenerateILSConfig = true;
                }

                bool state = bool.Parse(ILSActive);
                Log.Normal("new state: " + state + "; old state: " + oldState);
                if (oldState != state || regenerateILSConfig)
                {
                    if (state)
                    {
                        ILSConfig.GenerateFullILSConfig(selectedObject);
                    }
                    else
                    {
                        ILSConfig.DropILSConfig(selectedObject.launchSite.LaunchSiteName, true);
                    }
                }
            }


            if (addToDB)
            {
                selectedObject.launchSite.ParseLSConfig(selectedObject, null);
                selectedObject.SaveConfig();
                EditorGUI.instance.enableColliders = true;
                selectedObject.ToggleAllColliders(true);
                LaunchSiteManager.RegisterLaunchSite(selectedObject.launchSite);
            }
            selectedObject.SaveConfig();
        }
 void UseDefault()
 {
     selectedSite = LaunchSiteManager.GetDefaultSite();
     SetLaunchsite();
 }
示例#12
0
 /// <summary>
 /// Caches the launchsites for later use
 /// </summary>
 private void CacheLaunchSites()
 {
     lauchSites = LaunchSiteManager.getLaunchSites().ToArray();
 }
示例#13
0
        public void drawLaunchsites(MapObject target)
        {
            displayingTooltip = false;
            int iPulseRate = 180;

            iRadarCounter = iRadarCounter + 1;
            if (iRadarCounter > iPulseRate)
            {
                iRadarCounter = 0;
            }

            // Then do launchsites
            List <LaunchSite> sites = LaunchSiteManager.getLaunchSites();

            for (int index = 0; index < sites.Count; index++)
            {
                LaunchSite site = sites[index];

                PSystemSetup.SpaceCenterFacility facility = PSystemSetup.Instance.GetSpaceCenterFacility(site.name);

                if (facility == null)
                {
                    continue;
                }

                PSystemSetup.SpaceCenterFacility.SpawnPoint sp = facility.GetSpawnPoint(site.name);

                if (sp == null)
                {
                    continue;
                }

                if (facility.facilityPQS != target.celestialBody.pqsController)
                {
                    continue;
                }

                Transform spawnPointTransform = sp.GetSpawnPointTransform();
                if (spawnPointTransform == null)
                {
                    continue;
                }

                if (isOccluded(spawnPointTransform.position, target.celestialBody))
                {
                    if (KerbalKonstructs.instance.mapHideIconsBehindBody)
                    {
                        continue;
                    }
                }

                Vector3 pos        = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(spawnPointTransform.position));
                Rect    screenRect = new Rect((pos.x - 8), (Screen.height - pos.y) - 8, 16, 16);

                // Distance between camera and spawnpoint sort of
                float fPosZ = pos.z;

                float fRadarRadius = 12800 / fPosZ;
                float fRadarOffset = fRadarRadius / 2;

                string openclosed = site.openclosestate;
                string category   = site.category;

                bool display = true;

                if (!KerbalKonstructs.instance.mapShowHelipads && category == "Helipad")
                {
                    display = false;
                }
                if (!KerbalKonstructs.instance.mapShowOther && category == "Other")
                {
                    display = false;
                }
                if (!KerbalKonstructs.instance.mapShowRocketbases && category == "RocketPad")
                {
                    display = false;
                }
                if (!KerbalKonstructs.instance.mapShowRunways && category == "Runway")
                {
                    display = false;
                }

                if (display && MiscUtils.isCareerGame())
                {
                    if (!KerbalKonstructs.instance.mapShowOpen && openclosed == "Open")
                    {
                        display = false;
                    }
                    if (!KerbalKonstructs.instance.mapShowClosed && openclosed == "Closed")
                    {
                        display = false;
                    }
                    if (KerbalKonstructs.instance.disableDisplayClosed && openclosed == "Closed")
                    {
                        display = false;
                    }
                    if (openclosed == "OpenLocked" || openclosed == "ClosedLocked")
                    {
                        display = false;
                    }
                }

                if (!display)
                {
                    continue;
                }

                if (KerbalKonstructs.instance.mapShowRadar)
                {
                    drawRadar(pos, category, openclosed);
                }

                if (openclosed == "Open" && KerbalKonstructs.instance.mapShowGroundComms)
                {
                    drawGroundComms(null, site);
                }

                if (site.icon != null)
                {
                    if (fRadarRadius > 15)
                    {
                        Graphics.DrawTexture(screenRect, site.icon);
                    }
                }
                else
                {
                    if (fRadarRadius > 15)
                    {
                        switch (site.type)
                        {
                        case SiteType.VAB:
                            Graphics.DrawTexture(screenRect, UIMain.VABIcon);
                            break;

                        case SiteType.SPH:
                            Graphics.DrawTexture(screenRect, UIMain.SPHIcon);
                            break;

                        default:
                            Graphics.DrawTexture(screenRect, UIMain.ANYIcon);
                            break;
                        }
                    }
                }

                // Tooltip
                if (screenRect.Contains(Event.current.mousePosition) && !displayingTooltip)
                {
                    //Only display one tooltip at a time
                    string sToolTip = "";
                    sToolTip = site.name;
                    if (site.name == "Runway")
                    {
                        sToolTip = "KSC Runway";
                    }
                    if (site.name == "LaunchPad")
                    {
                        sToolTip = "KSC LaunchPad";
                    }
                    displayMapIconToolTip(sToolTip, pos);

                    // Select a base by clicking on the icon
                    if (Event.current.type == EventType.mouseDown && Event.current.button == 0)
                    {
                        MiscUtils.HUDMessage("Selected base is " + sToolTip + ".", 5f, 3);
                        BaseManager.setSelectedSite(site);
                        selectedSite = site;
                        NavGuidanceSystem.setTargetSite(selectedSite);
                        KerbalKonstructs.instance.showBaseManager = true;
                    }
                }
            }
        }
示例#14
0
        void drawBaseManagerWindow(int windowID)
        {
            if (!isInitialized)
            {
                InitializeLayout();
            }


            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", DeadButton, GUILayout.Height(16));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Inflight Base Boss", DeadButton, GUILayout.Height(16));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(16)))
                {
                    bShowFacilities = false;
                    this.Close();
                    return;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(5);
            GUILayout.Box("Flight Tools", BoxNoBorder);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(2);
                GUILayout.Label("Landing Guide ", LabelInfo);
                if (GUILayout.Button(LandingGuideUI.instance.IsOpen()? tIconOpen : tIconClosed, GUILayout.Height(18), GUILayout.Width(56)))
                {
                    KerbalKonstructs.instance.updateCache();
                    LandingGuideUI.instance.Toggle();
                }

                GUILayout.FlexibleSpace();
                GUILayout.Label("NGS ", LabelInfo);

                if (NavGuidanceSystem.instance.IsOpen())
                {
                    tToggle2 = tIconOpen;
                }
                else
                {
                    tToggle2 = tIconClosed;
                }
                if (GUILayout.Button(tToggle2, GUILayout.Height(18), GUILayout.Width(18)))
                {
                    NavGuidanceSystem.instance.Toggle();
                }


                GUILayout.Space(2);
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);

            GUILayout.Box("Active Beacons", BoxNoBorder);

            if (MiscUtils.isCareerGame())
            {
                GUILayout.BeginHorizontal();
                {
                    string snearestopen = "";
                    LaunchSiteManager.GetNearestOpenBase(FlightGlobals.ActiveVessel.GetTransform().position, out Base, out Range, out lNearest);
                    if (FlightGlobals.ActiveVessel.altitude > 75000)
                    {
                        GUILayout.Label("No base's beacon in range at this altitude.", LabelInfo);
                    }
                    else
                    if (Base == "")
                    {
                        GUILayout.Label("No open base found.", LabelInfo);
                    }
                    else
                    {
                        if (Range < 10000)
                        {
                            snearestopen = Base + " at " + Range.ToString("#0.0") + " m";
                        }
                        else
                        {
                            snearestopen = Base + " at " + (Range / 1000).ToString("#0.0") + " km";
                        }

                        GUILayout.Space(5);
                        GUILayout.Label("Nearest Open: ", LabelInfo);
                        GUILayout.Label(snearestopen, LabelInfo, GUILayout.Width(150));

                        if (NavGuidanceSystem.instance.IsOpen())
                        {
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("NGS", GUILayout.Height(21)))
                            {
                                NavGuidanceSystem.setTargetSite(lNearest);
                                smessage = "NGS set to " + Base;
                                MiscUtils.HUDMessage(smessage, 10, 2);
                            }
                        }
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(2);
            }

            GUILayout.BeginHorizontal();
            {
                string sNearestbase = "";
                LaunchSiteManager.getNearestBase(FlightGlobals.ActiveVessel.GetTransform().position, out Base, out Base2, out Range, out lBase, out lBase2);

                if (FlightGlobals.ActiveVessel.altitude > 75000)
                {
                    GUILayout.Label("No base's beacon in range at this altitude.", LabelInfo);
                }
                else
                if (Base == "")
                {
                    GUILayout.Label("No nearest base found.", LabelInfo);
                }
                else
                {
                    if (Range < 10000)
                    {
                        sNearestbase = Base + " at " + Range.ToString("#0.0") + " m";
                    }
                    else
                    {
                        sNearestbase = Base + " at " + (Range / 1000).ToString("#0.0") + " km";
                    }

                    GUILayout.Space(5);
                    GUILayout.Label("Nearest Base: ", LabelInfo);
                    GUILayout.Label(sNearestbase, LabelInfo, GUILayout.Width(150));

                    if (NavGuidanceSystem.instance.IsOpen())
                    {
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("NGS", GUILayout.Height(21)))
                        {
                            NavGuidanceSystem.setTargetSite(lBase);

                            smessage = "NGS set to " + Base;
                            MiscUtils.HUDMessage(smessage, 10, 2);
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);
            GUILayout.Box("Base Status", BoxNoBorder);

            if (MiscUtils.isCareerGame())
            {
                bool bLanded = (FlightGlobals.ActiveVessel.Landed);

                if (Range < 2000)
                {
                    LaunchSiteManager.getSiteOpenCloseState(Base, out sClosed, out fOpenCost);
                    fOpenCost = fOpenCost / 2f;

                    if (bLanded && sClosed == "Closed")
                    {
                        GUILayout.Space(2);
                        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                        GUILayout.Space(2);
                        if (GUILayout.Button("Open Base for " + fOpenCost + " funds", GUILayout.Height(23)))
                        {
                            double currentfunds = Funding.Instance.Funds;

                            if (fOpenCost > currentfunds)
                            {
                                MiscUtils.HUDMessage("Insufficient funds to open this site!", 10, 0);
                            }
                            else
                            {
                                Funding.Instance.AddFunds(-fOpenCost, TransactionReasons.Cheating);

                                LaunchSiteManager.setSiteOpenCloseState(Base, "Open");
                                smessage = Base + " opened";
                                MiscUtils.HUDMessage(smessage, 10, 2);
                            }
                        }
                    }

                    if (bLanded && sClosed == "Open")
                    {
                        GUI.enabled = false;
                        GUILayout.Button("Base is Open", GUILayout.Height(23));
                        GUI.enabled = true;
                    }

                    if (bLanded && (sClosed == "OpenLocked" || sClosed == "ClosedLocked"))
                    {
                        GUI.enabled = false;
                        GUILayout.Button("Base cannot be opened or closed", GUILayout.Height(23));
                        GUI.enabled = true;
                    }

                    GUILayout.Space(2);
                    GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                    GUILayout.Space(2);
                }
                else
                {
                    GUILayout.Label("Bases can only be opened or closed at the base when within 2km of the base.", LabelInfo);
                }

                //if (Range > 100000)
                //{
                //    if (bLanded)
                //    {
                //        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                //        GUILayout.Space(2);
                //        GUILayout.Label("This feature is WIP.", LabelInfo);
                //        GUI.enabled = false;
                //        if (GUILayout.Button("Found a New Base", GUILayout.Height(23)))
                //        {
                //            foundingBase = true;
                //        }
                //        GUI.enabled = true;
                //        GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
                //        GUILayout.Space(2);
                //    }
                //}
                //else
                //{
                //    GUILayout.Label("This feature is WIP.", LabelInfo);
                //}
            }

            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);
            GUILayout.Box("Operational Facilities", BoxNoBorder);

            bool bAreFacilities = false;

            if (FlightGlobals.ActiveVessel.Landed)
            {
                if (GUILayout.Button("Show/Hide", GUILayout.Height(23)))
                {
                    if (bShowFacilities)
                    {
                        bShowFacilities = false;
                    }
                    else
                    {
                        CacheFacilities();
                        bShowFacilities = true;
                    }
                }

                if (bShowFacilities && allFacilities.Count > 0)
                {
                    scrollPos = GUILayout.BeginScrollView(scrollPos);

                    for (int i = 0; i < allFacilities.Count; i++)
                    {
                        bAreFacilities = true;
                        GUILayout.BeginHorizontal();
                        {
                            bIsOpen = allFacilities[i].myFacilities[0].isOpen;

                            if (!bIsOpen)
                            {
                                iFundsOpen2 = allFacilities[i].myFacilities[0].OpenCost;
                                if (iFundsOpen2 == 0)
                                {
                                    bIsOpen = true;
                                }
                            }

                            if (GUILayout.Button(allFacilities[i].model.title, GUILayout.Height(23)))
                            {
                                selectedObject = allFacilities[i];
                                KerbalKonstructs.instance.selectObject(allFacilities[i], false, true, false);
                                FacilityManager.selectedInstance = allFacilities[i];
                                FacilityManager.instance.Open();
                            }

                            if (bIsOpen)
                            {
                                GUILayout.Label(tIconOpen, GUILayout.Height(23), GUILayout.Width(23));
                            }

                            if (!bIsOpen)
                            {
                                GUILayout.Label(tIconClosed, GUILayout.Height(23), GUILayout.Width(23));
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                    GUILayout.EndScrollView();
                }
                else
                {
                    GUILayout.Label("Click the button above to display a list of nearby operational facilities.", LabelInfo);

                    if (KerbalKonstructs.instance.DebugMode)
                    {
                        GUILayout.Box("Debug Mode ActiveVessel Report");
                        GUILayout.Label("Name " + FlightGlobals.ActiveVessel.vesselName);
                        GUILayout.Label("Acceleration " + FlightGlobals.ActiveVessel.acceleration.ToString());
                        GUILayout.Label("Angular Momentum " + FlightGlobals.ActiveVessel.angularMomentum.ToString("#0.000"));
                        GUILayout.Label("Angular Velocity " + FlightGlobals.ActiveVessel.angularVelocity.ToString("#0.000"));
                        //GUILayout.Label("Centrifugal Acc " + FlightGlobals.ActiveVessel.CentrifugalAcc.ToString());
                        GUILayout.Label("Horiz Srf Speed " + FlightGlobals.ActiveVessel.horizontalSrfSpeed.ToString("#0.00"));
                        GUILayout.Label("Indicated Air Speed " + FlightGlobals.ActiveVessel.indicatedAirSpeed.ToString("#0.00"));
                        GUILayout.Label("Mach " + FlightGlobals.ActiveVessel.mach.ToString("#0.00"));
                        GUILayout.Label("Orbit Speed " + FlightGlobals.ActiveVessel.obt_speed.ToString("#0.00"));
                        GUILayout.Label("Orbit Velocity " + FlightGlobals.ActiveVessel.obt_velocity.ToString());
                        GUILayout.Label("Perturbation " + FlightGlobals.ActiveVessel.perturbation.ToString());
                        GUILayout.Label("rb_velocity " + FlightGlobals.ActiveVessel.rb_velocity.ToString("#0.000"));
                        GUILayout.Label("Specific Acc " + FlightGlobals.ActiveVessel.specificAcceleration.ToString("#0.00"));
                        GUILayout.Label("speed " + FlightGlobals.ActiveVessel.speed.ToString("#0.00"));
                        GUILayout.Label("srf_velocity " + FlightGlobals.ActiveVessel.srf_velocity.ToString());
                        GUILayout.Label("srfspeed " + FlightGlobals.ActiveVessel.srfSpeed.ToString("#0.00"));
                    }
                }
            }
            else
            {
                GUILayout.Label("Nearby facilities can only be shown when landed.", LabelInfo);
                bShowFacilities = false;
            }

            if (bAreFacilities == false)
            {
                //GUILayout.Label("There are no nearby operational facilities.", LabelInfo);
            }

            GUILayout.FlexibleSpace();
            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);
            GUILayout.Box("Other Features", BoxNoBorder);
            if (GUILayout.Button("Start Air Racing!", GUILayout.Height(23)))
            {
                AirRacing.instance.Open();
                AirRacing.runningRace = true;
                NavGuidanceSystem.instance.Close();
                FacilityManager.instance.Close();
            }
            if (GUILayout.Button("Basic Orbital Data", GUILayout.Height(23)))
            {
                AirRacing.instance.Open();
                AirRacing.runningRace     = false;
                AirRacing.basicorbitalhud = true;
                NavGuidanceSystem.instance.Close();
                FacilityManager.instance.Close();
            }
            GUILayout.Space(5);

            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(2);

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
        public void DrawSelectorWindow(int id)
        {
            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", UIMain.DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Launchsite Selector", UIMain.DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (GUILayout.Button("X", UIMain.DeadButtonRed, GUILayout.Height(21)))
                {
                    this.Close();
                    return;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(UIMain.tHorizontalSep, UIMain.BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(5);

                if (MiscUtils.isCareerGame())
                {
                    if (GUILayout.Button(new GUIContent(showOpen ? UIMain.tOpenBasesOn : UIMain.tOpenBasesOff, "Open"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        if (showOpen)
                        {
                            showOpen   = false;
                            showClosed = true;
                        }
                        else
                        {
                            showOpen = true;
                        }
                    }

                    if (GUILayout.Button(new GUIContent(showClosed ? UIMain.tClosedBasesOn : UIMain.tClosedBasesOff, "Closed"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                    {
                        if (showClosed)
                        {
                            showClosed = false;
                            showOpen   = true;
                        }
                        else
                        {
                            showClosed = true;
                        }
                    }

                    GUILayout.FlexibleSpace();
                }

                if (GUILayout.Button(new GUIContent(showFavOnly ? UIMain.tFavesOn : UIMain.tFavesOff, "Only Favourites"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    showFavOnly = !showFavOnly;
                }

                GUILayout.FlexibleSpace();

                if (EditorDriver.editorFacility == EditorFacility.SPH)
                {
                    GUI.enabled = false;
                }

                isSelected = (showAllcategorys || (category == LaunchSiteCategory.RocketPad));
                if (GUILayout.Button(new GUIContent(isSelected? UIMain.tLaunchpadsOn : UIMain.tLaunchpadsOff, "Rocketpads"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    category         = LaunchSiteCategory.RocketPad;
                    showAllcategorys = false;
                }

                GUI.enabled = true;
                GUILayout.Space(2);

                if (EditorDriver.editorFacility == EditorFacility.VAB)
                {
                    GUI.enabled = false;
                }
                isSelected = (showAllcategorys || (category == LaunchSiteCategory.RocketPad));
                if (GUILayout.Button(new GUIContent(isSelected ? UIMain.tRunwaysOn : UIMain.tRunwaysOff, "Runways"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    category         = LaunchSiteCategory.Runway;
                    showAllcategorys = false;
                }

                GUI.enabled = true;
                GUILayout.Space(2);

                if (EditorDriver.editorFacility == EditorFacility.VAB)
                {
                    GUI.enabled = false;
                }
                isSelected = (showAllcategorys || (category == LaunchSiteCategory.Helipad));
                if (GUILayout.Button(new GUIContent(isSelected ? UIMain.tHelipadsOn: UIMain.tHelipadsOff, "Helipads"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    category         = LaunchSiteCategory.Helipad;
                    showAllcategorys = false;
                }

                GUI.enabled = true;
                GUILayout.Space(2);

                if (EditorDriver.editorFacility == EditorFacility.VAB)
                {
                    GUI.enabled = false;
                }

                isSelected = (showAllcategorys || (category == LaunchSiteCategory.Waterlaunch));
                if (GUILayout.Button(new GUIContent(isSelected ? UIMain.tWaterOn : UIMain.tWaterOff, "WalterLaunch"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    category         = LaunchSiteCategory.Waterlaunch;
                    showAllcategorys = false;
                }

                GUI.enabled = true;
                GUILayout.Space(2);

                isSelected = (showAllcategorys || (category == LaunchSiteCategory.Other));
                if (GUILayout.Button(new GUIContent(isSelected ? UIMain.tOtherOn : UIMain.tOtherOff, "Other"), UIMain.ButtonKK, GUILayout.Width(32), GUILayout.Height(32)))
                {
                    category         = LaunchSiteCategory.Other;
                    showAllcategorys = false;
                }

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("ALL", GUILayout.Width(32), GUILayout.Height(32)))
                {
                    showAllcategorys = true;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            sitesScrollPosition = GUILayout.BeginScrollView(sitesScrollPosition);
            {
                foreach (KKLaunchSite site in LaunchSiteManager.allLaunchSites)
                {
                    if (showFavOnly && (site.favouriteSite != "Yes"))
                    {
                        continue;
                    }

                    if (category != site.sitecategory && !showAllcategorys)
                    {
                        continue;
                    }

                    if (LaunchSiteManager.CheckLaunchSiteIsValid(site) == false)
                    {
                        continue;
                    }

                    if (MiscUtils.isCareerGame())
                    {
                        if ((!showOpen && site.isOpen) || (!showClosed && !site.isOpen))
                        {
                            continue;
                        }
                        // Don't show hidden closed Bases
                        if (site.LaunchSiteIsHidden && (!site.isOpen))
                        {
                            continue;
                        }
                    }

                    GUILayout.BeginHorizontal();
                    {
                        ShowOpenStatus(site);

                        launchButtonName = site.LaunchSiteName;
                        if (site.LaunchSiteName == "Runway")
                        {
                            launchButtonName = "KSC Runway";
                        }

                        if (site.LaunchSiteName == "LaunchPad")
                        {
                            launchButtonName = "KSC LaunchPad";
                        }

                        GUI.enabled = (selectedSite != site);
                        if (GUILayout.Button(launchButtonName, GUILayout.Height(30)))
                        {
                            selectedSite             = site;
                            BaseManager.selectedSite = selectedSite;

                            //if (!MiscUtils.isCareerGame())
                            //{
                            //    LaunchSiteManager.setLaunchSite(site);
                            //    smessage = "Launchsite set to " + launchButtonName;
                            //    MiscUtils.HUDMessage(smessage, 10, 2);
                            //}
                        }
                        GUI.enabled = true;

                        ShowOpenStatus(site);
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();

            GUILayout.Space(5);

            sCurrentSite = LaunchSiteManager.getCurrentLaunchSite();

            switch (sCurrentSite)
            {
            case "Runway":
                GUILayout.Box("Current Launchsite: KSC Runway");
                break;

            case "LaunchPad":
                GUILayout.Box("Current Launchsite: KSC LaunchPad");
                break;

            default:
                GUILayout.Box("Current Launchsite: " + sCurrentSite);
                break;
            }

            GUI.enabled = (selectedSite.isOpen && (selectedSite.LaunchSiteName != sCurrentSite));
            if (GUILayout.Button("Set as Launchsite", GUILayout.Height(46)))
            {
                LaunchSiteManager.setLaunchSite(selectedSite);
                MiscUtils.HUDMessage(selectedSite.LaunchSiteName + " has been set as the launchsite", 10, 0);
            }
            GUI.enabled = true;

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                if ((selectedSite.isOpen) && (EditorDriver.editorFacility == EditorFacility.SPH) && (KerbalKonstructs.instance.defaultSPHlaunchsite != selectedSite.LaunchSiteName))
                {
                    GUI.enabled = true;
                }

                if ((selectedSite.isOpen) && (EditorDriver.editorFacility == EditorFacility.VAB) && (KerbalKonstructs.instance.defaultVABlaunchsite != selectedSite.LaunchSiteName))
                {
                    GUI.enabled = true;
                }

                if (GUILayout.Button("Set as Default", GUILayout.Height(23)))
                {
                    if (selectedSite != null)
                    {
                        MiscUtils.HUDMessage(selectedSite.LaunchSiteName + " has been set as the default", 10, 0);
                        if (EditorDriver.editorFacility == EditorFacility.SPH)
                        {
                            KerbalKonstructs.instance.defaultSPHlaunchsite = selectedSite.LaunchSiteName;
                        }

                        if (EditorDriver.editorFacility == EditorFacility.VAB)
                        {
                            KerbalKonstructs.instance.defaultVABlaunchsite = selectedSite.LaunchSiteName;
                        }
                    }
                }
                GUI.enabled = true;

                if (GUILayout.Button("Use Default", GUILayout.Height(23)))
                {
                    selectedSite = LaunchSiteManager.GetDefaultSite();
                    LaunchSiteManager.setLaunchSite(selectedSite);
                    MiscUtils.HUDMessage(selectedSite.LaunchSiteName + " has been set as the launchsite", 10, 0);
                    BaseManager.selectedSite = selectedSite;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.Box(UIMain.tHorizontalSep, UIMain.BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            GUI.enabled = true;

            if (GUI.tooltip != "")
            {
                var labelSize = GUI.skin.GetStyle("Label").CalcSize(new GUIContent(GUI.tooltip));
                GUI.Box(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y + 20, labelSize.x + 5, labelSize.y + 6), GUI.tooltip, UIMain.KKToolTip);
            }

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
示例#16
0
 public override bool RequirementMet(ConfiguredContract contract)
 {
     return(LaunchSiteManager.checkLaunchSiteExists(basename));
 }
        public void drawBaseManagerWindow(int windowID)
        {
            DeadButton = new GUIStyle(GUI.skin.button);
            DeadButton.normal.background  = null;
            DeadButton.hover.background   = null;
            DeadButton.active.background  = null;
            DeadButton.focused.background = null;
            DeadButton.normal.textColor   = Color.white;
            DeadButton.hover.textColor    = Color.white;
            DeadButton.active.textColor   = Color.white;
            DeadButton.focused.textColor  = Color.white;
            DeadButton.fontSize           = 14;
            DeadButton.fontStyle          = FontStyle.Bold;

            DeadButtonRed = new GUIStyle(GUI.skin.button);
            DeadButtonRed.normal.background  = null;
            DeadButtonRed.hover.background   = null;
            DeadButtonRed.active.background  = null;
            DeadButtonRed.focused.background = null;
            DeadButtonRed.normal.textColor   = Color.red;
            DeadButtonRed.hover.textColor    = Color.yellow;
            DeadButtonRed.active.textColor   = Color.red;
            DeadButtonRed.focused.textColor  = Color.red;
            DeadButtonRed.fontSize           = 12;
            DeadButtonRed.fontStyle          = FontStyle.Bold;

            Yellowtext = new GUIStyle(GUI.skin.box);
            Yellowtext.normal.textColor  = Color.yellow;
            Yellowtext.normal.background = null;

            TextAreaNoBorder = new GUIStyle(GUI.skin.textArea);
            TextAreaNoBorder.normal.background = null;
            TextAreaNoBorder.normal.textColor  = Color.white;
            TextAreaNoBorder.fontSize          = 12;
            TextAreaNoBorder.padding.left      = 1;
            TextAreaNoBorder.padding.right     = 1;
            TextAreaNoBorder.padding.top       = 4;

            BoxNoBorder = new GUIStyle(GUI.skin.box);
            BoxNoBorder.normal.background = null;
            BoxNoBorder.normal.textColor  = Color.white;

            LabelWhite = new GUIStyle(GUI.skin.label);
            LabelWhite.normal.background = null;
            LabelWhite.normal.textColor  = Color.white;
            LabelWhite.fontSize          = 12;
            LabelWhite.padding.left      = 1;
            LabelWhite.padding.right     = 1;
            LabelWhite.padding.top       = 4;

            LabelInfo = new GUIStyle(GUI.skin.label);
            LabelInfo.normal.background = null;
            LabelInfo.normal.textColor  = Color.white;
            LabelInfo.fontSize          = 13;
            LabelInfo.fontStyle         = FontStyle.Bold;
            LabelInfo.padding.left      = 3;
            LabelInfo.padding.top       = 0;
            LabelInfo.padding.bottom    = 0;

            KKWindowTitle = new GUIStyle(GUI.skin.box);
            KKWindowTitle.normal.background = null;
            KKWindowTitle.normal.textColor  = Color.white;
            KKWindowTitle.fontSize          = 14;
            KKWindowTitle.fontStyle         = FontStyle.Bold;

            SmallButton = new GUIStyle(GUI.skin.button);
            SmallButton.normal.textColor  = Color.red;
            SmallButton.hover.textColor   = Color.white;
            SmallButton.padding.top       = 1;
            SmallButton.padding.left      = 1;
            SmallButton.padding.right     = 1;
            SmallButton.padding.bottom    = 4;
            SmallButton.normal.background = null;
            SmallButton.hover.background  = null;
            SmallButton.fontSize          = 12;

            if (!loadedPersistence && MiscUtils.isCareerGame())
            {
                PersistenceFile <LaunchSite> .LoadList(LaunchSiteManager.AllLaunchSites, "LAUNCHSITES", "KK");

                loadedPersistence = true;
            }

            string sButtonName = "";

            sButtonName = selectedSite.name;
            if (selectedSite.name == "Runway")
            {
                sButtonName = "KSC Runway";
            }
            if (selectedSite.name == "LaunchPad")
            {
                sButtonName = "KSC LaunchPad";
            }

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Base Manager", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (HighLogic.LoadedScene != GameScenes.EDITOR)
                {
                    if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21)))
                    {
                        InputLockManager.RemoveControlLock("KKEditorLock");
                        selectedSite      = null;
                        loadedPersistence = false;
                        KerbalKonstructs.instance.showBaseManager = false;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            if (selectedSite.name == "Runway")
            {
                GUILayout.Box("KSC Runway", Yellowtext);
            }
            else
            if (selectedSite.name == "LaunchPad")
            {
                GUILayout.Box("KSC LaunchPad", Yellowtext);
            }
            else
            {
                GUILayout.Box("" + selectedSite.name, Yellowtext);
            }

            if (!foldedIn)
            {
                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(2);
                    GUILayout.Box(tVerticalSep, BoxNoBorder, GUILayout.Width(4), GUILayout.Height(135));
                    GUILayout.FlexibleSpace();
                    GUILayout.Box(selectedSite.logo, BoxNoBorder, GUILayout.Height(135), GUILayout.Width(135));
                    GUILayout.FlexibleSpace();
                    GUILayout.Box(tVerticalSep, BoxNoBorder, GUILayout.Width(4), GUILayout.Height(135));
                    GUILayout.Space(2);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(3);

                descriptionScrollPosition = GUILayout.BeginScrollView(descriptionScrollPosition, GUILayout.Height(120));
                {
                    GUI.enabled = false;
                    GUILayout.Label(selectedSite.description, LabelWhite);
                    GUI.enabled = true;
                }
                GUILayout.EndScrollView();
            }

            GUILayout.Space(1);

            isFavourite = (selectedSite.favouritesite == "Yes");

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = (!displayStats);
                if (GUILayout.Button("Stats", GUILayout.Height(23)))
                {
                    displayLog   = false;
                    displayStats = true;
                }
                GUI.enabled = true;

                GUI.enabled = (!displayLog);
                if (GUILayout.Button("Log", GUILayout.Height(23)))
                {
                    displayLog   = true;
                    displayStats = false;
                }
                GUI.enabled = true;

                if (isFavourite)
                {
                    tFaveTemp = tIsFave;
                }
                else
                {
                    tFaveTemp = tMakeFavourite;
                }

                if (GUILayout.Button(tFaveTemp, GUILayout.Height(23), GUILayout.Width(23)))
                {
                    if (isFavourite)
                    {
                        selectedSite.favouritesite = "No";
                    }
                    else
                    {
                        selectedSite.favouritesite = "Yes";
                    }

                    List <LaunchSite> sites = LaunchSiteManager.getLaunchSites();
                    PersistenceFile <LaunchSite> .SaveList(sites, "LAUNCHSITES", "KK");
                }

                if (foldedIn)
                {
                    tFolded = tFoldOut;
                }
                if (!foldedIn)
                {
                    tFolded = tFoldIn;
                }

                if (GUILayout.Button(tFolded, GUILayout.Height(23), GUILayout.Width(23)))
                {
                    if (foldedIn)
                    {
                        foldedIn = false;
                    }
                    else
                    {
                        foldedIn = true;
                    }
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);

            if (displayStats)
            {
                GUILayout.Label("Altitude: " + selectedSite.refalt.ToString("#0.0") + " m", LabelInfo);
                GUILayout.Label("Longitude: " + selectedSite.reflon.ToString("#0.000"), LabelInfo);
                GUILayout.Label("Latitude: " + selectedSite.reflat.ToString("#0.000"), LabelInfo);
                GUILayout.Space(3);
                GUILayout.Label("Length: " + selectedSite.sitelength.ToString("#0" + " m"), LabelInfo);
                GUILayout.Label("Width: " + selectedSite.sitewidth.ToString("#0" + " m"), LabelInfo);

                GUILayout.FlexibleSpace();
            }

            iFundsOpen  = selectedSite.opencost;
            iFundsClose = selectedSite.closevalue;

            bool isAlwaysOpen   = false;
            bool cannotBeClosed = false;

            if (iFundsOpen == 0)
            {
                isAlwaysOpen = true;
            }

            if (iFundsClose == 0)
            {
                cannotBeClosed = true;
            }

            if (MiscUtils.isCareerGame())
            {
                if (displayStats)
                {
                    if (!KerbalKonstructs.instance.disableRemoteRecovery)
                    {
                        if (selectedSite.recoveryfactor > 0)
                        {
                            GUILayout.Label("Recovery Factor: " + selectedSite.recoveryfactor.ToString() + "%", LabelInfo);
                            if (selectedSite.name != "Runway" && selectedSite.name != "LaunchPad")
                            {
                                if (selectedSite.recoveryrange > 0)
                                {
                                    rangekm = selectedSite.recoveryrange / 1000;
                                }
                                else
                                {
                                    rangekm = 0;
                                }

                                GUILayout.Label("Effective Range: " + rangekm.ToString() + " km", LabelInfo);
                            }
                            else
                            {
                                GUILayout.Label("Effective Range: Unlimited", LabelInfo);
                            }
                        }
                        else
                        {
                            GUILayout.Label("No Recovery Capability", LabelInfo);
                        }
                    }

                    GUILayout.FlexibleSpace();
                    GUILayout.Label("Launch Refund: " + selectedSite.launchrefund.ToString() + "%", LabelInfo);
                }

                if (displayLog)
                {
                    logScrollPosition = GUILayout.BeginScrollView(logScrollPosition, GUILayout.Height(120));
                    {
                        GUILayout.Box("Feature is WIP");
                        GUILayout.Box("Log Entry");
                        GUILayout.Box("Log Entry");
                        GUILayout.Box("Log Entry");
                    }
                    GUILayout.EndScrollView();

                    GUILayout.FlexibleSpace();
                }

                isOpen      = (selectedSite.openclosestate == "Open");
                GUI.enabled = !isOpen;
                List <LaunchSite> sites = LaunchSiteManager.getLaunchSites();
                if (!isAlwaysOpen)
                {
                    if (!KerbalKonstructs.instance.disableRemoteBaseOpening)
                    {
                        if (GUILayout.Button("Open Base for \n" + iFundsOpen + " funds", GUILayout.Height(40)))
                        {
                            double currentfunds = Funding.Instance.Funds;

                            if (iFundsOpen > currentfunds)
                            {
                                MiscUtils.HUDMessage("Insufficient funds to open this base!", 10,
                                                     3);
                            }
                            else
                            {
                                selectedSite.openclosestate = "Open";
                                Funding.Instance.AddFunds(-iFundsOpen, TransactionReasons.Cheating);
                                PersistenceFile <LaunchSite> .SaveList(sites, "LAUNCHSITES", "KK");
                            }
                        }
                    }
                }
                GUI.enabled = true;

                GUI.enabled = isOpen;
                if (!cannotBeClosed)
                {
                    if (GUILayout.Button("Close Base for \n" + iFundsClose + " funds", GUILayout.Height(40)))
                    {
                        Funding.Instance.AddFunds(iFundsClose, TransactionReasons.Cheating);
                        selectedSite.openclosestate = "Closed";

                        PersistenceFile <LaunchSite> .SaveList(sites, "LAUNCHSITES", "KK");
                    }
                }
                GUI.enabled = true;

                GUILayout.FlexibleSpace();

                if (HighLogic.LoadedScene == GameScenes.EDITOR)
                {
                    GUILayout.BeginHorizontal();
                    {
                        if (selectedSite.name == EditorLogic.fetch.launchSiteName)
                        {
                            tStatusLaunchsite = tSetLaunchsite;
                        }
                        else
                        if (isOpen || isAlwaysOpen)
                        {
                            tStatusLaunchsite = tOpenedLaunchsite;
                        }
                        else
                        {
                            tStatusLaunchsite = tClosedLaunchsite;
                        }

                        GUILayout.Label(tStatusLaunchsite, GUILayout.Height(32), GUILayout.Width(32));

                        GUI.enabled = (isOpen || isAlwaysOpen) && !(selectedSite.name == EditorLogic.fetch.launchSiteName);
                        if (GUILayout.Button("Set as \nLaunchsite", GUILayout.Height(40)))
                        {
                            LaunchSiteManager.setLaunchSite(selectedSite);
                            string smessage = sButtonName + " has been set as the launchsite";
                            MiscUtils.HUDMessage(smessage, 10, 0);
                        }
                        GUI.enabled = true;
                    }
                    GUILayout.EndHorizontal();
                }
            }

            GUILayout.Space(3);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));
            GUILayout.Space(1);

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
        public void drawKKSettingsWindow(int WindowID)
        {
            DeadButton = new GUIStyle(GUI.skin.button);
            DeadButton.normal.background  = null;
            DeadButton.hover.background   = null;
            DeadButton.active.background  = null;
            DeadButton.focused.background = null;
            DeadButton.normal.textColor   = Color.white;
            DeadButton.hover.textColor    = Color.white;
            DeadButton.active.textColor   = Color.white;
            DeadButton.focused.textColor  = Color.white;
            DeadButton.fontSize           = 14;
            DeadButton.fontStyle          = FontStyle.Bold;

            DeadButtonRed = new GUIStyle(GUI.skin.button);
            DeadButtonRed.normal.background  = null;
            DeadButtonRed.hover.background   = null;
            DeadButtonRed.active.background  = null;
            DeadButtonRed.focused.background = null;
            DeadButtonRed.normal.textColor   = Color.red;
            DeadButtonRed.hover.textColor    = Color.yellow;
            DeadButtonRed.active.textColor   = Color.red;
            DeadButtonRed.focused.textColor  = Color.red;
            DeadButtonRed.fontSize           = 12;
            DeadButtonRed.fontStyle          = FontStyle.Bold;

            BoxNoBorder = new GUIStyle(GUI.skin.box);
            BoxNoBorder.normal.background = null;
            BoxNoBorder.normal.textColor  = Color.white;

            Yellowtext = new GUIStyle(GUI.skin.box);
            Yellowtext.normal.textColor  = Color.yellow;
            Yellowtext.normal.background = null;

            LabelInfo = new GUIStyle(GUI.skin.label);
            LabelInfo.normal.background = null;
            LabelInfo.normal.textColor  = Color.white;
            LabelInfo.fontSize          = 13;
            LabelInfo.fontStyle         = FontStyle.Normal;
            LabelInfo.padding.left      = 3;
            LabelInfo.padding.top       = 0;
            LabelInfo.padding.bottom    = 0;

            LabelYellow = new GUIStyle(GUI.skin.label);
            LabelYellow.normal.background = null;
            LabelYellow.normal.textColor  = Color.yellow;
            LabelYellow.fontSize          = 13;
            LabelYellow.fontStyle         = FontStyle.Bold;
            LabelYellow.padding.left      = 3;
            LabelYellow.padding.top       = 0;
            LabelYellow.padding.bottom    = 0;

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", DeadButton, GUILayout.Height(16));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Settings", DeadButton, GUILayout.Height(16));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(16)))
                {
                    KerbalKonstructs.instance.showSettings = false;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            scrollSettings = GUILayout.BeginScrollView(scrollSettings);
            GUILayout.Box("Default VAB Launchsite");
            if (GUILayout.Button("" + KerbalKonstructs.instance.defaultVABlaunchsite, GUILayout.Height(23)))
            {
                bChangeVABDefault = true;
            }

            if (bChangeVABDefault)
            {
                if (sites == null)
                {
                    sites = LaunchSiteManager.getLaunchSites();
                }

                sites.Sort(delegate(LaunchSite a, LaunchSite b)
                {
                    return((a.name).CompareTo(b.name));
                });

                GUILayout.Label("Select a default site from the list that follows.", LabelInfo);

                foreach (LaunchSite site in sites)
                {
                    if (MiscUtils.isCareerGame())
                    {
                        if (site.openclosestate != "Open" && site.opencost != 0)
                        {
                            continue;
                        }
                    }

                    if (!KerbalKonstructs.instance.launchFromAnySite)
                    {
                        if (site.type == SiteType.SPH)
                        {
                            continue;
                        }
                    }

                    string sButtonName = "";
                    sButtonName = site.name;
                    if (site.name == "Runway")
                    {
                        sButtonName = "KSC Runway";
                    }
                    if (site.name == "LaunchPad")
                    {
                        sButtonName = "KSC LaunchPad";
                    }

                    if (GUILayout.Button(sButtonName, GUILayout.Height(21)))
                    {
                        KerbalKonstructs.instance.defaultVABlaunchsite = site.name;
                        bChangeVABDefault = false;
                    }
                }

                if (GUILayout.Button("CANCEL - NO CHANGE", GUILayout.Height(21)))
                {
                    bChangeVABDefault = false;
                }
            }

            GUILayout.Box("Default SPH Launchsite");
            if (GUILayout.Button("" + KerbalKonstructs.instance.defaultSPHlaunchsite, GUILayout.Height(23)))
            {
                bChangeSPHDefault = true;
            }

            if (bChangeSPHDefault)
            {
                if (sites == null)
                {
                    sites = LaunchSiteManager.getLaunchSites();
                }

                sites.Sort(delegate(LaunchSite a, LaunchSite b)
                {
                    return((a.name).CompareTo(b.name));
                });

                GUILayout.Label("Select a default site from the list that follows.", LabelInfo);

                foreach (LaunchSite site in sites)
                {
                    if (MiscUtils.isCareerGame())
                    {
                        if (site.openclosestate != "Open" && site.opencost != 0)
                        {
                            continue;
                        }
                    }

                    if (!KerbalKonstructs.instance.launchFromAnySite)
                    {
                        if (site.type == SiteType.VAB)
                        {
                            continue;
                        }
                    }

                    string sButtonName = "";
                    sButtonName = site.name;
                    if (site.name == "Runway")
                    {
                        sButtonName = "KSC Runway";
                    }
                    if (site.name == "LaunchPad")
                    {
                        sButtonName = "KSC LaunchPad";
                    }

                    if (GUILayout.Button(sButtonName, GUILayout.Height(21)))
                    {
                        KerbalKonstructs.instance.defaultSPHlaunchsite = site.name;
                        bChangeSPHDefault = false;
                    }
                }

                if (GUILayout.Button("CANCEL - NO CHANGE", GUILayout.Height(21)))
                {
                    bChangeSPHDefault = false;
                }
            }

            GUILayout.Space(3);

            GUILayout.Box("General Settings");
            GUILayout.Label("Does launching from the VAB or SPH limit the type of launchsite that can be used?", LabelInfo);
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.launchFromAnySite)
            {
                if (GUILayout.Button("Launch From Any Site", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.launchFromAnySite = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Launch From Any Site", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.launchFromAnySite = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.Label("Should the career strategy features of KK be enabled? WARNING: Disabling them in the middle of a career game is not advised!", LabelInfo);
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.disableCareerStrategyLayer)
            {
                if (GUILayout.Button("Disable Career Strategy", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableCareerStrategyLayer = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Disable Career Strategy", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableCareerStrategyLayer = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("Should it be possible to launch from sites other than the KSC?", LabelInfo);
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.disableCustomLaunchsites)
            {
                if (GUILayout.Button("Disable Custom Launchsites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableCustomLaunchsites = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Disable Custom Launchsites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableCustomLaunchsites = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("Should it only be possible to open bases at the base?", LabelInfo);
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.disableRemoteBaseOpening)
            {
                if (GUILayout.Button("Can Only Open Bases at the Base", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableRemoteBaseOpening = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Can Only Open Bases at the Base", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableRemoteBaseOpening = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUILayout.Box("Inflight Instruments Defaults");
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.enableATC)
            {
                if (GUILayout.Button("ATC Enabled", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.enableATC = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("ATC Enabled", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.enableATC = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.enableNGS)
            {
                if (GUILayout.Button("NGS Enabled", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.enableNGS = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("NGS Enabled", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.enableNGS = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.enableDownlink)
            {
                if (GUILayout.Button("Downlink Enabled", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.enableDownlink = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Downlink Enabled", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.enableDownlink = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUILayout.Box("Facility Defaults");
            GUILayout.Label("Some facilities require a craft or kerbal to be close to use them.", LabelInfo);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Use Range: " + KerbalKonstructs.instance.facilityUseRange.ToString("#0") + " m", LabelYellow);
            GUILayout.FlexibleSpace();
            sFacilityUseRange = GUILayout.TextField(sFacilityUseRange, 4, GUILayout.Width(70));
            GUILayout.Label(" m", LabelYellow);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Update", GUILayout.Height(23)))
            {
                KerbalKonstructs.instance.facilityUseRange = float.Parse(sFacilityUseRange);

                if (KerbalKonstructs.instance.facilityUseRange < 1f)
                {
                    KerbalKonstructs.instance.facilityUseRange = 1f;
                }
                if (KerbalKonstructs.instance.facilityUseRange > 5000f)
                {
                    KerbalKonstructs.instance.facilityUseRange = 5000f;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUILayout.Box("Tracking/Map View Settngs");
            GUILayout.Label("Never show the icons of closed launchsites?", LabelInfo);
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.disableDisplayClosed)
            {
                if (GUILayout.Button("Never Display Closed Launchsites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableDisplayClosed = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Never Display Closed Launchsites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableDisplayClosed = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.Label("Toggle icon display with Base Boss display?", LabelInfo);
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.toggleIconsWithBB)
            {
                if (GUILayout.Button("Toggle Icons With Base Boss", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.toggleIconsWithBB = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Toggle Icons With Base Boss", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.toggleIconsWithBB = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUILayout.Box("Tracking/Map View Defaults");

            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.mapShowOpen)
            {
                if (GUILayout.Button("Show Open Sites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowOpen = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Show Open Sites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowOpen = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.mapShowClosed)
            {
                if (GUILayout.Button("Show Closed Sites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowClosed = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Show Closed Sites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowClosed = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.mapShowOpenT)
            {
                if (GUILayout.Button("Show Tracking Stations", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowOpenT = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Show Tracking Stations", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowOpenT = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.mapShowHelipads)
            {
                if (GUILayout.Button("Show Helipads", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowHelipads = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Show Helipads", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowHelipads = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.mapShowRunways)
            {
                if (GUILayout.Button("Show Runways", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowRunways = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Show Runways", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowRunways = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.mapShowRocketbases)
            {
                if (GUILayout.Button("Show Rocket Bases", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowRocketbases = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Show Rocket Bases", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowRocketbases = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.mapShowOther)
            {
                if (GUILayout.Button("Show Other Sites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowOther = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Show Other Sites", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.mapShowOther = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUILayout.Box("Base Recovery Settings");
            GUILayout.Label("Should custom bases carry out recovery, or should it only be KSC?", LabelInfo);
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.disableRemoteRecovery)
            {
                if (GUILayout.Button("Disable Recovery by Custom Bases", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableRemoteRecovery = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Disable Recovery by Custom Bases", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.disableRemoteRecovery = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUILayout.Box("Base Recovery Capability Defaults");

            GUILayout.Label("A percentage of the base amount recovered (modified by distance per KSP functions), IF the recovery is made by a base outside its effective range.", LabelInfo);
            GUILayout.BeginHorizontal();

            GUILayout.Label("Recovery Factor: " + KerbalKonstructs.instance.defaultRecoveryFactor.ToString("#0") + "%", LabelYellow);
            GUILayout.FlexibleSpace();
            sDefaultFactor = GUILayout.TextField(sDefaultFactor, 3, GUILayout.Width(70));
            GUILayout.Label("%", LabelYellow);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Update", GUILayout.Height(23)))
            {
                KerbalKonstructs.instance.defaultRecoveryFactor = float.Parse(sDefaultFactor);

                if (KerbalKonstructs.instance.defaultRecoveryFactor < 0f)
                {
                    KerbalKonstructs.instance.defaultRecoveryFactor = 0f;
                }
                if (KerbalKonstructs.instance.defaultRecoveryFactor > 100f)
                {
                    KerbalKonstructs.instance.defaultRecoveryFactor = 100f;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Label("100% of the base amount is recovered (modified by distance per KSP functions), IF the recovery is made by a base within its effective range.", LabelInfo);

            GUILayout.BeginHorizontal();

            GUILayout.Label("Effective Range: " + KerbalKonstructs.instance.defaultEffectiveRange.ToString("#0") + "m", LabelYellow);
            GUILayout.FlexibleSpace();
            sDefaultRange = GUILayout.TextField(sDefaultRange, 6, GUILayout.Width(70));
            GUILayout.Label("m", LabelYellow);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Update", GUILayout.Height(23)))
            {
                KerbalKonstructs.instance.defaultEffectiveRange = float.Parse(sDefaultRange);

                if (KerbalKonstructs.instance.defaultEffectiveRange < 1000f)
                {
                    KerbalKonstructs.instance.defaultEffectiveRange = 1000f;
                }
                if (KerbalKonstructs.instance.defaultEffectiveRange > 250000f)
                {
                    KerbalKonstructs.instance.defaultEffectiveRange = 250000f;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUILayout.Box("Editor Tools Defaults");
            GUILayout.BeginHorizontal();

            GUILayout.Label("Max Visibility Range: " + KerbalKonstructs.instance.maxEditorVisRange.ToString("#0") + "m", LabelYellow);
            GUILayout.FlexibleSpace();
            sVisRange = GUILayout.TextField(sVisRange, 15, GUILayout.Width(70));
            GUILayout.Label(" m", LabelYellow);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Update", GUILayout.Height(23)))
            {
                KerbalKonstructs.instance.maxEditorVisRange = float.Parse(sVisRange);

                if (KerbalKonstructs.instance.maxEditorVisRange < 0f)
                {
                    KerbalKonstructs.instance.maxEditorVisRange = 0f;
                }
                if (KerbalKonstructs.instance.maxEditorVisRange > 1000000000000f)
                {
                    KerbalKonstructs.instance.maxEditorVisRange = 1000000000000f;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Label("Should a preview of a static model be spawned when editing a model config?", LabelInfo);
            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.spawnPreviewModels)
            {
                if (GUILayout.Button("Spawn Preview Static Models", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.spawnPreviewModels = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Spawn Preview Static Models", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.spawnPreviewModels = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUILayout.Box("Modes");
            GUILayout.Label("WARNING: This will lag your game because of additional writes to KSP.log. Do not switch it on unless a developer of the mod asks you to.", LabelInfo);

            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.DebugMode)
            {
                if (GUILayout.Button("Debug Mode", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.DebugMode = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Debug Mode", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.DebugMode = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();
            GUILayout.Label("WARNING: This will enable unfinished features that will NOT WORK properly. They may break your save games. Any changes made to static instances will NOT be tagged as custom and CANNOT be exported.", LabelInfo);

            GUILayout.BeginHorizontal();
            if (!KerbalKonstructs.instance.DevMode)
            {
                if (GUILayout.Button("Developer Mode", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.DevMode = true;
                }

                GUILayout.Button(tCross, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            else
            {
                if (GUILayout.Button("Developer Mode", GUILayout.Height(23)))
                {
                    KerbalKonstructs.instance.DevMode = false;
                }

                GUILayout.Button(tTick, DeadButton, GUILayout.Height(23), GUILayout.Width(23));
            }
            GUILayout.EndHorizontal();

            GUILayout.EndScrollView();
            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);
            if (GUILayout.Button("Save Config Settings", GUILayout.Height(23)))
            {
                KerbalKonstructs.instance.saveConfig();
            }
            if (GUILayout.Button("Reload Saved Settings", GUILayout.Height(23)))
            {
                KerbalKonstructs.instance.loadConfig();
            }
            if (GUILayout.Button("Reset To Factory Settings", GUILayout.Height(23)))
            {
                KerbalKonstructs.instance.defaultVABlaunchsite       = "LaunchPad";
                KerbalKonstructs.instance.defaultSPHlaunchsite       = "Runway";
                KerbalKonstructs.instance.launchFromAnySite          = false;
                KerbalKonstructs.instance.disableCareerStrategyLayer = false;
                KerbalKonstructs.instance.disableCustomLaunchsites   = false;
                KerbalKonstructs.instance.disableRemoteBaseOpening   = false;
                KerbalKonstructs.instance.enableATC             = true;
                KerbalKonstructs.instance.enableNGS             = true;
                KerbalKonstructs.instance.enableDownlink        = true;
                KerbalKonstructs.instance.facilityUseRange      = 100;
                KerbalKonstructs.instance.disableDisplayClosed  = false;
                KerbalKonstructs.instance.toggleIconsWithBB     = false;
                KerbalKonstructs.instance.mapShowOpen           = true;
                KerbalKonstructs.instance.mapShowClosed         = false;
                KerbalKonstructs.instance.mapShowOpenT          = true;
                KerbalKonstructs.instance.mapShowHelipads       = true;
                KerbalKonstructs.instance.mapShowRunways        = true;
                KerbalKonstructs.instance.mapShowRocketbases    = true;
                KerbalKonstructs.instance.mapShowOther          = false;
                KerbalKonstructs.instance.disableRemoteRecovery = false;
                KerbalKonstructs.instance.defaultRecoveryFactor = 50;
                KerbalKonstructs.instance.defaultEffectiveRange = 100000;
                KerbalKonstructs.instance.maxEditorVisRange     = 100000;
                KerbalKonstructs.instance.spawnPreviewModels    = true;
                KerbalKonstructs.instance.DebugMode             = false;
                KerbalKonstructs.instance.DevMode = false;

                KerbalKonstructs.instance.saveConfig();
            }
            GUILayout.Space(2);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
        public void drawGroundComms(StaticObject obj, LaunchSite lSite = null)
        {
            string     Base   = "";
            string     Base2  = "";
            float      Range  = 0f;
            LaunchSite lBase  = null;
            LaunchSite lBase2 = null;
            Vector3    pos    = Vector3.zero;

            if (lSite != null)
            {
                GameObject golSite = lSite.GameObject;
                pos = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(golSite.transform.position));
                LaunchSiteManager.getNearestBase(golSite.transform.position, out Base, out Base2, out Range, out lBase, out lBase2);
            }

            if (obj != null)
            {
                pos = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(obj.gameObject.transform.position));
                LaunchSiteManager.getNearestBase(obj.gameObject.transform.position, out Base, out Base2, out Range, out lBase, out lBase2);
            }

            Vector3 vNeighbourPos  = Vector3.zero;
            Vector3 vNeighbourPos2 = Vector3.zero;
            Vector3 vBasePos       = Vector3.zero;
            Vector3 vBasePos2      = Vector3.zero;

            GameObject goNeighbour  = null;
            GameObject goNeighbour2 = null;

            if (Base != "")
            {
                if (Base == "KSC")
                {
                    goNeighbour = SpaceCenterManager.KSC.gameObject;
                }
                else
                {
                    goNeighbour = LaunchSiteManager.getSiteGameObject(Base);
                }
            }

            if (Base2 != "")
            {
                if (Base2 == "KSC")
                {
                    goNeighbour2 = SpaceCenterManager.KSC.gameObject;
                }
                else
                {
                    goNeighbour2 = LaunchSiteManager.getSiteGameObject(Base2);
                }
            }

            if (goNeighbour != null)
            {
                vNeighbourPos = goNeighbour.transform.position;
                vBasePos      = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(vNeighbourPos));
            }

            if (goNeighbour2 != null)
            {
                vNeighbourPos2 = goNeighbour2.transform.position;
                vBasePos2      = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(vNeighbourPos2));
            }

            if (goNeighbour != null && vNeighbourPos != Vector3.zero && vBasePos != Vector3.zero)
            {
                NavUtils.CreateLineMaterial(1);

                GL.Begin(GL.LINES);
                NavUtils.lineMaterial1.SetPass(0);
                GL.Color(new Color(1f, 1f, 1f, 0.7f));
                GL.Vertex3(pos.x - Screen.width / 2, pos.y - Screen.height / 2, pos.z);
                GL.Vertex3(vBasePos.x - Screen.width / 2, vBasePos.y - Screen.height / 2, vBasePos.z);
                GL.End();
            }

            if (goNeighbour2 != null && vNeighbourPos2 != Vector3.zero && vBasePos2 != Vector3.zero)
            {
                NavUtils.CreateLineMaterial(2);

                GL.Begin(GL.LINES);
                NavUtils.lineMaterial2.SetPass(0);
                GL.Color(new Color(1f, 1f, 1f, 0.7f));
                GL.Vertex3(pos.x - Screen.width / 2, pos.y - Screen.height / 2, pos.z);
                GL.Vertex3(vBasePos2.x - Screen.width / 2, vBasePos2.y - Screen.height / 2, vBasePos2.z);
                GL.End();
            }
        }
示例#20
0
        public void drawIcons()
        {
            displayingTooltip = false;
            MapObject target = PlanetariumCamera.fetch.target;

            if (target.type == MapObject.MapObjectType.CELESTIALBODY)
            {
                // Do tracking stations first
                foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics())
                {
                    bool display2 = false;
                    if ((string)obj.getSetting("FacilityType") == "TrackingStation")
                    {
                        if (!isOccluded(obj.gameObject.transform.position, target.celestialBody))
                        {
                            if (MiscUtils.isCareerGame())
                            {
                                //PersistenceUtils.loadStaticPersistence(obj);
                                string openclosed2 = (string)obj.getSetting("OpenCloseState");
                                // To do manage open and close state of tracking stations
                                if (KerbalKonstructs.instance.mapShowOpenT)                                 // && openclosed == "Open")
                                {
                                    display2 = true;
                                }
                                if (!KerbalKonstructs.instance.mapShowClosed && openclosed2 == "Closed")
                                {
                                    display2 = false;
                                }
                                if (!KerbalKonstructs.instance.mapShowOpen && openclosed2 == "Open")
                                {
                                    display2 = false;
                                }
                            }
                            else
                            {                             // Not a career game
                            }

                            if (display2)
                            {
                                Vector3 pos         = MapView.MapCamera.camera.WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(obj.gameObject.transform.position));
                                Rect    screenRect2 = new Rect((pos.x - 8), (Screen.height - pos.y) - 8, 16, 16);
                                Graphics.DrawTexture(screenRect2, TrackingStationIcon);

                                if (screenRect2.Contains(Event.current.mousePosition) && !displayingTooltip)
                                {
                                    CelestialBody cPlanetoid = (CelestialBody)obj.getSetting("CelestialBody");

                                    var objectpos2    = cPlanetoid.transform.InverseTransformPoint(obj.gameObject.transform.position);
                                    var dObjectLat2   = NavUtils.GetLatitude(objectpos2);
                                    var dObjectLon2   = NavUtils.GetLongitude(objectpos2);
                                    var disObjectLat2 = dObjectLat2 * 180 / Math.PI;
                                    var disObjectLon2 = dObjectLon2 * 180 / Math.PI;

                                    if (disObjectLon2 < 0)
                                    {
                                        disObjectLon2 = disObjectLon2 + 360;
                                    }

                                    //Only display one tooltip at a time
                                    displayMapIconToolTip("Tracking Station " + "\n(Lat." + disObjectLat2.ToString("#0.00") + "/ Lon." + disObjectLon2.ToString("#0.00") + ")", pos);
                                    // TO DO Display Lat and Lon in tooltip too

                                    if (Event.current.type == EventType.mouseDown && Event.current.button == 0)
                                    {
                                        //MiscUtils.HUDMessage("Selected base is " + sToolTip + ".", 5f, 3);
                                        Debug.Log("KK: Selected station in map");
                                        float sTrackAngle = (float)obj.getSetting("TrackingAngle");
                                        Debug.Log("KK: Before save load " + sTrackAngle.ToString());
                                        float sTrackRange = (float)obj.getSetting("TrackingShort");
                                        Debug.Log("KK: Before save load " + sTrackRange.ToString());

                                        //PersistenceUtils.saveStaticPersistence(obj);
                                        PersistenceUtils.loadStaticPersistence(obj);

                                        float sTrackAngle2 = (float)obj.getSetting("TrackingAngle");
                                        Debug.Log("KK: After save load " + sTrackAngle2.ToString());
                                        float sTrackRange2 = (float)obj.getSetting("TrackingShort");
                                        Debug.Log("KK: After save load " + sTrackRange2.ToString());

                                        selectedFacility = obj;
                                        FacilityManager.setSelectedFacility(obj);
                                        KerbalKonstructs.instance.showFacilityManager = true;
                                        //EditorGUI.setTargetSite(selectedSite);
                                    }
                                }
                                else
                                {                                 // Mouse is not over tooltip
                                }
                            }
                            else
                            {                             // Filter set to not display
                            }
                        }
                        else
                        {                         // is occluded
                        }
                    }
                    else
                    {             // Not a tracking station
                    }
                }                 //end foreach

                // Then do launchsites
                List <LaunchSite> sites = LaunchSiteManager.getLaunchSites();
                foreach (LaunchSite site in sites)
                {
                    bool display = false;
                    PSystemSetup.SpaceCenterFacility facility = PSystemSetup.Instance.GetSpaceCenterFacility(site.name);
                    if (facility != null)
                    {
                        PSystemSetup.SpaceCenterFacility.SpawnPoint sp = facility.GetSpawnPoint(site.name);
                        if (sp != null)
                        {
                            if (facility.facilityPQS == target.celestialBody.pqsController)
                            {
                                if (!isOccluded(sp.GetSpawnPointTransform().position, target.celestialBody))
                                {
                                    Vector3 pos        = MapView.MapCamera.camera.WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(sp.GetSpawnPointTransform().position));
                                    Rect    screenRect = new Rect((pos.x - 8), (Screen.height - pos.y) - 8, 16, 16);

                                    string openclosed = site.openclosestate;
                                    string category   = site.category;

                                    if (KerbalKonstructs.instance.mapShowHelipads && category == "Helipad")
                                    {
                                        display = true;
                                    }
                                    if (KerbalKonstructs.instance.mapShowOther && category == "Other")
                                    {
                                        display = true;
                                    }
                                    if (KerbalKonstructs.instance.mapShowRocketbases && category == "RocketPad")
                                    {
                                        display = true;
                                    }
                                    if (KerbalKonstructs.instance.mapShowRunways && category == "Runway")
                                    {
                                        display = true;
                                    }

                                    if (display && MiscUtils.isCareerGame())
                                    {
                                        if (!KerbalKonstructs.instance.mapShowOpen && openclosed == "Open")
                                        {
                                            display = false;
                                        }
                                        if (!KerbalKonstructs.instance.mapShowClosed && openclosed == "Closed")
                                        {
                                            display = false;
                                        }
                                        if (KerbalKonstructs.instance.disableDisplayClosed && openclosed == "Closed")
                                        {
                                            display = false;
                                        }
                                    }

                                    if (display)
                                    {
                                        if (site.icon != null)
                                        {
                                            Graphics.DrawTexture(screenRect, site.icon);
                                        }
                                        else
                                        {
                                            switch (site.type)
                                            {
                                            case SiteType.VAB:
                                                Graphics.DrawTexture(screenRect, VABIcon);
                                                break;

                                            case SiteType.SPH:
                                                Graphics.DrawTexture(screenRect, SPHIcon);
                                                break;

                                            default:
                                                Graphics.DrawTexture(screenRect, ANYIcon);
                                                break;
                                            }
                                        }

                                        // Tooltip
                                        if (screenRect.Contains(Event.current.mousePosition) && !displayingTooltip)
                                        {
                                            //Only display one tooltip at a time
                                            string sToolTip = "";
                                            sToolTip = site.name;
                                            if (site.name == "Runway")
                                            {
                                                sToolTip = "KSC Runway";
                                            }
                                            if (site.name == "LaunchPad")
                                            {
                                                sToolTip = "KSC LaunchPad";
                                            }
                                            displayMapIconToolTip(sToolTip, pos);

                                            // Select a base by clicking on the icon
                                            if (Event.current.type == EventType.mouseDown && Event.current.button == 0)
                                            {
                                                MiscUtils.HUDMessage("Selected base is " + sToolTip + ".", 5f, 3);
                                                BaseManager.setSelectedSite(site);
                                                selectedSite = site;
                                                NavGuidanceSystem.setTargetSite(selectedSite);
                                                KerbalKonstructs.instance.showBaseManager = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        public void drawLaunchsites()
        {
            displayingTooltip = false;
            int           iPulseRate = 180;
            CelestialBody body       = PlanetariumCamera.fetch.target.GetReferenceBody();

            iRadarCounter = iRadarCounter + 1;
            if (iRadarCounter > iPulseRate)
            {
                iRadarCounter = 0;
            }

            // Then do launchsites
            List <LaunchSite> sites = LaunchSiteManager.getLaunchSites();

            for (int index = 0; index < sites.Count; index++)
            {
                LaunchSite site = sites[index];

                // don't spam the logfile for the KSC. doesn't work roght now.
                if (site.name == "Runway" || site.name == "LaunchPad")
                {
                    continue;
                }

                // check if we should display the site or not this is the fastst check, so it shoud be first
                string openclosed = site.openclosestate;
                string category   = site.category;

                if (!KerbalKonstructs.instance.mapShowHelipads && category == "Helipad")
                {
                    continue;
                }
                if (!KerbalKonstructs.instance.mapShowOther && category == "Other")
                {
                    continue;
                }
                if (!KerbalKonstructs.instance.mapShowRocketbases && category == "RocketPad")
                {
                    continue;
                }
                if (!KerbalKonstructs.instance.mapShowRunways && category == "Runway")
                {
                    continue;
                }

                if (MiscUtils.isCareerGame())
                {
                    if (!KerbalKonstructs.instance.mapShowOpen && openclosed == "Open")
                    {
                        continue;
                    }
                    if (!KerbalKonstructs.instance.mapShowClosed && openclosed == "Closed")
                    {
                        continue;
                    }
                    if (KerbalKonstructs.instance.disableDisplayClosed && openclosed == "Closed")
                    {
                        continue;
                    }
                    if (openclosed == "OpenLocked" || openclosed == "ClosedLocked")
                    {
                        continue;
                    }
                }


                PSystemSetup.SpaceCenterFacility facility = PSystemSetup.Instance.GetSpaceCenterFacility(site.name);
                if (facility == null)
                {
                    continue;
                }

                PSystemSetup.SpaceCenterFacility.SpawnPoint sp = facility.GetSpawnPoint(site.name);
                if (sp == null)
                {
                    Log.Error("No Spawn Point found for: " + site.name);
                    continue;
                }

                if (facility.facilityPQS != body.pqsController)
                {
                    Log.Error("No PQS found for: " + site.name);
                    continue;
                }
                ;

                Transform spawnPointTransform = sp.GetSpawnPointTransform();
                if (spawnPointTransform == null)
                {
                    Log.Error("No Spawn PointTransform found for: " + site.name);
                    continue;
                }

                if (isOccluded((spawnPointTransform.position), body))
                {
                    if (KerbalKonstructs.instance.mapHideIconsBehindBody)
                    {
                        continue;
                    }
                }

                Vector3 pos = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(spawnPointTransform.position));

                Rect screenRect = new Rect((pos.x - 8), (Screen.height - pos.y) - 8, 16, 16);

                // Distance between camera and spawnpoint sort of
                float fPosZ = pos.z;

                float fRadarRadius = 12800 / fPosZ;
                //      Log.Warning("fRadarRadius = " + Math.Round(fRadarRadius,2));
                float fRadarOffset = fRadarRadius / 2;



                if (KerbalKonstructs.instance.mapShowRadar)
                {
                    drawRadar(pos, category, openclosed);
                }

                if (openclosed == "Open" && KerbalKonstructs.instance.mapShowGroundComms)
                {
                    drawGroundComms(null, site);
                }

                if (site.icon != null)
                {
                    if (fRadarRadius > 15)
                    {
                        GUI.DrawTexture(screenRect, site.icon, ScaleMode.ScaleToFit, true);
                    }
                }
                else
                {
                    if (fRadarRadius > 15)
                    {
                        switch (site.type)
                        {
                        case SiteType.VAB:
                            GUI.DrawTexture(screenRect, UIMain.VABIcon, ScaleMode.ScaleToFit, true);
                            break;

                        case SiteType.SPH:
                            GUI.DrawTexture(screenRect, UIMain.SPHIcon, ScaleMode.ScaleToFit, true);
                            break;

                        default:
                            GUI.DrawTexture(screenRect, UIMain.ANYIcon, ScaleMode.ScaleToFit, true);
                            break;
                        }
                    }
                }

                // Tooltip
                if (screenRect.Contains(Event.current.mousePosition) && !displayingTooltip)
                {
                    //Only display one tooltip at a time
                    string sToolTip = "";
                    sToolTip = site.name;
                    if (site.name == "Runway")
                    {
                        sToolTip = "KSC Runway";
                    }
                    if (site.name == "LaunchPad")
                    {
                        sToolTip = "KSC LaunchPad";
                    }
                    displayMapIconToolTip(sToolTip, pos);

                    // Select a base by clicking on the icon
                    if (Event.current.type == EventType.mouseDown && Event.current.button == 0)
                    {
                        MiscUtils.HUDMessage("Selected base is " + sToolTip + ".", 5f, 3);
                        BaseManager.setSelectedSite(site);
                        selectedSite = site;
                        NavGuidanceSystem.setTargetSite(selectedSite);
                        WindowManager.instance.OpenWindow(KerbalKonstructs.instance.GUI_BaseManager.drawBaseManager);
                    }
                }
            }
        }
 public override bool RequirementMet(ConfiguredContract contract)
 {
     return(!LaunchSiteManager.getIsSiteOpen(basename));
 }
        /// <summary>
        /// Launchsite Editor
        /// </summary>
        /// <param name="id"></param>
        void drawLaunchSiteEditorWindow(int id)
        {
            BoxNoBorder = new GUIStyle(GUI.skin.box);
            BoxNoBorder.normal.background = null;
            BoxNoBorder.normal.textColor  = Color.white;

            DeadButton = new GUIStyle(GUI.skin.button);
            DeadButton.normal.background  = null;
            DeadButton.hover.background   = null;
            DeadButton.active.background  = null;
            DeadButton.focused.background = null;
            DeadButton.normal.textColor   = Color.yellow;
            DeadButton.hover.textColor    = Color.white;
            DeadButton.active.textColor   = Color.yellow;
            DeadButton.focused.textColor  = Color.yellow;
            DeadButton.fontSize           = 14;
            DeadButton.fontStyle          = FontStyle.Normal;

            DeadButtonRed = new GUIStyle(GUI.skin.button);
            DeadButtonRed.normal.background  = null;
            DeadButtonRed.hover.background   = null;
            DeadButtonRed.active.background  = null;
            DeadButtonRed.focused.background = null;
            DeadButtonRed.normal.textColor   = Color.red;
            DeadButtonRed.hover.textColor    = Color.yellow;
            DeadButtonRed.active.textColor   = Color.red;
            DeadButtonRed.focused.textColor  = Color.red;
            DeadButtonRed.fontSize           = 12;
            DeadButtonRed.fontStyle          = FontStyle.Bold;


            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Launchsite Editor", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21)))
                {
                    this.Close();
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(UIMain.tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            GUILayout.Box(selectedObject.model.title);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Site Name: ", GUILayout.Width(120));
            siteName = GUILayout.TextField(siteName, GUILayout.Height(19));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Transform: ", GUILayout.Width(120));
            GUILayout.Box("" + siteTrans);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Length: ", GUILayout.Width(120));
            stLength = GUILayout.TextField(stLength, GUILayout.Height(19));
            GUILayout.Label(" m");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Width: ", GUILayout.Width(120));
            stWidth = GUILayout.TextField(stWidth, GUILayout.Height(19));
            GUILayout.Label(" m");
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Site Category: ", GUILayout.Width(115));
            GUILayout.Label(siteCategory, GUILayout.Width(85));
            GUILayout.FlexibleSpace();
            GUI.enabled = !(siteCategory == "RocketPad");
            if (GUILayout.Button("RP", GUILayout.Width(25), GUILayout.Height(23)))
            {
                siteCategory = "RocketPad";
            }
            GUI.enabled = !(siteCategory == "Runway");
            if (GUILayout.Button("RW", GUILayout.Width(25), GUILayout.Height(23)))
            {
                siteCategory = "Runway";
            }
            GUI.enabled = !(siteCategory == "Helipad");
            if (GUILayout.Button("HP", GUILayout.Width(25), GUILayout.Height(23)))
            {
                siteCategory = "Helipad";
            }
            GUI.enabled = !(siteCategory == "Waterlaunch");
            if (GUILayout.Button("WA", GUILayout.Width(25), GUILayout.Height(23)))
            {
                siteCategory = "Waterlaunch";
            }
            GUI.enabled = !(siteCategory == "Other");
            if (GUILayout.Button("OT", GUILayout.Width(25), GUILayout.Height(23)))
            {
                siteCategory = "Other";
            }
            GUILayout.EndHorizontal();

            GUI.enabled = true;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Site Type: ", GUILayout.Width(120));
            if (siteType == SiteType.VAB)
            {
                GUILayout.Label("VAB", GUILayout.Width(40));
            }
            if (siteType == SiteType.SPH)
            {
                GUILayout.Label("SPH", GUILayout.Width(40));
            }
            if (siteType == SiteType.Any)
            {
                GUILayout.Label("Any", GUILayout.Width(40));
            }
            GUILayout.FlexibleSpace();
            GUI.enabled = !(siteType == (SiteType)0);
            if (GUILayout.Button("VAB", GUILayout.Height(23)))
            {
                siteType = SiteType.VAB;
            }
            GUI.enabled = !(siteType == (SiteType)1);
            if (GUILayout.Button("SPH", GUILayout.Height(23)))
            {
                siteType = SiteType.SPH;
            }
            GUI.enabled = !(siteType == (SiteType)2);
            if (GUILayout.Button("Any", GUILayout.Height(23)))
            {
                siteType = SiteType.Any;
            }
            GUILayout.EndHorizontal();

            GUI.enabled = true;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Author: ", GUILayout.Width(120));
            siteAuthor = GUILayout.TextField(siteAuthor, GUILayout.Height(19));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Open Cost: ", GUILayout.Width(120));
            stOpenCost = GUILayout.TextField(stOpenCost, GUILayout.Height(19));
            GUILayout.Label(" \\F");
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Close Value: ", GUILayout.Width(120));
            stCloseValue = GUILayout.TextField(stCloseValue, GUILayout.Height(19));
            GUILayout.Label(" \\F");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Recovery Factor: ", GUILayout.Width(120));
            stRecoveryFactor = GUILayout.TextField(stRecoveryFactor, GUILayout.Height(19));
            GUILayout.Label(" %");
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Effective Range: ", GUILayout.Width(120));
            stRecoveryRange = GUILayout.TextField(stRecoveryRange, GUILayout.Height(19));
            GUILayout.Label(" m");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Launch Refund: ", GUILayout.Width(120));
            stLaunchRefund = GUILayout.TextField(stLaunchRefund, GUILayout.Height(19));
            GUILayout.Label(" %");
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Site is hidden: ", GUILayout.Width(115));
            GUILayout.Label(siteHidden, GUILayout.Width(85));
            GUILayout.FlexibleSpace();
            GUI.enabled = !(siteHidden == "false");
            if (GUILayout.Button("No", GUILayout.Width(40), GUILayout.Height(23)))
            {
                siteHidden = "false";
            }
            GUI.enabled = !(siteHidden == "true");
            if (GUILayout.Button("Yes", GUILayout.Width(40), GUILayout.Height(23)))
            {
                siteHidden = "true";
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();

            //if (ILSConfig.DetectNavUtils ()) {
            // NavUtilities config generator
            GUILayout.BeginHorizontal();
            GUILayout.Label("ILS/HSI on (NavUtilities)", GUILayout.Width(115));
            GUILayout.Label(ILSActive, GUILayout.Width(85));
            GUILayout.FlexibleSpace();
            GUI.enabled = !(ILSActive == "false");
            if (GUILayout.Button("No", GUILayout.Width(40), GUILayout.Height(23)))
            {
                ILSActive = "false";
            }
            GUI.enabled = !(ILSActive == "true");
            if (GUILayout.Button("Yes", GUILayout.Width(40), GUILayout.Height(23)))
            {
                ILSActive = "true";
            }
            GUILayout.EndHorizontal();
            //}
            GUI.enabled = true;
            GUILayout.Label("Description: ");
            descScroll = GUILayout.BeginScrollView(descScroll);
            siteDesc   = GUILayout.TextArea(siteDesc, GUILayout.ExpandHeight(true));
            GUILayout.EndScrollView();

            GUI.enabled = true;
            GUILayout.BeginHorizontal();
            GUI.enabled = siteName.Length > 0;
            if (GUILayout.Button("Save", GUILayout.Width(115), GUILayout.Height(23)))
            {
                bool addToDB = false;
                if (!selectedObject.hasLauchSites)
                {
                    Log.Normal("Creating LaunchSite");
                    LaunchSite lsite = new LaunchSite();
                    selectedObject.launchSite = lsite;
                    Log.Normal("created; lsite = " + lsite + "; launch site = " + selectedObject.launchSite);
                    selectedObject.hasLauchSites   = true;
                    lsite.parentInstance           = selectedObject;
                    selectedObject.launchSite.body = selectedObject.CelestialBody;
                    addToDB = true;
                }

                string oldName     = selectedObject.launchSite.LaunchSiteName;
                string oldCategory = selectedObject.launchSite.Category;
                bool   oldState    = selectedObject.launchSite.ILSIsActive;

                selectedObject.launchSite.LaunchSiteName        = siteName;
                selectedObject.launchSite.LaunchSiteLength      = float.Parse(stLength);
                selectedObject.launchSite.LaunchSiteWidth       = float.Parse(stWidth);
                selectedObject.launchSite.LaunchSiteType        = siteType;
                selectedObject.launchSite.LaunchPadTransform    = siteTrans;
                selectedObject.launchSite.LaunchSiteDescription = siteDesc;
                selectedObject.launchSite.OpenCost           = float.Parse(stOpenCost);
                selectedObject.launchSite.CloseValue         = float.Parse(stCloseValue);
                selectedObject.launchSite.RecoveryFactor     = float.Parse(stRecoveryFactor);
                selectedObject.launchSite.RecoveryRange      = float.Parse(stRecoveryRange);
                selectedObject.launchSite.LaunchRefund       = float.Parse(stLaunchRefund);
                selectedObject.launchSite.OpenCloseState     = "Open";
                selectedObject.launchSite.Category           = siteCategory;
                selectedObject.launchSite.LaunchSiteIsHidden = bool.Parse(siteHidden);
                selectedObject.launchSite.ILSIsActive        = bool.Parse(ILSActive);
                selectedObject.launchSite.LaunchSiteAuthor   = siteAuthor;
                selectedObject.launchSite.refLat             = (float)selectedObject.RefLatitude;
                selectedObject.launchSite.refLon             = (float)selectedObject.RefLongitude;
                selectedObject.launchSite.refAlt             = selectedObject.RadiusOffset;

                if (ILSConfig.DetectNavUtils())
                {
                    Log.Normal("NavUtils detected");
                    Log.Debug("object: " + selectedObject);
                    Log.Debug("launchsite: " + selectedObject.launchSite);
                    Log.Debug("body: " + selectedObject.launchSite.body);

                    bool regenerateILSConfig = false;
                    Log.Debug("old name: " + oldName);
                    Log.Debug("new name: " + selectedObject.launchSite.LaunchSiteName);
                    if (oldName != null && !oldName.Equals(siteName))
                    {
                        ILSConfig.RenameSite(selectedObject.launchSite.LaunchSiteName, siteName);
                        regenerateILSConfig = true;
                    }

                    Log.Debug("old category: " + oldCategory);
                    if (oldCategory != null && !oldCategory.Equals(siteCategory))
                    {
                        ILSConfig.HandleCategoryChange(selectedObject.launchSite.Category,
                                                       siteCategory, selectedObject);
                        regenerateILSConfig = true;
                    }

                    bool state = bool.Parse(ILSActive);
                    Log.Normal("new state: " + state + "; old state: " + oldState);
                    if (oldState != state || regenerateILSConfig)
                    {
                        if (state)
                        {
                            ILSConfig.GenerateFullILSConfig(selectedObject);
                        }
                        else
                        {
                            ILSConfig.DropILSConfig(selectedObject.launchSite.name, true);
                        }
                    }
                }


                if (addToDB)
                {
                    KerbalKonstructs.instance.SaveInstanceByCfg(selectedObject.configPath);
                    LaunchSiteManager.RegisterLaunchSite(selectedObject.launchSite);
                }
                KerbalKonstructs.instance.SaveInstanceByCfg(selectedObject.configPath);
                this.Close();
            }
            GUI.enabled = true;
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel", GUILayout.Width(115), GUILayout.Height(23)))
            {
                this.Close();
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("NOTE: If a newly created launchsite object does not display when launched from, a restart of KSP will be required for the site to be correctly rendered.");

            GUILayout.Space(1);
            GUILayout.Box(UIMain.tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }