コード例 #1
0
        protected virtual void OnErrorRender()
        {
            GUILayout.BeginVertical();

            GUILayoutOption maxWidth   = GUILayout.MaxWidth(this.window.width);
            GUILayoutOption lockWidth  = GUILayout.ExpandWidth(false);
            GUILayoutOption lockHeight = GUILayout.ExpandHeight(false);

            GUILayoutOption informationLabelMaxHeight = GUILayout.MaxHeight(this.window.height * 0.75f);    // Magically use 3/4ths of the window for the top information label.

            GUILayout.Label(string.Format(CultureInfo.CurrentCulture, Localized.GuiRenderErrorTextFormat, Version.FriendlyName), maxWidth, informationLabelMaxHeight, lockWidth, lockHeight);

            // Fix up the path for the current environment.
            string platformCompatibleRootPath = KSPUtil.ApplicationRootPath.Replace('/', Path.DirectorySeparatorChar);
            // Trim off the extra path components to get the actual KSP root path.
            string actualRootPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(platformCompatibleRootPath)));
            string kspDataPath    = Path.Combine(actualRootPath, "KSP_Data");
            string kspLogFile     = Path.Combine(kspDataPath, "output_log.txt");

            GUIStyle textFieldStyle = new GUIStyle();

            textFieldStyle.wordWrap         = true;
            textFieldStyle.normal.textColor = Color.white;

            GUILayoutOption informationFieldMaxHeight = GUILayout.MaxHeight(this.window.height * 0.25f);    // Magically use 1/4th of the window for the bottom information field.

            GUILayout.TextField(kspLogFile, textFieldStyle, maxWidth, informationFieldMaxHeight, lockWidth, lockHeight);

            GUILayout.EndVertical();
        }
コード例 #2
0
        private void windowGUI(int ID)
        {
            GUILayout.BeginVertical();

            SmokeScreenConfig.Instance.globalCollideDisable =
                GUILayout.Toggle(SmokeScreenConfig.Instance.globalCollideDisable, "Globally disable Collide");
            SmokeScreenConfig.Instance.globalPhysicalDisable =
                GUILayout.Toggle(SmokeScreenConfig.Instance.globalPhysicalDisable, "Globally disable Physical");

            SmokeScreenConfig.Instance.forceEmitOnUpdate =
                GUILayout.Toggle(SmokeScreenConfig.Instance.forceEmitOnUpdate, "Globally force emitOnUpdate");

            SmokeScreenConfig.Instance.forceDecluster =
                GUILayout.Toggle(SmokeScreenConfig.Instance.forceDecluster, "Globally force decluster");

            SmokeScreenConfig.Instance.shareManualInput =
                GUILayout.Toggle(SmokeScreenConfig.Instance.shareManualInput, "Share manual input values across effects");

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.Label("maximumActiveParticles", GUILayout.ExpandWidth(true));
            int.TryParse(
                GUILayout.TextField(
                    SmokeScreenConfig.Instance.maximumActiveParticles.ToString(),
                    GUILayout.ExpandWidth(true),
                    GUILayout.Width(100)),
                out SmokeScreenConfig.Instance.maximumActiveParticles);
            GUILayout.EndHorizontal();

            // 'SmokeScreenConfig.activeParticles' isn't accurate anymore
            int activeParticles = 0;

            ModelMultiShurikenPersistFX.List.ForEach(x => activeParticles += x.CurrentlyActiveParticles);
            GUILayout.Label($"Active particles: {activeParticles}");

            GUILayout.Space(10);

            GUILayout.Label("Open ModelMultiShurikenPersistFX UI :");

            foreach (var mmFX in ModelMultiShurikenPersistFX.List)
            {
                if (mmFX.hostPart != null)
                {
                    // Changed to string interpolation, and added current particle count alongside max particle count per plume
                    mmFX.showUI = GUILayout.Toggle(
                        mmFX.showUI,
                        $"{mmFX.hostPart.name}: {mmFX.effectName}, {mmFX.instanceName}: {mmFX.CurrentlyActiveParticles} ({mmFX.MaxActiveParticles} max)"
                        );
                }
            }

            GUILayout.EndVertical();

            GUI.DragWindow();
        }
コード例 #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);
        }
コード例 #4
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();
            }
        }
コード例 #5
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);
        }
コード例 #6
0
        private void Window(int id)
        {
            if (!cfgWinData)
            {
                cfgWinData = true;
//				newScreenshotAtIntervals = AS.configuration.screenshotAtIntervals;
                newInterval          = AS.configuration.screenshotInterval;
                interval             = newInterval.ToString();
                newConvertToJPG      = AS.configuration.convertToJPG;
                newKeepOrginalPNG    = AS.configuration.keepOrginalPNG;
                newNoGUIOnScreenshot = AS.configuration.noGUIOnScreenshot;
                newGUIOnScreenshot   = AS.configuration.guiOnScreenshot;

                newScreenshotPath          = AS.configuration.screenshotPath;
                newFilename                = AS.configuration.filename;
                newJPGQuality              = AS.configuration.JPGQuality;
                JPGQuality                 = newJPGQuality.ToString();
                newScreenshotOnSceneChange = AS.configuration.screenshotOnSceneChange;
                newOnSpecialEvent          = AS.configuration.onSpecialEvent;
                newKeycode                 = AS.configuration.keycode;

                newprecrashSnapshots    = AS.configuration.precrashSnapshots;
                newsecondsUntilImpact   = AS.configuration.secondsUntilImpact;
                newhsAltitudeLimit      = AS.configuration.hsAltitudeLimit;
                newhsMinVerticalSpeed   = AS.configuration.hsMinVerticalSpeed;
                newhsScreenshotInterval = AS.configuration.hsScreenshotInterval;

                secondsUntilImpact   = AS.configuration.secondsUntilImpact.ToString();
                hsAltitudeLimit      = AS.configuration.hsAltitudeLimit.ToString();
                hsMinVerticalSpeed   = AS.configuration.hsMinVerticalSpeed.ToString();
                hsScreenshotInterval = AS.configuration.hsScreenshotInterval.ToString();

                newsupersize = AS.configuration.supersize;
                strsupersize = AS.configuration.supersize.ToString();

                newautoSave            = AS.configuration.autoSave;
                newminBetweenSaves     = AS.configuration.minBetweenSaves;
                minBetweenSaves        = AS.configuration.minBetweenSaves.ToString();
                newsavePrefix          = AS.configuration.savePrefix;
                newnumToRotate         = AS.configuration.numToRotate;
                numToRotate            = AS.configuration.numToRotate.ToString();
                newautoSaveOnGameStart = AS.configuration.autoSaveOnGameStart;
            }

            SetVisible(true);
            GUI.enabled = true;

            GUILayout.BeginHorizontal();
            GUILayout.EndHorizontal();
            //DrawTitle ("Options");
            GUILayout.BeginArea(new Rect(10, 50, 375, 450));

            GUILayout.BeginVertical();

            DrawTitle("Screenshot Options");

            //GUILayout.BeginHorizontal ();
            //GUILayout.Label ("Take screenshots at specified intervals: ");
            //GUILayout.FlexibleSpace ();
            //newScreenshotAtIntervals = GUILayout.Toggle (newScreenshotAtIntervals, "");
            //GUILayout.EndHorizontal ();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Screenshot Interval in seconds: ");
            GUILayout.FlexibleSpace();
            interval = GUILayout.TextField(interval, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(30.0F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Convert to JPG: ");
            GUILayout.FlexibleSpace();
            newConvertToJPG = GUILayout.Toggle(newConvertToJPG, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Keep original PNG: ");
            GUILayout.FlexibleSpace();
            newKeepOrginalPNG = GUILayout.Toggle(newKeepOrginalPNG, "");
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("JPEG Quality (1-100):");
            GUILayout.FlexibleSpace();
            JPGQuality = GUILayout.TextField(JPGQuality, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(30.0F));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Supersize images (0-4):");
            GUILayout.FlexibleSpace();
            strsupersize = GUILayout.TextField(strsupersize, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(30.0F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Screenshot path:");
            GUILayout.FlexibleSpace();
//			GUILayout.EndHorizontal ();

//			GUILayout.BeginHorizontal ();
//			GUILayout.FlexibleSpace ();
            newScreenshotPath = GUILayout.TextField(newScreenshotPath, GUILayout.MinWidth(50F), GUILayout.MaxWidth(250F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Filename Format:");
            GUILayout.FlexibleSpace();
            newFilename = GUILayout.TextField(newFilename, GUILayout.MinWidth(30F), GUILayout.MaxWidth(160F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Screenshot after scene change:");
            GUILayout.FlexibleSpace();
            newScreenshotOnSceneChange = GUILayout.Toggle(newScreenshotOnSceneChange, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Screenshot after special event:");
            GUILayout.FlexibleSpace();
            newOnSpecialEvent = GUILayout.Toggle(newOnSpecialEvent, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Use Blizzy Toolbar if available:");
            GUILayout.FlexibleSpace();
            newUseBlizzyToolbar = GUILayout.Toggle(newUseBlizzyToolbar, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Activation Keycode:");
            GUILayout.FlexibleSpace();
            newKeycode = GUILayout.TextField(newKeycode, GUILayout.MinWidth(30F), GUILayout.MaxWidth(40F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("No GUI on screenshot:");
            GUILayout.FlexibleSpace();
            newNoGUIOnScreenshot = GUILayout.Toggle(newNoGUIOnScreenshot, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("GUI on screenshot:   ");
            GUILayout.FlexibleSpace();
            newGUIOnScreenshot = GUILayout.Toggle(newGUIOnScreenshot, "");
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUILayout.EndArea();


            GUILayout.BeginArea(new Rect(400, 50, 300, 400));
            GUILayout.BeginVertical();

            DrawTitle("Pre-Crash Settings");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Take pre-crash snapshots:");
            GUILayout.FlexibleSpace();
            newprecrashSnapshots = GUILayout.Toggle(newprecrashSnapshots, "");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Seconds until impact:");
            secondsUntilImpact = GUILayout.TextField(secondsUntilImpact, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(30.0F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Altitude limit (meters):");
            hsAltitudeLimit = GUILayout.TextField(hsAltitudeLimit, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(60.0F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Minimum vertical speed:");
            hsMinVerticalSpeed = GUILayout.TextField(hsMinVerticalSpeed, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(30.0F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Screenshot interval (pre-crash):");
            hsScreenshotInterval = GUILayout.TextField(hsScreenshotInterval, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(30.0F));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("");
            GUILayout.EndHorizontal();

            DrawTitle("Automatic Save Settings");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Activation Key (not configurable):");
            GUILayout.FlexibleSpace();
            GUILayout.Label("Ctrl-F6");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Minutes between saves:");
            minBetweenSaves = GUILayout.TextField(minBetweenSaves, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(30.0F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Save file format:");
            newsavePrefix = GUILayout.TextField(newsavePrefix, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(160.0F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Max save files:");
            numToRotate = GUILayout.TextField(numToRotate, GUILayout.MinWidth(30.0F), GUILayout.MaxWidth(30.0F));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Autosave on at game start:");
            GUILayout.FlexibleSpace();
            newautoSaveOnGameStart = GUILayout.Toggle(newautoSaveOnGameStart, "");
            GUILayout.EndHorizontal();



            GUILayout.EndVertical();
            GUILayout.EndArea();


            //
            // I probably don't need to have the "finally" sections, but
            // it doesn't hurt and will be there if I need it in the future
            //
            try {
                newInterval = Convert.ToSingle(Convert.ToDouble(interval));
            } catch (Exception) {
            } finally {     }

            try {
                newJPGQuality = Convert.ToUInt16(JPGQuality);
            } catch (Exception) {
            } finally {     }


            try {
                newsecondsUntilImpact = Convert.ToUInt16(secondsUntilImpact);
            } catch (Exception) {
            } finally {     }
            try {
                newhsAltitudeLimit = Convert.ToUInt16(hsAltitudeLimit);
            } catch (Exception) {
            } finally {     }
            try {
                newhsMinVerticalSpeed = Convert.ToUInt16(hsMinVerticalSpeed);
            } catch (Exception) {
            } finally {     }
            try {
                newhsScreenshotInterval = Convert.ToSingle(Convert.ToDouble(hsScreenshotInterval));
            } catch (Exception) {
            } finally {     }

            try {
                newsupersize = Convert.ToUInt16(strsupersize);
                if (newsupersize < 0)
                {
                    newsupersize = 0;
                }
                if (newsupersize > AS.configuration.MAX_SUPERSIZE)
                {
                    newsupersize = AS.configuration.MAX_SUPERSIZE;
                }
            } catch (Exception) {
            } finally {     }

            try {
                newminBetweenSaves = Convert.ToUInt16(minBetweenSaves);
            } catch (Exception) {
            } finally {     }

            try {
                newnumToRotate = Convert.ToUInt16(numToRotate);
            } catch (Exception) {
            } finally {     }

            GUI.DragWindow();
        }
コード例 #7
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);
        }
コード例 #8
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();
        }
コード例 #9
0
        internal void drawWindow(int id)
        {
            if (PartCommander.Instance.settings.altSkin)
            {
                GUI.skin = PartCommander.Instance.modStyleUnity.skin;
            }
            else
            {
                GUI.skin = PartCommander.Instance.modStyle.skin;
            }
            GUILayout.BeginVertical();
            GUILayout.Label("Settings", modStyle.guiStyles["titleLabel"]);
            GUILayout.EndVertical();
            if (Event.current.type == EventType.Repaint)
            {
                dragRect = GUILayoutUtility.GetLastRect();
            }
            GUILayout.BeginVertical();
            scrollPos = GUILayout.BeginScrollView(scrollPos);

            GUILayout.BeginHorizontal();
            bool newHideUnAct = GUILayout.Toggle(settings.hideUnAct, "Hide unactionable parts", modStyle.guiStyles["toggleText"]);

            if (newHideUnAct != settings.hideUnAct)
            {
                PartCommander.Instance.updateParts = true;
                settings.hideUnAct = newHideUnAct;
                settings.Save();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();

            GUILayout.Label("Font Size:", modStyle.guiStyles["settingsLabel"]);
            bool fontChanged = false;

            GUILayout.FlexibleSpace();
            if (settings.fontSize <= 12)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("<", modStyle.guiStyles["settingsButton"]))
            {
                settings.fontSize--;
                fontChanged = true;
            }
            GUI.enabled = true;
            string s = GUILayout.TextField(settings.fontSize.ToString(), modStyle.guiStyles["settingsLabel"]);

            if (settings.fontSize >= 20)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button(">", modStyle.guiStyles["settingsButton"]))
            {
                settings.fontSize++;
                fontChanged = true;
            }
            GUI.enabled = true;
            if (fontChanged)
            {
                settings.Save();
                PartCommander.Instance.modStyle.UpdateFontSize(settings.fontSize);
                PartCommander.Instance.modStyleUnity.UpdateFontSize(settings.fontSize);
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();

            bool newAltSkin = GUILayout.Toggle(settings.altSkin, "Use alternate skin", modStyle.guiStyles["toggleText"]);

            if (newAltSkin != settings.altSkin)
            {
                settings.altSkin = newAltSkin;
                settings.Save();
                if (PartCommander.Instance.settings.altSkin)
                {
                    modStyle = PartCommander.Instance.modStyleUnity;
                    PartCommander.Instance.modStyle = PartCommander.Instance.modStyleUnity;
                }
                else
                {
                    modStyle = PartCommander.Instance.modStyleKSP;
                    PartCommander.Instance.modStyle = PartCommander.Instance.modStyle;
                }
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();

            bool newEnableHotKey = GUILayout.Toggle(settings.enableHotKey, "Enable hot key", modStyle.guiStyles["toggleText"]);

            if (newEnableHotKey != settings.enableHotKey)
            {
                settings.enableHotKey = newEnableHotKey;
                settings.Save();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.BeginHorizontal();

            if (settingHotKey)
            {
                GUILayout.Label("Type a new hot key...", modStyle.guiStyles["settingsLabel"]);
                if (Event.current.isKey)
                {
                    settings.hotKey = Event.current.keyCode;
                    settings.Save();
                    settingHotKey = false;
                }
            }
            else
            {
                if (settings.enableHotKey)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Mod + ");
                    if (GUILayout.Button(new GUIContent(settings.hotKey.ToString(), "Click to set new hot key"), modStyle.guiStyles["settingsButton"]))
                    {
                        settingHotKey = true;
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
            GUILayout.Space(25f);
            GUILayout.EndVertical();

            if (GUI.Button(new Rect(windowRect.width - 18, 3f, 15f, 15f), new GUIContent("", "Close"), modStyle.guiStyles["closeButton"]))
            {
                showWindow = false;
            }
            // Create resize button in bottom right corner
            if (GUI.RepeatButton(new Rect(windowRect.width - 23, windowRect.height - 23, 20, 20), "", modStyle.guiStyles["resizeButton"]))
            {
                resizingWindow = true;
            }
            GUI.DragWindow();
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
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();
        }