Esempio n. 1
0
        void showMoveGui(int id)
        {
            GUILayout.BeginVertical();
            moveScrollPos = GUILayout.BeginScrollView(moveScrollPos, GUILayout.Width(230), GUILayout.Height(350));
            GUILayout.Label("Test subjects needed: " + exp.getTestSubjectsNeeded());
            if (exp.isTestSubjectAvailable())
            {
                GUILayout.Label("Choose a Kerbal:");
                foreach (string s in avilableSubjects)
                {
                    if (GUILayout.Button(s))
                    {
                        exp.getActiveStep().start(s, cbMethod);
                        closeGui();
                    }
                }
            }
            if (exp.getActiveStepIndex() > 0)
            {
                GUILayout.Label("Already tested:");


                foreach (KerbalResearchStep krs in exp.getExperimentSteps())
                {
                    if (krs.getSubjectName() != "")
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Space(20);
                        GUILayout.Label(krs.getSubjectName());
                        GUILayout.EndHorizontal();
                    }
                }
            }
            GUILayout.EndScrollView();
            if (GUILayout.Button("Close"))
            {
                closeGui();
                cbMethod(false);
            }
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
        /* +------------------------------------------------+
         * |         Choose Test Subject                    |
         * +------------------------------------------------+
         * | | Choose a Kerbal:                         |^| |
         * | | <Kerbal>                          [Test] | | |
         * | | <Kerbal>                          [Test] | | |
         * | | <Kerbal>                          [Test] | | |
         * | |                                          | | |
         * | | Already Tested:                          | | |
         * | | <Kerbal>                                 | | |
         * | | <Kerbal>                                 |v| |
         * | Test subjects needed: <x> / <y>                |
         * |                  [Close]                       |
         * +------------------------------------------------+
         */
        void showMoveWindow()
        {
            // Adjust the default UI style for our window
            var style = HighLogic.UISkin;

            style.button.fontSize      = 15;
            style.button.stretchHeight = false;
            style.button.stretchWidth  = false;
            style.label.fontSize       = 15;
            style.label.stretchHeight  = false;
            style.label.stretchWidth   = false;
            style.label.wordWrap       = false;

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

            int           numAvailable   = availableSubjects.Count;
            List <string> testedSubjects = getTestedKerbalNames();
            int           numTested      = testedSubjects.Count;

            // This is a list of content items to add to the dialog
            List <DialogGUIBase> dialog = new List <DialogGUIBase>();

            // Window Header - info string
            l  = new DialogGUILabel(Localizer.Format("#ne_For_1", exp.getName()));
            hl = new DialogGUIHorizontalLayout(false, false, 4, noPad, TextAnchor.MiddleCenter, l);
            dialog.Add(hl);

            // Window Contents - scroll list of available and tested Kerbals
            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));


            // Show available Kerbals
            // TODO: Make this a bigger font / different colour
            l  = new DialogGUILabel("#ne_Available_Kerbals");
            hl = new DialogGUIHorizontalLayout(false, false, 4, noPad, TextAnchor.MiddleCenter, l);
            vl.AddChild(hl);
            if (numAvailable > 0)
            {
                for (int i = 0, count = availableSubjects.Count; i < count; i++)
                {
                    b      = new DialogGUIButton <string>("#ne_Test", onKerbalClicked, availableSubjects[i], true);
                    b.size = new Vector2(60, 30);
                    // TODO: Increase label font to match button size
                    l  = new DialogGUILabel(availableSubjects[i], true, false);
                    hl = new DialogGUIHorizontalLayout(false, false, 4, noPad, TextAnchor.MiddleCenter, l, b);
                    vl.AddChild(hl);
                }
            }

            // Show already-tested Kerbals
            vl.AddChild(new DialogGUISpace(4));
            l  = new DialogGUILabel("#ne_Tested_Kerbals");
            hl = new DialogGUIHorizontalLayout(false, false, 4, noPad, TextAnchor.MiddleCenter, l);
            vl.AddChild(hl);
            if (numTested > 0)
            {
                // TODO: Make this a bigger font / different colour
                for (int i = 0, count = testedSubjects.Count; i < count; i++)
                {
                    l = new DialogGUILabel(testedSubjects[i], true, false);
                    vl.AddChild(l);
                }
            }

            // Add scroll list to window, having it expand to fill all available space both horizontally and vertically
            dialog.Add(new DialogGUIHorizontalLayout(true, true, new DialogGUIScrollList(Vector2.one, false, true, vl)));

            // Window footer - "Needed" info and Close button
            dialog.Add(new DialogGUILabel(Localizer.Format("#ne_Needed_1_of_2", exp.getTestSubjectsNeeded() - numTested, exp.getTestSubjectsNeeded())));
            b      = new DialogGUIButton("#ne_Close", onCloseClicked, true);
            b.size = new Vector2(60, 30);
            dialog.Add(new DialogGUIHorizontalLayout(
                           new DialogGUIFlexibleSpace(),
                           b,
                           new DialogGUIFlexibleSpace()
                           )
                       );

            // Position -and- size of dialog
            var rct = new Rect(0.5f, 0.5f, 400, 400);
            var mod = new MultiOptionDialog("", "", "#ne_Choose_Test_Subject", HighLogic.UISkin, rct, dialog.ToArray());

            PopupDialog.SpawnPopupDialog(mod, false, HighLogic.UISkin);
        }