示例#1
0
 void OpenBase()
 {
     if (CareerUtils.isCareerGame && selectedSite.OpenCost > Funding.Instance.Funds)
     {
         MiscUtils.HUDMessage(KKLocalization.InsuficientFundsToOpenBase, 10, 3);
     }
     else
     {
         LaunchSiteManager.OpenLaunchSite(selectedSite);
         if (CareerUtils.isCareerGame)
         {
             //FIXME why is this cheating?
             Funding.Instance.AddFunds(-selectedSite.OpenCost, TransactionReasons.Cheating);
         }
     }
 }
        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();
            }
        }
示例#3
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));
        }
示例#4
0
        private 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("Selected Base", BoxNoBorder);

            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())
            {
                if (Range < 5000)
                {
                    LaunchSiteManager.getSiteOpenCloseState(Base, out sClosed, out fOpenCost);
                    fOpenCost /= 2f;

                    if (FlightGlobals.ActiveVessel.Landed && 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
                            {
                                LaunchSiteManager.OpenLaunchSite(LaunchSiteManager.GetLaunchSiteByName(Base));
                                if (MiscUtils.isCareerGame())
                                {
                                    Funding.Instance.AddFunds(-LaunchSiteManager.GetLaunchSiteByName(Base).OpenCost, TransactionReasons.Cheating);
                                }
                                smessage = Base + " opened";
                                MiscUtils.HUDMessage(smessage, 10, 2);
                            }
                        }
                    }

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

                    if (FlightGlobals.ActiveVessel.Landed && (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 5km 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);


            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)
                {
                    GUILayout.Label("No facilities within 5000m", LabelInfo);
                }


                if (bShowFacilities && allFacilities.Count > 0)
                {
                    scrollPos = GUILayout.BeginScrollView(scrollPos);
                    {
                        for (int i = 0; i < allFacilities.Count; i++)
                        {
                            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.SelectInstance(allFacilities[i], 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);
                }
            }
            else
            {
                GUILayout.Label("Nearby facilities can only be shown when landed.", LabelInfo);
                bShowFacilities = false;
            }

            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));
        }