コード例 #1
0
        void Start()
        {
            this.Log("Start, new game = " + TacLifeSupport.Instance.gameSettings.IsNewSave);
            if (HighLogic.CurrentGame.Parameters.CustomParams<TAC_SettingsParms>().enabled)
            {
                if (TacLifeSupport.Instance.gameSettings.IsNewSave)
                {
                    this.Log("New save detected!");
                    //TACMenuAppLToolBar.onAppLaunchToggle();
                    Vector2 anchormin = new Vector2(0.5f, 0.5f);
                    Vector2 anchormax = new Vector2(0.5f, 0.5f);
                    string msg =
                        "TAC LS Config Settings are now available via the KSP Settings - Difficulty Options Window.";
                    string title = "TAC Life Support";
                    UISkinDef skin = HighLogic.UISkin;
                    DialogGUIBase[] dialogGUIBase = new DialogGUIBase[1];
                    dialogGUIBase[0] = new DialogGUIButton("Ok", delegate { });
                    PopupDialog.SpawnPopupDialog(anchormin, anchormax,
                        new MultiOptionDialog(msg, title, skin, dialogGUIBase), false, HighLogic.UISkin, true,
                        string.Empty);
                    TacLifeSupport.Instance.gameSettings.IsNewSave = false;
                }

                AddLifeSupport als = new AddLifeSupport();
                als.run();
            }
            else
            {
                Destroy(this);
            }
        }
コード例 #2
0
        protected override void OnCompleted()
        {
            foreach (CelestialBody body in Database.instance.BodyList)
            {
                if (Database.instance.CelestialBodies[body].isResearched && Database.instance.CelestialBodies[body].researchState < 100)
                {
                    if (RBRange.WithinObsRange(body.transform))
                    {
                        ResearchBodiesController.Research(body, 10);
                        return;
                    }
                }
            }
            Vector2   anchormin = new Vector2(0.5f, 0.5f);
            Vector2   anchormax = new Vector2(0.5f, 0.5f);
            string    msg       = "Despite our best efforts, we were unable to find anything new that's interesting in the sky.";
            string    title     = "Research Bodies";
            UISkinDef skin      = HighLogic.UISkin;

            DialogGUIBase[] dialogGUIBase = new DialogGUIBase[1];
            dialogGUIBase[0] = new DialogGUIButton("Ok", delegate { });
            PopupDialog.SpawnPopupDialog(anchormin, anchormax,
                                         new MultiOptionDialog(title, msg, title, skin, dialogGUIBase), false, HighLogic.UISkin, true,
                                         string.Empty);
        }
コード例 #3
0
        /// <summary>
        /// Clear and recreate the list of constellations
        /// </summary>
        private void refreshList(List <short> freqs)
        {
            List <DialogGUIBase> rows = frequencyRowLayout.children;

            //deregister
            int size = rows.Count;

            for (int i = size - 1; i >= 0; i--)
            {
                DialogGUIBase thisChild = rows[i];
                if (!(thisChild is DialogGUIContentSizer)) // avoid if DialogGUIContentSizer is detected
                {
                    rows.RemoveAt(i);
                    thisChild.uiItem.gameObject.DestroyGameObjectImmediate();
                }
            }

            //create
            for (int i = 0; i < freqs.Count; i++)
            {
                rows.Add(createConstellationRow(freqs[i]));
            }

            //register
            Stack <Transform> stack = new Stack <Transform>();

            stack.Push(frequencyRowLayout.uiItem.gameObject.transform);
            for (int i = 0; i < rows.Count; i++)
            {
                if (!(rows[i] is DialogGUIContentSizer))         // avoid if DialogGUIContentSizer is detected
                {
                    rows[i].Create(ref stack, HighLogic.UISkin); // recursively create child's children
                }
            }
        }
コード例 #4
0
        void Start()
        {
            this.Log("Start, new game = " + TacLifeSupport.Instance.gameSettings.IsNewSave);
            if (HighLogic.CurrentGame.Parameters.CustomParams <TAC_SettingsParms>().enabled)
            {
                if (TacLifeSupport.Instance.gameSettings.IsNewSave)
                {
                    this.Log("New save detected!");
                    //TACMenuAppLToolBar.onAppLaunchToggle();
                    Vector2 anchormin = new Vector2(0.5f, 0.5f);
                    Vector2 anchormax = new Vector2(0.5f, 0.5f);
                    string  msg       =
                        "TAC LS Config Settings are now available via the KSP Settings - Difficulty Options Window.";
                    string          title         = "TAC Life Support";
                    UISkinDef       skin          = HighLogic.UISkin;
                    DialogGUIBase[] dialogGUIBase = new DialogGUIBase[1];
                    dialogGUIBase[0] = new DialogGUIButton("Ok", delegate { });
                    PopupDialog.SpawnPopupDialog(anchormin, anchormax,
                                                 new MultiOptionDialog(msg, title, skin, dialogGUIBase), false, HighLogic.UISkin, true,
                                                 string.Empty);
                    TacLifeSupport.Instance.gameSettings.IsNewSave = false;
                }

                AddLifeSupport als = new AddLifeSupport();
                als.run();
            }
            else
            {
                Destroy(this);
            }
        }
コード例 #5
0
ファイル: KCT_Flight.cs プロジェクト: todi/KCT
        public void RecoverVessel()
        {
            bool sph = (FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR);
            bool vab = KCT_Utilities.IsVabRecoveryAvailable();

            int cnt = 2;

            if (sph)
            {
                cnt++;
            }
            if (vab)
            {
                cnt++;
            }

            DialogGUIBase[] options = new DialogGUIBase[cnt];
            cnt = 0;
            if (sph)
            {
                options[cnt++] = new DialogGUIButton("Recover to SPH", RecoverToSPH);
            }
            if (vab)
            {
                options[cnt++] = new DialogGUIButton("Recover to VAB", RecoverToVAB);
            }
            options[cnt++] = new DialogGUIButton("Normal recovery", DoNormalRecovery);
            options[cnt]   = new DialogGUIButton("Cancel", Cancel);

            MultiOptionDialog diag = new MultiOptionDialog("scrapVesselPopup", "Do you want KCT to do the recovery?", "Kerbal Construction Time (KCT)", null, options: options);

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
        }
コード例 #6
0
ファイル: FSGUI.cs プロジェクト: KvaNTy/RP-0
        private void CancelCourse(ActiveCourse course)
        {
            DialogGUIBase[] options = new DialogGUIBase[3];
            options[0] = new DialogGUIFlexibleSpace();
            options[1] = new DialogGUIButton("Yes", () =>
            {
                // We "complete" the course but we didn't mark it as Completed, so it just releases the students and doesn't apply rewards
                course.CompleteCourse();
                CrewHandler.Instance.ActiveCourses.Remove(course);
                MaintenanceHandler.Instance?.UpdateUpkeep();
            });
            options[2] = new DialogGUIButton("No", () => { });
            var sb = new StringBuilder("Are you sure you want to cancel this course? The following students will cease study:");

            foreach (ProtoCrewMember stud in course.Students)
            {
                sb.AppendLine();
                sb.Append(stud.name);
            }
            var diag = new MultiOptionDialog("ConfirmCancelCourse", sb.ToStringAndRelease(), "Stop Course?",
                                             HighLogic.UISkin,
                                             new Rect(0.5f, 0.5f, 150f, 60f),
                                             new DialogGUIFlexibleSpace(),
                                             new DialogGUIHorizontalLayout(options));

            PopupDialog.SpawnPopupDialog(diag, false, HighLogic.UISkin);
        }
コード例 #7
0
        private void updateGroundStationGUIRow(string stationID)
        {
            if (this.currentContentType != ContentType.GROUNDSTATIONS)
            {
                return;
            }

            List <DialogGUIBase> rows = contentLayout.children;

            for (int i = 1; i < rows.Count; i++)
            {
                DialogGUIBase thisRow = rows[i];
                if (thisRow.OptionText.Equals(stationID))
                {
                    DialogGUIImage colorImage = thisRow.children[0] as DialogGUIImage;
                    DialogGUILabel nameLabel  = thisRow.children[1] as DialogGUILabel;
                    DialogGUILabel freqsLabel = thisRow.children[3] as DialogGUILabel;
                    CNCCommNetHome station    = CNCCommNetScenario.Instance.groundStations.Find(x => x.ID.Equals(stationID));
                    colorImage.uiItem.GetComponent <RawImage>().color = station.Color;
                    nameLabel.SetOptionText(station.stationName);
                    freqsLabel.SetOptionText(getFreqString(station.getFrequencyList()));

                    break;
                }
            }
        }
コード例 #8
0
        public void OpenConvertWindow()
        {
            CreateFolder();

            //convert the selected vessel to a craft file and save it in the ships folder for the save
            string dir = KSPUtil.ApplicationRootPath + "Ships/export/";

            //provide a list of all the craft we can import
            string[] files = System.IO.Directory.GetFiles(dir);
            int      count = files.Length;

            DialogGUIBase[] options = new DialogGUIBase[count + 1];
            for (int i = 0; i < count; i++)
            {
                int    select = i;
                string vname  = "";
                string vname1 = files[i].Split('/').Last();
                Localizer.TryGetStringByTag(vname1, out vname);
                if (vname == "" || vname == null)
                {
                    vname = vname1;
                }
                options[i] = new DialogGUIButton(vname, () => { ConvertToCraft(files[select]); });
            }
            options[count] = new DialogGUIButton("Close", Dummy);
            string msg = "Select a vessel to convert to a .craft file.";

            MultiOptionDialog a = new MultiOptionDialog("convertPopup", msg, "Convert Vessel to .craft", null, options);

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), a, false, HighLogic.UISkin);
        }
コード例 #9
0
        private DialogGUIBase DrawProgressionTab()
        {
            if (this.progress.Count == 0)
            {
                return(new DialogGUILabel("No technologies are being researched here."));
            }

            DialogGUIBase[] rows = new DialogGUIBase[this.progress.Count + 1];
            rows[0] = new DialogGUIHorizontalLayout(
                new DialogGUILabel(TextEffects.DialogHeading("Researching:"), 160),
                new DialogGUILabel(TextEffects.DialogHeading("Progress:"), 70),
                new DialogGUILabel(TextEffects.DialogHeading("Notes:"), 140)
                );

            for (int i = 0; i < this.progress.Count; ++i)
            {
                var field = this.progress[i];

                string fieldName = field.IsAtMaxTier
                    ? field.Category.DisplayName
                    : $"{field.TierBeingResearched.DisplayName()} {field.Category.DisplayName}";
                string progressText = field.HasProgress ? $"{100 * field.AccumulatedKerbalDays / field.KerbalDaysRequired:N}%" : "-";
                string notes        = field.KerbalDaysContributedPerDay > 0
                    ? $"{(field.KerbalDaysRequired - field.AccumulatedKerbalDays) / field.KerbalDaysContributedPerDay:N} days to go"
                    : field.WhyBlocked;

                rows[i + 1] = new DialogGUIHorizontalLayout(
                    new DialogGUILabel(fieldName, 160),
                    new DialogGUILabel(progressText, 70),
                    new DialogGUILabel(notes, 140));
            }

            return(new DialogGUIVerticalLayout(rows));
        }
コード例 #10
0
        private void cancelCourse(ActiveCourse course)
        {
            DialogGUIBase[] options = new DialogGUIBase[3];
            options[0] = new DialogGUIFlexibleSpace();
            options[1] = new DialogGUIButton("Yes", () =>
            {
                /* We "complete" the course but we didn't mark it as Completed, so it just releases the students and doesn't apply rewards */
                course.CompleteCourse();
            });
            options[2] = new DialogGUIButton("No", () => { });
            StringBuilder msg = new StringBuilder("Are you sure you want to cancel this course?  The following students will cease study:");

            foreach (ProtoCrewMember stud in course.Students)
            {
                msg.AppendLine();
                msg.Append(stud.name);
            }
            MultiOptionDialog diag = new MultiOptionDialog("ConfirmCancelCourse", msg.ToStringAndRelease(), "Stop Course?",
                                                           HighLogic.UISkin,
                                                           new Rect(0.5f, 0.5f, 150f, 60f),
                                                           new DialogGUIFlexibleSpace(),
                                                           new DialogGUIVerticalLayout(options));

            PopupDialog.SpawnPopupDialog(diag, false, HighLogic.UISkin);
        }
コード例 #11
0
        private void mapfilterChanged(MapViewFiltering.VesselTypeFilter filter)
        {
            if (this.currentContentType != ContentType.VESSELS)
            {
                return;
            }

            //clear vessel rows
            List <DialogGUIBase> rows = contentLayout.children;

            for (int i = rows.Count - 1; i >= 1; i--)
            {
                DialogGUIBase thisRow = rows[i];
                rows.RemoveAt(i);
                thisRow.uiItem.gameObject.DestroyGameObjectImmediate(); // necessary to free memory up
            }

            List <DialogGUIHorizontalLayout> newRows = populateVesselRows(filter);
            Stack <Transform> stack = new Stack <Transform>();     // some data on hierarchy of GUI components

            stack.Push(contentLayout.uiItem.gameObject.transform); // need the reference point of the parent GUI component for position and size
            for (int i = 0; i < newRows.Count; i++)
            {
                newRows[i].Create(ref stack, HighLogic.UISkin); // required to force the GUI creation
                rows.Add(newRows[i]);
            }
        }
コード例 #12
0
        private DialogGUIHorizontalLayout GetBoxes(string passingUi)
        {
            int arrayPointer = 0;

            DialogGUIBase[] horizontal = new DialogGUIBase[5];
            if (passingUi != "main")
            {
                horizontal[arrayPointer] = new DialogGUIButton("Budget", () => ActivateUi("main"));
                arrayPointer++;
            }
            if (passingUi != "facility")
            {
                horizontal[arrayPointer] = new DialogGUIButton("Construction", () => ActivateUi("facility"));
                arrayPointer++;
            }
            if (passingUi != "research")
            {
                horizontal[arrayPointer] = new DialogGUIButton("Research", () => ActivateUi("research"));
                arrayPointer++;
            }
            if (passingUi != "allocation")
            {
                horizontal[arrayPointer] = new DialogGUIButton("Allocation", () => ActivateUi("allocation"));
                arrayPointer++;
            }
            if (passingUi != "crew")
            {
                horizontal[arrayPointer] = new DialogGUIButton("Crew", () => ActivateUi("crew"));
                arrayPointer++;
            }
            horizontal[arrayPointer] = new DialogGUIButton("Close", ValidateAllocations, false);
            return(new DialogGUIHorizontalLayout(280, 35, horizontal));
        }
コード例 #13
0
        private void TryBackup()
        {
            Vector2   anchormin = new Vector2(0.5f, 2f);
            Vector2   anchormax = new Vector2(0.5f, 2f);
            UISkinDef skin      = HighLogic.UISkin;

            string msg;
            string title;

            if (!BackupSaves())
            {
                msg = "\nCannot create backuo\n\n" +
                      "Please consider making a manual backup of the saves";
                title = "Planetary Base System Updater";
            }
            else
            {
                msg   = "\nBackup successfully created at: \"Kerbal Space Program/" + backup_dir + "\"!\n";
                title = "Planetary Base System Updater";
            }

            DialogGUIBase[] dialogGUIBase = new DialogGUIBase[1];
            dialogGUIBase[0] = new DialogGUIButton("Ok", delegate { }, true);

            PopupDialog.SpawnPopupDialog(anchormin, anchormax,
                                         new MultiOptionDialog(msg, title, skin, dialogGUIBase), false, HighLogic.UISkin, true,
                                         string.Empty);
        }
コード例 #14
0
        public void ManualTracking()
        {
            KopernicusStar[] orderedStars = KopernicusStar.Stars.OrderBy(s => Vector3.Distance(vessel.transform.position, s.sun.position)).ToArray();
            Int32            stars        = orderedStars.Count();

            DialogGUIBase[] options = new DialogGUIBase[stars + 1];
            // Assemble the buttons
            options[0] = new DialogGUIButton(button_Auto, () => { _manualTracking = false; }, true);//Auto
            for (Int32 i = 0; i < stars; i++)
            {
                CelestialBody body = orderedStars[i].sun;
                options[i + 1] = new DialogGUIButton
                                 (
                    body.bodyDisplayName.Replace("^N", ""),
                    () => SetTrackingBody(body),
                    true
                                 );
            }

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog(
                                             "SelectTrackingBody",
                                             SelectBody_Msg, //Please select the Body you want to track with this Solar Panel.
                                             SelectBody,     //Select Tracking Body
                                             UISkinManager.GetSkin("MainMenuSkin"),
                                             options), false, UISkinManager.GetSkin("MainMenuSkin"));
        }
コード例 #15
0
        private DialogGUIHorizontalLayout createConstellationRow(Constellation thisConstellation)
        {
            Color color = Constellation.getColor(thisConstellation.frequency);

            DialogGUIImage        colorImage     = new DialogGUIImage(new Vector2(32, 32), Vector2.zero, thisConstellation.color, colorTexture);
            DialogGUILabel        constNameLabel = new DialogGUILabel(thisConstellation.name, 170, 12);
            DialogGUILabel        freqLabel      = new DialogGUILabel(Localizer.Format("#CNC_Generic_FrequencyLabel") + string.Format(": <color={0}>{1}</color>", UIUtils.colorToHex(color), thisConstellation.frequency), 100, 12); //Frequency
            DialogGUILabel        numSatsLabel   = new DialogGUILabel(Localizer.Format("#CNC_ConstellationControl_numSatsLabel", Constellation.countVessels(thisConstellation)), 75, 12);                                            //string.Format("{0} vessels", )
            DialogGUIButton       updateButton   = new DialogGUIButton(Localizer.Format("#CNC_Generic_Editbutton"), delegate { editConstellationClick(thisConstellation); }, 50, 32, false);                                         //"Edit"
            DialogGUIToggleButton toggleButton   = new DialogGUIToggleButton(thisConstellation.visibility, Localizer.Format("#CNC_Generic_Mapbutton"), delegate { toggleConstellationVisibility(thisConstellation); }, 45, 32);      //"Map"

            DialogGUIBase[] rowGUIBase = new DialogGUIBase[] { colorImage, constNameLabel, freqLabel, numSatsLabel, toggleButton, updateButton, null };
            if (thisConstellation.frequency == CNCSettings.Instance.PublicRadioFrequency)
            {
                rowGUIBase[rowGUIBase.Length - 1] = new DialogGUIButton(Localizer.Format("#CNC_Generic_Resetbutton"), resetPublicConstClick, 60, 32, false);//"Reset"
            }
            else
            {
                rowGUIBase[rowGUIBase.Length - 1] = new DialogGUIButton(Localizer.Format("#CNC_Generic_DeleteButton"), delegate { deleteConstellationClick(thisConstellation); }, 60, 32, false);//"Delete"
            }
            DialogGUIHorizontalLayout constellationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, rowGUIBase);

            constellationGroup.SetOptionText(thisConstellation.frequency.ToString()); //for quick identification
            return(constellationGroup);
        }
コード例 #16
0
        /// <summary>
        /// Refresh list of stats without closing and opening the window
        /// </summary>
        internal void RefreshStatsListLayout()
        {
            Stack <Transform> stack = new Stack <Transform>();       // some data on hierarchy of GUI components

            stack.Push(statsListLayout.uiItem.gameObject.transform); // need the reference point of the parent GUI component for position and size

            List <DialogGUIBase> rows = statsListLayout.children;

            // Clear list
            while (rows.Count > 0)
            {
                DialogGUIBase child = rows.ElementAt(0);              // Get child
                rows.RemoveAt(0);                                     // Drop row
                child.uiItem.gameObject.DestroyGameObjectImmediate(); // Free memory up
            }

            // Add rows
            if (currentController != null)
            {
                List <DisplayedSystemCheckResult[]> resultsList = currentController.GetDisplayedSystemCheckResults();

                for (int i = 0; i < resultsList.Count; i++)
                {
                    rows.Add(CreateListLayoutRow(resultsList[i]));
                    rows.Last().Create(ref stack, CommonWindowProperties.ActiveSkin); // required to force the GUI creation
                }
            }
            rows.Add(new DialogGUISpace(3f));
            rows.Last().Create(ref stack, CommonWindowProperties.ActiveSkin); // required to force the GUI creation
        }
コード例 #17
0
 private DialogGUIBase[] PaddedLabel(string stringToPad)
 {
     DialogGUIBase[] paddedLayout = new DialogGUIBase[2];
     paddedLayout[0] = new DialogGUISpace(10);
     paddedLayout[1] = new DialogGUILabel(stringToPad);
     return(paddedLayout);
 }
コード例 #18
0
        [KSPEvent(active = true, guiActive = false, guiName = "#Kopernicus_UI_SelectBody")]//Select Tracking Body
        public void ManualTracking()
        {
            // Assemble the buttons
            Int32 stars = KopernicusStar.Stars.Count;

            DialogGUIBase[] options = new DialogGUIBase[stars + 1];
            options[0] = new DialogGUIButton(button_Auto, () => { _manualTracking = false; }, true);//Auto
            for (Int32 i = 0; i < stars; i++)
            {
                CelestialBody body = KopernicusStar.Stars[i].sun;
                options[i + 1] = new DialogGUIButton
                                 (
                    body.bodyDisplayName.Replace("^N", ""),
                    () =>
                {
                    for (int n = SPs?.Length ?? 0; n > 0; n--)
                    {
                        ModuleDeployableSolarPanel SP = SPs[n - 1];
                        _manualTracking = true;
                        SP.trackingBody = body;
                        SP.GetTrackingBodyTransforms();
                    }
                },
                    true
                                 );
            }

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog(
                                             "SelectTrackingBody",
                                             SelectBody_Msg, //Please select the Body you want to track with this Solar Panel.
                                             SelectBody,     //Select Tracking Body
                                             UISkinManager.GetSkin("MainMenuSkin"),
                                             options), false, UISkinManager.GetSkin("MainMenuSkin"));
        }
コード例 #19
0
 //
 private MultiOptionDialog CreateDialog()
 {
     //Create Fields
     List<DialogGUIBase> dialogBase = new List<DialogGUIBase>();
     DialogGUIBase[] scrollList = new DialogGUIBase[bodylist.Count];
     scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true);
     TechLevel tLev = new TechLevel();
コード例 #20
0
        private int deleteConstellationGUIRow(Constellation thisConstellation)
        {
            if (this.currentContentType != ContentType.CONSTELLATIONS)
            {
                return(-1);
            }

            List <DialogGUIBase> rows = contentLayout.children;

            for (int i = 2; i < rows.Count; i++)
            {
                DialogGUIBase thisRow = rows[i];
                if (thisRow.OptionText.Equals(thisConstellation.frequency.ToString()))
                {
                    rows.RemoveAt(i);                                     // drop from the scrolllist rows
                    for (int j = thisRow.children.Count - 1; j >= 0; j--) // necessary to free memory up
                    {
                        thisRow.children[j].uiItem.gameObject.DestroyGameObjectImmediate();
                    }
                    thisRow.uiItem.gameObject.DestroyGameObjectImmediate();
                    return(i);
                }
            }

            return(-1);
        }
コード例 #21
0
        protected override void OnCompleted()
        {
            List <CelestialBody> PotentialDiscovery = new List <CelestialBody>();

            foreach (CelestialBody body in Database.instance.BodyList)
            {
                if (!Database.instance.CelestialBodies[body].isResearched && RBRange.WithinObsRange(body.transform))
                {
                    PotentialDiscovery.Add(body);
                }
            }
            if (PotentialDiscovery.Count > 0)
            {
                int           discovered = Random.Range(0, PotentialDiscovery.Count - 1);
                bool          withParent;
                CelestialBody parentBody;
                ResearchBodiesController.FoundBody(Database.instance.RB_SettingsParms.ScienceReward, PotentialDiscovery[discovered], out withParent, out parentBody);
                return;
            }
            Vector2   anchormin = new Vector2(0.5f, 0.5f);
            Vector2   anchormax = new Vector2(0.5f, 0.5f);
            string    msg       = "Despite our best efforts, we were unable to find anything intersting in the sky.";
            string    title     = "Research Bodies";
            UISkinDef skin      = HighLogic.UISkin;

            DialogGUIBase[] dialogGUIBase = new DialogGUIBase[1];
            dialogGUIBase[0] = new DialogGUIButton("Ok", delegate { });
            PopupDialog.SpawnPopupDialog(anchormin, anchormax,
                                         new MultiOptionDialog(title, msg, title, skin, dialogGUIBase), false, HighLogic.UISkin, true,
                                         string.Empty);
        }
コード例 #22
0
        private void updateConstellationGUIRow(short updatedfrequency, short previousFrequency)
        {
            if (this.currentContentType != ContentType.CONSTELLATIONS)
            {
                return;
            }

            List <DialogGUIBase> rows = contentLayout.children;

            for (int i = 2; i < rows.Count; i++)
            {
                DialogGUIBase thisRow = rows[i];
                if (thisRow.OptionText.Equals(updatedfrequency.ToString()) || thisRow.OptionText.Equals(previousFrequency.ToString()))
                {
                    DialogGUIImage colorImage  = thisRow.children[0] as DialogGUIImage;
                    DialogGUILabel nameLabel   = thisRow.children[1] as DialogGUILabel;
                    DialogGUILabel freqLabel   = thisRow.children[2] as DialogGUILabel;
                    DialogGUILabel vesselLabel = thisRow.children[3] as DialogGUILabel;

                    Constellation updatedConstellation = CNCCommNetScenario.Instance.constellations.Find(x => x.frequency == updatedfrequency);
                    colorImage.uiItem.GetComponent <RawImage>().color = updatedConstellation.color;
                    nameLabel.SetOptionText(updatedConstellation.name);
                    freqLabel.SetOptionText(Localizer.Format("#CNC_Generic_FrequencyLabel") + string.Format(": <color={0}>{1}</color>", UIUtils.colorToHex(updatedConstellation.color), updatedConstellation.frequency)); //Frequency
                    vesselLabel.SetOptionText(Localizer.Format("#CNC_ConstellationControl_numSatsLabel", Constellation.countVessels(updatedConstellation)));                                                              // + " vessels"

                    thisRow.SetOptionText(updatedConstellation.frequency.ToString());
                    break;
                }
            }
        }
コード例 #23
0
        /// <summary>
        /// Refresh list of vessels without reloading the list of controllers
        /// </summary>
        internal void RefreshVesselListLayout()
        {
            lock (refreshLock)                                            // Only one refresh at a time
            {
                Stack <Transform> stack = new Stack <Transform>();        // some data on hierarchy of GUI components
                stack.Push(vesselListLayout.uiItem.gameObject.transform); // need the reference point of the parent GUI component for position and size

                List <DialogGUIBase> rows = vesselListLayout.children;

                // Clear list. We are skiping DialogGUIContentSizer
                while (rows.Count > 1)
                {
                    DialogGUIBase child = rows.ElementAt(1);              // Get child
                    rows.RemoveAt(1);                                     // Drop row
                    child.uiItem.gameObject.DestroyGameObjectImmediate(); // Free memory up
                }

                // Add rows
                foreach (BVController controller in BonVoyage.Instance.BVControllers.Values)
                {
                    controller.OnStateChanged -= OnControllerStateChanged; // Clear possible event
                    DialogGUIHorizontalLayout row = CreateListLayoutRow(controller);
                    if (row != null)
                    {
                        rows.Add(row);
                        rows.Last().Create(ref stack, CommonWindowProperties.ActiveSkin); // required to force the GUI creation
                    }
                }
            }
        }
コード例 #24
0
        private PopupDialog DrawResearchUi()
        {
            padding = 0;
            float scienceCount = 0;
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            innerElements.Add(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true));
            innerElements.Add(new DialogGUISpace(10));
            if (ResearchManager.Instance.ProcessingScience.Count == 0)
            {
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("No research in progress", false)));
            }
            for (int i = 0; i < ResearchManager.Instance.ProcessingScience.Count; i++)
            {
                ScienceEvent se = ResearchManager.Instance.ProcessingScience.ElementAt(i).Value;
                if (se.IsComplete)
                {
                    continue;
                }
                scienceCount += se.RemainingScience;
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel(se.UiName + ": " + Math.Round(se.OriginalScience - se.RemainingScience, 1) + "/" + Math.Round(se.OriginalScience, 1), false)));
            }

            dialogElements.Add(new DialogGUIScrollList(new Vector2(300, 300), false, true, new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.UpperLeft, innerElements.ToArray())));
            DialogGUIBase[] horizontal = new DialogGUIBase[3];
            horizontal[0] = new DialogGUILabel("Processing Science: " + Math.Round(scienceCount, 1));
            horizontal[1] = new DialogGUILabel("|");
            double scienceOutput = ResearchManager.Instance.ThisMonthsBudget / SettingsClass.Instance.ScienceMultiplier * ResearchManager.Instance.ScienceMultiplier;

            horizontal[2] = new DialogGUILabel("Research Output: " + Math.Round(scienceOutput, 1));
            dialogElements.Add(new DialogGUIHorizontalLayout(horizontal));
            dialogElements.Add(GetBoxes("research"));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("ResearchDialog", "", "Bureaucracy: Research", UISkinManager.GetSkin("MainMenuSkin"), GetRect(dialogElements), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")));
        }
コード例 #25
0
 private DialogGUIBase[] PaddedLabel(string stringToPad, bool largePrint)
 {
     DialogGUIBase[] paddedLayout = new DialogGUIBase[2];
     paddedLayout[0] = new DialogGUISpace(10);
     EvaluatePadding(stringToPad);
     paddedLayout[1] = new DialogGUILabel(stringToPad, MessageStyle(largePrint));
     return(paddedLayout);
 }
コード例 #26
0
        /// <summary>
        /// Get layout of the list of vessels
        /// </summary>
        /// <returns></returns>
        internal DialogGUIVerticalLayout GetVesselListLayout()
        {
            // Count disabled controllers
            int disabledControllersCount = 0;
            int controllersCount         = BonVoyage.Instance.BVControllers.Count();

            foreach (BVController controller in BonVoyage.Instance.BVControllers.Values)
            {
                if (controller.Shutdown)
                {
                    disabledControllersCount++;
                }
            }

            int listLength = 1;

            if (activeControllersChecked)
            {
                listLength += controllersCount - disabledControllersCount;
            }
            if (disabledControllersChecked)
            {
                listLength += disabledControllersCount;
            }

            DialogGUIBase[] list = new DialogGUIBase[listLength];
            list[0] = new DialogGUIContentSizer(UnityEngine.UI.ContentSizeFitter.FitMode.Unconstrained, UnityEngine.UI.ContentSizeFitter.FitMode.PreferredSize, true);

            if (listLength > 1) // anything is checked
            {
                int counter = 1;
                foreach (BVController controller in BonVoyage.Instance.BVControllers.Values)
                {
                    DialogGUIHorizontalLayout row = CreateListLayoutRow(controller);
                    if (row != null)
                    {
                        list[counter] = row;
                        counter++;
                        if (counter >= listLength) // break if we are at the end of list
                        {
                            break;
                        }
                    }
                }
            }

            vesselListLayout = new DialogGUIVerticalLayout(
                CommonWindowProperties.mainListMinWidth,
                CommonWindowProperties.mainListMinHeight,
                CommonWindowProperties.mainWindowSpacing,
                CommonWindowProperties.mainListPadding,
                TextAnchor.UpperLeft,
                list
                );

            return(vesselListLayout);
        }
コード例 #27
0
        public static void PopUpVesselError(List <KCT_BuildListVessel> errored)
        {
            DialogGUIBase[] options = new DialogGUIBase[2];
            options[0] = new DialogGUIButton("Understood", () => { });
            // new DialogGUIBase("Understood", () => { }); //do nothing and close the window
            options[1] = new DialogGUIButton("Delete Vessels", () =>
            {
                foreach (KCT_BuildListVessel blv in errored)
                {
                    blv.RemoveFromBuildList();
                    KCT_Utilities.AddFunds(blv.cost, TransactionReasons.VesselRollout);
                    //remove any associated recon_rollout
                }
            });

            string txt        = "The following KCT vessels contain missing or invalid parts and have been quarantined. Either add the missing parts back into your game or delete the vessels. A file containing the ship names and missing parts has been added to your save folder.\n";
            string txtToWrite = "";

            foreach (KCT_BuildListVessel blv in errored)
            {
                txt        += blv.shipName + "\n";
                txtToWrite += blv.shipName + "\n";
                txtToWrite += String.Join("\n", blv.MissingParts().ToArray());
                txtToWrite += "\n\n";
            }

            //HighLogic.SaveFolder
            //make new file for missing ships
            string filename = KSPUtil.ApplicationRootPath + "/saves/" + HighLogic.SaveFolder + "/missingParts.txt";

            System.IO.File.WriteAllText(filename, txtToWrite);


            //remove all rollout and recon items since they're invalid without the ships
            foreach (KCT_BuildListVessel blv in errored)
            {
                //remove any associated recon_rollout
                foreach (KCT_KSC ksc in KCT_GameStates.KSCs)
                {
                    for (int i = 0; i < ksc.Recon_Rollout.Count; i++)
                    {
                        KCT_Recon_Rollout rr = ksc.Recon_Rollout[i];
                        if (rr.associatedID == blv.id.ToString())
                        {
                            ksc.Recon_Rollout.Remove(rr);
                            i--;
                        }
                    }
                }
            }


            MultiOptionDialog diag = new MultiOptionDialog("missingPartsPopup", txt, "Vessels Contain Missing Parts", null, options);

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
            //PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Vessel Contains Missing Parts", "The KCT vessel " + errored.shipName + " contains missing or invalid parts. You will not be able to do anything with the vessel until the parts are available again.", "Understood", false, HighLogic.UISkin);
        }
コード例 #28
0
        private void SpawnConfirmationDialog()
        {
            var options = new DialogGUIBase[] {
                new DialogGUIButton("Yes", Boom),
                new DialogGUIButton("No", () => {})
            };
            var dialog = new MultiOptionDialog("ConfirmRangeSafety", "Destroy Vessel?", "Range Safety", HighLogic.UISkin, 300, options);

            PopupDialog.SpawnPopupDialog(dialog, true, HighLogic.UISkin);
        }
コード例 #29
0
ファイル: TrackingStationAddon.cs プロジェクト: ryanc55/RP-0
        private void KCT_Recovery()
        {
            DialogGUIBase[] options = new DialogGUIBase[2];
            options[0] = new DialogGUIButton("Go to Flight scene", Fly);
            options[1] = new DialogGUIButton("Cancel", () => { });

            var diag = new MultiOptionDialog("scrapVesselPopup", "KCT can only recover vessels in the Flight scene", "Recover Vessel", null, options: options);

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
        }
コード例 #30
0
ファイル: KCT_Flight.cs プロジェクト: tivec/KCT
        public void RecoverVessel()
        {
            bool sph = (FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR);
            bool vab = KCT_Utilities.IsVabRecoveryAvailable();

            int  cnt           = 2;
            bool kerbInExtSeat = KCT_Utilities.KerbalInExternalSeat(FlightGlobals.ActiveVessel);

            if (!FlightGlobals.ActiveVessel.isEVA && !kerbInExtSeat)
            {
                if (sph)
                {
                    cnt++;
                }
                if (vab)
                {
                    cnt++;
                }
            }
            DialogGUIBase[] options = new DialogGUIBase[cnt];
            cnt = 0;
            string msg = "Do you want KCT to do the recovery?";

            if (!FlightGlobals.ActiveVessel.isEVA)
            {
                if (!kerbInExtSeat)
                {
                    if (sph)
                    {
                        options[cnt++] = new DialogGUIButton("Recover to SPH", RecoverToSPH);
                    }
                    if (vab)
                    {
                        options[cnt++] = new DialogGUIButton("Recover to VAB", RecoverToVAB);
                    }
                }
                else
                {
                    msg = "KCT cannot recover if any kerbals are in external seats";
                }
                options[cnt++] = new DialogGUIButton("Normal recovery", DoNormalRecovery);
            }
            else
            {
                options[cnt++] = new DialogGUIButton("Recover", DoNormalRecovery);
            }
            options[cnt] = new DialogGUIButton("Cancel", Cancel);

            MultiOptionDialog diag = new MultiOptionDialog("scrapVesselPopup",
                                                           msg,
                                                           "Kerbal Construction Time (KCT)",
                                                           null, options: options);

            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
        }
コード例 #31
0
        protected DialogGUIBase DrawTabbedDialog()
        {
            DialogGUIBase[] buttons = new DialogGUIBase[this.allTabTitles.Length];
            for (int i = 0; i < buttons.Length; ++i)
            {
                var thisTab = this.allTabTitles[i];
                buttons[i] = new DialogGUIToggleButton(this.selectedTabTitle == thisTab, thisTab, (isSet) => { this.selectedTabTitle = thisTab; this.Redraw(); }, w: buttonWidth, h: buttonHeight);
            }

            return(new DialogGUIVerticalLayout(new DialogGUIHorizontalLayout(buttons), this.DrawTab(this.selectedTabTitle)));
        }
コード例 #32
0
        private static void DrawBLPlusWindow(int windowID)
        {
            //bLPlusPosition.xMax = buildListWindowPosition.xMin;
            //bLPlusPosition.width = 100;
            bLPlusPosition.yMin = buildListWindowPosition.yMin;
            bLPlusPosition.height = 225;
            //bLPlusPosition.height = bLPlusPosition.yMax - bLPlusPosition.yMin;
            KCT_BuildListVessel b = KCT_Utilities.FindBLVesselByID(IDSelected);
            GUILayout.BeginVertical();
            string launchSite = b.launchSite;
            if (launchSite == "LaunchPad")
            {
                if (b.launchSiteID >= 0)
                    launchSite = b.KSC.LaunchPads[b.launchSiteID].name;
                else
                    launchSite = b.KSC.ActiveLPInstance.name;
            }
            KCT_Recon_Rollout rollout = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollout, launchSite);
            bool onPad = rollout != null && rollout.AsBuildItem().IsComplete() && rollout.associatedID == b.id.ToString();
            //This vessel is rolled out onto the pad
            if (!onPad && GUILayout.Button("Select LaunchSite"))
            {
                string launchType = b.type == KCT_BuildListVessel.ListType.VAB ? "RocketPad" : "Runway";
                launchSites = KCT_Utilities.GetAllOpenKKLaunchSites(launchType);
                launchSites.AddRange(KCT_Utilities.GetAllOpenKKLaunchSites("Other"));
                if (b.type == KCT_BuildListVessel.ListType.SPH)
                    launchSites.AddRange(KCT_Utilities.GetAllOpenKKLaunchSites("Helipad"));
                showBLPlus = false;
                showLaunchSiteSelector = true;
            }
            if (!onPad && GUILayout.Button("Scrap"))
            {
                InputLockManager.SetControlLock(ControlTypes.KSC_ALL, "KCTPopupLock");
                DialogGUIBase[] options = new DialogGUIBase[2];
                options[0] = new DialogGUIButton("Yes", ScrapVessel);
                options[1] = new DialogGUIButton("No", DummyVoid);
                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", "Scrap Vessel", null, 300, options);
                PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
                showBLPlus = false;
                ResetBLWindow();
            }
            if (!onPad && GUILayout.Button("Edit"))
            {
                showBLPlus = false;
                editorWindowPosition.height = 1;
                string tempFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/Ships/temp.craft";
                b.shipNode.Save(tempFile);
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                KCT_GameStates.editedVessel = b;
                KCT_GameStates.EditorShipEditingMode = true;
                KCT_GameStates.delayStart = true;

                InputLockManager.SetControlLock(ControlTypes.EDITOR_EXIT, "KCTEditExit");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_LOAD, "KCTEditLoad");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_NEW, "KCTEditNew");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_LAUNCH, "KCTEditLaunch");

                KCT_GameStates.EditedVesselParts.Clear();
                foreach (ConfigNode node in b.ExtractedPartNodes)
                {
                    string name = KCT_Utilities.PartNameFromNode(node) + KCT_Utilities.GetTweakScaleSize(node);
                    if (!KCT_GameStates.EditedVesselParts.ContainsKey(name))
                        KCT_GameStates.EditedVesselParts.Add(name, 1);
                    else
                        ++KCT_GameStates.EditedVesselParts[name];
                }

                //EditorDriver.StartAndLoadVessel(tempFile);
                EditorDriver.StartAndLoadVessel(tempFile, b.type == KCT_BuildListVessel.ListType.VAB ? EditorFacility.VAB : EditorFacility.SPH);
            }
            if (GUILayout.Button("Rename"))
            {
                centralWindowPosition.width = 360;
                centralWindowPosition.x = (Screen.width - 360) / 2;
                centralWindowPosition.height = 1;
                showBuildList = false;
                showBLPlus = false;
                showRename = true;
                newName = b.shipName;
                renamingLaunchPad = false;
                //newDesc = b.getShip().shipDescription;
            }
            if (GUILayout.Button("Duplicate"))
            {
                KCT_Utilities.AddVesselToBuildList(b.NewCopy(true), b.InventoryParts.Count > 0);
            }
            if (KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()) != null && GUILayout.Button("Rollback"))
            {
                KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()).SwapRolloutType();
            }
            if (!b.isFinished && GUILayout.Button("Warp To"))
            {
                KCT_GameStates.targetedItem = b;
                KCT_GameStates.canWarp = true;
                KCT_Utilities.RampUpWarp(b);
                KCT_GameStates.warpInitiated = true;
                showBLPlus = false;
               /* if (b.buildRate > 0)
                {
                    TimeWarp.fetch.WarpTo(Planetarium.GetUniversalTime() + b.timeLeft, KCT_GameStates.settings.MaxTimeWarp, 1);
                }*/
            }
            if (!b.isFinished && GUILayout.Button("Move to Top"))
            {
                if (b.type == KCT_BuildListVessel.ListType.VAB)
                {
                    b.RemoveFromBuildList();
                    KCT_GameStates.ActiveKSC.VABList.Insert(0, b);
                }
                else if (b.type == KCT_BuildListVessel.ListType.SPH)
                {
                    b.RemoveFromBuildList();
                    KCT_GameStates.ActiveKSC.SPHList.Insert(0, b);
                }
            }
            if (!b.isFinished && GUILayout.Button("Rush Build 10%\n√" + Math.Round(0.2 * b.GetTotalCost())))
            {
                double cost = b.GetTotalCost();
                cost *= 0.2;
                double remainingBP = b.buildPoints - b.progress;
                if (Funding.Instance.Funds >= cost)
                {
                    b.AddProgress(remainingBP * 0.1);
                    KCT_Utilities.SpendFunds(cost, TransactionReasons.None);
                }

            }
            if (GUILayout.Button("Close"))
            {
                showBLPlus = false;
            }
            GUILayout.EndVertical();
            float width = bLPlusPosition.width;
            bLPlusPosition.x = buildListWindowPosition.x - width;
            bLPlusPosition.width = width;
        }
コード例 #33
0
        public static void PopUpVesselError(List<KCT_BuildListVessel> errored)
        {
            DialogGUIBase[] options = new DialogGUIBase[2];
            options[0] = new DialogGUIButton("Understood", () => { });
               // new DialogGUIBase("Understood", () => { }); //do nothing and close the window
            options[1] = new DialogGUIButton("Delete Vessels", () =>
            {
                foreach (KCT_BuildListVessel blv in errored)
                {
                    blv.RemoveFromBuildList();
                    KCT_Utilities.AddFunds(blv.cost, TransactionReasons.VesselRollout);
                    //remove any associated recon_rollout
                }
            });

            string txt = "The following KCT vessels contain missing or invalid parts and have been quarantined. Either add the missing parts back into your game or delete the vessels. A file containing the ship names and missing parts has been added to your save folder.\n";
            string txtToWrite = "";
            foreach (KCT_BuildListVessel blv in errored)
            {
                txt += blv.shipName + "\n";
                txtToWrite += blv.shipName+"\n";
                txtToWrite += String.Join("\n", blv.MissingParts().ToArray());
                txtToWrite += "\n\n";
            }

            //HighLogic.SaveFolder
            //make new file for missing ships
            string filename = KSPUtil.ApplicationRootPath + "/saves/" + HighLogic.SaveFolder + "/missingParts.txt";
            System.IO.File.WriteAllText(filename, txtToWrite);

            //remove all rollout and recon items since they're invalid without the ships
            foreach (KCT_BuildListVessel blv in errored)
            {
                //remove any associated recon_rollout
                foreach (KCT_KSC ksc in KCT_GameStates.KSCs)
                {
                    for (int i = 0; i < ksc.Recon_Rollout.Count; i++)
                    {
                        KCT_Recon_Rollout rr = ksc.Recon_Rollout[i];
                        if (rr.associatedID == blv.id.ToString())
                        {
                            ksc.Recon_Rollout.Remove(rr);
                            i--;
                        }
                    }
                }
            }

            MultiOptionDialog diag = new MultiOptionDialog(txt, "Vessels Contain Missing Parts", null, options);
            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
            //PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Vessel Contains Missing Parts", "The KCT vessel " + errored.shipName + " contains missing or invalid parts. You will not be able to do anything with the vessel until the parts are available again.", "Understood", false, HighLogic.UISkin);
        }
コード例 #34
0
ファイル: KCT_GUI.cs プロジェクト: Kerbas-ad-astra/KCT
        private static void DrawEditorGUI(int windowID)
        {
            GUILayout.BeginVertical();
            //GUILayout.Label("Current KSC: " + KCT_GameStates.ActiveKSC.KSCName);
            if (!KCT_GameStates.EditorShipEditingMode) //Build mode
            {
                double buildTime = KCT_GameStates.EditorBuildTime;
                KCT_BuildListVessel.ListType type = EditorLogic.fetch.launchSiteName == "LaunchPad" ? KCT_BuildListVessel.ListType.VAB : KCT_BuildListVessel.ListType.SPH;
                //GUILayout.Label("Total Build Points (BP):", GUILayout.ExpandHeight(true));
                //GUILayout.Label(Math.Round(buildTime, 2).ToString(), GUILayout.ExpandHeight(true));
                GUILayout.BeginHorizontal();
                GUILayout.Label("Build Time at ");
                if (buildRateForDisplay == null) buildRateForDisplay = KCT_Utilities.GetBuildRate(0, type, null).ToString();
                buildRateForDisplay = GUILayout.TextField(buildRateForDisplay, GUILayout.Width(75));
                GUILayout.Label(" BP/s:");
                List<double> rates = new List<double>();
                if (type == KCT_BuildListVessel.ListType.VAB) rates = KCT_Utilities.BuildRatesVAB(null);
                else rates = KCT_Utilities.BuildRatesSPH(null);
                double bR;
                if (double.TryParse(buildRateForDisplay, out bR))
                {
                    if (GUILayout.Button("*", GUILayout.ExpandWidth(false)))
                    {
                        rateIndexHolder = (rateIndexHolder + 1) % rates.Count;
                        bR = rates[rateIndexHolder];
                        if (bR > 0)
                            buildRateForDisplay = bR.ToString();
                        else
                        {
                            rateIndexHolder = (rateIndexHolder + 1) % rates.Count;
                            bR = rates[rateIndexHolder];
                            buildRateForDisplay = bR.ToString();
                        }
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.Label(MagiCore.Utilities.GetFormattedTime(buildTime / bR));
                }
                else
                {
                    GUILayout.EndHorizontal();
                    GUILayout.Label("Invalid Build Rate");
                }

                if (KCT_GameStates.EditorRolloutCosts > 0)
                    GUILayout.Label("Rollout Cost: " + Math.Round(KCT_GameStates.EditorRolloutCosts, 1));

                bool useHolder = useInventory;
                useInventory = GUILayout.Toggle(useInventory, " Use parts from inventory?");
                if (useInventory != useHolder) KCT_Utilities.RecalculateEditorBuildTime(EditorLogic.fetch.ship);

                if (!KCT_GameStates.settings.OverrideLaunchButton)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Build"))
                    {
                        KCT_Utilities.AddVesselToBuildList(useInventory);
                        SwitchCurrentPartCategory();
                        KCT_Utilities.RecalculateEditorBuildTime(EditorLogic.fetch.ship);
                    }
                    if (KCT_PresetManager.Instance.ActivePreset.generalSettings.Simulations && GUILayout.Button("Simulate"))
                    {
                        simulationConfigPosition.height = 1;
                        EditorLogic.fetch.Lock(true, true, true, "KCTGUILock");
                        showSimConfig = true;
                    }
                    GUILayout.EndHorizontal();
                }
                if (GUILayout.Button("Show/Hide Build List"))
                {
                    showBuildList = !showBuildList;
                }

                if (GUILayout.Button("Part Inventory"))
                {
                    showInventory = !showInventory;
                    editorWindowPosition.width = 275;
                    editorWindowPosition.height = 135;
                }
            }
            else //Edit mode
            {
                if (showInventory) //The part inventory is not shown in the editor mode
                {
                    showInventory = false;
                    editorWindowPosition.width = 275;
                    editorWindowPosition.height = 1;
                }

                KCT_BuildListVessel ship = KCT_GameStates.editedVessel;
                if (finishedShipBP < 0 && ship.isFinished)
                    finishedShipBP = KCT_Utilities.GetBuildTime(ship.ExtractedPartNodes, true, ship.InventoryParts);
                double origBP = ship.isFinished ? finishedShipBP : ship.buildPoints; //If the ship is finished, recalculate times. Else, use predefined times.
                double buildTime = KCT_GameStates.EditorBuildTime;
                double difference = Math.Abs(buildTime - origBP);
                double progress;
                if (ship.isFinished) progress = origBP;
                else progress = ship.progress;
                double newProgress = Math.Max(0, progress - (1.1 * difference));
                //GUILayout.Label("Original: " + Math.Max(0, Math.Round(progress, 2)) + "/" + Math.Round(origBP, 2) + " BP (" + Math.Max(0, Math.Round(100 * (progress / origBP), 2)) + "%)");
                GUILayout.Label("Original: " + Math.Max(0, Math.Round(100 * (progress / origBP), 2)) + "%");
                //GUILayout.Label("Edited: " + Math.Round(newProgress, 2) + "/" + Math.Round(buildTime, 2) + " BP (" + Math.Round(100 * newProgress / buildTime, 2) + "%)");
                GUILayout.Label("Edited: " + Math.Round(100 * newProgress / buildTime, 2) + "%");

                KCT_BuildListVessel.ListType type = EditorLogic.fetch.launchSiteName == "LaunchPad" ? KCT_BuildListVessel.ListType.VAB : KCT_BuildListVessel.ListType.SPH;
                GUILayout.BeginHorizontal();
                GUILayout.Label("Build Time at ");
                if (buildRateForDisplay == null) buildRateForDisplay = KCT_Utilities.GetBuildRate(0, type, null).ToString();
                buildRateForDisplay = GUILayout.TextField(buildRateForDisplay, GUILayout.Width(75));
                GUILayout.Label(" BP/s:");
                List<double> rates = new List<double>();
                if (ship.type == KCT_BuildListVessel.ListType.VAB) rates = KCT_Utilities.BuildRatesVAB(null);
                else rates = KCT_Utilities.BuildRatesSPH(null);
                double bR;
                if (double.TryParse(buildRateForDisplay, out bR))
                {
                    if (GUILayout.Button("*", GUILayout.ExpandWidth(false)))
                    {
                        rateIndexHolder = (rateIndexHolder + 1) % rates.Count;
                        bR = rates[rateIndexHolder];
                        buildRateForDisplay = bR.ToString();
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.Label(MagiCore.Utilities.GetFormattedTime(Math.Abs(buildTime - newProgress) / bR));
                }
                else
                {
                    GUILayout.EndHorizontal();
                    GUILayout.Label("Invalid Build Rate");
                }

                bool oldInv = useInventory;
                useInventory = GUILayout.Toggle(useInventory, " Pull new parts from inventory?");
                if (oldInv != useInventory) KCT_Utilities.RecalculateEditorBuildTime(EditorLogic.fetch.ship);

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Save Edits"))
                {

                    finishedShipBP = -1;
                    Dictionary<string, int> partsForInventory = new Dictionary<string, int>();
                    //List<string> partsForInventory = new List<string>();
                    if (KCT_GUI.useInventory)
                    {
                        Dictionary<string, int> newParts = new Dictionary<string, int>(KCT_GUI.PartsInUse);
                        //List<string> newParts = new List<string>(KCT_Utilities.PartDictToList(KCT_GUI.PartsInUse));
                        //List<string> theInventory = new List<string>(KCT_Utilities.PartDictToList(KCT_GameStates.PartInventory));
                        Dictionary<string, int> theInventory = new Dictionary<string, int>(KCT_GameStates.PartInventory);
                       /* foreach (string s in KCT_Utilities.PartDictToList(KCT_GameStates.EditedVesselParts))
                            if (newParts.Contains(s))
                                newParts.Remove(s);*/
                        foreach (KeyValuePair<string, int> kvp in KCT_GameStates.EditedVesselParts)
                        {
                            if (newParts.ContainsKey(kvp.Key))
                            {
                                if (newParts[kvp.Key] >= kvp.Value)
                                    newParts[kvp.Key] -= kvp.Value;
                                else
                                    newParts[kvp.Key] = 0;
                            }
                        }

                        /*foreach (string s in newParts)
                        {
                            if (theInventory.Contains(s))
                            {
                                theInventory.Remove(s);
                                partsForInventory.Add(s);
                            }
                        }*/
                        foreach (KeyValuePair<string, int> kvp in newParts)
                        {
                            if (theInventory.ContainsKey(kvp.Key))
                            {
                                if (theInventory[kvp.Key] >= kvp.Value)
                                {
                                    theInventory[kvp.Key] -= kvp.Value;
                                    KCT_Utilities.AddToDict(partsForInventory, kvp.Key, kvp.Value);
                                }
                                else
                                {
                                    KCT_Utilities.AddToDict(partsForInventory, kvp.Key, theInventory[kvp.Key]);
                                    theInventory[kvp.Key] = 0;
                                }
                            }
                        }

                    }
                    //foreach (string s in ship.InventoryParts)
                    //    partsForInventory.Add(s);
                    foreach (KeyValuePair<string, int> kvp in ship.InventoryParts)
                        KCT_Utilities.AddToDict(partsForInventory, kvp.Key, kvp.Value);

                    KCT_Utilities.AddFunds(ship.cost, TransactionReasons.VesselRollout);
                    KCT_BuildListVessel newShip = KCT_Utilities.AddVesselToBuildList(partsForInventory);//new KCT_BuildListVessel(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, buildTime, EditorLogic.FlagURL);
                    if (newShip == null)
                    {
                        KCT_Utilities.SpendFunds(ship.cost, TransactionReasons.VesselRollout);
                        return;
                    }

                    ship.RemoveFromBuildList();
                    newShip.progress = newProgress;
                    KCTDebug.Log("Finished? " + ship.isFinished);
                    if (ship.isFinished)
                        newShip.cannotEarnScience = true;

                    //foreach (string s in newShip.InventoryParts) //Compare the old inventory parts and the new one, removing the new ones from the old
                    foreach (KeyValuePair<string, int> kvp in newShip.InventoryParts)
                    {
                        if (ship.InventoryParts.ContainsKey(kvp.Key))
                        {
                            if (ship.InventoryParts[kvp.Key] >= newShip.InventoryParts[kvp.Key])
                                ship.InventoryParts[kvp.Key] -= newShip.InventoryParts[kvp.Key];
                            else
                                ship.InventoryParts[kvp.Key] = 0;
                            //ship.InventoryParts.Remove(s);
                        }
                    }
                    //foreach (string s in ship.InventoryParts) //Add the remaining old parts to the overall inventory
                    foreach (KeyValuePair<string, int> kvp in ship.InventoryParts)
                        KCT_Utilities.AddPartToInventory(kvp.Key, kvp.Value);

                    GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);

                    KCT_GameStates.EditorShipEditingMode = false;

                    InputLockManager.RemoveControlLock("KCTEditExit");
                    InputLockManager.RemoveControlLock("KCTEditLoad");
                    InputLockManager.RemoveControlLock("KCTEditNew");
                    InputLockManager.RemoveControlLock("KCTEditLaunch");
                    EditorLogic.fetch.Unlock("KCTEditorMouseLock");
                    KCTDebug.Log("Edits saved.");
                    HighLogic.LoadScene(GameScenes.SPACECENTER);
                }
                if (GUILayout.Button("Cancel Edits"))
                {
                    finishedShipBP = -1;
                    KCT_GameStates.EditorShipEditingMode = false;

                    InputLockManager.RemoveControlLock("KCTEditExit");
                    InputLockManager.RemoveControlLock("KCTEditLoad");
                    InputLockManager.RemoveControlLock("KCTEditNew");
                    InputLockManager.RemoveControlLock("KCTEditLaunch");
                    EditorLogic.fetch.Unlock("KCTEditorMouseLock");
                    KCTDebug.Log("Edits cancelled.");
                    HighLogic.LoadScene(GameScenes.SPACECENTER);
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                if (KCT_PresetManager.Instance.ActivePreset.generalSettings.Simulations && GUILayout.Button("Simulate"))
                {
                    finishedShipBP = -1;
                    simulationConfigPosition.height = 1;
                    EditorLogic.fetch.Lock(true, true, true, "KCTGUILock");
                    showSimConfig = true;
                    KCT_GameStates.launchedVessel = new KCT_BuildListVessel(EditorLogic.fetch.ship, EditorLogic.fetch.launchSiteName, buildTime, EditorLogic.FlagURL);
                }
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Fill Tanks"))
                {
                    foreach (Part p in EditorLogic.fetch.ship.parts)
                    {
                        //fill as part prefab would be filled?
                        if (KCT_Utilities.PartIsProcedural(p))
                        {
                            foreach (PartResource rsc in p.Resources)
                            {
                                rsc.amount = rsc.maxAmount;
                            }
                        }
                        else
                        {
                            foreach (PartResource rsc in p.Resources)
                            {
                                PartResource templateRsc = p.partInfo.partPrefab.Resources.list.Find(r => r.resourceName == rsc.resourceName);
                                if (templateRsc != null)
                                    rsc.amount = templateRsc.amount;
                            }
                        }
                    }
                }
            }

            if (showInventory)
            {
                if (GUILayout.Button("Clear Out Inventory"))
                {
                    float totalValue = 0;
                    foreach (KeyValuePair<string, int> kvp in KCT_GameStates.PartInventory)
                    {
                        AvailablePart part = KCT_Utilities.GetAvailablePartByName(kvp.Key);
                        if (part != null)
                        {
                            if (!KCT_Utilities.PartIsProcedural(part.partPrefab))
                            {
                                totalValue += part.cost * kvp.Value;
                            }
                            else
                            {
                                totalValue += kvp.Value / 100.0F;
                            }
                        }
                    }
                    int newUpgrades = 0;
                    newUpgrades = (int)(KCT_MathParsing.GetStandardFormulaValue("InventorySales", new Dictionary<string, string> { {"V", totalValue.ToString()}, {"P", KCT_GameStates.InventorySalesFigures.ToString() } }) - KCT_GameStates.InventorySaleUpgrades);
                    DialogGUIBase[] options = new DialogGUIBase[2];
                    options[0] = new DialogGUIButton("Clear Out Inventory", ClearOutInventory);
                    options[1] = new DialogGUIButton("Cancel", DummyVoid);
                    MultiOptionDialog a = new MultiOptionDialog("Do you wish to clear out the inventory? In return, you will receive "+newUpgrades+" upgrade points.", "Clear Out Inventory", null, 300, options);
                    PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), a, false, HighLogic.UISkin);
                }

                List<string> categories = new List<string> { "Pods", "Fuel.", "Eng.", "Ctl.", "Struct.", "Aero", "Util.", "Sci." };
                int lastCat = currentCategoryInt;
                currentCategoryInt = GUILayout.Toolbar(currentCategoryInt, categories.ToArray(), GUILayout.ExpandWidth(false));

                SwitchCurrentPartCategory();

                if (GUI.changed)
                {
                    editorWindowPosition.height = 1;
                    if (lastCat == currentCategoryInt)
                    {
                        currentCategoryInt = -1;
                    }
                    SwitchCurrentPartCategory();
                }

                float windowWidth = editorWindowPosition.width;
                GUILayout.BeginVertical();
                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(Math.Min((InventoryForCategory.Count+1) * 27, Screen.height / 4F)));
                GUILayout.BeginHorizontal();
                GUILayout.Label("Name:");
                GUILayout.Label("Available:", GUILayout.Width(windowWidth / 7));
                GUILayout.Label("In use:", GUILayout.Width(windowWidth / 7));
                GUILayout.EndHorizontal();

                var ordered = InventoryForCategory.OrderBy(x => PartsInUse.ContainsKey(x.Key) ? PartsInUse[x.Key] : 0).ToDictionary(x => x.Key, x => x.Value).Reverse();
                foreach (KeyValuePair<string, int> entry in ordered)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(InventoryCommonNames[entry.Key]);
                    GUILayout.Label(entry.Value.ToString(), GUILayout.Width(windowWidth / 7));
                    int inUse = PartsInUse.ContainsKey(entry.Key) ? PartsInUse[entry.Key] : 0;
                    GUILayout.Label(inUse.ToString(), GUILayout.Width(windowWidth / 7));
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
                GUILayout.EndScrollView();
            }

            GUILayout.EndVertical();
            if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2))
                GUI.DragWindow();

            CheckEditorLock();
        }
コード例 #35
0
        public static void DrawPresetWindow(int windowID)
        {
            GUIStyle yellowText = new GUIStyle(GUI.skin.label);
            yellowText.normal.textColor = Color.yellow;

            if (WorkingPreset == null)
            {
                SetNewWorkingPreset(new KCT_Preset(KCT_PresetManager.Instance.ActivePreset), false); //might need to copy instead of assign here
                presetIndex = KCT_PresetManager.Instance.GetIndex(WorkingPreset);
            }

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();

            //preset selector
            GUILayout.BeginVertical();
            GUILayout.Label("Presets", yellowText, GUILayout.ExpandHeight(false));
            //preset toolbar in a scrollview
            presetScrollView = GUILayout.BeginScrollView(presetScrollView, GUILayout.Width(presetPosition.width/6.0f)); //TODO: update HighLogic.Skin.textArea
            string[] presetShortNames = KCT_PresetManager.Instance.PresetShortNames(true);
            if (presetIndex == -1)
            {
                SetNewWorkingPreset(null, true);
                /*presetIndex = presetShortNames.Length - 1;
                WorkingPreset.name = "Custom";
                WorkingPreset.shortName = "Custom";
                WorkingPreset.description = "A custom set of configs.";
                WorkingPreset.author = HighLogic.SaveFolder;*/
            }
            if (changed && presetIndex < presetShortNames.Length - 1 && !KCT_Utilities.ConfigNodesAreEquivalent(WorkingPreset.AsConfigNode(), KCT_PresetManager.Instance.Presets[presetIndex].AsConfigNode())) //!KCT_PresetManager.Instance.PresetsEqual(WorkingPreset, KCT_PresetManager.Instance.Presets[presetIndex], true)
            {
                SetNewWorkingPreset(null, true);
                /*presetIndex = presetShortNames.Length - 1; //Custom preset
                WorkingPreset.name = "Custom";
                WorkingPreset.shortName = "Custom";
                WorkingPreset.description = "A custom set of configs.";
                WorkingPreset.author = HighLogic.SaveFolder;*/
            }
               /* presetIndex = KCT_PresetManager.Instance.GetIndex(WorkingPreset); //Check that the current preset is equal to the expected one
            if (presetIndex == -1)
                presetIndex = presetNames.Length - 1;*/
            int prev = presetIndex;
            presetIndex = GUILayout.SelectionGrid(presetIndex, presetShortNames, 1);
            if (prev != presetIndex) //If a new preset was selected
            {
                if (presetIndex != presetShortNames.Length - 1)
                {
                    SetNewWorkingPreset(new KCT_Preset(KCT_PresetManager.Instance.Presets[presetIndex]), false);
                }
                else
                {
                    SetNewWorkingPreset(null, true);
                    /*WorkingPreset.name = "Custom";
                    WorkingPreset.shortName = "Custom";
                    WorkingPreset.description = "A custom set of configs.";
                    WorkingPreset.author = HighLogic.SaveFolder;*/
                }
            }

            //presetIndex = GUILayout.Toolbar(presetIndex, presetNames);

            GUILayout.EndScrollView();
            if (GUILayout.Button("Save as\nNew Preset", GUILayout.ExpandHeight(false)))
            {
                //create new preset
                SaveAsNewPreset(WorkingPreset);
            }
            if (WorkingPreset.AllowDeletion && presetIndex != presetShortNames.Length - 1 && GUILayout.Button("Delete Preset")) //allowed to be deleted and isn't Custom
            {

                DialogGUIBase[] options = new DialogGUIBase[2];
                options[0] = new DialogGUIButton("Delete File", DeleteActivePreset);
                options[1] = new DialogGUIButton("Cancel", DummyVoid);
                MultiOptionDialog dialog = new MultiOptionDialog("Are you sure you want to delete the selected Preset, file and all? This cannot be undone!", "Confirm Deletion", null, options);
                PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, HighLogic.UISkin);
            }
            GUILayout.EndVertical();

            //Main sections
            GUILayout.BeginVertical();
            presetMainScroll = GUILayout.BeginScrollView(presetMainScroll);
            //Preset info section)
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            GUILayout.Label("Preset Name: " + WorkingPreset.name);
            GUILayout.Label("Description: " + WorkingPreset.description);
            GUILayout.Label("Author(s): " + WorkingPreset.author);
            GUILayout.EndVertical();

            GUILayout.BeginHorizontal();
            //Features section
            GUILayout.BeginVertical();
            GUILayout.Label("Features", yellowText);
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            WorkingPreset.generalSettings.Enabled= GUILayout.Toggle(WorkingPreset.generalSettings.Enabled, "Mod Enabled", HighLogic.Skin.button);
            WorkingPreset.generalSettings.BuildTimes = GUILayout.Toggle(WorkingPreset.generalSettings.BuildTimes, "Build Times", HighLogic.Skin.button);
            WorkingPreset.generalSettings.ReconditioningTimes = GUILayout.Toggle(WorkingPreset.generalSettings.ReconditioningTimes, "Launchpad Reconditioning", HighLogic.Skin.button);
            WorkingPreset.generalSettings.TechUnlockTimes = GUILayout.Toggle(WorkingPreset.generalSettings.TechUnlockTimes, "Tech Unlock Times", HighLogic.Skin.button);
            WorkingPreset.generalSettings.KSCUpgradeTimes = GUILayout.Toggle(WorkingPreset.generalSettings.KSCUpgradeTimes, "KSC Upgrade Times", HighLogic.Skin.button);
            WorkingPreset.generalSettings.Simulations = GUILayout.Toggle(WorkingPreset.generalSettings.Simulations, "Allow Simulations", HighLogic.Skin.button);
            WorkingPreset.generalSettings.SimulationCosts = GUILayout.Toggle(WorkingPreset.generalSettings.SimulationCosts, "Simulation Costs", HighLogic.Skin.button);
            WorkingPreset.generalSettings.RequireVisitsForSimulations = GUILayout.Toggle(WorkingPreset.generalSettings.RequireVisitsForSimulations, "Must Visit Planets", HighLogic.Skin.button);
            WorkingPreset.generalSettings.TechUpgrades = GUILayout.Toggle(WorkingPreset.generalSettings.TechUpgrades, "Upgrades From Tech Tree", HighLogic.Skin.button);
            WorkingPreset.generalSettings.SharedUpgradePool = GUILayout.Toggle(WorkingPreset.generalSettings.SharedUpgradePool, "Shared Upgrade Pool (KSCSwitcher)", HighLogic.Skin.button);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Starting Upgrades:");
            WorkingPreset.generalSettings.StartingPoints = GUILayout.TextField(WorkingPreset.generalSettings.StartingPoints, GUILayout.Width(100));
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndVertical(); //end Features

            GUILayout.BeginVertical(); //Begin time settings
            GUILayout.Label("Time Settings", yellowText);
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Overall Multiplier: ");
            double.TryParse(OMultTmp = GUILayout.TextField(OMultTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.OverallMultiplier);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Build Effect: ");
            double.TryParse(BEffTmp = GUILayout.TextField(BEffTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.BuildEffect);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Inventory Effect: ");
            double.TryParse(IEffTmp = GUILayout.TextField(IEffTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.InventoryEffect);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Reconditioning Effect: ");
            double.TryParse(ReEffTmp = GUILayout.TextField(ReEffTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.ReconditioningEffect);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Max Reconditioning: ");
            double.TryParse(MaxReTmp = GUILayout.TextField(MaxReTmp, 10, GUILayout.Width(80)), out WorkingPreset.timeSettings.MaxReconditioning);
            GUILayout.EndHorizontal();
            GUILayout.Label("Rollout-Reconditioning Split:");
            GUILayout.BeginHorizontal();
            //GUILayout.Label("Rollout", GUILayout.ExpandWidth(false));
            WorkingPreset.timeSettings.RolloutReconSplit = GUILayout.HorizontalSlider((float)Math.Floor(WorkingPreset.timeSettings.RolloutReconSplit * 100f), 0, 100)/100.0;
            //GUILayout.Label("Recon.", GUILayout.ExpandWidth(false));
            GUILayout.EndHorizontal();
            GUILayout.Label((Math.Floor(WorkingPreset.timeSettings.RolloutReconSplit*100))+"% Rollout, "+(100-Math.Floor(WorkingPreset.timeSettings.RolloutReconSplit*100))+"% Reconditioning");
            GUILayout.EndVertical(); //end time settings
            GUILayout.EndVertical();
            GUILayout.EndHorizontal(); //end feature/time setting split

            //begin formula settings
            GUILayout.BeginVertical();
            GUILayout.Label("Formula Settings (Advanced)", yellowText);
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Show/Hide Formulas"))
            {
                showFormula = !showFormula;
            }
            if (GUILayout.Button("View Wiki in Browser"))
            {
                Application.OpenURL("https://github.com/magico13/KCT/wiki");
            }
            GUILayout.EndHorizontal();

            if (showFormula)
            {
                //show half here, half on other side? Or all in one big list
                int textWidth = 350;
                GUILayout.BeginHorizontal();
                GUILayout.Label("NodeFormula: ");
                WorkingPreset.formulaSettings.NodeFormula = GUILayout.TextField(WorkingPreset.formulaSettings.NodeFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("UpgradeFunds: ");
                WorkingPreset.formulaSettings.UpgradeFundsFormula = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradeFundsFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("UpgradeScience: ");
                WorkingPreset.formulaSettings.UpgradeScienceFormula = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradeScienceFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("ResearchFormula: ");
                WorkingPreset.formulaSettings.ResearchFormula = GUILayout.TextField(WorkingPreset.formulaSettings.ResearchFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("EffectivePart: ");
                WorkingPreset.formulaSettings.EffectivePartFormula = GUILayout.TextField(WorkingPreset.formulaSettings.EffectivePartFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("ProceduralPart: ");
                WorkingPreset.formulaSettings.ProceduralPartFormula = GUILayout.TextField(WorkingPreset.formulaSettings.ProceduralPartFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("BPFormula: ");
                WorkingPreset.formulaSettings.BPFormula = GUILayout.TextField(WorkingPreset.formulaSettings.BPFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("KSCUpgrade: ");
                WorkingPreset.formulaSettings.KSCUpgradeFormula = GUILayout.TextField(WorkingPreset.formulaSettings.KSCUpgradeFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Reconditioning: ");
                WorkingPreset.formulaSettings.ReconditioningFormula = GUILayout.TextField(WorkingPreset.formulaSettings.ReconditioningFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("BuildRate: ");
                WorkingPreset.formulaSettings.BuildRateFormula = GUILayout.TextField(WorkingPreset.formulaSettings.BuildRateFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("SimCost: ");
                WorkingPreset.formulaSettings.SimCostFormula = GUILayout.TextField(WorkingPreset.formulaSettings.SimCostFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("KerbinSimCost: ");
                WorkingPreset.formulaSettings.KerbinSimCostFormula = GUILayout.TextField(WorkingPreset.formulaSettings.KerbinSimCostFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("UpgradeReset: ");
                WorkingPreset.formulaSettings.UpgradeResetFormula = GUILayout.TextField(WorkingPreset.formulaSettings.UpgradeResetFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("InventorySale: ");
                WorkingPreset.formulaSettings.InventorySaleFormula = GUILayout.TextField(WorkingPreset.formulaSettings.InventorySaleFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("RolloutCosts: ");
                WorkingPreset.formulaSettings.RolloutCostFormula = GUILayout.TextField(WorkingPreset.formulaSettings.RolloutCostFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("NewLaunchPadCost: ");
                WorkingPreset.formulaSettings.NewLaunchPadCostFormula = GUILayout.TextField(WorkingPreset.formulaSettings.NewLaunchPadCostFormula, GUILayout.Width(textWidth));
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
            GUILayout.EndVertical(); //end formula settings

            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Save", GUILayout.ExpandWidth(false)))
            {
                KCT_PresetManager.Instance.ActivePreset = WorkingPreset;
                KCT_PresetManager.Instance.SaveActiveToSaveData();
                WorkingPreset = null;
                showSettings = false;

                if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
                    KCT_Utilities.DisableModFunctionality();
                //KCT_GameStates.settings.enabledForSave = KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled;
                KCT_GameStates.settings.MaxTimeWarp = newTimewarp;
                KCT_GameStates.settings.ForceStopWarp = forceStopWarp;
                KCT_GameStates.settings.DisableAllMessages = disableAllMsgs;
                KCT_GameStates.settings.OverrideLaunchButton = overrideLaunchBtn;
                KCT_GameStates.settings.Debug = debug;
                KCT_GameStates.settings.AutoKACAlarms = autoAlarms;
                KCT_GameStates.settings.PreferBlizzyToolbar = useBlizzyToolbar;
                KCT_GameStates.settings.CheckForDebugUpdates = debugUpdateChecking;

                KCT_GameStates.settings.Save();
                showSettings = false;
                if (!PrimarilyDisabled && !showFirstRun)
                {
                    ResetBLWindow();
                    if (KCT_Events.instance.KCTButtonStock != null)
                        KCT_Events.instance.KCTButtonStock.SetTrue();
                    else
                    {
                        showBuildList = true;
                    }
                }
                if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled) InputLockManager.RemoveControlLock("KCTKSCLock");

                for (int j = 0; j < KCT_GameStates.TechList.Count; j++)
                    KCT_GameStates.TechList[j].UpdateBuildRate(j);

                KCT_GUI.ResetFormulaRateHolders();
            }
            if (GUILayout.Button("Cancel", GUILayout.ExpandWidth(false)))
            {
                WorkingPreset = null;
                showSettings = false;
                if (!PrimarilyDisabled && !showFirstRun)
                {
                    ResetBLWindow();
                    if (KCT_Events.instance.KCTButtonStock != null)
                        KCT_Events.instance.KCTButtonStock.SetTrue();
                    else
                        showBuildList = true;
                }

                for (int j = 0; j < KCT_GameStates.TechList.Count; j++)
                    KCT_GameStates.TechList[j].UpdateBuildRate(j);
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndVertical(); //end column 2

            GUILayout.BeginVertical(GUILayout.Width(100)); //Start general settings
            GUILayout.Label("General Settings", yellowText);
            GUILayout.Label("NOTE: Affects all saves!", yellowText);
            GUILayout.BeginVertical(HighLogic.Skin.textArea);
            GUILayout.Label("Max Timewarp");
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("-", GUILayout.ExpandWidth(false)))
            {
                newTimewarp = Math.Max(newTimewarp - 1, 0);
            }
            //current warp setting
            GUILayout.Label(TimeWarp.fetch.warpRates[newTimewarp] + "x");
            if (GUILayout.Button("+", GUILayout.ExpandWidth(false)))
            {
                newTimewarp = Math.Min(newTimewarp + 1, TimeWarp.fetch.warpRates.Length - 1);
            }
            GUILayout.EndHorizontal();

            forceStopWarp = GUILayout.Toggle(forceStopWarp, "Auto Stop TimeWarp", HighLogic.Skin.button);
            autoAlarms = GUILayout.Toggle(autoAlarms, "Auto KAC Alarms", HighLogic.Skin.button);
            overrideLaunchBtn = GUILayout.Toggle(overrideLaunchBtn, "Override Launch Button", HighLogic.Skin.button);
            useBlizzyToolbar = GUILayout.Toggle(useBlizzyToolbar, "Use Toolbar Mod", HighLogic.Skin.button);
            disableAllMsgs = !GUILayout.Toggle(!disableAllMsgs, "Use Message System", HighLogic.Skin.button);
            debug = GUILayout.Toggle(debug, "Debug Logging", HighLogic.Skin.button);
            #if DEBUG
            debugUpdateChecking = GUILayout.Toggle(debugUpdateChecking, "Check for Dev Updates", HighLogic.Skin.button);
            #endif
            GUILayout.EndVertical();
            GUILayout.EndVertical();

            GUILayout.EndHorizontal(); //end main split
            GUILayout.EndVertical(); //end window

            changed = GUI.changed;

            if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2))
                GUI.DragWindow();
        }
コード例 #36
0
        public static void DrawBuildListWindow(int windowID)
        {
            if (buildListWindowPosition.xMax > Screen.width)
                buildListWindowPosition.x = Screen.width - buildListWindowPosition.width;

            //if (Input.touchCount == 0) MouseOnRolloutButton = false;

            //GUI.skin = HighLogic.UISkin;
            GUIStyle redText = new GUIStyle(GUI.skin.label);
            redText.normal.textColor = Color.red;
            GUIStyle yellowText = new GUIStyle(GUI.skin.label);
            yellowText.normal.textColor = Color.yellow;
            GUIStyle greenText = new GUIStyle(GUI.skin.label);
            greenText.normal.textColor = Color.green;

            GUIStyle normalButton = new GUIStyle(GUI.skin.button);
            GUIStyle yellowButton = new GUIStyle(GUI.skin.button);
            yellowButton.normal.textColor = Color.yellow;
            yellowButton.hover.textColor = Color.yellow;
            yellowButton.active.textColor = Color.yellow;
            GUIStyle redButton = new GUIStyle(GUI.skin.button);
            redButton.normal.textColor = Color.red;
            redButton.hover.textColor = Color.red;
            redButton.active.textColor = Color.red;

            GUIStyle greenButton = new GUIStyle(GUI.skin.button);
            greenButton.normal.textColor = Color.green;
            greenButton.hover.textColor = Color.green;
            greenButton.active.textColor = Color.green;

            int width1 = 120;
            int width2 = 100;
            int butW = 20;
            GUILayout.BeginVertical();
            //GUILayout.Label("Current KSC: " + KCT_GameStates.ActiveKSC.KSCName);
            //List next vessel to finish
            GUILayout.BeginHorizontal();
            GUILayout.Label("Next:", windowSkin.label);
            IKCTBuildItem buildItem = KCT_Utilities.NextThingToFinish();
            if (buildItem != null)
            {
                //KCT_BuildListVessel ship = (KCT_BuildListVessel)buildItem;

                string txt = buildItem.GetItemName(), locTxt = "VAB";
                if (buildItem.GetListType() == KCT_BuildListVessel.ListType.Reconditioning)
                {
                    KCT_Recon_Rollout reconRoll = buildItem as KCT_Recon_Rollout;
                    if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Reconditioning)
                    {
                        txt = "Reconditioning";
                        locTxt = reconRoll.launchPadID;
                    }
                    else if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout)
                    {
                        KCT_BuildListVessel associated = reconRoll.KSC.VABWarehouse.FirstOrDefault(blv => blv.id.ToString() == reconRoll.associatedID);
                        txt = associated.shipName + " Rollout";
                        locTxt = reconRoll.launchPadID;
                    }
                    else if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Rollback)
                    {
                        KCT_BuildListVessel associated = reconRoll.KSC.VABWarehouse.FirstOrDefault(blv => blv.id.ToString() == reconRoll.associatedID);
                        txt = associated.shipName + " Rollback";
                        locTxt = reconRoll.launchPadID;
                    }
                    else
                    {
                        locTxt = "VAB";
                    }
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.VAB)
                {
                    locTxt = "VAB";
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.SPH)
                {
                    locTxt = "SPH";
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.TechNode)
                {
                    locTxt = "Tech";
                }
                else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.KSC)
                {
                    locTxt = "KSC";
                }

                GUILayout.Label(txt);
                GUILayout.Label(locTxt, windowSkin.label);
                GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(buildItem.GetTimeLeft()));

                if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex == 0 && GUILayout.Button("Warp to" + System.Environment.NewLine + "Complete"))
                {
                    KCT_GameStates.targetedItem = buildItem;
                    KCT_GameStates.canWarp = true;
                    KCT_Utilities.RampUpWarp();
                    KCT_GameStates.warpInitiated = true;
                   /* if (buildItem.GetBuildRate() > 0)
                    {
                        TimeWarp.fetch.WarpTo(Planetarium.GetUniversalTime() + buildItem.GetTimeLeft(), KCT_GameStates.settings.MaxTimeWarp, 1);
                    }*/
                }
                else if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex > 0 && GUILayout.Button("Stop" + System.Environment.NewLine + "Warp"))
                {
                    KCT_GameStates.canWarp = false;
                    TimeWarp.SetRate(0, true);
                    KCT_GameStates.lastWarpRate = 0;
                }

                if (KCT_GameStates.settings.AutoKACAlarms && KACWrapper.APIReady && buildItem.GetTimeLeft() > 30) //don't check if less than 30 seconds to completion. Might fix errors people are seeing
                {
                    double UT = Planetarium.GetUniversalTime();
                    if (!KCT_Utilities.ApproximatelyEqual(KCT_GameStates.KACAlarmUT - UT, buildItem.GetTimeLeft()))
                    {
                        KCTDebug.Log("KAC Alarm being created!");
                        KCT_GameStates.KACAlarmUT = (buildItem.GetTimeLeft() + UT);
                        KACWrapper.KACAPI.KACAlarm alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => a.ID == KCT_GameStates.KACAlarmId);
                        if (alarm == null)
                        {
                            alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => (a.Name.StartsWith("KCT: ")));
                        }
                        if (alarm != null)
                        {
                            KCTDebug.Log("Removing existing alarm");
                            KACWrapper.KAC.DeleteAlarm(alarm.ID);
                        }
                        txt = "KCT: ";
                        if (buildItem.GetListType() == KCT_BuildListVessel.ListType.Reconditioning)
                        {
                            KCT_Recon_Rollout reconRoll = buildItem as KCT_Recon_Rollout;
                            if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Reconditioning)
                            {
                                txt += reconRoll.launchPadID + " Reconditioning";
                            }
                            else if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout)
                            {
                                KCT_BuildListVessel associated = reconRoll.KSC.VABWarehouse.FirstOrDefault(blv => blv.id.ToString() == reconRoll.associatedID);
                                txt += associated.shipName + " rollout at " + reconRoll.launchPadID;
                            }
                            else if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Rollback)
                            {
                                KCT_BuildListVessel associated = reconRoll.KSC.VABWarehouse.FirstOrDefault(blv => blv.id.ToString() == reconRoll.associatedID);
                                txt += associated.shipName + " rollback at " + reconRoll.launchPadID;
                            }
                            else
                            {
                                txt += buildItem.GetItemName() + " Complete";
                            }
                        }
                        else
                            txt += buildItem.GetItemName() + " Complete";
                        KCT_GameStates.KACAlarmId = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, txt, KCT_GameStates.KACAlarmUT);
                        KCTDebug.Log("Alarm created with ID: " + KCT_GameStates.KACAlarmId);
                    }
                }
            }
            else
            {
                GUILayout.Label("No Active Projects");
            }
            GUILayout.EndHorizontal();

            //Buttons for VAB/SPH lists
               // List<string> buttonList = new List<string> { "VAB", "SPH", "KSC" };
            //if (KCT_Utilities.CurrentGameHasScience() && !KCT_GameStates.settings.InstantTechUnlock) buttonList.Add("Tech");
            GUILayout.BeginHorizontal();
            //if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { buttonList.Add("Upgrades"); buttonList.Add("Settings"); }
              //  int lastSelected = listWindow;
               // listWindow = GUILayout.Toolbar(listWindow, buttonList.ToArray());

            bool VABSelectedNew = GUILayout.Toggle(VABSelected, "VAB", GUI.skin.button);
            bool SPHSelectedNew = GUILayout.Toggle(SPHSelected, "SPH", GUI.skin.button);
            bool TechSelectedNew = false;
            if (KCT_Utilities.CurrentGameHasScience())
                TechSelectedNew = GUILayout.Toggle(TechSelected, "Tech", GUI.skin.button);
            if (VABSelectedNew != VABSelected)
                SelectList("VAB");
            else if (SPHSelectedNew != SPHSelected)
                SelectList("SPH");
            else if (TechSelectedNew != TechSelected)
                SelectList("Tech");

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Upgrades"))
            {
                showUpgradeWindow = true;
                showBuildList = false;
                showBLPlus = false;
            }
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Settings"))
            {
                showBuildList = false;
                showBLPlus = false;
                ShowSettings();
            }
            GUILayout.EndHorizontal();

              /*  if (GUI.changed)
            {
                buildListWindowPosition.height = 1;
                showBLPlus = false;
                if (lastSelected == listWindow)
                {
                    listWindow = -1;
                }
            }*/
            //Content of lists
            if (listWindow == 0) //VAB Build List
            {
                List<KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.VABList;
                GUILayout.BeginHorizontal();
              //  GUILayout.Space((butW + 4) * 3);
                GUILayout.Label("Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1 / 2));
                GUILayout.Label("Time Left:", GUILayout.Width(width2));
                //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10));
                GUILayout.EndHorizontal();
                //if (KCT_Utilities.ReconditioningActive(null))
                foreach (KCT_Recon_Rollout reconditioning in KCT_GameStates.ActiveKSC.Recon_Rollout.FindAll(r => r.RRType == KCT_Recon_Rollout.RolloutReconType.Reconditioning))
                {
                    GUILayout.BeginHorizontal();
                    IKCTBuildItem item = reconditioning.AsBuildItem();
                    if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width((butW + 4) * 3)))
                    {
                        KCT_GameStates.targetedItem = item;
                        KCT_GameStates.canWarp = true;
                        KCT_Utilities.RampUpWarp(item);
                        KCT_GameStates.warpInitiated = true;
                        /*if (item.GetBuildRate() > 0)
                        {
                            TimeWarp.fetch.WarpTo(Planetarium.GetUniversalTime() + item.GetTimeLeft(), KCT_GameStates.settings.MaxTimeWarp, 1);
                        }*/
                    }

                    GUILayout.Label("Reconditioning: "+reconditioning.launchPadID);
                    GUILayout.Label(reconditioning.ProgressPercent().ToString() + "%", GUILayout.Width(width1 / 2));
                    GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(item.GetTimeLeft()), GUILayout.Width(width2));
                    //GUILayout.Label(Math.Round(KCT_GameStates.ActiveKSC.GetReconditioning().BP, 2).ToString(), GUILayout.Width(width1 / 2 + 10));

                    //GUILayout.Space((butW + 4) * 3);
                    GUILayout.EndHorizontal();
                }

                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));
                {
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels under construction! Go to the VAB to build more.");
                    }
                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        if (!b.allPartsValid)
                            continue;
                        GUILayout.BeginHorizontal();
                        //GUILayout.Label(b.shipName, GUILayout.Width(width1));

                        if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW)))
                        {
                            if (IDSelected == b.id)
                                showBLPlus = !showBLPlus;
                            else
                                showBLPlus = true;
                            IDSelected = b.id;
                        }
                        else if (HighLogic.LoadedSceneIsEditor)
                        {
                            //GUILayout.Space(butW);
                            if (GUILayout.Button("X", GUILayout.Width(butW)))
                            {
                                InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock");
                                IDSelected = b.id;
                                DialogGUIBase[] options = new DialogGUIBase[2];
                                options[0] = new DialogGUIButton("Yes", ScrapVessel);
                                options[1] = new DialogGUIButton("No", DummyVoid);
                                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", "Scrap Vessel", null, options: options);
                                PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
                            }
                        }

                        if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Insert(0, b);
                            }
                            else
                            {
                                buildList.Insert(i - 1, b);
                            }
                        }
                        else if (i == 0)
                        {
                      //      GUILayout.Space(butW + 4);
                        }
                        if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Add(b);
                            }
                            else
                            {
                                buildList.Insert(i + 1, b);
                            }
                        }
                        else if (i >= buildList.Count - 1)
                        {
                      //      GUILayout.Space(butW + 4);
                        }

                        GUILayout.Label(b.shipName);
                        GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2));
                        if (b.buildRate > 0)
                            GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2));
                        else
                            GUILayout.Label("Est: " + MagiCore.Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.VAB, null)), GUILayout.Width(width2));
                       // GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10));
                        GUILayout.EndHorizontal();
                    }

                    //ADD Storage here!
                    buildList = KCT_GameStates.ActiveKSC.VABWarehouse;
                    GUILayout.Label("__________________________________________________");
                    GUILayout.Label("VAB Storage");
                    if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel"))
                    {
                        if (!KCT_Utilities.RecoverActiveVesselToStorage(KCT_BuildListVessel.ListType.VAB))
                        {
                            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),  "Error!", "There was an error while recovering the ship. Sometimes reloading the scene and trying again works. Sometimes a vessel just can't be recovered this way and you must use the stock recover system.", "OK", false, HighLogic.UISkin);
                        }
                    }
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete.");
                    }

                    //KCT_Recon_Rollout rollback = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollback);
                    bool rolloutEnabled = KCT_PresetManager.Instance.ActivePreset.generalSettings.ReconditioningTimes && KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit > 0;
                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        if (!b.allPartsValid)
                            continue;
                        string launchSite = b.launchSite;
                        if (launchSite == "LaunchPad")
                        {
                            if (b.launchSiteID >= 0)
                                launchSite = KCT_GameStates.ActiveKSC.LaunchPads[b.launchSiteID].name;
                            else
                                launchSite = KCT_GameStates.ActiveKSC.ActiveLPInstance.name;
                        }
                        KCT_Recon_Rollout rollout = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollout, launchSite);
                        KCT_Recon_Rollout rollback = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Rollback);
                        KCT_Recon_Rollout recovery = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery);
                        GUIStyle textColor = new GUIStyle(GUI.skin.label);
                        GUIStyle buttonColor = new GUIStyle(GUI.skin.button);

                        VesselPadStatus padStatus = VesselPadStatus.InStorage;
                        if (rollback != null)
                            padStatus = VesselPadStatus.RollingBack;
                        if (recovery != null)
                            padStatus = VesselPadStatus.Recovering;

                        string status = "In Storage";
                        if (rollout != null && rollout.associatedID == b.id.ToString())
                        {
                            padStatus = VesselPadStatus.RollingOut;
                            status = "Rolling Out to "+launchSite;
                            textColor = yellowText;
                            if (rollout.AsBuildItem().IsComplete())
                            {
                                padStatus = VesselPadStatus.RolledOut;
                                status = "At "+launchSite;
                                textColor = greenText;
                            }
                        }
                        else if (rollback != null)
                        {
                            status = "Rolling Back from "+launchSite;
                            textColor = yellowText;
                        }
                        else if (recovery != null)
                        {
                            status = "Recovering";
                            textColor = redText;
                        }

                        GUILayout.BeginHorizontal();
                        if (!HighLogic.LoadedSceneIsEditor && (padStatus == VesselPadStatus.InStorage || padStatus == VesselPadStatus.RolledOut))
                        {
                            if (GUILayout.Button("*", GUILayout.Width(butW)))
                            {
                                if (IDSelected == b.id)
                                    showBLPlus = !showBLPlus;
                                else
                                    showBLPlus = true;
                                IDSelected = b.id;
                            }
                        }
                        else
                            GUILayout.Space(butW + 4);

                        GUILayout.Label(b.shipName, textColor);
                        GUILayout.Label(status+"   ", textColor, GUILayout.ExpandWidth(false));
                        bool siteHasActiveRolloutOrRollback = rollout != null || KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollback, launchSite) != null;
                        if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && !siteHasActiveRolloutOrRollback) //rollout if the pad isn't busy
                        {
                            GUIStyle btnColor = greenButton;
                            if (KCT_GameStates.ActiveKSC.ActiveLPInstance.destroyed)
                                btnColor = redButton;
                            else if (KCT_GameStates.ActiveKSC.GetReconditioning(KCT_GameStates.ActiveKSC.ActiveLPInstance.name) != null)
                                btnColor = yellowButton;
                            KCT_Recon_Rollout tmpRollout = new KCT_Recon_Rollout(b, KCT_Recon_Rollout.RolloutReconType.Rollout, b.id.ToString(), launchSite);
                            string rolloutText = (i == MouseOnRolloutButton ? MagiCore.Utilities.GetColonFormattedTime(tmpRollout.AsBuildItem().GetTimeLeft()) : "Rollout");
                            if (GUILayout.Button(rolloutText, btnColor, GUILayout.ExpandWidth(false)))
                            {
                                List<string> facilityChecks = b.MeetsFacilityRequirements();
                                if (facilityChecks.Count == 0)
                                {
                                    if (!KCT_GameStates.ActiveKSC.ActiveLPInstance.destroyed)
                                    {
                                        b.launchSiteID = KCT_GameStates.ActiveKSC.ActiveLaunchPadID;

                                        if (rollout != null)
                                        {
                                            rollout.SwapRolloutType();
                                        }
                                       // tmpRollout.launchPadID = KCT_GameStates.ActiveKSC.ActiveLPInstance.name;
                                        KCT_GameStates.ActiveKSC.Recon_Rollout.Add(tmpRollout);
                                    }
                                    else
                                    {
                                        PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),  "Cannot Launch!", "You must repair the launchpad before you can launch a vessel from it!", "Acknowledged", false, HighLogic.UISkin);
                                    }
                                }
                                else
                                {
                                    PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),  "Cannot Launch!", "Warning! This vessel did not pass the editor checks! Until you upgrade the VAB and/or Launchpad it cannot be launched. Listed below are the failed checks:\n" + String.Join("\n", facilityChecks.ToArray()), "Acknowledged", false, HighLogic.UISkin);
                                }
                            }
                            if (Event.current.type == EventType.Repaint)
                                if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
                                    MouseOnRolloutButton = i;
                                else if (i == MouseOnRolloutButton)
                                    MouseOnRolloutButton = -1;
                        }
                        else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollout != null && b.id.ToString() == rollout.associatedID && !rollout.AsBuildItem().IsComplete() && rollback == null &&
                            GUILayout.Button(MagiCore.Utilities.GetColonFormattedTime(rollout.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false))) //swap rollout to rollback
                        {
                            rollout.SwapRolloutType();
                        }
                        else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollback != null && !rollback.AsBuildItem().IsComplete())
                        {
                            if (rollout == null)
                            {
                                if (GUILayout.Button(MagiCore.Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false))) //switch rollback back to rollout
                                    rollback.SwapRolloutType();
                            }
                            else
                            {
                                GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false));
                            }
                        }
                        else if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && (!rolloutEnabled || (rollout != null && b.id.ToString() == rollout.associatedID && rollout.AsBuildItem().IsComplete())))
                        {
                            KCT_LaunchPad pad = KCT_GameStates.ActiveKSC.LaunchPads.Find(lp => lp.name == launchSite);
                            bool operational = pad!=null ? !pad.destroyed : !KCT_GameStates.ActiveKSC.ActiveLPInstance.destroyed;
                            GUIStyle btnColor = greenButton;
                            string launchTxt = "Launch";
                            if (!operational)
                            {
                                launchTxt = "Repairs Required";
                                btnColor = redButton;
                            }
                            else if (KCT_Utilities.ReconditioningActive(null, launchSite))
                            {
                                launchTxt = "Reconditioning";
                                btnColor = yellowButton;
                            }
                            if (rolloutEnabled && GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button("Roll Back", GUILayout.ExpandWidth(false)))
                            {
                                rollout.SwapRolloutType();
                            }
                            else if (!GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button(launchTxt, btnColor, GUILayout.ExpandWidth(false)))
                            {
                                if (b.launchSiteID >= 0)
                                {
                                    KCT_GameStates.ActiveKSC.SwitchLaunchPad(b.launchSiteID);
                                }
                                b.launchSiteID = KCT_GameStates.ActiveKSC.ActiveLaunchPadID;

                                List<string> facilityChecks = b.MeetsFacilityRequirements();
                                if (facilityChecks.Count == 0)
                                {
                                   // bool operational = !KCT_GameStates.ActiveKSC.ActiveLPInstance.destroyed;// && KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.VAB);//new PreFlightTests.FacilityOperational("LaunchPad", "building").Test();
                                    if (!operational)
                                    {
                                        //ScreenMessages.PostScreenMessage("You must repair the launchpad prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                                        PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Cannot Launch!", "You must repair the launchpad before you can launch a vessel from it!", "Acknowledged", false, HighLogic.UISkin);
                                    }
                                    else if (KCT_Utilities.ReconditioningActive(null, launchSite))
                                    {
                                        //can't launch now
                                        ScreenMessage message = new ScreenMessage("[KCT] Cannot launch while LaunchPad is being reconditioned. It will be finished in "
                                            + MagiCore.Utilities.GetFormattedTime(((IKCTBuildItem)KCT_GameStates.ActiveKSC.GetReconditioning(launchSite)).GetTimeLeft()), 4.0f, ScreenMessageStyle.UPPER_CENTER);
                                        ScreenMessages.PostScreenMessage(message);
                                    }
                                    else
                                    {
                                        /*if (rollout != null)
                                            KCT_GameStates.ActiveKSC.Recon_Rollout.Remove(rollout);*/
                                        KCT_GameStates.launchedVessel = b;
                                        if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, b.launchSite).Count == 0)//  ShipConstruction.CheckLaunchSiteClear(HighLogic.CurrentGame.flightState, "LaunchPad", false))
                                        {
                                            showBLPlus = false;
                                            // buildList.RemoveAt(i);
                                            if (!IsCrewable(b.ExtractedParts))
                                                b.Launch();
                                            else
                                            {
                                                showBuildList = false;
                                                if (KCT_Events.instance.KCTButtonStock != null)
                                                {
                                                    KCT_Events.instance.KCTButtonStock.SetFalse();
                                                }

                                                centralWindowPosition.height = 1;
                                                KCT_GameStates.launchedCrew.Clear();
                                                parts = KCT_GameStates.launchedVessel.ExtractedParts;
                                                pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts();
                                                KCT_GameStates.launchedCrew = new List<CrewedPart>();
                                                foreach (PseudoPart pp in pseudoParts)
                                                    KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List<ProtoCrewMember>()));
                                                CrewFirstAvailable();
                                                showShipRoster = true;
                                            }
                                        }
                                        else
                                        {
                                            showBuildList = false;
                                            showClearLaunch = true;
                                        }
                                    }
                                }
                                else
                                {
                                    PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Cannot Launch!", "Warning! This vessel did not pass the editor checks! Until you upgrade the VAB and/or Launchpad it cannot be launched. Listed below are the failed checks:\n" + String.Join("\n", facilityChecks.ToArray()), "Acknowledged", false, HighLogic.UISkin);
                                }
                            }
                        }
                        else if (!HighLogic.LoadedSceneIsEditor && recovery != null)
                        {
                            GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false));
                        }

                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndScrollView();
                GUILayout.BeginHorizontal();
                int lpCount = KCT_GameStates.ActiveKSC.LaunchPadCount;
                if (lpCount > 1 && GUILayout.Button("<<", GUILayout.ExpandWidth(false)))
                {
                    //Simple fix for mod function being "weird" in the negative direction
                    //http://stackoverflow.com/questions/1082917/mod-of-negative-number-is-melting-my-brain
                    KCT_GameStates.ActiveKSC.SwitchLaunchPad(((KCT_GameStates.ActiveKSC.ActiveLaunchPadID - 1) % lpCount + lpCount) % lpCount);
                }
                GUILayout.FlexibleSpace();
                GUILayout.Label("Current: " + KCT_GameStates.ActiveKSC.ActiveLPInstance.name+" ("+(KCT_GameStates.ActiveKSC.ActiveLPInstance.level+1)+")");
                if (costOfNewLP == -13)
                    costOfNewLP = KCT_MathParsing.GetStandardFormulaValue("NewLaunchPadCost", new Dictionary<string, string> { { "N", KCT_GameStates.ActiveKSC.LaunchPads.Count.ToString() } });
              //  if (KCT_Utilities.KSCSwitcherInstalled) //todo
              //      costOfNewLP = -1; //disable purchasing additional launchpads when playing with KSC Switcher (until upgrades are properly per KSC)
                if (GUILayout.Button("Rename", GUILayout.ExpandWidth(false)))
                {
                    renamingLaunchPad = true;
                    newName = KCT_GameStates.ActiveKSC.ActiveLPInstance.name;
                    showRename = true;
                    showBuildList = false;
                    showBLPlus = false;
                }
                if (costOfNewLP >= 0 && GUILayout.Button("New", GUILayout.ExpandWidth(false)))
                {
                    //open dialog to unlock new
                    costOfNewLP = KCT_MathParsing.GetStandardFormulaValue("NewLaunchPadCost", new Dictionary<string, string> { { "N", KCT_GameStates.ActiveKSC.LaunchPads.Count.ToString() } });
                    DialogGUIBase[] options = new DialogGUIBase[2];
                    options[0] = new DialogGUIButton("Yes", () =>
                    {
                        if (!KCT_Utilities.CurrentGameIsCareer())
                        {
                            KCTDebug.Log("Building new launchpad!");
                            KCT_GameStates.ActiveKSC.LaunchPads.Add(new KCT_LaunchPad("LaunchPad " + (KCT_GameStates.ActiveKSC.LaunchPads.Count + 1), 2));
                        }
                        else if (Funding.CanAfford((float)costOfNewLP))
                        {
                            KCTDebug.Log("Building new launchpad!");
                            //take the funds
                            KCT_Utilities.SpendFunds(costOfNewLP, TransactionReasons.StructureConstruction);
                            //create new launchpad at level -1
                            KCT_GameStates.ActiveKSC.LaunchPads.Add(new KCT_LaunchPad("LaunchPad " + (KCT_GameStates.ActiveKSC.LaunchPads.Count + 1), -1));
                            //create new upgradeable
                            KCT_UpgradingBuilding newPad = new KCT_UpgradingBuilding();//(null, 0, -1, "LaunchPad");
                            newPad.id = "SpaceCenter/LaunchPad";
                            newPad.isLaunchpad = true;
                            newPad.launchpadID = KCT_GameStates.ActiveKSC.LaunchPads.Count-1;
                            newPad.upgradeLevel = 0;
                            newPad.currentLevel = -1;
                            newPad.cost = costOfNewLP;
                            newPad.SetBP(costOfNewLP);
                            newPad.commonName = "LaunchPad " + (KCT_GameStates.ActiveKSC.LaunchPads.Count);
                            KCT_GameStates.ActiveKSC.KSCTech.Add(newPad);

                        }
                        costOfNewLP = -13;
                    });
                    options[1] = new DialogGUIButton("No", DummyVoid);
                    MultiOptionDialog diag = new MultiOptionDialog("It will cost " + Math.Round(costOfNewLP, 2).ToString("N") + " funds to build a new launchpad. Would you like to build it?", "Build LaunchPad", null, 300, options);
                    PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
                }
                GUILayout.FlexibleSpace();
                if (lpCount > 1 && GUILayout.Button(">>", GUILayout.ExpandWidth(false)))
                {
                    KCT_GameStates.ActiveKSC.SwitchLaunchPad((KCT_GameStates.ActiveKSC.ActiveLaunchPadID + 1) % KCT_GameStates.ActiveKSC.LaunchPadCount);
                }
                GUILayout.EndHorizontal();
            }
            else if (listWindow == 1) //SPH Build List
            {
                List<KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.SPHList;
                GUILayout.BeginHorizontal();
              //  GUILayout.Space((butW + 4) * 3);
                GUILayout.Label("Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1 / 2));
                GUILayout.Label("Time Left:", GUILayout.Width(width2));
                //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10));
                GUILayout.EndHorizontal();
                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));
                {
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels under construction! Go to the SPH to build more.");
                    }
                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        if (!b.allPartsValid)
                            continue;
                        GUILayout.BeginHorizontal();
                        if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW)))
                        {
                            if (IDSelected == b.id)
                                showBLPlus = !showBLPlus;
                            else
                                showBLPlus = true;
                            IDSelected = b.id;
                        }
                        else if (HighLogic.LoadedSceneIsEditor)
                        {
                            //GUILayout.Space(butW);
                            if (GUILayout.Button("X", GUILayout.Width(butW)))
                            {
                                InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock");
                                IDSelected = b.id;
                                DialogGUIBase[] options = new DialogGUIBase[2];
                                options[0] = new DialogGUIButton("Yes", ScrapVessel);
                                options[1] = new DialogGUIButton("No", DummyVoid);
                                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap " + b.shipName + "?", "Scrap Vessel", null, 300, options);
                                PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);
                            }
                        }

                        if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Insert(0, b);
                            }
                            else
                            {
                                buildList.Insert(i - 1, b);
                            }
                        }
                        else if (i == 0)
                        {
                  //          GUILayout.Space(butW + 4);
                        }
                        if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW)))
                        {
                            buildList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                buildList.Add(b);
                            }
                            else
                            {
                                buildList.Insert(i + 1, b);
                            }
                        }
                        else if (i >= buildList.Count - 1)
                        {
                   //         GUILayout.Space(butW + 4);
                        }

                        GUILayout.Label(b.shipName);
                        GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2));
                        if (b.buildRate > 0)
                            GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2));
                        else
                            GUILayout.Label("Est: " + MagiCore.Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.SPH, null)), GUILayout.Width(width2));
                        //GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10));
                        GUILayout.EndHorizontal();
                    }

                    buildList = KCT_GameStates.ActiveKSC.SPHWarehouse;
                    GUILayout.Label("__________________________________________________");
                    GUILayout.Label("SPH Storage");
                    if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel"))
                    {
                        if (!KCT_Utilities.RecoverActiveVesselToStorage(KCT_BuildListVessel.ListType.SPH))
                        {
                            PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Error!", "There was an error while recovering the ship. Sometimes reloading the scene and trying again works. Sometimes a vessel just can't be recovered this way and you must use the stock recover system.", "OK", false, HighLogic.UISkin);
                        }
                    }

                    for (int i = 0; i < buildList.Count; i++)
                    {
                        KCT_BuildListVessel b = buildList[i];
                        if (!b.allPartsValid)
                            continue;
                        string status = "";
                        KCT_Recon_Rollout recovery = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery);
                        if (recovery != null)
                            status = "Recovering";

                        GUILayout.BeginHorizontal();
                        if (!HighLogic.LoadedSceneIsEditor && status == "")
                        {
                            if (GUILayout.Button("*", GUILayout.Width(butW)))
                            {
                                if (IDSelected == b.id)
                                    showBLPlus = !showBLPlus;
                                else
                                    showBLPlus = true;
                                IDSelected = b.id;
                            }
                        }
                        else
                            GUILayout.Space(butW + 4);

                        GUILayout.Label(b.shipName);
                        GUILayout.Label(status + "   ", GUILayout.ExpandWidth(false));
                        //ScenarioDestructibles.protoDestructibles["KSCRunway"].
                        if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && GUILayout.Button("Launch", GUILayout.ExpandWidth(false)))
                        {
                            List<string> facilityChecks = b.MeetsFacilityRequirements();
                            if (facilityChecks.Count == 0)
                            {
                                bool operational = KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.SPH);//new PreFlightTests.FacilityOperational("Runway", "building").Test();
                                if (!operational)
                                {
                                    ScreenMessages.PostScreenMessage("You must repair the runway prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER);
                                }
                                else
                                {
                                    showBLPlus = false;
                                    KCT_GameStates.launchedVessel = b;
                                    if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, "Runway").Count == 0)
                                    {
                                        if (!IsCrewable(b.ExtractedParts))
                                            b.Launch();
                                        else
                                        {
                                            showBuildList = false;
                                            if (KCT_Events.instance.KCTButtonStock != null)
                                            {
                                                KCT_Events.instance.KCTButtonStock.SetFalse();
                                            }
                                            centralWindowPosition.height = 1;
                                            KCT_GameStates.launchedCrew.Clear();
                                            parts = KCT_GameStates.launchedVessel.ExtractedParts;
                                            pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts();
                                            KCT_GameStates.launchedCrew = new List<CrewedPart>();
                                            foreach (PseudoPart pp in pseudoParts)
                                                KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List<ProtoCrewMember>()));
                                            CrewFirstAvailable();
                                            showShipRoster = true;
                                        }
                                    }
                                    else
                                    {
                                        showBuildList = false;
                                        showClearLaunch = true;
                                    }
                                }
                            }
                            else
                            {
                                PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Cannot Launch!", "Warning! This vessel did not pass the editor checks! Until you upgrade the SPH and/or Runway it cannot be launched. Listed below are the failed checks:\n" + String.Join("\n", facilityChecks.ToArray()), "Acknowledged", false, HighLogic.UISkin);
                            }
                        }
                        else if (recovery != null)
                        {
                            GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false));
                        }
                        GUILayout.EndHorizontal();
                    }
                    if (buildList.Count == 0)
                    {
                        GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete.");
                    }
                }
                GUILayout.EndScrollView();
            }
            else if (listWindow == 2) //Tech nodes
            {
                List<KCT_UpgradingBuilding> KSCList = KCT_GameStates.ActiveKSC.KSCTech;
                List<KCT_TechItem> techList = KCT_GameStates.TechList;
                //GUILayout.Label("Tech Node Research");
                GUILayout.BeginHorizontal();
                GUILayout.Label("Name:");
                GUILayout.Label("Progress:", GUILayout.Width(width1/2));
                GUILayout.Label("Time Left:", GUILayout.Width(width1));
                GUILayout.Space(70);
                GUILayout.EndHorizontal();
                scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250));

                if (KCT_Utilities.CurrentGameIsCareer())
                {
                if (KSCList.Count == 0)
                        GUILayout.Label("No KSC upgrade projects are currently underway.");
                foreach (KCT_UpgradingBuilding KCTTech in KSCList)
                {
                    GUILayout.BeginHorizontal();
                    /*
                    int i = KSCList.IndexOf(KCTTech);
                    if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW)))
                    {
                        KSCList.RemoveAt(i);
                        if (GameSettings.MODIFIER_KEY.GetKey())
                        {
                            KSCList.Insert(0, KCTTech);
                        }
                        else
                        {
                            KSCList.Insert(i - 1, KCTTech);
                        }
                    }
                    if (i < KSCList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW)))
                    {
                        KSCList.RemoveAt(i);
                        if (GameSettings.MODIFIER_KEY.GetKey())
                        {
                            KSCList.Add(KCTTech);
                        }
                        else
                        {
                            KSCList.Insert(i + 1, KCTTech);
                        }
                    }
                    */

                    GUILayout.Label(KCTTech.AsIKCTBuildItem().GetItemName());
                    GUILayout.Label(Math.Round(100 * KCTTech.progress / KCTTech.BP, 2) + " %", GUILayout.Width(width1 / 2));
                    GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(KCTTech.AsIKCTBuildItem().GetTimeLeft()), GUILayout.Width(width1));
                    if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width(70)))
                    {
                        KCT_GameStates.targetedItem = KCTTech;
                        KCT_GameStates.canWarp = true;
                        KCT_Utilities.RampUpWarp(KCTTech);
                        KCT_GameStates.warpInitiated = true;
                        /*if (KCTTech.AsIKCTBuildItem().GetBuildRate() > 0)
                        {
                            TimeWarp.fetch.WarpTo(Planetarium.GetUniversalTime() + KCTTech.AsIKCTBuildItem().GetTimeLeft(), KCT_GameStates.settings.MaxTimeWarp, 1);
                        }*/
                    }
                    else if (HighLogic.LoadedSceneIsEditor)
                        GUILayout.Space(70);
                    GUILayout.EndHorizontal();
                }
            }

                if (techList.Count == 0)
                    GUILayout.Label("No tech nodes are being researched!\nBegin research by unlocking tech in the R&D building.");
                bool forceRecheck = false;
                int cancelID = -1;
                for (int i = 0; i < techList.Count; i++)
                {
                    KCT_TechItem t = techList[i];
                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button("X", GUILayout.Width(butW)))
                    {
                        forceRecheck = true;
                        cancelID = i;
                        DialogGUIBase[] options = new DialogGUIBase[2];
                        options[0] = new DialogGUIButton("Yes", () => { CancelTechNode(cancelID); });
                        options[1] = new DialogGUIButton("No", DummyVoid);
                        MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to stop researching "+t.techName+"?", "Cancel Node?", null, 300, options);
                        PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin);

                        /*if (CancelTechNode(i))
                        {
                            i--;
                            GUILayout.EndHorizontal();
                            continue;
                        }*/
                    }

                    if (i > 0 && t.BuildRate != techList[0].BuildRate)
                    {
                        if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW)))
                        {
                            techList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                techList.Insert(0, t);
                            }
                            else
                            {
                                techList.Insert(i - 1, t);
                            }
                            forceRecheck = true;
                        }
                    }
                    if ((i == 0 && t.BuildRate != techList[techList.Count - 1].BuildRate) || t.BuildRate != techList[techList.Count - 1].BuildRate)
                    {
                        if (i < techList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW)))
                        {
                            techList.RemoveAt(i);
                            if (GameSettings.MODIFIER_KEY.GetKey())
                            {
                                techList.Add(t);
                            }
                            else
                            {
                                techList.Insert(i + 1, t);
                            }
                            forceRecheck = true;
                        }
                    }
                    if (forceRecheck)
                    {
                        forceRecheck = false;
                        for (int j=0; j<techList.Count; j++)
                            techList[j].UpdateBuildRate(j);
                    }

                    GUILayout.Label(t.techName);
                    GUILayout.Label(Math.Round(100 * t.progress / t.scienceCost, 2) + " %", GUILayout.Width(width1/2));
                    if (t.BuildRate > 0)
                        GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(t.TimeLeft), GUILayout.Width(width1));
                    else
                        GUILayout.Label("Est: " + MagiCore.Utilities.GetColonFormattedTime(t.EstimatedTimeLeft), GUILayout.Width(width1));
                    if (t.BuildRate > 0)
                    {
                        if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp", GUILayout.Width(45)))
                        {
                            KCT_GameStates.targetedItem = t;
                            KCT_GameStates.canWarp = true;
                            KCT_Utilities.RampUpWarp(t);
                            KCT_GameStates.warpInitiated = true;
                        }
                        else if (HighLogic.LoadedSceneIsEditor)
                            GUILayout.Space(45);
                    }
                    else
                        GUILayout.Space(45);

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

            if (KCT_UpdateChecker.UpdateFound)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Current Version: " + KCT_UpdateChecker.CurrentVersion);
                GUILayout.Label("Latest: " + KCT_UpdateChecker.WebVersion);
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();

               // if (ToolbarManager.ToolbarAvailable && ToolbarManager.Instance != null && KCT_GameStates.settings.PreferBlizzyToolbar)
                if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2))
                    GUI.DragWindow();
        }