コード例 #1
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")));
        }
コード例 #2
0
        private static DialogGUIBase[] CreateOptions(ModuleB9PartSwitch module, IList <Callback> afterCreateCallbacks)
        {
            List <DialogGUIBase> options = new List <DialogGUIBase>();

            SwitcherSubtypeDescriptionGenerator subtypeDescriptionGenerator = new SwitcherSubtypeDescriptionGenerator(module);

            foreach (PartSubtype subtype in module.subtypes)
            {
                if (!subtype.IsUnlocked())
                {
                    continue;
                }

                if (subtype == module.CurrentSubtype)
                {
                    string         currentSubtypeText = Localization.PartSwitchFlightDialog_CurrentSubtypeLabel(subtype.title); // <<1>> (Current)
                    DialogGUILabel label = new DialogGUILabel(currentSubtypeText, HighLogic.UISkin.button);
                    afterCreateCallbacks.Add(delegate
                    {
                        if (!(label.uiItem.GetComponent <TextMeshProUGUI>() is TextMeshProUGUI textUI))
                        {
                            throw new Exception("Could not find TextMeshProUGUI");
                        }
                        else
                        {
                            textUI.raycastTarget = true;
                        }
                    });
コード例 #3
0
ファイル: VesselWindow.cs プロジェクト: canisin/PreciseEditor
        public void Show()
        {
            const string TITLE       = "Precise Editor - Vessel Window";
            const string MESSAGE     = "";
            const float  LABEL_WIDTH = 100;
            const float  VALUE_WIDTH = 150;
            const float  HEIGHT      = 25f;

            DialogGUILabel  labelCenterOfMass      = new DialogGUILabel("Center of Mass", LABEL_WIDTH, HEIGHT);
            DialogGUILabel  labelCenterOfLift      = new DialogGUILabel("Center of Lift", LABEL_WIDTH, HEIGHT);
            DialogGUILabel  labelCenterOfThrust    = new DialogGUILabel("Center of Thrust", LABEL_WIDTH, HEIGHT);
            DialogGUILabel  labelCloseButtonSpacer = new DialogGUILabel("", 60f, HEIGHT);
            DialogGUILabel  valueCenterOfMass      = new DialogGUILabel(this.GetCenterOfMass, VALUE_WIDTH, HEIGHT);
            DialogGUILabel  valueCenterOfLift      = new DialogGUILabel(this.GetCenterOfLift, VALUE_WIDTH, HEIGHT);
            DialogGUILabel  valueCenterOfThrust    = new DialogGUILabel(this.GetCenterOfThrust, VALUE_WIDTH, HEIGHT);
            DialogGUIButton buttonClose            = new DialogGUIButton("Close Window", delegate { }, 140f, HEIGHT, true);

            MultiOptionDialog dialog = new MultiOptionDialog("vesselWindowDialog", MESSAGE, TITLE, HighLogic.UISkin, this.dialogRect,
                                                             new DialogGUIFlexibleSpace(),
                                                             new DialogGUIHorizontalLayout(labelCenterOfMass, valueCenterOfMass),
                                                             new DialogGUIHorizontalLayout(labelCenterOfLift, valueCenterOfLift),
                                                             new DialogGUIHorizontalLayout(labelCenterOfThrust, valueCenterOfThrust),
                                                             new DialogGUIVerticalLayout(
                                                                 new DialogGUIFlexibleSpace(),
                                                                 new DialogGUIHorizontalLayout(labelCloseButtonSpacer, buttonClose)
                                                                 )
                                                             );

            this.popupDialog = PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, HighLogic.UISkin, false);
            this.popupDialog.onDestroy.AddListener(this.OnPopupDialogDestroy);
        }
コード例 #4
0
        protected override List <DialogGUIBase> drawContentComponents()
        {
            List <DialogGUIBase> listComponments = new List <DialogGUIBase>();

            DialogGUILabel newColorLabel = new DialogGUILabel("<b>  " + Localizer.Format("#CNC_ColorPicker_newColorLabel") + "</b>", 40, 12);//New

            newColorImage = new DialogGUIImage(new Vector2(30, 24), Vector2.zero, chosenColor, UIUtils.createAndColorize(30, 24, Color.white));
            DialogGUILabel currentColorLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_ColorPicker_CurrentColorLabel") + "  </b>", 45, 12);//Current
            DialogGUIImage currentColorImage = new DialogGUIImage(new Vector2(30, 24), Vector2.zero, currentColor, UIUtils.createAndColorize(30, 24, Color.white));

            listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { new DialogGUISpace(40), newColorImage, newColorLabel, new DialogGUISpace(dialogWidth - 80 - 145), currentColorLabel, currentColorImage, new DialogGUISpace(40) }));

            colorPickerImage = new DialogGUIImage(new Vector2(displayTextureWidth, displayTextureHeight), Vector2.zero, Color.white, colorPickerTexture);
            DialogGUIImage  hueSliderImage = new DialogGUIImage(new Vector2(displayTextureWidth, sliderHeight * 2), Vector2.zero, Color.white, renderHueSliderTexture());
            DialogGUISlider hueSlider      = new DialogGUISlider(() => hueValue, 0f, 1f, false, displayTextureWidth, sliderHeight, setHueValue);

            listComponments.Add(new DialogGUIVerticalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { colorPickerImage, new DialogGUISpace(5f), hueSliderImage, hueSlider }));

            DialogGUILabel hexColorLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_ColorPicker_HexColorLabel") + " <size=15>#</size></b>", true, false);//Or hex color

            colorHexInput = new DialogGUITextInput("", false, 6, setColorHexString, 75, 24);
            DialogGUIButton hexGoButton = new DialogGUIButton(Localizer.Format("#CNC_ColorPicker_HexGoButton"), delegate { this.readColorHexString(); }, 40, 24, false);//"Parse"

            listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(0, 0, 0, 5), TextAnchor.MiddleCenter, new DialogGUIBase[] { new DialogGUISpace(5), hexColorLabel, colorHexInput, new DialogGUISpace(3), hexGoButton, new DialogGUISpace(5) }));

            return(listComponments);
        }
コード例 #5
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);
        }
コード例 #6
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;
                }
            }
        }
コード例 #7
0
        public override List <DialogGUIBase> getContentComponents()
        {
            List <DialogGUIBase> layout = new List <DialogGUIBase>();

            DialogGUILabel msgLbl = new DialogGUILabel(Localizer.Format("#CNC_getContentCompon_msgLabel4"), 100, 32);//"Set up the master frequency in one go. All antennas will be assigned to this frequency, and Comm powers of those deployed antennas will be combined."

            layout.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { msgLbl }));

            DialogGUILabel freqLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_Generic_FrequencyLabel") + "</b>", 52, 12);//Frequency

            frequencyInput = new DialogGUITextInput(CNCSettings.Instance.PublicRadioFrequency + "", false, CNCSettings.MaxDigits, setConstellFreq, 45, 25);
            DialogGUIToggle membershipToggle = new DialogGUIToggle(false, "", membershipFlagToggle);
            DialogGUILabel  membershipLabel  = new DialogGUILabel("<b>" + Localizer.Format("#CNC_getContentCompon_membershipLabel") + "</b>", 200, 12);//Talk to constellation members only

            DialogGUIHorizontalLayout constellationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { freqLabel, frequencyInput, new DialogGUISpace(20), membershipToggle, membershipLabel });

            layout.Add(constellationGroup);

            constellationColorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.one, Color.white, colorTexture);
            DialogGUILabel constNameLabel = new DialogGUILabel(getConstellationName, 200, 12);

            layout.Add(new DialogGUIHorizontalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { constNameLabel, constellationColorImage }));

            DialogGUIButton           updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_UpdateButton"), updateClick, false);  //"Update"
            DialogGUIButton           publicButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_PublicButton"), defaultClick, false); //"Revert to public"
            DialogGUIHorizontalLayout actionGroup  = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), updateButton, publicButton, new DialogGUIFlexibleSpace() });

            layout.Add(actionGroup);

            return(layout);
        }
コード例 #8
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;
                }
            }
        }
コード例 #9
0
 private DialogGUIBase[] PaddedLabel(string stringToPad)
 {
     DialogGUIBase[] paddedLayout = new DialogGUIBase[2];
     paddedLayout[0] = new DialogGUISpace(10);
     paddedLayout[1] = new DialogGUILabel(stringToPad);
     return(paddedLayout);
 }
コード例 #10
0
        public void DisplayData()
        {
            Core.Log("KerbalHealthEditorReport.DisplayData");
            if ((ShipConstruction.ShipManifest == null) || (!ShipConstruction.ShipManifest.HasAnyCrew()))
            {
                Core.Log("Ship is empty. Let's get outta here!", Core.LogLevel.Important);
                return;
            }
            gridContents = new List <DialogGUIBase>((Core.KerbalHealthList.Count + 1) * colNum)
            {
                // Creating column titles
                new DialogGUILabel("Name", true),
                new DialogGUILabel("Trend", true),
                new DialogGUILabel("Time Left", true)
            };
            // Initializing Health Report's grid with empty labels, to be filled in Update()
            for (int i = 0; i < ShipConstruction.ShipManifest.CrewCount * colNum; i++)
            {
                gridContents.Add(new DialogGUILabel("", true));
            }

            // Preparing factors checklist
            List <DialogGUIToggle> checklist = new List <DialogGUIToggle>();

            foreach (HealthFactor f in Core.Factors)
            {
                checklist.Add(new DialogGUIToggle(f.IsEnabledInEditor, f.Title, (state) => { f.SetEnabledInEditor(state); Invalidate(); }));
            }
            checklist.Add(new DialogGUIToggle(true, "Health modules", (state) => { healthModulesEnabled = state; Invalidate(); }));

            reportWindow = PopupDialog.SpawnPopupDialog(
                new Vector2(0.5f, 0.5f),
                new Vector2(0.5f, 0.5f),
                new MultiOptionDialog(
                    "Health Report",
                    "",
                    "Health Report",
                    HighLogic.UISkin,
                    reportPosition,
                    new DialogGUIGridLayout(new RectOffset(0, 0, 0, 0), new Vector2(80, 30), new Vector2(20, 0), UnityEngine.UI.GridLayoutGroup.Corner.UpperLeft, UnityEngine.UI.GridLayoutGroup.Axis.Horizontal, TextAnchor.MiddleCenter, UnityEngine.UI.GridLayoutGroup.Constraint.FixedColumnCount, colNum, gridContents.ToArray()),
                    new DialogGUIHorizontalLayout(
                        new DialogGUILabel("Space: ", false),
                        spaceLbl = new DialogGUILabel("N/A", true),
                        new DialogGUILabel("Recuperation: ", false),
                        recupLbl = new DialogGUILabel("N/A", true)),
                    new DialogGUIHorizontalLayout(
                        new DialogGUILabel("Shielding: ", false),
                        shieldingLbl = new DialogGUILabel("N/A", true),
                        new DialogGUILabel("Exposure: ", false),
                        exposureLbl = new DialogGUILabel("N/A", true)),
                    new DialogGUIHorizontalLayout(
                        new DialogGUILabel("", true),
                        new DialogGUILabel("Factors", true),
                        new DialogGUIButton("Reset", OnResetButtonSelected, false)),
                    new DialogGUIGridLayout(new RectOffset(0, 0, 0, 0), new Vector2(140, 30), new Vector2(20, 0), UnityEngine.UI.GridLayoutGroup.Corner.UpperLeft, UnityEngine.UI.GridLayoutGroup.Axis.Horizontal, TextAnchor.MiddleCenter, UnityEngine.UI.GridLayoutGroup.Constraint.FixedColumnCount, 2, checklist.ToArray())),
                false,
                HighLogic.UISkin,
                false);
            Invalidate();
        }
コード例 #11
0
        public void Show()
        {
            Hide();

            string      title       = FormatLabel("Precise Editor - ") + "Vessel";
            const float LABEL_WIDTH = 100;
            const float VALUE_WIDTH = 150;
            const float HEIGHT      = 25f;

            DialogGUILabel  labelCenterOfMass   = new DialogGUILabel(FormatLabel("Center of Mass"), LABEL_WIDTH, HEIGHT);
            DialogGUILabel  labelCenterOfLift   = new DialogGUILabel(FormatLabel("Center of Lift"), LABEL_WIDTH, HEIGHT);
            DialogGUILabel  labelCenterOfThrust = new DialogGUILabel(FormatLabel("Center of Thrust"), LABEL_WIDTH, HEIGHT);
            DialogGUISpace  spaceToCenter       = new DialogGUISpace(-1);
            DialogGUILabel  valueCenterOfMass   = new DialogGUILabel(GetCenterOfMass, VALUE_WIDTH, HEIGHT);
            DialogGUILabel  valueCenterOfLift   = new DialogGUILabel(GetCenterOfLift, VALUE_WIDTH, HEIGHT);
            DialogGUILabel  valueCenterOfThrust = new DialogGUILabel(GetCenterOfThrust, VALUE_WIDTH, HEIGHT);
            DialogGUIButton buttonClose         = new DialogGUIButton("Close", delegate { }, 140f, HEIGHT, true);

            dialog = new MultiOptionDialog("vesselWindowDialog", "", title, HighLogic.UISkin, dialogRect,
                                           new DialogGUIFlexibleSpace(),
                                           new DialogGUIHorizontalLayout(labelCenterOfMass, valueCenterOfMass),
                                           new DialogGUIHorizontalLayout(labelCenterOfLift, valueCenterOfLift),
                                           new DialogGUIHorizontalLayout(labelCenterOfThrust, valueCenterOfThrust),
                                           new DialogGUIVerticalLayout(
                                               new DialogGUIFlexibleSpace(),
                                               new DialogGUIHorizontalLayout(spaceToCenter, buttonClose, spaceToCenter)
                                               )
                                           );

            popupDialog = PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, HighLogic.UISkin, false);
            popupDialog.onDestroy.AddListener(SaveWindowPosition);
        }
コード例 #12
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);
 }
コード例 #13
0
        private DialogGUIHorizontalLayout createConstellationRow(short freq)
        {
            Color color = Constellation.getColor(freq);
            string name = Constellation.getName(freq);

            DialogGUIImage colorImage = new DialogGUIImage(new Vector2(32, 32), Vector2.one, color, colorTexture);
            DialogGUILabel nameLabel = new DialogGUILabel(name, 140, 12);
            DialogGUILabel eachFreqLabel = new DialogGUILabel(string.Format("(<color={0}>{1}</color>)", UIUtils.colorToHex(color), freq), 40, 12);
            DialogGUIButton removeButton = new DialogGUIButton("Drop", delegate { deleteFreqClick(freq); }, 40, 25, false);
            return new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { colorImage, nameLabel, eachFreqLabel, removeButton });
        }
コード例 #14
0
        public static DialogGUILabel GUILabel(String message, Boolean expandW = false, Boolean expandH = false, Modifier <DialogGUILabel> modifier = null)
        {
            DialogGUILabel element = new DialogGUILabel(message, expandW, expandH);

            if (modifier != null)
            {
                element = modifier(element);
            }
            _elements.Add(element);
            return(element);
        }
コード例 #15
0
        public static DialogGUILabel GUILabel(Func <String> getString, Single width, Single height = 0.0f, Modifier <DialogGUILabel> modifier = null)
        {
            DialogGUILabel element = new DialogGUILabel(getString, width, height);

            if (modifier != null)
            {
                element = modifier(element);
            }
            _elements.Add(element);
            return(element);
        }
コード例 #16
0
        public static DialogGUILabel GUILabel(Func <String> getString, UIStyle style, Boolean expandW = false, Boolean expandH = false, Modifier <DialogGUILabel> modifier = null)
        {
            DialogGUILabel element = new DialogGUILabel(getString, style, expandW, expandH);

            if (modifier != null)
            {
                element = modifier(element);
            }
            _elements.Add(element);
            return(element);
        }
コード例 #17
0
        private DialogGUIBase[] getVesselSortLayout()
        {
            float btnWidth  = 100;
            float btnHeight = 28;

            DialogGUILabel  sortLabel     = new DialogGUILabel(Localizer.Format("#CNC_ConstellationControl_sortLabel"), 35, 12);                                                                                                                                              //"Sort by"
            DialogGUIButton launchSortBtn = new DialogGUIButton(Localizer.Format("#CNC_ConstellationControl_launchSortBtn"), delegate { currentVesselSort = VesselListSort.LAUNCHDATE; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth, btnHeight, false);   //"Launch time"
            DialogGUIButton freqSortBtn   = new DialogGUIButton(Localizer.Format("#CNC_ConstellationControl_freqSortBtn"), delegate { currentVesselSort = VesselListSort.RADIOFREQ; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth + 40, btnHeight, false); //"Strongest frequency"
            DialogGUIButton nameSortBtn   = new DialogGUIButton(Localizer.Format("#CNC_ConstellationControl_nameSortBtn"), delegate { currentVesselSort = VesselListSort.VESSELNAME; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth, btnHeight, false);     //"Vessel name"
            DialogGUIButton bodySortBtn   = new DialogGUIButton(Localizer.Format("#CNC_ConstellationControl_bodySortBtn"), delegate { currentVesselSort = VesselListSort.CBODY; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth, btnHeight, false);          //"Celestial body"

            return(new DialogGUIBase[] { sortLabel, launchSortBtn, freqSortBtn, nameSortBtn, bodySortBtn });
        }
コード例 #18
0
        private DialogGUIBase[] getVesselSortLayout()
        {
            float btnWidth  = 100;
            float btnHeight = 28;

            DialogGUILabel  sortLabel     = new DialogGUILabel("Sort by", 35, 12);
            DialogGUIButton launchSortBtn = new DialogGUIButton("Launch time", delegate { currentVesselSort = VesselListSort.LAUNCHDATE; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth, btnHeight, false);
            DialogGUIButton freqSortBtn   = new DialogGUIButton("Strongest frequency", delegate { currentVesselSort = VesselListSort.RADIOFREQ; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth + 40, btnHeight, false);
            DialogGUIButton nameSortBtn   = new DialogGUIButton("Vessel name", delegate { currentVesselSort = VesselListSort.VESSELNAME; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth, btnHeight, false);
            DialogGUIButton bodySortBtn   = new DialogGUIButton("Celestial body", delegate { currentVesselSort = VesselListSort.CBODY; mapfilterChanged(MapViewFiltering.vesselTypeFilter); }, btnWidth, btnHeight, false);

            return(new DialogGUIBase[] { sortLabel, launchSortBtn, freqSortBtn, nameSortBtn, bodySortBtn });
        }
コード例 #19
0
        private DialogGUIHorizontalLayout createFrequencyRow(short freq)
        {
            CNCCommNetVessel cncVessel = (CNCCommNetVessel)this.hostVessel.Connection;
            Color            color     = Constellation.getColor(freq);
            string           name      = Constellation.getName(freq);

            DialogGUIImage colorImage     = new DialogGUIImage(new Vector2(32, 32), Vector2.one, color, colorTexture);
            DialogGUILabel nameLabel      = new DialogGUILabel(name, 170, 12);
            DialogGUILabel eachFreqLabel  = new DialogGUILabel(string.Format("(<color={0}>{1}</color>)", UIUtils.colorToHex(color), freq), 70, 12);
            DialogGUILabel freqPowerLabel = new DialogGUILabel(string.Format("Combined Comm Power: {0}", UIUtils.RoundToNearestMetricFactor(cncVessel.getMaxComPower(freq), 2)), 220, 12);

            return(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { colorImage, new DialogGUISpace(20), nameLabel, eachFreqLabel, freqPowerLabel }));
        }
コード例 #20
0
        private PopupDialog DrawMainUi()
        {
            padding = 0;
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
            {
                innerElements.Add(new DialogGUILabel("Bureaucracy is only available in Career Games"));
            }
            else
            {
                innerElements.Add(new DialogGUISpace(10));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Next Budget: " + Utilities.Instance.ConvertUtToKspTimeStamp(BudgetManager.Instance.NextBudget.CompletionTime), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Gross Budget: $" + Utilities.Instance.GetGrossBudget(), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Wage Costs: $" + Costs.Instance.GetWageCosts(), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Facility Maintenance Costs: $" + Costs.Instance.GetFacilityMaintenanceCosts(), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Launch Costs: $" + Costs.Instance.GetLaunchCosts(), false)));
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Mission Bonuses: $" + GetBonusesToPay(), false)));
                for (int i = 0; i < Bureaucracy.Instance.registeredManagers.Count; i++)
                {
                    Manager m = Bureaucracy.Instance.registeredManagers.ElementAt(i);
                    if (m.Name == "Budget")
                    {
                        continue;
                    }
                    double departmentFunding = Math.Round(Utilities.Instance.GetNetBudget(m.Name), 0);
                    if (departmentFunding < 0.0f)
                    {
                        continue;
                    }
                    innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel(m.Name + " Department Funding: $" + departmentFunding, false)));
                }
                innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Net Budget: $" + Utilities.Instance.GetNetBudget("Budget"), false)));
                DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray());
                vertical.AddChild(new DialogGUIContentSizer(widthMode: ContentSizeFitter.FitMode.Unconstrained, heightMode: ContentSizeFitter.FitMode.MinSize));
                dialogElements.Add(new DialogGUIScrollList(new Vector2(300, 300), false, true, vertical));
                DialogGUIBase[] horizontal = new DialogGUIBase[6];
                horizontal[0] = new DialogGUILabel("Allocations: ");
                horizontal[1] = new DialogGUILabel("Funds: " + fundingAllocation + "%");
                horizontal[2] = new DialogGUILabel("|");
                horizontal[3] = new DialogGUILabel("Construction: " + constructionAllocation + "%");
                horizontal[4] = new DialogGUILabel("|");
                horizontal[5] = new DialogGUILabel("Research: " + researchAllocation + "%");
                dialogElements.Add(new DialogGUIHorizontalLayout(horizontal));
                dialogElements.Add(GetBoxes("main"));
            }
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("BureaucracyMain", "", "Bureaucracy: Budget", UISkinManager.GetSkin("MainMenuSkin"),
                                                                      GetRect(dialogElements), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"), false));
        }
コード例 #21
0
        private DialogGUIHorizontalLayout createGroundStationRow(CNCCommNetHome thisStation)
        {
            DialogGUIImage  colorImage       = new DialogGUIImage(new Vector2(16, 16), Vector2.one, thisStation.Color, groundstationTexture);
            DialogGUILabel  stationNameLabel = new DialogGUILabel(thisStation.stationName, 170, 12);
            DialogGUILabel  locationLabel    = new DialogGUILabel(Localizer.Format("#CNC_ConstellationControl_LatitudeAndLongitude", string.Format("{0:0.0}", thisStation.latitude), string.Format("{0:0.0}", thisStation.longitude)), 100, 24); //string.Format("LAT: \nLON: ", , )
            DialogGUILabel  freqsLabel       = new DialogGUILabel(getFreqString(thisStation.getFrequencyList()), 210, 12);
            DialogGUIButton updateButton     = new DialogGUIButton(Localizer.Format("#CNC_Generic_Editbutton"), delegate { groundstationEditClick(thisStation); }, 50, 32, false);                                                               //"Edit"

            DialogGUIBase[]           rowGUIBase         = new DialogGUIBase[] { colorImage, stationNameLabel, locationLabel, freqsLabel, updateButton };
            DialogGUIHorizontalLayout groundStationGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, rowGUIBase);

            groundStationGroup.SetOptionText(thisStation.ID); //for quick identification
            return(groundStationGroup);
        }
コード例 #22
0
        private PopupDialog DrawBudgetAllocationUi()
        {
            padding = 0;
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            DialogGUIBase[] horizontalArray = new DialogGUIBase[4];
            horizontalArray[0] = new DialogGUISpace(10);
            horizontalArray[1] = new DialogGUILabel("Budget", MessageStyle(true));
            horizontalArray[2] = new DialogGUISpace(70);
            horizontalArray[3] = new DialogGUITextInput(fundingAllocation.ToString(), false, 3, s => SetAllocation("Budget", s), 40.0f, 30.0f);
            innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            horizontalArray    = new DialogGUIBase[4];
            horizontalArray[0] = new DialogGUISpace(10);
            horizontalArray[1] = new DialogGUILabel("Construction", MessageStyle(true));
            horizontalArray[2] = new DialogGUISpace(10);
            horizontalArray[3] = new DialogGUITextInput(constructionAllocation.ToString(), false, 3, s => SetAllocation("Construction", s), 40.0f, 30.0f);
            innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            horizontalArray    = new DialogGUIBase[4];
            horizontalArray[0] = new DialogGUISpace(10);
            horizontalArray[1] = new DialogGUILabel("Research", MessageStyle(true));
            horizontalArray[2] = new DialogGUISpace(45);
            horizontalArray[3] = new DialogGUITextInput(researchAllocation.ToString(), false, 3, s => SetAllocation("Research", s), 40.0f, 30.0f);
            innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            for (int i = 0; i < Bureaucracy.Instance.registeredManagers.Count; i++)
            {
                Manager m = Bureaucracy.Instance.registeredManagers.ElementAt(i);
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (Utilities.Instance.GetNetBudget(m.Name) == -1.0f)
                {
                    continue;
                }
                horizontalArray    = new DialogGUIBase[3];
                horizontalArray[0] = new DialogGUISpace(10);
                horizontalArray[1] = new DialogGUILabel(m.Name + ": ");
                horizontalArray[2] = new DialogGUILabel(() => ShowFunding(m));
                innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            }
            horizontalArray    = new DialogGUIBase[2];
            horizontalArray[0] = new DialogGUISpace(10);
            horizontalArray[1] = new DialogGUIButton("Load Settings", () => SettingsClass.Instance.InGameLoad(), false);
            innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray));
            DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray());

            dialogElements.Add(new DialogGUIScrollList(-Vector2.one, false, false, vertical));
            dialogElements.Add(GetBoxes("allocation"));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("Bureaucracy", "", "Bureaucracy: Budget Allocation", UISkinManager.GetSkin("MainMenuSkin"),
                                                                      GetRect(dialogElements), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"), false));
        }
コード例 #23
0
        // TODO: Complete implementation
        private void showAddWindow()
        {
            // This is a list of content items to add to the dialog
            List <DialogGUIBase> dialog = new List <DialogGUIBase>();

            var                       noPad = new RectOffset();
            DialogGUIButton           b;
            DialogGUILabel            l;
            DialogGUIHorizontalLayout hl;
            DialogGUIVerticalLayout   vl;

            // Window Contents - scroll list of all available experiments with their descriptions
            vl         = new DialogGUIVerticalLayout(true, false);
            vl.padding = new RectOffset(6, 24, 6, 6); // Padding between border and contents - ensure we don't overlay content over scrollbar
            vl.spacing = 4;                           // Spacing between elements
            vl.AddChild(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true));

            int numExperiments = availableExperiments.Count;

            for (int idx = 0; idx < numExperiments; idx++)
            {
                var e = availableExperiments[idx];
                b      = new DialogGUIButton <ExperimentData>(e.getAbbreviation(), onAddExperiment, e, true);
                b.size = new Vector2(60, 30);
                l      = new DialogGUILabel(e.getDescription(), true, false);
                hl     = new DialogGUIHorizontalLayout(false, false, 4, new RectOffset(), TextAnchor.MiddleCenter, b, l);

                vl.AddChild(hl);
            }

            hl = new DialogGUIHorizontalLayout(true, true, new DialogGUIScrollList(Vector2.one, false, true, vl));
            dialog.Add(hl);

            // Add a centered "Cancel" button
            dialog.Add(new DialogGUIHorizontalLayout(new DialogGUIBase[]
            {
                new DialogGUIFlexibleSpace(),
                new DialogGUIButton("#ne_Cancel", null, true),
                new DialogGUIFlexibleSpace(),
            }));

            // Actually create and show the dialog
            Rect pos = new Rect(0.5f, 0.5f, 400, 400);

            PopupDialog.SpawnPopupDialog(
                new MultiOptionDialog("", "", "#ne_Add_Experiment", HighLogic.UISkin, pos, dialog.ToArray()),
                false, HighLogic.UISkin);
        }
コード例 #24
0
        protected override List <DialogGUIBase> drawContentComponents()
        {
            List <DialogGUIBase> listComponments = new List <DialogGUIBase>();

            listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description + "\n\n", false, false) }));

            //Current group
            DialogGUILabel currentLevelLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_GroundStationBuild_currentLevelLabel") + "</b>");//Current tech level

            currentTexture = new DialogGUIImage(new Vector2(100, 100), Vector2.zero, Color.white, getLevelTexture(this.hostStation.TechLevel));
            DialogGUILabel          currentPower      = new DialogGUILabel(currentPowerFunc);
            DialogGUIVerticalLayout currentLevelGroup = new DialogGUIVerticalLayout(100, 100, 4, new RectOffset(), TextAnchor.MiddleCenter,
                                                                                    new DialogGUIBase[] { currentLevelLabel, currentTexture, currentPower });

            //Upgrade arrow
            DialogGUIImage arrowTexture = new DialogGUIImage(new Vector2(40, 40), Vector2.zero, Color.white, upgradeArrowTexture);

            //Next group
            DialogGUILabel nextLevelLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_GroundStationBuild_nextLevelLabel") + "</b>");//Next tech level

            nextTexture = new DialogGUIImage(new Vector2(100, 100), Vector2.zero, Color.white, getLevelTexture((short)(this.hostStation.TechLevel + 1)));
            DialogGUILabel          nextPower      = new DialogGUILabel(nextPowerFunc);
            DialogGUIVerticalLayout nextLevelGroup = new DialogGUIVerticalLayout(100, 100, 4, new RectOffset(), TextAnchor.MiddleCenter,
                                                                                 new DialogGUIBase[] { nextLevelLabel, nextTexture, nextPower });

            listComponments.Add(new CustomDialogGUIScrollList(new Vector2(300 - 10, 150), false, false,
                                                              new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, new DialogGUIBase[] { currentLevelGroup, arrowTexture, nextLevelGroup })));

            //Requirements
            if (Funding.Instance != null) //only available in Career mode
            {
                DialogGUILabel costLabel      = new DialogGUILabel(costFunc);
                DialogGUILabel availableLabel = new DialogGUILabel(availableFunc);
                listComponments.Add(new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, new DialogGUIBase[] { costLabel }));
                listComponments.Add(new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, new DialogGUIBase[] { availableLabel }));
            }
            listComponments.Add(new DialogGUISpace(10));

            DialogGUIButton upgradeButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Upgradebutton"), onClickUpgrade, false);//Upgrade

            upgradeButton.OptionInteractableCondition = () => this.hostStation.TechLevel < 3 ? true : false;
            DialogGUIButton           closeButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Close"), delegate { this.dismiss(); }, false);//Close
            DialogGUIHorizontalLayout actionGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), upgradeButton, closeButton, new DialogGUIFlexibleSpace() });

            listComponments.Add(actionGroup);

            return(listComponments);
        }
コード例 #25
0
        protected override List <DialogGUIBase> drawContentComponents()
        {
            List <DialogGUIBase> listComponments = new List <DialogGUIBase>();

            listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description + "\n\n", false, false) }));

            DialogGUILabel nameLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_Generic_nameLabel") + "</b>", 30, 12);//Name

            nameInput = new DialogGUITextInput(this.hostStation.stationName, false, CNCSettings.MaxLengthName, setNameInput, 145, 25);
            DialogGUIButton           defaultButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Resetbutton"), defaultNameClick, 40, 25, false);//"Reset"
            DialogGUIHorizontalLayout nameGroup     = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { nameLabel, nameInput, new DialogGUIFlexibleSpace(), defaultButton });

            listComponments.Add(nameGroup);

            DialogGUILabel freqLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_GroundStationEdit_freqLabel") + "</b>", 85, 12);//New frequency

            frequencyInput = new DialogGUITextInput("", false, CNCSettings.MaxDigits, setFreqInput, 60, 25);
            DialogGUIButton addButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Addbutton"), addClick, 40, 25, false);//"Add"

            stationColorImage = new DialogGUIImage(new Vector2(16f, 16f), Vector2.zero, this.hostStation.Color, CNCCommNetHome.getGroundStationTexture(this.hostStation.TechLevel));
            DialogGUIHorizontalLayout imageBtnLayout = new DialogGUIHorizontalLayout(true, true, 0f, new RectOffset(5, 5, 5, 5), TextAnchor.MiddleCenter, new DialogGUIBase[] { stationColorImage });
            DialogGUIButton           colorButton    = new DialogGUIButton("", colorEditClick, 26, 26, false, new DialogGUIBase[] { imageBtnLayout });

            DialogGUIHorizontalLayout freqGRoup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { freqLabel, frequencyInput, addButton, new DialogGUISpace(50), colorButton });

            listComponments.Add(freqGRoup);

            //Prepare a list container for the GUILayout rows
            DialogGUIBase[] rows = new DialogGUIBase[this.hostStation.getFrequencyList().Count + 1];
            rows[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true);
            for (int i = 0; i < this.freqListShown.Count; i++)
            {
                rows[i + 1] = createConstellationRow(this.freqListShown[i]);
            }

            frequencyRowLayout = new DialogGUIVerticalLayout(10, 100, 0, new RectOffset(5, 25, 5, 5), TextAnchor.UpperLeft, rows);
            listComponments.Add(new CustomDialogGUIScrollList(new Vector2(240, 100), false, true, frequencyRowLayout));

            DialogGUIButton           updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_UpdateButton"), updateAction, false);                 //"Update"
            DialogGUIButton           cancelButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_CancelButton"), delegate { this.dismiss(); }, false); //"Cancel"
            DialogGUIHorizontalLayout actionGroup  = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), updateButton, cancelButton, new DialogGUIFlexibleSpace() });

            listComponments.Add(actionGroup);

            return(listComponments);
        }
コード例 #26
0
        private DialogGUIHorizontalLayout createVesselRow(CNCCommNetVessel thisVessel)
        {
            //answer is from FlagBrowserGUIButton
            DialogGUIImage            focusImage     = new DialogGUIImage(new Vector2(32f, 32f), Vector2.zero, Color.white, focusTexture);
            DialogGUIHorizontalLayout imageBtnLayout = new DialogGUIHorizontalLayout(true, true, 0f, new RectOffset(1, 1, 1, 1), TextAnchor.MiddleCenter, new DialogGUIBase[] { focusImage });
            DialogGUIButton           focusButton    = new DialogGUIButton("", delegate { vesselFocusClick(thisVessel.Vessel); }, 34, 34, false, new DialogGUIBase[] { imageBtnLayout });

            DialogGUILabel  vesselLabel   = new DialogGUILabel(thisVessel.Vessel.GetDisplayName(), 160, 12);
            DialogGUILabel  freqLabel     = new DialogGUILabel(getFreqString(thisVessel.getFrequencyList(), thisVessel.getStrongestFrequency()), 160, 12);
            DialogGUILabel  locationLabel = new DialogGUILabel(Localizer.Format("#CNC_ConstellationControl_locationLabel", thisVessel.Vessel.mainBody.GetDisplayName()), 100, 12); //Orbiting: <<1>>
            DialogGUIButton setupButton   = new DialogGUIButton(Localizer.Format("#CNC_Generic_Setupbutton"), delegate { vesselSetupClick(thisVessel.Vessel); }, 70, 32, false);   //"Setup"

            DialogGUIHorizontalLayout vesselGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { focusButton, vesselLabel, freqLabel, locationLabel, setupButton });

            vesselGroup.SetOptionText(thisVessel.Vessel.id.ToString());
            return(vesselGroup);
        }
コード例 #27
0
        private PopupDialog GenerateDialog()
        {
            List <DialogGUIBase> guiItems = new List <DialogGUIBase>();

            if (EditorLogic.fetch == null || EditorLogic.fetch.ship == null)
            {
                guiItems.Add(new DialogGUILabel("No Vessel Detected"));
            }
            else
            {
                guiItems.Add(new DialogGUILabel(_utilities.SystemNotes, _utilities.CreateNoteStyle()));
                guiItems.Add(new DialogGUILabel(_utilities.Warnings, _utilities.CreateNoteStyle()));
                DialogGUIBase[] vertical   = new DialogGUIBase[_utilities.Planets.Count];
                DialogGUIBase[] horizontal = new DialogGUIBase[2];
                horizontal[0] = new DialogGUIToggle(() => _returnTrip, "Return Trip?", delegate { SetReturnTrip(); });
                horizontal[1] = new DialogGUIToggle(() => payloadOnly, "Payload Only", delegate { SetPayoadOnly(); });
                guiItems.Add(new DialogGUIHorizontalLayout(horizontal));
                for (int i = 0; i < _utilities.Planets.Count; i++)
                {
                    PlanetDeltaV p = _utilities.Planets.ElementAt(i);
                    horizontal    = new DialogGUIBase[4];
                    horizontal[0] = new DialogGUILabel(p.GetName(), _utilities.GenerateStyle(-1, false));
                    horizontal[1] = GetDeltaVString(p, "Flyby: ");
                    horizontal[2] = GetDeltaVString(p, "Orbiting: ");
                    if (p.IsHomeWorld && p.SynchronousDv != -1)
                    {
                        horizontal[3] = GetDeltaVString(p, "Synchronous Orbit: ");
                    }
                    else
                    {
                        horizontal[3] = GetDeltaVString(p, "Landing: ");
                    }
                    vertical[i] = new DialogGUIHorizontalLayout(horizontal);
                }
                DialogGUIVerticalLayout layout = new DialogGUIVerticalLayout(vertical);
                guiItems.Add(new DialogGUIScrollList(-Vector2.one, false, true, layout));
            }
            guiItems.Add(new DialogGUILabel("*Assuming craft has enough chutes"));
            guiItems.Add(new DialogGUIButton("Close", () => _utilities.CloseDialog(_uiDialog), false));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("WhereCanIGoDialog", "", "Where Can I Go", UISkinManager.defaultSkin,
                                                                      _geometry,
                                                                      guiItems.ToArray()), false, UISkinManager.defaultSkin));
        }
コード例 #28
0
        private void showLabWindow()
        {
            // This is a list of content items to add to the dialog
            List <DialogGUIBase> dialog = new List <DialogGUIBase>();

            dialog.Add(new DialogGUILabel("#ne_Chooose_Lab"));

            // Build a button list of all available experiments with their descriptions
            int numLabs = availableLabs.Count;

            DialogGUIBase[] scrollList = new DialogGUIBase[numLabs + 1];
            scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true);
            for (int idx = 0; idx < numLabs; idx++)
            {
                var lab    = availableLabs[idx];
                var button = new DialogGUIButton <Lab>(lab.abbreviation, installExperimentInLab, lab, true);
                button.size = new Vector2(60, 30);
                var label = new DialogGUILabel(lab.GetInfo(), true, true);
                var h     = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.UpperLeft, new DialogGUIBase[] { button, label });

                scrollList[idx + 1] = h;
            }

#if true
            dialog.Add(new DialogGUIScrollList(new Vector2(200, 300), false, true, //Vector2.one, false, true,
                                               new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.UpperLeft, scrollList)
                                               ));
#else
            dialog.Add(new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.MiddleLeft, scrollList));
#endif

            // Add a centered "Cancel" button
            dialog.Add(new DialogGUIHorizontalLayout(new DialogGUIBase[]
            {
                new DialogGUIFlexibleSpace(),
                new DialogGUIButton("#ne_Cancel", null, true),
                new DialogGUIFlexibleSpace(),
            }));

            // Actually create and show the dialog
            PopupDialog.SpawnPopupDialog(
                new MultiOptionDialog("", "", "#ne_Install_Experiment", HighLogic.UISkin, dialog.ToArray()),
                false, HighLogic.UISkin);
        }
コード例 #29
0
        private PopupDialog GenerateDialog()
        {
            List <DialogGUIBase> guiItems = new List <DialogGUIBase>();
            bool vesselIsHome             = FlightGlobals.ActiveVessel.mainBody == FlightGlobals.GetHomeBody();

            if (FlightGlobals.ActiveVessel == null)
            {
                guiItems.Add(new DialogGUILabel("No Vessel Detected"));
            }
            else if (vesselIsHome && FlightGlobals.ActiveVessel.situation == Vessel.Situations.ORBITING)
            {
                guiItems.Add(new DialogGUILabel(_utilities.SystemNotes, _utilities.CreateNoteStyle()));
                guiItems.Add(new DialogGUILabel(_utilities.Warnings, _utilities.CreateNoteStyle()));
                guiItems.Add(new DialogGUIToggle(() => _returnTrip, "Return Trip?", delegate { SetReturnTrip(); }));
                for (int i = 0; i < _utilities.Planets.Count; i++)
                {
                    PlanetDeltaV    p          = _utilities.Planets.ElementAt(i);
                    DialogGUIBase[] horizontal = new DialogGUIBase[4];
                    horizontal[0] = new DialogGUILabel(p.GetName(), _utilities.GenerateStyle(-1, false));
                    horizontal[1] = GetDeltaVString(p, "Flyby: ");
                    horizontal[2] = GetDeltaVString(p, "Orbiting: ");
                    if (p.IsHomeWorld && p.SynchronousDv != -1)
                    {
                        horizontal[3] = GetDeltaVString(p, "Synchronous Orbit: ");
                    }
                    else
                    {
                        horizontal[3] = GetDeltaVString(p, "Landing: ");
                    }
                    guiItems.Add(new DialogGUIHorizontalLayout(horizontal));
                }

                guiItems.Add(new DialogGUILabel("*Assuming craft has enough chutes"));
            }
            else
            {
                guiItems.Add(new DialogGUILabel("No Data Available. Achieve stable orbit around " + FlightGlobals.GetHomeBodyName(), _utilities.GenerateStyle(99999, true)));
            }
            guiItems.Add(new DialogGUIButton("Close", () => _utilities.CloseDialog(_uiDialog), false));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("WhereCanIGoDialog", "", "Where Can I Go", UISkinManager.defaultSkin,
                                                                      _geometry,
                                                                      guiItems.ToArray()), false, UISkinManager.defaultSkin));
        }
コード例 #30
0
        public override List <DialogGUIBase> getContentComponents()
        {
            List <DialogGUIBase> layout = new List <DialogGUIBase>();

            DialogGUILabel msgLbl = new DialogGUILabel(Localizer.Format("#CNC_getContentCompon_msgLabel2"), 100, 16);//"Change the frequency of each antenna."

            layout.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { msgLbl }));

            freqInputArray = new DialogGUITextInput[antennas.Count];

            DialogGUIVerticalLayout nameColumn      = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft);
            DialogGUIVerticalLayout useColumn       = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft);
            DialogGUIVerticalLayout freqColumn      = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft);
            DialogGUIVerticalLayout freqInputColumn = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft);
            DialogGUIVerticalLayout updateColumn    = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft);

            for (int i = 0; i < antennas.Count; i++)
            {
                int index = i;//convert to solid-reference variable for delegate block
                CNCAntennaPartInfo antennaInfo = antennas[i];

                DialogGUILabel nameLabel  = new DialogGUILabel(Localizer.Format("#CNC_getContentCompon_nameLabel", antennaInfo.name), style); nameLabel.size = new Vector2(200, 32);                                                                                                                                                      //string.Format("Name: {0}",)
                DialogGUILabel usageLabel = new DialogGUILabel(Localizer.Format("#CNC_getContentCompon_usageLabel") + ": " + (antennaInfo.inUse ? "<color=green>" + Localizer.Format("#CNC_Generic_Yes") + "</color>" : "<color=red>" + Localizer.Format("#CNC_Generic_No") + "</color>"), style); usageLabel.size = new Vector2(75, 32); //In UseYesNo
                DialogGUILabel freqLabel  = new DialogGUILabel(Localizer.Format("#CNC_Generic_FrequencyLabel"), style); freqLabel.size = new Vector2(65, 32);                                                                                                                                                                             //"Frequency"
                freqInputArray[i] = new DialogGUITextInput(antennaInfo.frequency.ToString(), false, CNCSettings.MaxDigits, setAntennaFreq, 65, 25);
                DialogGUIButton updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_UpdateButton"), delegate { updateAntennaFreq(antennaInfo, freqInputArray[index].uiItem.GetComponent <TMP_InputField>().text); }, 70, 25, false);                                                                                        //"Update"

                nameColumn.AddChild(nameLabel);
                useColumn.AddChild(usageLabel);
                freqColumn.AddChild(freqLabel);
                freqInputColumn.AddChild(new DialogGUISpace(3));
                freqInputColumn.AddChild(freqInputArray[index]);
                freqInputColumn.AddChild(new DialogGUISpace(4));
                updateColumn.AddChild(new DialogGUISpace(3));
                updateColumn.AddChild(updateButton);
                updateColumn.AddChild(new DialogGUISpace(4));
            }

            layout.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { nameColumn, useColumn, freqColumn, freqInputColumn, updateColumn }));

            return(layout);
        }