private DialogGUIBase CreateMissionListDialog()
        {
            DialogGUIContentSizer sizer      = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true);
            DialogGUIToggleGroup  toggle     = new DialogGUIToggleGroup(this.CreateMissionListItems());
            DialogGUIGridLayout   layout     = new DialogGUIGridLayout(new RectOffset(0, 4, 4, 4), new Vector2(320f, 64f), new Vector2(0f, 0f), GridLayoutGroup.Corner.UpperLeft, GridLayoutGroup.Axis.Horizontal, TextAnchor.UpperLeft, GridLayoutGroup.Constraint.FixedColumnCount, 1, sizer, toggle);
            DialogGUIScrollList   scrollList = new DialogGUIScrollList(new Vector2(344f, 425f), false, true, layout);

            DialogGUIButton deleteButton = new DialogGUIButton("Delete", delegate
            {
                ShowDeleteMissionConfirmDialog();
            });

            deleteButton.OptionInteractableCondition = (() => selectedMissionIndex >= 0);

            DialogGUIButton cancelButton = new DialogGUIButton("Cancel", delegate
            {
                DismissDialog();
            });

            DialogGUIButton loadButton = new DialogGUIButton("Load", delegate
            {
                OnMissionSelected();
                DismissDialog();
            });

            loadButton.OptionInteractableCondition = (() => selectedMissionIndex >= 0);

            DialogGUIVerticalLayout dialogGUIVerticalLayout = new DialogGUIVerticalLayout(true, true);

            dialogGUIVerticalLayout.AddChild(scrollList);
            dialogGUIVerticalLayout.AddChild(new DialogGUIHorizontalLayout(deleteButton, cancelButton, loadButton));
            return(dialogGUIVerticalLayout);
        }
예제 #2
0
        public static DialogGUIGridLayout GUIGridLayout(Modifier <DialogGUIGridLayout> modifier = null)
        {
            DialogGUIGridLayout element = new DialogGUIGridLayout();

            if (modifier != null)
            {
                element = modifier(element);
            }
            _elements.Add(element);
            return(element);
        }
예제 #3
0
        public static DialogGUIGridLayout GUIGridLayout(Action optionBuilder, Modifier <DialogGUIGridLayout> modifier = null)
        {
            DialogGUIGridLayout element = new DialogGUIGridLayout(Declare(optionBuilder));

            if (modifier != null)
            {
                element = modifier(element);
            }
            _elements.Add(element);
            return(element);
        }
예제 #4
0
        public static DialogGUIGridLayout GUIGridLayout(RectOffset padding, Vector2 cellSize, Vector2 spacing,
                                                        GridLayoutGroup.Corner startCorner, GridLayoutGroup.Axis startAxis, TextAnchor childAligment,
                                                        GridLayoutGroup.Constraint constraint, Int32 constraintCount, Action optionBuilder, Modifier <DialogGUIGridLayout> modifier = null)
        {
            DialogGUIGridLayout element = new DialogGUIGridLayout(padding, cellSize, spacing, startCorner, startAxis,
                                                                  childAligment, constraint, constraintCount, Declare(optionBuilder));

            if (modifier != null)
            {
                element = modifier(element);
            }
            _elements.Add(element);
            return(element);
        }
예제 #5
0
        private void ButtonOnTrue()
        {
            // Store labels in separate data structure for easy access when updating
            labelMap.Clear();
            List <LifeSupportReportable> modules =
                FlightGlobals.ActiveVessel.FindPartModulesImplementing <LifeSupportReportable>();
            // Calculate once on window generation, instead of each frame
            bool buttonEnable = !FlightGlobals.ActiveVessel.isEVA &&
                                FlightGlobals.ActiveVessel.HasModule <Cons2LSModule>();
            // Cell padding
            RectOffset offset            = new RectOffset(20, 0, 10, 0);
            DialogGUIVerticalLayout vert = new DialogGUIVerticalLayout(
                false, false, 1f,
                new RectOffset(), TextAnchor.UpperLeft);

            DialogGUIBase[] vertHeader;

            if (compress)
            {
                vertHeader = new DialogGUIBase[2]
                {
                    new DialogGUILabel("<b>Kerbal</b>", true, true),
                    new DialogGUILabel("<b>Life Support</b>", true, true)
                };
            }
            else
            {
                vertHeader = new DialogGUIBase[4]
                {
                    new DialogGUILabel("<b>Kerbal</b>", true, true),
                    new DialogGUILabel("<b>Ship Life Support</b>", true, true),
                    new DialogGUILabel("<b>Suit Life Support</b>", true, true),
                    new DialogGUILabel("", true, true)
                };
            }

            vert.AddChild(
                new DialogGUIGridLayout(new RectOffset(),
                                        new Vector2(cellWidth, 20),
                                        Vector2.zero,
                                        UnityEngine.UI.GridLayoutGroup.Corner.UpperLeft,
                                        UnityEngine.UI.GridLayoutGroup.Axis.Horizontal,
                                        TextAnchor.MiddleLeft,
                                        UnityEngine.UI.GridLayoutGroup.Constraint.FixedColumnCount,
                                        compress ? 2 : 4,
                                        vertHeader
                                        ));

            emptyPartLabels.Clear();

            DialogGUILabel emptyLabel = new DialogGUILabel("", true, true);

            foreach (LifeSupportReportable module in modules)
            {
                if (module.part.protoModuleCrew.Count == 0)
                {
                    emptyPartLabels.Add(module.part, new DialogGUILabel("EE", true, true));
                    continue;
                }

                List <ProtoCrewMember> crew        = new List <ProtoCrewMember>(module.part.protoModuleCrew);
                List <DialogGUIBase>   kerbalCells = new List <DialogGUIBase>();
                crew.Sort(CompareCrewNames);
                vert.AddChild(new DialogGUILabel($"{ORANGE}<b>{module.part.partInfo.title}</b></color>"));

                foreach (ProtoCrewMember kerbal in crew)
                {
                    GUIElements elems = new GUIElements(kerbal, buttonEnable);
                    labelMap.Add(kerbal.name, elems);
                    kerbalCells.Add(elems.nameLabel);
                    kerbalCells.Add(elems.shipLS);
                    if (!compress)
                    {
                        elems.nameLabel.SetOptionText(kerbal.name);
                        kerbalCells.Add(elems.evaLS);
                        kerbalCells.Add(elems.fillEVAButton);
                    }

                    // Add raw EVA tracking values
                    if (Config.DEBUG_SHOW_EVA)
                    {
                        kerbalCells.Add(emptyLabel);
                        kerbalCells.Add(elems.evaLS_Value);
                        kerbalCells.Add(elems.evaProp);
                        kerbalCells.Add(emptyLabel);
                    }
                }

                vert.AddChild(
                    new DialogGUIGridLayout(new RectOffset(),
                                            new Vector2(cellWidth, 20),
                                            Vector2.zero,
                                            UnityEngine.UI.GridLayoutGroup.Corner.UpperLeft,
                                            UnityEngine.UI.GridLayoutGroup.Axis.Horizontal,
                                            TextAnchor.MiddleLeft,
                                            UnityEngine.UI.GridLayoutGroup.Constraint.FixedColumnCount,
                                            compress ? 2 : 4,
                                            kerbalCells.ToArray()));
            }

            if (emptyPartLabels.Count > 0 && !compress)
            {
                vert.AddChild(new DialogGUISpace(20));

                foreach (Part part in emptyPartLabels.Keys)
                {
                    vert.AddChild(
                        new DialogGUIGridLayout(new RectOffset(),
                                                new Vector2(cellWidth * 2, 20),
                                                Vector2.zero,
                                                UnityEngine.UI.GridLayoutGroup.Corner.UpperLeft,
                                                UnityEngine.UI.GridLayoutGroup.Axis.Horizontal,
                                                TextAnchor.MiddleLeft,
                                                UnityEngine.UI.GridLayoutGroup.Constraint.FixedColumnCount, 2,
                                                new DialogGUILabel($"{ORANGE}{part.partInfo.title}</color>"),
                                                emptyPartLabels[part]
                                                ));
                }
            }

            // How can the SizeUp() -> RefreshGUI() -> OnButtonTrue() dependency
            // be altered to make these fields static, so that they don't have
            // to be re-initialized each time?
            sizeUpButton   = new DialogGUIButton("+", SizeUp, CanSizeUp, buttonHeight, buttonHeight, false);
            sizeDownButton = new DialogGUIButton("-", SizeDown, CanSizeDown, buttonHeight, buttonHeight, false);

            DialogGUIToggleButton compressButton = new DialogGUIToggleButton(
                compress, "Minimize", ToggleCompressGUI, w: 70, h: buttonHeight);
            DialogGUIHorizontalLayout compressLayout = new DialogGUIHorizontalLayout(
                false, true, 0f, noOffset, TextAnchor.MiddleLeft,
                compressButton, sizeDownButton, sizeUpButton);

            riskToggle = new DialogGUIToggle(
                EVALifeSupportTracker.AllowUnsafeActivity,
                "Allow unsafe crew transfer",
                RiskButtonSelected);
            riskLayout = new DialogGUIHorizontalLayout(
                0f, 0f, 0f, noOffset, TextAnchor.MiddleLeft,
                riskToggle);

            // Define the header which contains additional info
            // (status, Consumables)
            DialogGUIGridLayout statusGrid =
                new DialogGUIGridLayout(noOffset,
                                        new Vector2(cellWidth * (compress ? 1 : 2), 25),
                                        Vector2.zero,
                                        UnityEngine.UI.GridLayoutGroup.Corner.UpperLeft,
                                        UnityEngine.UI.GridLayoutGroup.Axis.Horizontal,
                                        TextAnchor.MiddleLeft,
                                        UnityEngine.UI.GridLayoutGroup.Constraint.FixedColumnCount, 2,
                                        statusLabel, compressLayout);

            // Contains the statusGrid and the "unsafe" toggle
            DialogGUIGridLayout masterGrid =
                new DialogGUIGridLayout(statusOffset,
                                        new Vector2(cellWidth * (compress ? 2 : 4), 25),
                                        new Vector2(0f, 5f),
                                        UnityEngine.UI.GridLayoutGroup.Corner.UpperLeft,
                                        UnityEngine.UI.GridLayoutGroup.Axis.Horizontal,
                                        TextAnchor.MiddleLeft,
                                        UnityEngine.UI.GridLayoutGroup.Constraint.FixedColumnCount, 1,
                                        statusGrid, riskLayout);

            // Set up the pop window
            size.x = compress ? 270 : 470;
            MultiOptionDialog multi = new MultiOptionDialog(
                "lifesupport_readout",
                "",
                "LifeSupport Readout",
                UISkinManager.defaultSkin,
                new Rect(position, size),
                masterGrid,
                new DialogGUIScrollList(Vector2.zero, false, true,
                                        new DialogGUIVerticalLayout(false, false, 1f,
                                                                    offset, TextAnchor.UpperLeft,
                                                                    new DialogGUIContentSizer(
                                                                        UnityEngine.UI.ContentSizeFitter.FitMode.Unconstrained,
                                                                        UnityEngine.UI.ContentSizeFitter.FitMode.PreferredSize,
                                                                        true),
                                                                    vert)));

            gui = PopupDialog.SpawnPopupDialog(
                multi,
                false,
                UISkinManager.defaultSkin,
                false,
                "");

            showgui = true;
            drewgui = false;
        }