private static int DisplaySpaceButtons(int selectedSpace, string[] spaceNames)
        {
            // Selected Space options
            GUIContent[] options          = new GUIContent[spaceNames.Length];
            GUIStyle[]   styles           = new GUIStyle[spaceNames.Length];
            int          newSelectedSpace = selectedSpace;

            // Populate button characteristics
            for (int x = 0; x < spaceNames.Length; x++)
            {
                options[x] = new GUIContent(spaceNames[x]);
                styles[x]  = new GUIStyle(newSelectedSpace == x ? CLSStyles.ButtonToggledStyle : CLSStyles.ButtonStyle);
            }

            // Build Option Buttons
            GUILayout.BeginVertical();
            for (int x = 0; x < spaceNames.Length; x++)
            {
                if (GUILayout.Button(options[x], styles[x], GUILayout.Height(20)))
                {
                    if (newSelectedSpace != x)
                    {
                        newSelectedSpace = x;
                    }
                    else
                    {
                        newSelectedSpace = -1; // revert to none selected.
                    }
                }
            }
            GUILayout.EndVertical();

            return(newSelectedSpace);
        }
Esempio n. 2
0
        private void drawSetting()
        {
            Settings.ChangeVesselType = GUILayout.Toggle(Settings.ChangeVesselType, "change vessel type",
                                                         buttonStyle, GUILayout.Width(200), GUILayout.Height(20));

            // volume
            GUILayout.Label(String.Format("Volume: {0}%", Math.Round(Settings.Volume * 100.0f)));
            Settings.Volume = (float)Math.Round(GUILayout.HorizontalSlider(Settings.Volume, 0.0f, 1.0f), 2);

            // Use Captions
            Settings.UseCaption = GUILayout.Toggle(Settings.UseCaption, "Screen Captions", toggleStyle);

            switch (Gpws.ActiveVesselType)
            {
            case SimpleTypes.VesselType.PLANE:
                drawPlaneSetting();
                break;

            case SimpleTypes.VesselType.LANDER:
                drawLanderSetting();
                break;

            default:
                break;
            }

            // save
            if (GUILayout.Button("Save", buttonStyle, GUILayout.Width(200), GUILayout.Height(30)))
            {
                float newFloat;
                if (float.TryParse(tooLowGearAltitudeString, out newFloat))
                {
                    planeConfig.TooLowGearAltitude = newFloat;
                }
                if (float.TryParse(touchDownSpeedString, out newFloat))
                {
                    landerConfig.TouchDownSpeed = newFloat;
                }
                if (float.TryParse(horizontalSpeedCheckAltitudeString, out newFloat))
                {
                    landerConfig.HorizontalSpeedCheckAltitude = newFloat;
                }
                // save
                Settings.SaveSettings();
                Settings.SaveCurrentVesselConfig(FlightGlobals.ActiveVessel);
            }
        }
Esempio n. 3
0
        private void drawLanderSetting()
        {
            landerConfig.EnableSystem =
                GUILayout.Toggle(landerConfig.EnableSystem, "System Enable", toggleStyle);

            // descent rate
            landerConfig.EnableDescentRate =
                GUILayout.Toggle(landerConfig.EnableDescentRate, "Descent Rate", toggleStyle);

            GUILayout.Label(String.Format("Safety Factor: {0}", landerConfig.DescentRateSafetyFactor));
            landerConfig.DescentRateSafetyFactor = (float)Math.Round(GUILayout.HorizontalSlider(landerConfig.DescentRateSafetyFactor, 1.0f, 4.0f), 1);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Final Speed");
                GUILayout.FlexibleSpace();
                touchDownSpeedString =
                    GUILayout.TextField(touchDownSpeedString, GUILayout.Height(30), GUILayout.Width(80));
                GUILayout.Label(Util.GetShortString(landerConfig.UnitOfAltitude) + "/s");
            }
            GUILayout.EndHorizontal();

            // horizontal speed
            landerConfig.EnableHorizontalSpeed =
                GUILayout.Toggle(landerConfig.EnableHorizontalSpeed, "Horizontal Speed", toggleStyle);
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("vh Check Alt");
                GUILayout.FlexibleSpace();
                horizontalSpeedCheckAltitudeString =
                    GUILayout.TextField(horizontalSpeedCheckAltitudeString, GUILayout.Height(30), GUILayout.Width(80));
                GUILayout.Label(Util.GetShortString(landerConfig.UnitOfAltitude));
            }
            GUILayout.EndHorizontal();

            GUILayout.Label(String.Format("Horizontal Speed Factor: {0}", landerConfig.HorizontalSpeedFactor));
            landerConfig.HorizontalSpeedFactor = (float)Math.Round(GUILayout.HorizontalSlider(landerConfig.HorizontalSpeedFactor, 0.01f, 1.0f), 2);

            // altitude
            landerConfig.EnableAltitudeCallouts =
                GUILayout.Toggle(landerConfig.EnableAltitudeCallouts, "Altitude Callouts", toggleStyle);

            // retard
            landerConfig.EnableRetard =
                GUILayout.Toggle(landerConfig.EnableRetard, "Retard", toggleStyle);
        }
Esempio n. 4
0
        private void WindowFunc(int windowID)
        {
            planeConfig  = Settings.CurrentPlaneConfig;
            landerConfig = Settings.CurrentLanderConfig;
            ConfigureStyles();

            // begin drawing
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            {
                GUILayout.Box(Util.audio.GetKindOfSoundRTF(), boxStyle, GUILayout.Height(30));

                drawConfigUI();
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUI.DragWindow();   // allow moving window
        }
Esempio n. 5
0
        private void drawConfigUI()
        {
            GUILayout.BeginVertical();
            {
                vesselType = Gpws.ActiveVesselType;
                if (vesselType != SimpleTypes.VesselType.NONE)
                {
                    showConfigs = GUILayout.Toggle(
                        showConfigs, String.Format("select {0} function", vesselType.ToString().ToLower()),
                        buttonStyle, GUILayout.Width(200), GUILayout.Height(20));

                    if (showConfigs)
                    {
                        drawSetting();
                    }
                }
            }
            GUILayout.EndVertical();
        }
Esempio n. 6
0
        public static double numberEntryBox(double old_val, out bool inc_dec_pressed, double inc = 1.0, string nFormat = ",0.0#####", float boxWidth = 60)
        {
            GUILayout.BeginHorizontal();

            double val     = old_val;
            string boxText = val.ToString(nFormat);
            string text    = GUILayout.TextField(boxText, UISkin.customStyles[(int)myStyles.numBoxText], GUILayout.Width(boxWidth));

            inc_dec_pressed = false;

            try
            {
                val = double.Parse(text);
            }
            catch
            {
                val = old_val;
            }

            GUILayout.Space(2);

            GUILayout.BeginVertical();

            if (GUILayout.Button("+", UISkin.customStyles[(int)myStyles.btnPlus], GUILayout.Width(20), GUILayout.Height(13)))
            {
                val            += inc;
                inc_dec_pressed = true;
            }
            if (GUILayout.Button("-", UISkin.customStyles[(int)myStyles.btnMinus], GUILayout.Width(20), GUILayout.Height(13)))
            {
                val            -= inc;
                inc_dec_pressed = true;
            }

            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            return(val);
        }
Esempio n. 7
0
        public static double labPlusNumBox(GUIContent labelText, string boxText, float labelWidth = 100, float boxWidth = 60)
        {
            double val;

            GUILayout.BeginHorizontal();

            GUILayout.Label(labelText, UISkin.customStyles[(int)myStyles.numBoxLabel], GUILayout.Width(labelWidth));
            val     = double.Parse(boxText);
            boxText = val.ToString(",0.0#####");
            string text = GUILayout.TextField(boxText, UISkin.customStyles[(int)myStyles.numBoxText], GUILayout.Width(boxWidth));

            //
            try
            {
                val = double.Parse(text);
            }
            catch
            {
                val = double.Parse(boxText);
            }
            //
            GUILayout.BeginVertical();
            if (GUILayout.Button("+", UISkin.customStyles[(int)myStyles.btnPlus], GUILayout.Width(20), GUILayout.Height(13)))
            {
                if (val != 0)
                {
                    val *= 1.1;
                }
                else
                {
                    val = 0.01;
                }
            }
            if (GUILayout.Button("-", UISkin.customStyles[(int)myStyles.btnMinus], GUILayout.Width(20), GUILayout.Height(13)))
            {
                val /= 1.1;
            }
            GUILayout.EndVertical();
            //
            GUILayout.EndHorizontal();
            return(val);
        }
Esempio n. 8
0
        private void CrewSelectionWindow(int windowID)
        {
            KerbalRoster kerbalRoster = HighLogic.CurrentGame.CrewRoster;

            GUILayout.BeginVertical();
            _displayViewerPosition = GUILayout.BeginScrollView(_displayViewerPosition, GUI.skin.box, GUILayout.Height(250), GUILayout.Width(280));
            IEnumerator <ProtoCrewMember> kerbals = kerbalRoster.Kerbals(ProtoCrewMember.RosterStatus.Available).GetEnumerator();

            while (kerbals.MoveNext())
            {
                ProtoCrewMember crewMember = kerbals.Current;
                if (crewMember == null)
                {
                    continue;
                }
                bool     selected    = SelectedCrewMembers.Contains(crewMember);
                GUIStyle buttonStyle = selected ? ButtonToggledStyle : HighLogic.Skin.button;
                selected = GUILayout.Toggle(selected, $"{crewMember.name}, {crewMember.gender}, {crewMember.trait}", buttonStyle);
                if (selected && !SelectedCrewMembers.Contains(crewMember))
                {
                    SelectedCrewMembers.Clear();
                    SelectedCrewMembers.Add(crewMember);
                }
                else if (!selected && SelectedCrewMembers.Contains(crewMember))
                {
                    SelectedCrewMembers.Clear();
                }
            }
            kerbals.Dispose();
            GUILayout.EndScrollView();
            GUILayout.Space(20);
            if (GUILayout.Button("Select", HighLogic.Skin.button))
            {
                VesselSpawn.SelectedCrewData = SelectedCrewMembers;
                VesselSpawn.IsSelectingCrew  = false;
                VesselSpawn.IsCrewSelected   = true;
            }
            GUILayout.EndVertical();
        }
Esempio n. 9
0
        private void drawPlaneSetting()
        {
            planeConfig.EnableSystem =
                GUILayout.Toggle(planeConfig.EnableSystem, "System Enable", toggleStyle);

            // descent rate config
            planeConfig.EnableDescentRate =
                GUILayout.Toggle(planeConfig.EnableDescentRate, "Descent Rate", toggleStyle);

            planeConfig.EnableClosureToTerrain =
                GUILayout.Toggle(planeConfig.EnableClosureToTerrain, "Closure to Terrain", toggleStyle);

            GUILayout.Label(String.Format("Descent Rate Factor: {0}", planeConfig.DescentRateFactor));
            descentRateFactorExp          = GUILayout.HorizontalSlider(descentRateFactorExp, -1.0f, 1.0f);
            planeConfig.DescentRateFactor = (float)Math.Round(Math.Pow(10, descentRateFactorExp), 1);

            // altitude loss
            planeConfig.EnableAltitudeLoss =
                GUILayout.Toggle(planeConfig.EnableAltitudeLoss, "Altitude Loss After Takeoff", toggleStyle);

            // terrain clearance
            planeConfig.EnableTerrainClearance =
                GUILayout.Toggle(planeConfig.EnableTerrainClearance, "Terrain Clearance", toggleStyle);
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Gear Alt");
                GUILayout.FlexibleSpace();
                tooLowGearAltitudeString =
                    GUILayout.TextField(tooLowGearAltitudeString, GUILayout.Height(30), GUILayout.Width(80));
                GUILayout.Label(Util.GetShortString(planeConfig.UnitOfAltitude));
            }
            GUILayout.EndHorizontal();

            // altitude
            planeConfig.EnableAltitudeCallouts =
                GUILayout.Toggle(planeConfig.EnableAltitudeCallouts, "Altitude Callouts", toggleStyle);

            // retard
            planeConfig.EnableRetard =
                GUILayout.Toggle(planeConfig.EnableRetard, "Retard", toggleStyle);

            // bank angle
            planeConfig.EnableTraffic =
                GUILayout.Toggle(planeConfig.EnableTraffic, "Traffic", toggleStyle);

            // traffic
            planeConfig.EnableBankAngle =
                GUILayout.Toggle(planeConfig.EnableBankAngle, "Bank Angle", toggleStyle);

            // v1
            planeConfig.EnableV1 =
                GUILayout.Toggle(planeConfig.EnableV1, "V1", toggleStyle);

            // rotate
            planeConfig.EnableRotate =
                GUILayout.Toggle(planeConfig.EnableRotate, "Rotate", toggleStyle);

            // gear up
            planeConfig.EnableGearUp =
                GUILayout.Toggle(planeConfig.EnableGearUp, "Gear Up", toggleStyle);

            // stall
            GUILayout.BeginHorizontal();
            {
                planeConfig.EnableStall =
                    GUILayout.Toggle(planeConfig.EnableStall, "Stall", toggleStyle);
                GUILayout.Space(50);
                planeConfig.EnableStallShake =
                    GUILayout.Toggle(planeConfig.EnableStallShake, "Shake", toggleStyle);
            }
            GUILayout.EndHorizontal();
            GUILayout.Label(String.Format("Max AOA: {0} deg", planeConfig.StallAoa));
            planeConfig.StallAoa = (float)Math.Round(GUILayout.HorizontalSlider(planeConfig.StallAoa, 0.0f, 180.0f), 0);

            // take off speed
            GUILayout.Label(String.Format("V1 Speed: {0} m/s", planeConfig.V1Speed));
            planeConfig.V1Speed = (float)Math.Round(GUILayout.HorizontalSlider(planeConfig.V1Speed, 10.0f, 200.0f), 0);
            GUILayout.Label(String.Format("Take Off Speed: {0} m/s", planeConfig.TakeOffSpeed));
            planeConfig.TakeOffSpeed = (float)Math.Round(GUILayout.HorizontalSlider(planeConfig.TakeOffSpeed, 10.0f, 200.0f), 0);

            // landing speed
            GUILayout.Label(String.Format("Landing Speed: {0} m/s", planeConfig.LandingSpeed));
            planeConfig.LandingSpeed = (float)Math.Round(GUILayout.HorizontalSlider(planeConfig.LandingSpeed, 10.0f, 200.0f), 0);
        }
Esempio n. 10
0
        public override void WindowElements()
        {
            GUILayout.BeginVertical();
            GUILayout.Label("WARNING: You can click through this window!", HighLogic.Skin.label);
            //Red
            GUILayout.BeginHorizontal();
            GUILayout.Label("Red:", HighLogic.Skin.label, GUILayout.Width(50));
            if (float.TryParse(GUILayout.TextField(color.r.ToString(), HighLogic.Skin.textField), out f))
            {
                color.r = Mathf.Clamp01(f);
            }
            GUILayout.EndHorizontal();
            color.r = GUILayout.HorizontalSlider(color.r, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb);
            //Green
            GUILayout.BeginHorizontal();
            GUILayout.Label("Green:", HighLogic.Skin.label, GUILayout.Width(50));
            if (float.TryParse(GUILayout.TextField(color.g.ToString(), HighLogic.Skin.textField), out f))
            {
                color.g = Mathf.Clamp01(f);
            }
            GUILayout.EndHorizontal();
            color.g = GUILayout.HorizontalSlider(color.g, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb);
            //Blue
            GUILayout.BeginHorizontal();
            GUILayout.Label("Blue:", HighLogic.Skin.label, GUILayout.Width(50));
            if (float.TryParse(GUILayout.TextField(color.b.ToString(), HighLogic.Skin.textField), out f))
            {
                color.b = Mathf.Clamp01(f);
            }
            GUILayout.EndHorizontal();
            color.b = GUILayout.HorizontalSlider(color.b, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb);
            //alpha
            if (showAlpha)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Alpha:", HighLogic.Skin.label, GUILayout.Width(50));
                if (float.TryParse(GUILayout.TextField(color.a.ToString(), HighLogic.Skin.textField), out f))
                {
                    color.a = Mathf.Clamp01(f);
                }
                GUILayout.EndHorizontal();
                color.a = GUILayout.HorizontalSlider(color.a, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb);
            }
            //preset list
            if (presets.Count > 0)
            {
                selectedIndex = -1;
                for (int j = 0; j < presets.Count; j++)
                {
                    if (float.Parse(presets[j].GetValue("r")) == color.r && float.Parse(presets[j].GetValue("g")) == color.g &&
                        float.Parse(presets[j].GetValue("b")) == color.b && float.Parse(presets[j].GetValue("a")) == color.a)
                    {
                        selectedIndex = j;
                        break;
                    }
                }
                GUILayout.Label("Select preset:", HighLogic.Skin.label);
                scrollPosition = GUILayout.BeginScrollView(scrollPosition, HighLogic.Skin.horizontalSlider, HighLogic.Skin.label, GUILayout.Height(48));
                i = GUILayout.Toolbar(selectedIndex, (from n in presets select n.GetValue("name")).ToArray(), HighLogic.Skin.button);
                GUILayout.EndScrollView();
                if (i >= 0)
                {
                    color = new Color(float.Parse(presets[i].GetValue("r")), float.Parse(presets[i].GetValue("g")), float.Parse(presets[i].GetValue("b")), showAlpha ? float.Parse(presets[i].GetValue("a")) : 1);
                }
            }
            else
            {
                selectedIndex = -1;
            }

            //add preset
            newPresetName = GUILayout.TextField(newPresetName, HighLogic.Skin.textField);
            GUILayout.BeginHorizontal();
            if (selectedIndex == -1 && GUILayout.Button("Add preset", HighLogic.Skin.button))
            {
                ConfigNode n = new ConfigNode("PRESET");
                n.AddValue("r", color.r);
                n.AddValue("g", color.g);
                n.AddValue("b", color.b);
                n.AddValue("a", color.a);
                n.AddValue("name", newPresetName);
                presets.Add(n);
                SavePresets();
                newPresetName = "";
            }
            //rename preset
            if (selectedIndex >= 0 && GUILayout.Button("Rename preset", HighLogic.Skin.button))
            {
                presets[selectedIndex].SetValue("name", newPresetName);
                newPresetName = "";
                SavePresets();
            }
            //delete preset
            if (selectedIndex >= 0 && GUILayout.Button("Delete preset", HighLogic.Skin.button))
            {
                presets.RemoveAt(selectedIndex);
                SavePresets();
            }
            GUILayout.EndHorizontal();
            //End
            GUILayout.EndVertical();
        }
Esempio n. 11
0
        private void DoWindow(int id)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("For each mod, select which toolbar to put it's button on.");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("If the Blizzy toobar is not installed, all buttons will be put on the stock toolbar, regardless of the setting");
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Stock", GUILayout.Width(50));
            GUILayout.Label("Blizzy", GUILayout.Width(50));
            GUILayout.Label("Both", GUILayout.Width(50));
            GUILayout.Label("None", GUILayout.Width(50));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            //ToolbarControl.sortedModList = ToolbarControl.sortedModList.OrderBy(x => x.displayName).ToList();


            scrollVector = GUILayout.BeginScrollView(scrollVector, scrollbar_style, GUILayout.Height(scrollBarHeight));

            foreach (ToolbarControl.Mod mod in ToolbarControl.sortedModList)
            {
                bool doUseButtons = false;
                GUILayout.BeginHorizontal();
                bool stock = GUILayout.Toggle(mod.useStock, "", GUILayout.Width(60));
                if (stock != mod.useStock)
                {
                    if (ToolbarControl.registeredMods[mod.modId].useStock == ToolbarControl.registeredMods[mod.modId].useBlizzy &&
                        ToolbarControl.registeredMods[mod.modId].useStock)
                    {
                        ToolbarControl.registeredMods[mod.modId].useBlizzy = false;
                    }
                    else
                    {
                        ToolbarControl.registeredMods[mod.modId].useStock  = stock;
                        ToolbarControl.registeredMods[mod.modId].useBlizzy = !stock;
                    }

                    doUseButtons = true;
                }

                bool blizzy = GUILayout.Toggle(mod.useBlizzy, "", GUILayout.Width(50));

                if (blizzy != ToolbarControl.registeredMods[mod.modId].useBlizzy)
                {
                    if (ToolbarControl.registeredMods[mod.modId].useStock == ToolbarControl.registeredMods[mod.modId].useBlizzy &&
                        ToolbarControl.registeredMods[mod.modId].useBlizzy)
                    {
                        ToolbarControl.registeredMods[mod.modId].useStock = false;
                    }
                    else
                    {
                        ToolbarControl.registeredMods[mod.modId].useBlizzy = blizzy;
                        ToolbarControl.registeredMods[mod.modId].useStock  = !blizzy;
                    }

                    doUseButtons = true;
                }

                bool both    = (stock & blizzy);
                bool newboth = GUILayout.Toggle(both, "", GUILayout.Width(50));
                if (newboth != both)
                {
                    ToolbarControl.registeredMods[mod.modId].useBlizzy = true;
                    ToolbarControl.registeredMods[mod.modId].useStock  = true;

                    doUseButtons = true;
                }
                if (!ToolbarControl.registeredMods[mod.modId].noneAllowed)
                {
                    GUI.enabled = false;
                }
                bool none    = (!stock & !blizzy);
                bool newnone = GUILayout.Toggle(none, "", GUILayout.Width(25));
                if (newnone != none)
                {
                    ToolbarControl.registeredMods[mod.modId].useBlizzy = false;
                    ToolbarControl.registeredMods[mod.modId].useStock  = false;

                    doUseButtons = true;
                }

                if (doUseButtons)
                {
                    ToolbarControl.SaveData();
                    if (ToolbarControl.registeredMods[mod.modId].modToolbarControl != null)
                    {
                        ToolbarControl.registeredMods[mod.modId].modToolbarControl.UseButtons(mod.modId);
                    }
                    else
                    {
                        Log.Debug("mod.Key: " + mod.modId + " modToolbarControl is null");
                    }
                }
                GUI.enabled = true;
                GUILayout.Label(" " + mod.displayName);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Close"))
            {
                GUIEnabled = false;
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("?"))
            {
                IntroWindowClass.showHelp  = true;
                IntroWindowClass.automoved = 0;
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }
Esempio n. 12
0
        void OnWindowGUI(int id)
        {
            GUI.skin = HighLogic.Skin;
            Historian historian = Historian.Instance;

            // column one
            using (GUILayout.AreaScope columnOne = new GUILayout.AreaScope(new Rect(15, 20, 380, 550)))
            {
                using (GUILayout.VerticalScope col = new GUILayout.VerticalScope())
                {
                    GUILayout.Space(20);
                    historian.Suppressed              = GUILayout.Toggle(historian.Suppressed, Localizer.GetStringByTag("#Historian_Suppressed"));
                    historian.AlwaysActive            = GUILayout.Toggle(historian.AlwaysActive, Localizer.GetStringByTag("#Historian_AlwaysActive"));
                    historian.AutoHideUI              = GUILayout.Toggle(historian.AutoHideUI, Localizer.GetStringByTag("#Historian_AutoHideUI"));
                    Configuration.Instance.AutoHideUI = historian.AutoHideUI;

                    Configuration.Instance.PersistentConfigurationWindow = GUILayout.Toggle(Configuration.Instance.PersistentConfigurationWindow, Localizer.GetStringByTag("#Historian_AlwaysShowConfigWindow"));
                    Configuration.Instance.EnableLauncherButton          = GUILayout.Toggle(Configuration.Instance.EnableLauncherButton, Localizer.GetStringByTag("#Historian_UseAppLauncher"));
                    Configuration.Instance.EnableToolbarButton           = GUILayout.Toggle(Configuration.Instance.EnableToolbarButton, Localizer.GetStringByTag("#Historian_UseToolbar"));
                    GUILayout.Space(10);

                    using (GUILayout.HorizontalScope layout = new GUILayout.HorizontalScope())
                    {
                        int rightClickOptionsCount = 4;
                        //GUILayout.Space(40);
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_RightClickAction"));
                        GUILayout.Space(10);
                        if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight)))
                        {
                            Configuration.Instance.RightClickAction = (RightClickAction)Mathf.Clamp((int)Configuration.Instance.RightClickAction - 1, 0, rightClickOptionsCount - 1);
                        }
                        else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight)))
                        {
                            Configuration.Instance.RightClickAction = (RightClickAction)Mathf.Clamp((int)Configuration.Instance.RightClickAction + 1, 0, rightClickOptionsCount - 1);
                        }
                        GUILayout.Space(5);
                        GUILayout.Label(Configuration.Instance.RightClickAction.ToString(), GUI.skin.textArea, GUILayout.ExpandWidth(true));
                    }

                    ManageButtons();

                    GUILayout.Space(10);
                    using (GUILayout.HorizontalScope layout = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_Layout"));
                        GUILayout.Space(10);
                        string[] layouts = historian.GetLayoutNames();
                        if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight)))
                        {
                            historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex - 1, 0, layouts.Length - 1);
                        }
                        else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight)))
                        {
                            historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex + 1, 0, layouts.Length - 1);
                        }
                        GUILayout.Space(5);
                        GUILayout.Label(historian.GetCurrentLayoutName(), GUI.skin.textArea, GUILayout.ExpandWidth(true));
                    }

                    GUILayout.Space(10);
                    using (GUILayout.HorizontalScope customHead = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_CustomText"));
                        GUILayout.FlexibleSpace();
                        Configuration.Instance.PersistentCustomText = GUILayout.Toggle(Configuration.Instance.PersistentCustomText, Localizer.GetStringByTag("#Historian_Persistent"), GUILayout.Width(120));
                    }
                    Configuration.Instance.CustomText = GUILayout.TextArea(Configuration.Instance.CustomText, GUI.skin.textArea, GUILayout.Height(60));

                    GUILayout.Space(10);
                    using (GUILayout.HorizontalScope spaceCentre = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_DefaultSpaceCenterLabel"));
                        GUILayout.FlexibleSpace();
                        Configuration.Instance.DefaultSpaceCenterName = GUILayout.TextField(Configuration.Instance.DefaultSpaceCenterName, GUI.skin.textArea, GUILayout.Width(150));
                    }


                    GUILayout.Space(10);
                    GUILayout.Label($"{Localizer.GetStringByTag("#Historian_LastActionTime")}: {Configuration.Instance.TimeToRememberLastAction} ms");
                    Configuration.Instance.TimeToRememberLastAction = (int)GUILayout.HorizontalSlider(Configuration.Instance.TimeToRememberLastAction, 250, 10000, GUILayout.ExpandWidth(true));
                }
            }

            // column two
            using (GUILayout.AreaScope columnTwo = new GUILayout.AreaScope(new Rect(410, 20, 220, 500)))
            {
                using (GUILayout.VerticalScope col = new GUILayout.VerticalScope())
                {
                    GUILayout.Space(20);
                    GUILayout.Label(Localizer.GetStringByTag("#Historian_DayNames"));
                    for (int i = 0; i < Configuration.Instance.KerbinDayNames.Length; i++)
                    {
                        using (GUILayout.HorizontalScope item = new GUILayout.HorizontalScope())
                        {
                            GUILayout.Label($"{i + 1}:");
                            GUILayout.FlexibleSpace();
                            Configuration.Instance.KerbinDayNames[i] = GUILayout.TextField(Configuration.Instance.KerbinDayNames[i], GUI.skin.textArea, GUILayout.Width(190f));
                        }
                    }

                    GUILayout.Space(50);
                    GUILayout.Label(Localizer.GetStringByTag("#Historian_DefaultEmptyCrewSlot"));
                    GUILayout.Space(10);
                    using (GUILayout.HorizontalScope noCrewLabel = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_CrewedLabel"));
                        GUILayout.FlexibleSpace();
                        Configuration.Instance.DefaultNoCrewLabel = GUILayout.TextField(Configuration.Instance.DefaultNoCrewLabel, GUI.skin.textArea, GUILayout.Width(120));
                    }
                    using (GUILayout.HorizontalScope noCrewLabel = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label(Localizer.GetStringByTag("#Historian_UncrewedLabel"));
                        GUILayout.FlexibleSpace();
                        Configuration.Instance.DefaultUnmannedLabel = GUILayout.TextField(Configuration.Instance.DefaultUnmannedLabel, GUI.skin.textArea, GUILayout.Width(120));
                    }
                }
            }

            // column three
            using (GUILayout.AreaScope columnThree = new GUILayout.AreaScope(new Rect(660, 20, 220, 480)))
            {
                using (GUILayout.VerticalScope col = new GUILayout.VerticalScope())
                {
                    GUILayout.Space(20);
                    GUILayout.Label(Localizer.GetStringByTag("#Historian_MonthNames"));
                    for (int i = 0; i < Configuration.Instance.KerbinMonthNames.Length; i++)
                    {
                        using (GUILayout.HorizontalScope item = new GUILayout.HorizontalScope())
                        {
                            GUILayout.Label($"{i + 1}:");
                            GUILayout.FlexibleSpace();
                            Configuration.Instance.KerbinMonthNames[i] = GUILayout.TextField(Configuration.Instance.KerbinMonthNames[i], GUI.skin.textArea, GUILayout.Width(190f));
                        }
                    }
                }
            }

            // bottom bar
            using (GUILayout.AreaScope buttonBar = new GUILayout.AreaScope(new Rect(5, 525, 890, 30)))
            {
                using (GUILayout.HorizontalScope layout = new GUILayout.HorizontalScope())
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button(Localizer.GetStringByTag("#autoLOC_900539"), GUILayout.Width(100.0f))) // #autoLOC_900539 = Load
                    {
                        historian.Reload();
                    }
                    if (GUILayout.Button(Localizer.GetStringByTag("#autoLOC_174778"), GUILayout.Width(100.0f))) // #autoLOC_174778 = Save
                    {
                        Configuration.Instance.Layout = historian.GetCurrentLayoutName();

                        historian.SetConfiguration(Configuration.Instance);
                        if (!Configuration.Instance.PersistentConfigurationWindow)
                        {
                            Toggle();
                        }

                        if (!String.IsNullOrEmpty(Configuration.Instance.CustomText))
                        {
                            Configuration.Instance.TokenizedCustomText = Parser.GetTokens(Configuration.Instance.CustomText);
                        }
                    }
                    GUILayout.Space(20);
                    // GUILayout.FlexibleSpace();
                }
            }

            GUI.DragWindow();
        }
        private void DisplayCLSWindow()
        {
            // set scrollviewer sizes...
            if (Event.current.type == EventType.Repaint)
            {
                _scrollY      = _scrollCrew.height > _scrollParts.height ? _scrollCrew.height : _scrollParts.height;
                _scrollXCrew  = _scrollCrew.width > 140 ? _scrollCrew.width : 140;
                _scrollXParts = _scrollParts.width > 240 ? _scrollParts.width : 240;

                // reset counters.
                _scrollCrew.height = _scrollParts.height = _scrollCrew.width = _scrollParts.width = 0;
            }
            try
            {
                Rect rect = new Rect(_windowPosition.width - 20, 4, 16, 16);
                if (GUI.Button(rect, ""))
                {
                    OnCLSButtonToggle();
                }
                rect = new Rect(_windowPosition.width - 90, 4, 65, 16);
                if (GUI.Button(rect, new GUIContent(_clsLocOptions, _clsLocOptionTt))) // "Options","Click to view/edit options"
                {
                    _optionsVisible = !_optionsVisible;
                }
                GUILayout.BeginVertical();
                GUI.enabled = true;

                // Build strings describing the contents of each of the spaces.
                if (null != _vessel)
                {
                    string[] spaceNames       = new string[_vessel.Spaces.Count];
                    int      counter          = 0;
                    int      newSelectedSpace = -1;

                    string partsList = "";
                    List <ICLSSpace> .Enumerator spaces = _vessel.Spaces.GetEnumerator();
                    while (spaces.MoveNext())
                    {
                        if (spaces.Current == null)
                        {
                            continue;
                        }
                        if (spaces.Current.Name == "")
                        {
                            spaceNames[counter] = $"{_clsLocSpace} {counter + 1}";
                        }
                        else
                        {
                            spaceNames[counter] = spaces.Current.Name;
                        }
                        counter++;
                    }
                    spaces.Dispose();

                    if (_vessel.Spaces.Count > 0)
                    {
                        newSelectedSpace = DisplaySpaceButtons(WindowSelectedSpace, spaceNames);
                    }


                    // Only fiddle with the highlighting if the selected space has actually changed
                    UpdateDisplayHighlghting(newSelectedSpace);

                    // Update the space that has been selected.
                    WindowSelectedSpace = newSelectedSpace;

                    // If one of the spaces has been selected then display lists of the crew and parts that make it up
                    if (WindowSelectedSpace != -1)
                    {
                        Rect _rect;
                        // Loop through all the parts in the newly selected space and create a list of all the spaces in it.
                        partsList = $"{_clsLocParts}:";
                        List <ICLSPart> .Enumerator parts = _vessel.Spaces[WindowSelectedSpace].Parts.GetEnumerator();
                        while (parts.MoveNext())
                        {
                            if (parts.Current == null)
                            {
                                continue;
                            }
                            partsList += $"\n- {(parts.Current.Part).partInfo.title}";
                        }
                        parts.Dispose();

                        string crewList = $"{_clsLocInfo}:";
                        if (_vessel.Spaces[WindowSelectedSpace].Crew.Count == 0)
                        {
                            crewList += $"\n- {_clsLocNone}";
                        }
                        else
                        {
                            List <ICLSKerbal> .Enumerator crewmembers = _vessel.Spaces[WindowSelectedSpace].Crew.GetEnumerator();
                            while (crewmembers.MoveNext())
                            {
                                if (crewmembers.Current == null)
                                {
                                    continue;
                                }
                                crewList += $"\n- {(crewmembers.Current.Kerbal).name}";
                            }
                            crewmembers.Dispose();
                        }

                        // Display the text box that allows the space name to be changed
                        GUILayout.BeginHorizontal();
                        GUILayout.Label($"{_clsLocName}:");  // "Name:"
                        _spaceNameEditField = GUILayout.TextField(_spaceNameEditField, GUILayout.Width(200));
                        if (GUILayout.Button(_clsLocUpdate)) // "Update"
                        {
                            _vessel.Spaces[WindowSelectedSpace].Name = _spaceNameEditField;
                        }
                        GUILayout.EndHorizontal();

                        // Lets use 2 scrollers for Crew and parts to save space...
                        GUILayout.BeginHorizontal();

                        // Crew Scroller
                        _scrollViewerCrew = GUILayout.BeginScrollView(_scrollViewerCrew, GUILayout.Width(_scrollXCrew), GUILayout.Height(20 > _scrollY ? 20 : _scrollY + 20));
                        GUILayout.BeginVertical();

                        // Display the crew capacity of the space.
                        GUILayout.Label($"{_clsLocCapacity}:  {_vessel.Spaces[WindowSelectedSpace].MaxCrew}");
                        _rect = GUILayoutUtility.GetLastRect();
                        if (Event.current.type == EventType.Repaint)
                        {
                            _scrollCrew.height = _rect.height;
                            _scrollCrew.width  = _rect.width;
                        }

                        // Crew Capacity
                        GUILayout.Label(crewList);
                        _rect = GUILayoutUtility.GetLastRect();
                        if (Event.current.type == EventType.Repaint)
                        {
                            _scrollCrew.height += _rect.height;
                            _scrollCrew.width   = _scrollCrew.width > _rect.width ? _scrollCrew.width : _rect.width;
                        }

                        GUILayout.EndVertical();
                        GUILayout.EndScrollView();

                        // Part Scroller
                        _scrollViewerParts = GUILayout.BeginScrollView(_scrollViewerParts, GUILayout.Width(_scrollXParts), GUILayout.Height(20 > _scrollY ? 20 : _scrollY + 20));
                        GUILayout.BeginVertical();

                        // Display the Part count of the space.
                        GUILayout.Label($"{_clsLocPartCount}:  {_vessel.Spaces[WindowSelectedSpace].Parts.Count}"); // Selected Space Parts Count
                        _rect = GUILayoutUtility.GetLastRect();
                        if (Event.current.type == EventType.Repaint)
                        {
                            _scrollParts.height = _rect.height;
                            _scrollParts.width  = _rect.width;
                        }

                        // Display the list of component parts.
                        GUILayout.Label(partsList);
                        _rect = GUILayoutUtility.GetLastRect();
                        if (Event.current.type == EventType.Repaint)
                        {
                            _scrollParts.height += _rect.height;
                            _scrollParts.width   = _scrollParts.width > _rect.width ? _scrollParts.width : _rect.width;
                        }

                        GUILayout.EndVertical();
                        GUILayout.EndScrollView();
                        GUILayout.EndHorizontal();
                    }
                }
                else
                {
                    GUILayout.Label("", GUILayout.Height(20));                                        // Add some vertical space.
                    GUILayout.Label(_clsLocNoVessel, CLSStyles.LabelStyleBold, GUILayout.Width(380)); // "No current vessel"
                }
                GUILayout.EndVertical();
                GUI.DragWindow();
                RepositionWindow(ref _windowPosition);
            }
            catch (Exception ex)
            {
                Log.error(ex, this);
            }
        }
        private void OnGUI()
        {
            if (WindowVisable)
            {
                //Set the GUI Skin
                //GUI.skin = HighLogic.Skin;
                CLSStyles.SetupGuiStyles();

                _windowPosition = GUILayout.Window(947695, _windowPosition, OnWindow, _clsLocTitle, _windowStyle, GUILayout.MinHeight(80), GUILayout.MinWidth(400), GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.Width(400), GUILayout.Height(80));
                if (!_optionsVisible)
                {
                    return;
                }
                if (_windowOptionsPosition == new Rect(0, 0, 0, 0))
                {
                    _windowOptionsPosition = new Rect(_windowPosition.x + _windowPosition.width + 10, _windowPosition.y, 260, 120);
                }
                _windowOptionsPosition = GUILayout.Window(947696, _windowOptionsPosition, DisplayOptionWindow, _clsLocOptions, _windowStyle, GUILayout.MinHeight(120), GUILayout.ExpandWidth(true));
            }
            else
            {
                if (WindowSelectedSpace <= -1)
                {
                    return;
                }
                _vessel.Spaces[WindowSelectedSpace].Highlight(false);
                WindowSelectedSpace = -1;
            }
        }
        private void LoadAndDisplay(string f)
        {
            if (!loaded)
            {
                Load(f);
                loaded = true;
            }
            int    imgcnt = 0;
            string l      = "";

            foreach (string line in lines)
            {
                if (line.Length >= 7 && line.Substring(0, 7) == "<IMAGE=")
                {
                    if (l.Length > 0)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label(l);
                        GUILayout.EndHorizontal();
                        l = "";
                    }
                    if (imgcnt <= images.Count)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        GUILayout.Box(images[imgcnt], GUILayout.Width(images[imgcnt].width + 10), GUILayout.Height(images[imgcnt].height + 10));
                        GUILayout.FlexibleSpace();
                        imgcnt++;
                        GUILayout.EndHorizontal();
                    }
                }
                else
                {
                    if (l == "")
                    {
                        l = line;
                    }
                    else
                    {
                        l += "\n" + line;
                    }
                }
            }
            if (l.Length > 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(l);
                GUILayout.EndHorizontal();
                l = "";
            }
        }
Esempio n. 16
0
        /*************************************************************************************************************************/
        public void MainGUI(int windowID)
        {
            List <string> save_files = new List <string>();
            Vessel        temp_vessel;
            string        temp_string;
            Guid          guid_delete_vessel = FlightGlobals.ActiveVessel.id;
            bool          delete_vessel      = false;
            float         scrollbar_size;
            bool          scrollbar_enable = false;
            float         window_height, window_width, scrollbar_width_offset;

            window_height = 60;
            window_width  = 280;

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();

            if (!_SETTING_Minimize)
            {
                if (_SAVE_Has_Launched)
                {
                    GUILayout.Box("Mission Time: " + get_time_string(Planetarium.GetUniversalTime() - _SAVE_Launched_At), text_main, GUILayout.Width(188));
                }
                else
                {
                    GUILayout.Box("Mission Time: " + "00:00", text_main, GUILayout.Width(137));
                }
            }
            else
            {
                GUILayout.Space(5);
            }

            if (_SETTING_Armed)
            {
                temp_string = "Armed";
            }
            else
            {
                temp_string = "Arm";
            }

            if (!_SAVE_Has_Launched)
            {
                _SETTING_Armed = GUILayout.Toggle(_SETTING_Armed, temp_string, button_small, GUILayout.Width(50));
            }
            else
            if (_SETTING_Minimize)
            {
                GUILayout.Box("Flight", text_main, GUILayout.Width(50));
            }

            if (!_SETTING_Minimize)
            {
                show_setting = GUILayout.Toggle(show_setting, buttonContent, button_small, GUILayout.Width(25));
                if (show_setting)
                {
                    buttonContent = upContent;
                }
                else
                {
                    buttonContent = downContent;
                }
            }

            _SETTING_Minimize = GUILayout.Toggle(_SETTING_Minimize, "_", button_small, GUILayout.Width(25));
            if (really_close && _SETTING_Minimize)
            {
                _SETTING_Minimize = false;
            }

            if (!_SETTING_Minimize)
            {
                really_close = GUILayout.Toggle(really_close, "x", button_small, GUILayout.Width(25));
            }
            else
            {
                window_width = 105;
            }

            GUILayout.EndHorizontal();

            if (really_close)
            {
                if (_SAVE_Has_Launched)
                {
                    GUILayout.Space(5);
                    window_height += 5;

                    GUILayout.Box("Plugin will be reset!", text_heading, GUILayout.Width(266));
                    window_height += 29;
                    GUILayout.Box("Close?", text_heading, GUILayout.Width(266));
                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button("YES", button_big, GUILayout.Width(132)))
                    {
                        close_FMRS();
                    }

                    if (GUILayout.Button("NO", button_big, GUILayout.Width(133)))
                    {
                        really_close = false;
                    }

                    GUILayout.EndHorizontal();
                    window_height += 58;
                }
                else
                {
                    close_FMRS();
                }
            }

            if (really_close == false && _SETTING_Minimize == false && show_setting == true)
            {
                GUILayout.Space(5);
                window_height += 5;
                GUILayout.BeginVertical(/* area_style ,*/ GUILayout.Width(266));
                GUILayout.Space((5 * 30) + 5);
                _SETTING_Messages     = GUI.Toggle(new Rect(5, 35 + (30 * 1), 25, 25), _SETTING_Messages, "Messaging System");
                window_height        += 30;
                _SETTING_Auto_Cut_Off = GUI.Toggle(new Rect(5, 35 + (30 * 2), 25, 25), _SETTING_Auto_Cut_Off, "Auto Cut Off Engines");
                window_height        += 30;
                _SETTING_Auto_Recover = GUI.Toggle(new Rect(5, 35 + (30 * 3), 25, 25), _SETTING_Auto_Recover, "Auto Recover Landed Crafts");
                window_height        += 30;
                _SETTING_Throttle_Log = GUI.Toggle(new Rect(5, 35 + (30 * 4), 25, 25), _SETTING_Throttle_Log, "Throttle Logger WIP");
                window_height        += 30;
                Timer_Stage_Delay     = GUI.HorizontalSlider(new Rect(45, 35 + (30 * 6) + 15, 205, 25), Timer_Stage_Delay, 0.2f, 5.0f);
                window_height        += 45;
                GUI.Label(new Rect(20, 35 + (30 * 7), 225, 25), "Stage Save Delay: " + Timer_Stage_Delay.ToString("F1"));
                GUILayout.EndVertical();
                window_height += 42;
            }

            if (really_close == false && _SETTING_Minimize == false && show_setting == false)
            {
                if (Vessels_dropped.Count > 0)
                {
                    GUILayout.Space(5);
                    window_height += 5;

                    GUILayout.Box("Separated Stages:", text_heading, GUILayout.Width(266));
                    window_height += 33;

                    foreach (KeyValuePair <Guid, string> temp_keyvalue in Vessels_dropped)
                    {
                        if (!save_files.Contains(temp_keyvalue.Value))
                        {
                            save_files.Add(temp_keyvalue.Value);
                        }
                    }

                    save_files.Sort(delegate(string x, string y)
                    {
                        return(get_save_value(save_cat.SAVEFILE, y).CompareTo(get_save_value(save_cat.SAVEFILE, x)));
                    });

                    nr_save_files = save_files.Count;

                    scrollbar_size  = nr_save_files * 61;
                    scrollbar_size += (Vessels_dropped.Count - nr_save_files) * 25;
                    if (_SAVE_Switched_To_Dropped && can_q_save_load)
                    {
                        scrollbar_size += 43;
                    }

                    if (scrollbar_size > 225)
                    {
                        scrollbar_enable = true;
                        scroll_Vector    = GUILayout.BeginScrollView(scroll_Vector, scrollbar_stlye, GUILayout.Width(266), GUILayout.Height(225));
                        GUILayout.BeginVertical();
                        window_height         += 220;
                        scrollbar_width_offset = 0;
                    }
                    else
                    {
                        GUILayout.BeginVertical(/* area_style, */ GUILayout.Width(266));
                        window_height         += scrollbar_size;
                        scrollbar_width_offset = 20;
                    }

                    while (save_files.Count != 0)
                    {
                        GUILayout.Space(5);
                        GUILayout.BeginVertical(); //  area_style);
                        if (save_files.Last().Contains("separated_"))
                        {
                            GUILayout.Box("Separated at " + get_time_string(Convert.ToDouble(get_save_value(save_cat.SAVEFILE, save_files.Last())) - _SAVE_Launched_At), text_main, GUILayout.Width(230 + scrollbar_width_offset));
                        }
                        else
                        {
                            GUILayout.Box("Stage " + save_files.Last().Substring(10) + " separated at " + get_time_string(Convert.ToDouble(get_save_value(save_cat.SAVEFILE, save_files.Last())) - _SAVE_Launched_At), text_main, GUILayout.Width(230 + scrollbar_width_offset));
                        }

                        foreach (KeyValuePair <Guid, string> vessel_in_savefile in Vessels_dropped)
                        {
                            if (FMRS_SAVE_Util.Instance.jumpInProgress)
                            {
                                GUI.enabled = false;
                            }
                            if (vessel_in_savefile.Value == save_files.Last())
                            {
                                GUILayout.BeginHorizontal();
                                if (get_vessel_state(vessel_in_savefile.Key) == vesselstate.RECOVERED)
                                {
                                    GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " recovered", text_cyan, GUILayout.Width(205 + scrollbar_width_offset));
                                }
                                else if (get_vessel_state(vessel_in_savefile.Key) == vesselstate.LANDED)
                                {
                                    GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " landed", text_green, GUILayout.Width(205 + scrollbar_width_offset));
                                }
                                else if (vessel_in_savefile.Key == FlightGlobals.ActiveVessel.id || vessel_in_savefile.Key == anz_id)
                                {
                                    float temp_float = 230 + scrollbar_width_offset;
                                    if (can_q_save_load)
                                    {
                                        GUILayout.EndHorizontal();
                                        GUILayout.Space(5);
                                        GUILayout.BeginVertical(/* area_style, */ GUILayout.Width(230));
                                        temp_float = 222 + scrollbar_width_offset;
                                    }
                                    if (FlightGlobals.ActiveVessel.LandedOrSplashed)
                                    {
                                        GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " landed", text_green, GUILayout.Width(temp_float));
                                    }
                                    else
                                    {
                                        GUILayout.Box("contr.: " + Vessels_dropped_names[vessel_in_savefile.Key], text_yellow, GUILayout.Width(temp_float));
                                    }
                                    if (can_q_save_load)
                                    {
                                        if (GUILayout.Button("Jump back to Separation", button_main, GUILayout.Width(222 + scrollbar_width_offset)))
                                        {
                                            jump_to_vessel(vessel_in_savefile.Key, false);
                                        }

                                        GUILayout.EndVertical();
                                        GUILayout.Space(5);
                                        GUILayout.BeginHorizontal();
                                    }
                                }
                                else if (get_vessel_state(vessel_in_savefile.Key) == vesselstate.DESTROYED)
                                {
                                    GUILayout.Box(Vessels_dropped_names[vessel_in_savefile.Key] + " destroyed", text_red, GUILayout.Width(205 + scrollbar_width_offset));
                                }
                                else
                                {
                                    temp_vessel = FlightGlobals.Vessels.Find(p => p.id == vessel_in_savefile.Key);

                                    if (temp_vessel == null)
                                    {
                                        if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key], button_main, GUILayout.Width(205 + scrollbar_width_offset)))
                                        {
                                            jump_to_vessel(vessel_in_savefile.Key, true);
                                        }
                                    }
                                    else
                                    {
                                        if (loaded_vessels.Contains(temp_vessel.id) && _SAVE_Switched_To_Dropped)
                                        {
                                            if (temp_vessel.LandedOrSplashed)
                                            {
                                                if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key] + " landed", button_green, GUILayout.Width(205 + scrollbar_width_offset)))
                                                {
                                                    FlightGlobals.ForceSetActiveVessel(temp_vessel);
                                                }
                                            }
                                            else
                                            {
                                                if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key] + " is near", button_yellow, GUILayout.Width(205 + scrollbar_width_offset)))
                                                {
                                                    FlightGlobals.ForceSetActiveVessel(temp_vessel);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (GUILayout.Button(Vessels_dropped_names[vessel_in_savefile.Key], button_main, GUILayout.Width(205 + scrollbar_width_offset)))
                                            {
                                                jump_to_vessel(vessel_in_savefile.Key, true);
                                            }
                                        }
                                    }
                                }

                                if (vessel_in_savefile.Key != FlightGlobals.ActiveVessel.id && vessel_in_savefile.Key != anz_id)
                                {
                                    if (GUILayout.Button("X", button_small_red, GUILayout.Width(25)))
                                    {
                                        guid_delete_vessel = vessel_in_savefile.Key;
                                        delete_vessel      = true;
                                    }
                                }
                                GUILayout.EndHorizontal();
                                button_main.normal.textColor = button_main.focused.textColor = Color.white;
                            }
                            GUI.enabled = true;
                        }
                        GUILayout.EndVertical();
                        temp_string = save_files.Last();
                        save_files.Remove(temp_string);
                    }

                    if (scrollbar_enable)
                    {
                        GUILayout.EndVertical();
                        GUILayout.EndScrollView();
                    }
                    else
                    {
                        GUILayout.EndVertical();
                    }
                }

                if (_SAVE_Switched_To_Dropped)
                {
                    GUILayout.Space(5);
                    window_height += 5;
                    if (FMRS_SAVE_Util.Instance.jumpInProgress)
                    {
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button("Jump back to Main Mission", button_big, GUILayout.Width(266)))
                    {
                        jump_to_vessel("Main");
                    }
                    GUI.enabled    = true;
                    window_height += 31;
                }

                if (_SAVE_Has_Launched && can_restart)
                {
                    GUILayout.Space(5);
                    window_height += 5;
                    if (FMRS_SAVE_Util.Instance.jumpInProgress)
                    {
                        GUI.enabled = false;
                    }
                    if (revert_to_launch)
                    {
                        GUILayout.Box("Revert Flight?", text_heading, GUILayout.Width(266));

                        GUILayout.BeginHorizontal();

                        if (GUILayout.Button("YES", button_big, GUILayout.Width(132)))
                        {
                            // _SETTING_Enabled = false;
                            jump_to_vessel(_SAVE_Main_Vessel, "before_launch");
                        }
                        if (GUILayout.Button("NO", button_big, GUILayout.Width(133)))
                        {
                            revert_to_launch = false;
                        }

                        GUILayout.EndHorizontal();
                        window_height += 58;
                    }
                    else
                    {
                        if (_SAVE_Flight_Reset)
                        {
                            revert_to_launch = GUILayout.Toggle(revert_to_launch, "Revert To Plugin Start", button_big, GUILayout.Width(266));
                        }
                        else
                        {
                            revert_to_launch = GUILayout.Toggle(revert_to_launch, "Revert To Launch", button_big, GUILayout.Width(266));
                        }
                        window_height += 31;
                    }
                    GUI.enabled = true;
                }
            }
            GUILayout.EndVertical();

            if (delete_vessel && guid_delete_vessel != FlightGlobals.ActiveVessel.id)
            {
                delete_dropped_vessel(guid_delete_vessel);
            }

            windowPos.height = window_height;
            //   windowPos.width = window_width;

            GUI.DragWindow();
        }
Esempio n. 17
0
        private void DrawBlacklistGUI(int windowID)
        {
            GUILayout.BeginVertical();
            scrollPos = GUILayout.BeginScrollView(scrollPos, HighLogic.Skin.textArea, GUILayout.Height(Screen.height / 4));
            foreach (string s in Settings.Instance.BlackList.ignore)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(s);
                if (GUILayout.Button("Remove", GUILayout.ExpandWidth(false)))
                {
                    Settings.Instance.BlackList.Remove(s);
                    break;
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();
            GUILayout.BeginHorizontal();
            tempListItem = GUILayout.TextField(tempListItem);
            if (GUILayout.Button("Add", GUILayout.ExpandWidth(false)))
            {
                Settings.Instance.BlackList.Add(tempListItem);
                tempListItem = "";
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Save"))
            {
                Settings.Instance.BlackList.Save();
                showBlacklist = false;
            }
            if (GUILayout.Button("Cancel"))
            {
                Settings.Instance.BlackList.Load();
                showBlacklist = false;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2))
            {
                GUI.DragWindow();
            }
        }