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);
        }
Example #2
0
 private DialogGUIBase[] PaddedLabel(string stringToPad)
 {
     DialogGUIBase[] paddedLayout = new DialogGUIBase[2];
     paddedLayout[0] = new DialogGUISpace(10);
     paddedLayout[1] = new DialogGUILabel(stringToPad);
     return(paddedLayout);
 }
Example #3
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);
 }
Example #4
0
        public static DialogGUISpace GUISpace(Single v, Modifier <DialogGUISpace> modifier = null)
        {
            DialogGUISpace element = new DialogGUISpace(v);

            if (modifier != null)
            {
                element = modifier(element);
            }
            _elements.Add(element);
            return(element);
        }
Example #5
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));
        }
Example #6
0
        /// <summary>
        /// Get layout of the list of stats
        /// </summary>
        /// <returns></returns>
        internal DialogGUIVerticalLayout GetStatsListLayout()
        {
            if (currentController != null)
            {
                List <DisplayedSystemCheckResult[]> resultsList = currentController.GetDisplayedSystemCheckResults();

                DialogGUIBase[] list  = new DialogGUIBase[1 + resultsList.Count];
                int             index = 0;
                for (int i = 0; i < resultsList.Count; i++)
                {
                    list[index] = CreateListLayoutRow(resultsList[i]);
                    index++;
                }
                list[index]     = new DialogGUISpace(3f);
                statsListLayout = new DialogGUIVerticalLayout(list);
            }
            else
            {
                statsListLayout = new DialogGUIVerticalLayout(new DialogGUISpace(3f));
            }
            return(statsListLayout);
        }
Example #7
0
        private PopupDialog RandomKerbalDialog()
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            int numberOfRandomKerbals           = 4;

            dialogElements.Add(new DialogGUIToggle(() => randomKerbals, "Generate Random Kerbals", b => { SwitchMode(); }));
            DialogGUIBase[] verticalArray = new DialogGUIBase[3];
            verticalArray[0] = new DialogGUILabel(() => "Number of Kerbals: " + numberOfRandomKerbals);
            verticalArray[1] = new DialogGUISpace(30.0f);
            verticalArray[2] = new DialogGUISlider(() => numberOfRandomKerbals, 1, 10, true, 90.0f, 30.0f, newValue => { numberOfRandomKerbals = (int)newValue; });
            dialogElements.Add(new DialogGUIHorizontalLayout(verticalArray));
            verticalArray = new DialogGUIBase[2];
            DialogGUIBase[] splitBox = new DialogGUIBase[2];
            verticalArray[0] = new DialogGUIToggle(allowFemales, "Allow Female Kerbals", b => allowFemales = b);
            verticalArray[1] = new DialogGUIToggle(allowMales, "Allow Male Kerbals", b => allowMales = b);
            splitBox[0]      = new DialogGUIVerticalLayout(verticalArray);
            splitBox[1]      = new DialogGUIVerticalLayout(TraitDialogOptions());
            dialogElements.Add(new DialogGUIHorizontalLayout(splitBox));
            dialogElements.Add(new DialogGUISpace(5.0f));
            dialogElements.Add(new DialogGUIButton("I'm Done", () => GenerateRandomKerbals(numberOfRandomKerbals), true));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("FirstKerbaliserRandomKerbals", "", "Earn Your Stripes", UISkinManager.defaultSkin,
                                                                      new Rect(0.5f, 0.5f, 280.0f, 210), dialogElements.ToArray()), false, UISkinManager.defaultSkin));
        }
Example #8
0
        private PopupDialog DrawCrewUI()
        {
            List <DialogGUIBase> dialogElements = new List <DialogGUIBase>();
            List <DialogGUIBase> innerElements  = new List <DialogGUIBase>();

            innerElements.Add(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true));
            DialogGUIBase[] horizontal;
            for (int i = 0; i < CrewManager.Instance.Kerbals.Count; i++)
            {
                KeyValuePair <string, CrewMember> crew = CrewManager.Instance.Kerbals.ElementAt(i);
                if (crew.Value.CrewReference().rosterStatus != ProtoCrewMember.RosterStatus.Available)
                {
                    continue;
                }
                if (crew.Value.CrewReference().inactive)
                {
                    continue;
                }
                if (crew.Value.CrewReference().experienceLevel >= 5)
                {
                    continue;
                }
                horizontal    = new DialogGUIBase[3];
                horizontal[0] = new DialogGUISpace(10);
                horizontal[1] = new DialogGUILabel(crew.Key, MessageStyle(true));
                horizontal[2] = new DialogGUIButton("Train", () => TrainKerbal(crew.Value), false);
                innerElements.Add(new DialogGUIHorizontalLayout(horizontal));
            }
            DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray());

            dialogElements.Add(new DialogGUIScrollList(new Vector2(300, 300), false, true, vertical));
            dialogElements.Add(GetBoxes("crew"));
            return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                new MultiOptionDialog("Bureaucracy", "", "Bureaucracy: Crew Manager", UISkinManager.GetSkin("MainMenuSkin"),
                                                                      new Rect(0.5f, 0.5f, 350, 265), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"), false));
        }
        public void Show(Part part)
        {
            if (IsVisible())
            {
                Hide();
                newPart = part;
                return;
            }

            LoadCfgFile();

            this.part = part;

            DialogGUISpace        spaceAxisLeft        = new DialogGUISpace(30f);
            DialogGUISpace        spaceAxisCenter      = new DialogGUISpace(115f);
            DialogGUISpace        spaceAxisRight       = new DialogGUISpace(120f);
            DialogGUISpace        spaceTransform       = new DialogGUISpace(15f);
            DialogGUIButton       buttonReferenceSpace = new DialogGUIButton(GetReferenceSpaceLabel, ToggleReferenceSpace, 100f, LINE_HEIGHT, false);
            DialogGUILabel        labelX                 = new DialogGUILabel(FormatLabel("X"), LINE_HEIGHT);
            DialogGUILabel        labelY                 = new DialogGUILabel(FormatLabel("Y"), LINE_HEIGHT);
            DialogGUILabel        labelZ                 = new DialogGUILabel(FormatLabel("Z"), LINE_HEIGHT);
            DialogGUILabel        labelMinusPlus         = new DialogGUILabel(FormatLabel("- / +"), LINE_HEIGHT);
            DialogGUILabel        labelPosition          = new DialogGUILabel(FormatLabel("Position"), LABEL_WIDTH);
            DialogGUILabel        labelRotation          = new DialogGUILabel(FormatLabel("Rotation"), LABEL_WIDTH);
            DialogGUITextInput    inputPositionX         = new DialogGUITextInput("", false, MAXLENGTH, delegate(string value) { return(SetPosition(0, value)); }, delegate { return(GetPosition(0)); }, TMP_InputField.ContentType.DecimalNumber, LINE_HEIGHT);
            DialogGUITextInput    inputPositionY         = new DialogGUITextInput("", false, MAXLENGTH, delegate(string value) { return(SetPosition(1, value)); }, delegate { return(GetPosition(1)); }, TMP_InputField.ContentType.DecimalNumber, LINE_HEIGHT);
            DialogGUITextInput    inputPositionZ         = new DialogGUITextInput("", false, MAXLENGTH, delegate(string value) { return(SetPosition(2, value)); }, delegate { return(GetPosition(2)); }, TMP_InputField.ContentType.DecimalNumber, LINE_HEIGHT);
            DialogGUITextInput    inputDeltaPosition     = new DialogGUITextInput("", false, MAXLENGTH, delegate(string value) { return(SetDeltaPosition(value)); }, delegate { return(deltaPosition.ToString(FORMAT)); }, TMP_InputField.ContentType.DecimalNumber, LINE_HEIGHT);
            DialogGUITextInput    inputRotationX         = new DialogGUITextInput("", false, MAXLENGTH, delegate(string value) { return(SetRotation(0, value)); }, delegate { return(GetRotation(0)); }, TMP_InputField.ContentType.DecimalNumber, LINE_HEIGHT);
            DialogGUITextInput    inputRotationY         = new DialogGUITextInput("", false, MAXLENGTH, delegate(string value) { return(SetRotation(1, value)); }, delegate { return(GetRotation(1)); }, TMP_InputField.ContentType.DecimalNumber, LINE_HEIGHT);
            DialogGUITextInput    inputRotationZ         = new DialogGUITextInput("", false, MAXLENGTH, delegate(string value) { return(SetRotation(2, value)); }, delegate { return(GetRotation(2)); }, TMP_InputField.ContentType.DecimalNumber, LINE_HEIGHT);
            DialogGUITextInput    inputDeltaRotation     = new DialogGUITextInput("", false, MAXLENGTH, delegate(string value) { return(SetDeltaRotation(value)); }, delegate { return(deltaRotation.ToString(FORMAT)); }, TMP_InputField.ContentType.DecimalNumber, LINE_HEIGHT);
            DialogGUIButton       buttonPosXMinus        = new DialogGUIButton("-", delegate { Translate(0, true); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonPosXPlus         = new DialogGUIButton("+", delegate { Translate(0, false); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonPosYMinus        = new DialogGUIButton("-", delegate { Translate(1, true); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonPosYPlus         = new DialogGUIButton("+", delegate { Translate(1, false); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonPosZMinus        = new DialogGUIButton("-", delegate { Translate(2, true); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonPosZPlus         = new DialogGUIButton("+", delegate { Translate(2, false); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonDeltaPosDiv      = new DialogGUIButton("/10", delegate { SetDeltaPosition((deltaPosition / 10).ToString()); }, 35f, LINE_HEIGHT, false);
            DialogGUIButton       buttonDeltaPosMult     = new DialogGUIButton("×10", delegate { SetDeltaPosition((deltaPosition * 10).ToString()); }, 35f, LINE_HEIGHT, false);
            DialogGUIButton       buttonRotXMinus        = new DialogGUIButton("-", delegate { Rotate(0, true); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonRotXPlus         = new DialogGUIButton("+", delegate { Rotate(0, false); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonRotYMinus        = new DialogGUIButton("-", delegate { Rotate(1, true); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonRotYPlus         = new DialogGUIButton("+", delegate { Rotate(1, false); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonRotZMinus        = new DialogGUIButton("-", delegate { Rotate(2, true); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonRotZPlus         = new DialogGUIButton("+", delegate { Rotate(2, false); }, LINE_HEIGHT, LINE_HEIGHT, false);
            DialogGUIButton       buttonDeltaRotDiv      = new DialogGUIButton("/10", delegate { SetDeltaRotation((deltaRotation / 10).ToString()); }, 35f, LINE_HEIGHT, false);
            DialogGUIButton       buttonDeltaRotMult     = new DialogGUIButton("×10", delegate { SetDeltaRotation((deltaRotation * 10).ToString()); }, 35f, LINE_HEIGHT, false);
            DialogGUIToggleButton toggleButtonAttachment = new DialogGUIToggleButton(showAttachment, "Attachment Rules", delegate { ToggleAttachment(); }, -1, LINE_HEIGHT);
            DialogGUIToggleButton toggleButtonColliders  = new DialogGUIToggleButton(showColliders, "Colliders", delegate { ToggleColliders(); }, -1, LINE_HEIGHT);
            DialogGUISpace        spaceToCenter          = new DialogGUISpace(-1);
            DialogGUIButton       buttonClose            = new DialogGUIButton("Close", delegate { CloseWindow(); }, 140f, LINE_HEIGHT, true);

            List <DialogGUIBase> dialogGUIBaseList = new List <DialogGUIBase>
            {
                new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, buttonReferenceSpace, spaceAxisLeft, labelX, spaceAxisCenter, labelY, spaceAxisCenter, labelZ, spaceAxisRight, labelMinusPlus),
                new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, labelPosition, buttonPosXMinus, inputPositionX, buttonPosXPlus, spaceTransform, buttonPosYMinus, inputPositionY, buttonPosYPlus, spaceTransform, buttonPosZMinus, inputPositionZ, buttonPosZPlus, spaceTransform, buttonDeltaPosDiv, inputDeltaPosition, buttonDeltaPosMult),
                new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, labelRotation, buttonRotXMinus, inputRotationX, buttonRotXPlus, spaceTransform, buttonRotYMinus, inputRotationY, buttonRotYPlus, spaceTransform, buttonRotZMinus, inputRotationZ, buttonRotZPlus, spaceTransform, buttonDeltaRotDiv, inputDeltaRotation, buttonDeltaRotMult)
            };

            if (part.isCompund)
            {
                DialogGUILabel  labelCompound  = new DialogGUILabel(FormatLabel("Anchor"), LABEL_WIDTH);
                DialogGUIButton buttonCompound = new DialogGUIButton(GetCompoundLabel, ToggleCompound, 100f, LINE_HEIGHT, false);
                dialogGUIBaseList.Add(new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, labelCompound, buttonCompound));
            }
            dialogGUIBaseList.Add(new DialogGUIHorizontalLayout(toggleButtonAttachment, toggleButtonColliders));
            dialogGUIBaseList.Add(new DialogGUIHorizontalLayout(spaceToCenter, buttonClose, spaceToCenter));

            string windowTitle = FormatLabel("Precise Editor - ") + part.partInfo.title;

            dialog      = new MultiOptionDialog("partEditionDialog", "", windowTitle, HighLogic.UISkin, dialogRect, new DialogGUIVerticalLayout(dialogGUIBaseList.ToArray()));
            popupDialog = PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog, false, HighLogic.UISkin, false);
            popupDialog.onDestroy.AddListener(SaveWindowPosition);
            popupDialog.onDestroy.AddListener(RemoveControlLock);
            popupDialog.onDestroy.AddListener(OnPopupDialogDestroy);

            SetTextInputColor(inputPositionX, axisLines.red);
            SetTextInputColor(inputPositionY, axisLines.green);
            SetTextInputColor(inputPositionZ, axisLines.cyan);
            SetTextInputColor(inputRotationX, axisLines.red);
            SetTextInputColor(inputRotationY, axisLines.green);
            SetTextInputColor(inputRotationZ, axisLines.cyan);

            SetTextInputListeners(inputPositionX);
            SetTextInputListeners(inputPositionY);
            SetTextInputListeners(inputPositionZ);
            SetTextInputListeners(inputRotationX);
            SetTextInputListeners(inputRotationY);
            SetTextInputListeners(inputRotationZ);
            SetTextInputListeners(inputDeltaPosition);
            SetTextInputListeners(inputDeltaRotation);

            if (showAttachment)
            {
                attachmentWindow.Show(part);
            }

            if (showColliders)
            {
                colliderWindow.Show(part);
            }

            axisLines.Show(part, referenceSpace, compoundTargetSelected);
        }