Exemplo n.º 1
0
        private void OnWindow(int windowID)
        {
            //Add some space
            GUILayout.BeginHorizontal();
            GUILayout.Label("");
            GUILayout.EndHorizontal();

            //Field to type in kerbal's name.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name:");
            stringToEdit = GUILayout.TextField(stringToEdit, 50);

            /*if (GUILayout.Button("Random"))
             * {
             *  getRandomKerbal = true;
             * }*/
            GUILayout.EndHorizontal();

            //Toggle female/male
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(gender))
            {
                male = !male;
            }
            if (GUILayout.Button(Trait))
            {
                if (traitInt < 2)
                {
                    traitInt += 1;
                }
                else
                {
                    traitInt = 0;
                }
            }
            GUILayout.EndHorizontal();

            //Sets kerbal's courage.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Courage:");
            sliderValue = GUILayout.HorizontalSlider(sliderValue, 0.0f, 1.0f);
            GUILayout.EndHorizontal();

            //Sets kerbal's stupidity.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Stupidity:");
            sliderValue2 = GUILayout.HorizontalSlider(sliderValue2, 0.0f, 1.0f);
            GUILayout.EndHorizontal();

            //Toggles BadS state.
            GUILayout.BeginHorizontal();
            buttonState = GUILayout.Toggle(buttonState, "BadS: " + buttonState);
            GUILayout.EndHorizontal();

            //Toggles Veteran state.
            GUILayout.BeginHorizontal();
            veteran = GUILayout.Toggle(veteran, "Veteran: " + veteran);
            GUILayout.EndHorizontal();

            //Toggles close on complete
            GUILayout.BeginHorizontal();
            closeOnComplete = GUILayout.Toggle(closeOnComplete, "Close On Complete: " + closeOnComplete);
            GUILayout.EndHorizontal();

            //Button to create the kerbal using above paramaters.
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Kreate Kustom Kerbal"))
            {
                if (stringToEdit == "My Kustom Kerbal" && sliderValue == 0.0f && sliderValue2 == 0.0f && buttonState == false && male == true && Trait == "Pilot")
                {
                    ProtoCrewMember kerbal = HighLogic.CurrentGame.CrewRoster.GetNewKerbal();
                    kerbal.rosterStatus = ProtoCrewMember.RosterStatus.Available;
                    ScreenMessages.PostScreenMessage("Random Kerbal Spawned.", 1, ScreenMessageStyle.UPPER_CENTER);
                    Debug.Log("Random Kerbal Spawned");
                    if (closeOnComplete)
                    {
                        ScreenMessages.PostScreenMessage("Closing window...", 1, ScreenMessageStyle.UPPER_CENTER);
                        windowState = false;
                    }
                }
                else
                {
                    Debug.Log("Kustom Kerbal Kreated.");
                    Debug.Log("KK window closed.");
                    SpawnKerbal(kerbal, false);
                }
            }
            if (GUILayout.Button("Close"))
            {
                appLauncherButton.SetFalse(true);
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Kraken Feeding"))
            {
                KrakenEnabled = !KrakenEnabled;
            }
            if (GUILayout.Button("Kerbal Editor"))
            {
                editorEnabled = !editorEnabled;
            }
            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }
Exemplo n.º 2
0
        private void OnWindow(int windowID)
        {
            GUILayout.ExpandWidth(true);
            GUILayout.ExpandHeight(true);
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            GUILayout.Label("G Tolerance Mult:", labelStyle);
            string newGToleranceMult = GUILayout.TextField(ReentryPhysics.gToleranceMult.ToString(), GUILayout.MinWidth(100));

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            GUILayout.Label("Crew G Max", labelStyle);
            string newcrewGClamp = GUILayout.TextField(ReentryPhysics.crewGClamp.ToString(), GUILayout.MinWidth(100));

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            GUILayout.Label("Crew G Exponent", labelStyle);
            string newcrewGPower = GUILayout.TextField(ReentryPhysics.crewGPower.ToString(), GUILayout.MinWidth(100));

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            GUILayout.Label("Crew G Min", labelStyle);
            string newcrewGMin = GUILayout.TextField(ReentryPhysics.crewGMin.ToString(), GUILayout.MinWidth(100));

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            GUILayout.Label("Crew G Warn Level", labelStyle);
            string newcrewGWarn = GUILayout.TextField(ReentryPhysics.crewGWarn.ToString(), GUILayout.MinWidth(100));

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            GUILayout.Label("Crew G Kill threshold", labelStyle);
            string newcrewGLimit = GUILayout.TextField(ReentryPhysics.crewGLimit.ToString(), GUILayout.MinWidth(100));

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            GUILayout.Label("Crew G Kill chance per update", labelStyle);
            string newcrewGKillChance = GUILayout.TextField(ReentryPhysics.crewGKillChance.ToString(), GUILayout.MinWidth(100));

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            DeadlyReentryScenario.displayCrewGForceWarning = GUILayout.Toggle(DeadlyReentryScenario.displayCrewGForceWarning, "Warn crew G forces are becoming dangerous!");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            GUILayout.Label(Localizer.Format("#autoLOC_189833", new string[] { (HighLogic.CurrentGame.Parameters.Difficulty.ReentryHeatScale * 100f).ToString("N0") }), labelStyle);
            //string mylabel = Localizer.Format("#autoLOC_189833", new string[] { (100f).ToString("N0")});

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Height(0);
            DeadlyReentryScenario.DREReentryHeatScale = GUILayout.HorizontalSlider(DeadlyReentryScenario.DREReentryHeatScale, 0, ReentryPhysics.maxHeatScale);
            GUILayout.EndHorizontal();

            GUILayout.Width(0);
            GUILayout.Height(0);
            GUILayout.Label("For other thermal settings, press F12 then select Physics->Thermals.", windowStyleCenter);
            GUILayout.Label(Rachel, windowStyleCenter);

            GUILayout.EndVertical();

            GUI.DragWindow();

            if (GUI.changed)
            {
                //print("GUI CHANGED!!!111oneone");
                float newValue;

                if (float.TryParse(newGToleranceMult, out newValue))
                {
                    ReentryPhysics.gToleranceMult = newValue;
                }

                if (float.TryParse(newcrewGClamp, out newValue))
                {
                    ReentryPhysics.crewGClamp = newValue;
                }

                if (float.TryParse(newcrewGPower, out newValue))
                {
                    ReentryPhysics.crewGPower = newValue;
                }

                if (float.TryParse(newcrewGMin, out newValue))
                {
                    ReentryPhysics.crewGMin = newValue;
                }
                if (float.TryParse(newcrewGWarn, out newValue))
                {
                    ReentryPhysics.crewGWarn = newValue;
                }
                if (float.TryParse(newcrewGLimit, out newValue))
                {
                    ReentryPhysics.crewGLimit = newValue;
                }
                if (float.TryParse(newcrewGKillChance, out newValue))
                {
                    ReentryPhysics.crewGKillChance = newValue;
                }
                DeadlyReentry.ReentryPhysics.SaveSettings();
                DeadlyReentry.ReentryPhysics.SaveCustomSettings();
                if (!DeadlyReentryScenario.displayCrewGForceWarning)
                {
                    ScreenMessages.RemoveMessage(ReentryPhysics.crewGWarningMsg);
                }
                HighLogic.CurrentGame.Parameters.Difficulty.ReentryHeatScale = DeadlyReentryScenario.DREReentryHeatScale;
            }
        }
Exemplo n.º 3
0
        static void DoWindow(int windowID)
        {
            timeScale = Time.timeScale;

            Event e = Event.current;

            GUI.backgroundColor = Color.green;
            GUI.enabled         = focused;

            if (GUI.Button(new Rect(180f, 4f, 20f, 6f), ""))
            {
                resetPosition = true;
                GUI.FocusControl(null);
            }

            GUI.enabled         = focused;
            GUI.backgroundColor = defaultBackgroundColor;

            GUILayout.BeginHorizontal();

            if (timeScale < 1)
            {
                contentTextStyle.normal.textColor = coldColor;
            }
            else if (timeScale > 1)
            {
                contentTextStyle.normal.textColor = hotColor;
            }

            GUI.SetNextControlName(LABEL_TIME_SCALE);
            timeScale = Mathf.Clamp(EditorGUILayout.FloatField(LABEL_TIME_SCALE, timeScale, contentTextStyle, GUILayout.MaxWidth(startWindowRect.size.x)), 0f, MAX_SCALE);

            contentTextStyle.normal.textColor = textColor;
            GUILayout.EndHorizontal();
            GUILayout.Space(horizontalSpace);

            GUI.enabled = focused;
            GUILayout.BeginHorizontal();
            GUI.enabled = timeScale > 0f && focused;
            GUI.SetNextControlName("decrease");
            if (GUILayout.Button(emptyContent, GUI.skin.horizontalScrollbarLeftButton))
            {
                timeScale -= 0.01f;
                GUI.FocusControl("decrease");
            }
            GUI.enabled = focused;

            GUI.SetNextControlName("slider");
            EditorGUI.BeginChangeCheck();
            timeScale = GUILayout.HorizontalSlider(timeScale, 0f, MAX_SCALE, GUI.skin.horizontalScrollbar, GUI.skin.horizontalScrollbarThumb);
            if (EditorGUI.EndChangeCheck())
            {
                if (timeScale > 1f)
                {
                    timeScale = Mathf.RoundToInt(timeScale);
                }
                else
                {
                    timeScale = Mathf.RoundToInt(timeScale * 10f) / 10f;
                }
            }

            GUI.enabled = timeScale < MAX_SCALE && focused;
            GUI.SetNextControlName("increase");
            if (GUILayout.Button(emptyContent, GUI.skin.horizontalScrollbarRightButton))
            {
                timeScale += 0.01f;
                GUI.FocusControl("increase");
            }
            GUI.enabled = focused;

            GUILayout.EndHorizontal();
            GUILayout.Space(horizontalSpace);

            GUIStyle buttonStyle = GUI.skin.button;

            buttonStyle.fontSize = 9;

            GUILayout.BeginHorizontal();
            GUI.enabled         = focused && (timeScale != 1f / 4f);
            GUI.backgroundColor = (GUI.enabled) ? coldColor : defaultBackgroundColor;
            GUI.SetNextControlName(BUTTON_NAME_BY_FOUR);
            if (GUILayout.Button(BUTTON_NAME_BY_FOUR, buttonStyle, GUILayout.MaxWidth(25f)))
            {
                timeScale = 1f / 4f;
                GUI.FocusControl(BUTTON_NAME_BY_FOUR);
            }
            GUI.enabled         = focused && (timeScale != 1f / 2f);
            GUI.backgroundColor = (GUI.enabled) ? coldColor : defaultBackgroundColor;
            GUI.SetNextControlName(BUTTON_NAME_BY_TWO);
            if (GUILayout.Button(BUTTON_NAME_BY_TWO, buttonStyle, GUILayout.MaxWidth(25f)))
            {
                timeScale = 1f / 2f;
                GUI.FocusControl(BUTTON_NAME_BY_TWO);
            }

            if (timeScale == 1f)
            {
                GUI.backgroundColor = defaultBackgroundColor;
            }
            else if (timeScale < 1f)
            {
                GUI.backgroundColor = coldColor;
            }
            else if (timeScale > 1f)
            {
                GUI.backgroundColor = hotColor;
            }

            GUI.enabled = focused && (timeScale != 1f);

            GUI.SetNextControlName(BUTTON_NAME_RESET);
            if (GUILayout.Button(BUTTON_NAME_RESET, buttonStyle))
            {
                timeScale = 1f;
                GUI.FocusControl(BUTTON_NAME_RESET);
            }

            GUI.enabled         = focused && (timeScale != 1f * 2f);
            GUI.backgroundColor = (GUI.enabled) ? hotColor : defaultBackgroundColor;
            GUI.SetNextControlName(BUTTON_NAME_TIMES_TWO);
            if (GUILayout.Button(BUTTON_NAME_TIMES_TWO, buttonStyle, GUILayout.MaxWidth(25f)))
            {
                timeScale = 1f * 2f;
                GUI.FocusControl(BUTTON_NAME_TIMES_TWO);
            }
            GUI.enabled         = focused && (timeScale != 1f * 4f);
            GUI.backgroundColor = (GUI.enabled) ? hotColor : defaultBackgroundColor;
            GUI.SetNextControlName(BUTTON_NAME_TIMES_FOUR);
            if (GUILayout.Button(BUTTON_NAME_TIMES_FOUR, buttonStyle, GUILayout.MaxWidth(25f)))
            {
                timeScale = 1f * 4f;
                GUI.FocusControl(BUTTON_NAME_TIMES_FOUR);
            }
            GUILayout.EndHorizontal();

            GUI.enabled         = focused;
            GUI.backgroundColor = defaultBackgroundColor;

            if (GUI.changed)
            {
                Time.timeScale = Mathf.Min(Mathf.RoundToInt(timeScale * 100f) / 100f, MAX_SCALE);
            }

            // Make the window drag
            Vector2 dragSize = new Vector2(startWindowRect.size.x, windowTitleHeight);

            if (e.type == EventType.MouseDrag)
            {
                isDragging = true;
            }
            // Mouse is released when dragging either inside (mouse up event) the window area or outside (ignore event)
            if (isDragging && (e.type == EventType.MouseUp || e.type == EventType.Ignore))
            {
                isDragging      = false;
                positionChanged = true;
                e.Use();
            }
            GUI.DragWindow(new Rect(Vector2.zero, dragSize)); // this will eat the mouseDrag event

            // Preventing click through by use all the mouse event
            if (e.isMouse)
            {
                e.Use();
            }
        }
Exemplo n.º 4
0
        private void AdvancedTab()
        {
            PlanetShine.renderEnabled = GUILayout.Toggle(PlanetShine.renderEnabled, "Planetshine global ON/OFF");
            if (config.blizzyToolbarInstalled)
            {
                bool stockToolbarEnabledOldValue = config.stockToolbarEnabled;
                config.stockToolbarEnabled = GUILayout.Toggle(config.stockToolbarEnabled, "Use stock toolbar");
                if (config.stockToolbarEnabled != stockToolbarEnabledOldValue)
                {
                    guiManager.UpdateToolbarStock();
                }
            }

            GUILayout.Space(15);


            GUI.contentColor = new Color(0.8f, 1.0f, 0.8f);
            GUILayout.Label("Planetshine fade altitude: " + config.minAlbedoFadeAltitude + " to " + config.maxAlbedoFadeAltitude);
            GUILayout.Label("(from " + Math.Round(config.minAlbedoFadeAltitude * planetShine.bodyRadius / 1000f) +
                            "km to " + Math.Round(config.maxAlbedoFadeAltitude * planetShine.bodyRadius / 1000f) +
                            "km on " + planetShine.body.name + ")");
            GUI.contentColor = originalTextColor;
            GUILayout.BeginHorizontal();
            GUILayout.Label("Min", GUILayout.Width(50));
            config.minAlbedoFadeAltitude = (float)Math.Round(GUILayout.HorizontalSlider(config.minAlbedoFadeAltitude, 0.0f,
                                                                                        config.maxAlbedoFadeAltitude), 2);
            ResetButton(ref config.minAlbedoFadeAltitude, ConfigDefaults.minAlbedoFadeAltitude);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Max", GUILayout.Width(50));
            config.maxAlbedoFadeAltitude = (float)Math.Round(GUILayout.HorizontalSlider(config.maxAlbedoFadeAltitude,
                                                                                        config.minAlbedoFadeAltitude, 0.10f), 2);
            ResetButton(ref config.maxAlbedoFadeAltitude, ConfigDefaults.maxAlbedoFadeAltitude);
            GUILayout.EndHorizontal();

            GUILayout.Space(15);

            GUI.contentColor = new Color(0.8f, 1.0f, 0.8f);
            GUILayout.Label("Ground ambient fade altitude: " + config.minAmbientFadeAltitude + " to " + config.maxAmbientFadeAltitude);
            GUILayout.Label("(from " + Math.Round(config.minAmbientFadeAltitude * planetShine.bodyRadius / 1000f) +
                            "km to " + Math.Round(config.maxAmbientFadeAltitude * planetShine.bodyRadius / 1000f) +
                            "km on " + planetShine.body.name + ")");
            GUI.contentColor = originalTextColor;
            GUILayout.BeginHorizontal();
            GUILayout.Label("Min", GUILayout.Width(50));
            config.minAmbientFadeAltitude = (float)Math.Round(GUILayout.HorizontalSlider(config.minAmbientFadeAltitude, 0.0f,
                                                                                         config.maxAmbientFadeAltitude), 2);
            ResetButton(ref config.minAmbientFadeAltitude, ConfigDefaults.minAmbientFadeAltitude);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Max", GUILayout.Width(50));
            config.maxAmbientFadeAltitude = (float)Math.Round(GUILayout.HorizontalSlider(config.maxAmbientFadeAltitude,
                                                                                         config.minAmbientFadeAltitude, 0.10f), 2);
            ResetButton(ref config.maxAmbientFadeAltitude, ConfigDefaults.maxAmbientFadeAltitude);
            GUILayout.EndHorizontal();


            GUILayout.Space(30);

            GUI.contentColor = new Color(1.0f, 0.7f, 0.6f);
            config.debug     = GUILayout.Toggle(config.debug, "Debug mode");
            GUI.contentColor = originalTextColor;
        }
        public void DoWindow(int window)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUI.Button(new Rect(windowRect.width - 24, 4, 20, 20), "X"))
            //if (GUILayout.Button("X", GUILayout.Height(16)))
            {
                shouldBeDestroyed = true;
                return;
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Use stock skin");
            AdvancedFlyByWire.Instance.settings.m_UseKSPSkin = GUILayout.Toggle(AdvancedFlyByWire.Instance.settings.m_UseKSPSkin, "");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Use old presets editor");
            AdvancedFlyByWire.Instance.settings.m_UseOldPresetsWindow = GUILayout.Toggle(AdvancedFlyByWire.Instance.settings.m_UseOldPresetsWindow, "");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("PrecisionMode Factor");
            AdvancedFlyByWire.Instance.settings.m_UsePrecisionModeFactor = GUILayout.Toggle(AdvancedFlyByWire.Instance.settings.m_UsePrecisionModeFactor, "");
            GUILayout.FlexibleSpace();
            GUILayout.Label(AdvancedFlyByWire.Instance.settings.m_PrecisionModeFactor.ToString("0.000"));
            AdvancedFlyByWire.Instance.settings.m_PrecisionModeFactor = GUILayout.HorizontalSlider(AdvancedFlyByWire.Instance.settings.m_PrecisionModeFactor, 0.0f, 1.0f, GUILayout.Width(150));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("AFBW input overrides SAS and other control inputs");
            AdvancedFlyByWire.Instance.settings.m_IgnoreFlightCtrlState = GUILayout.Toggle(AdvancedFlyByWire.Instance.settings.m_IgnoreFlightCtrlState, "");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("AFBW input overrides throttle");
            AdvancedFlyByWire.Instance.settings.m_ThrottleOverride = GUILayout.Toggle(AdvancedFlyByWire.Instance.settings.m_ThrottleOverride, "");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("AtmosphereAutopilot compatibility");
            AdvancedFlyByWire.Instance.settings.m_UseOnPreInsteadOfOnFlyByWire = GUILayout.Toggle(AdvancedFlyByWire.Instance.settings.m_UseOnPreInsteadOfOnFlyByWire, "");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("Run at max speed always (even when not going forward)");
            AdvancedFlyByWire.Instance.settings.m_MaxMoveSpeedAlways = GUILayout.Toggle(AdvancedFlyByWire.Instance.settings.m_MaxMoveSpeedAlways, "");
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Save configuration"))
            {
                AdvancedFlyByWire.Instance.SaveState(null);
                shouldBeDestroyed = true;
            }
            GUILayout.EndHorizontal();
            GUI.DragWindow();
        }
Exemplo n.º 6
0
        //Draw the advanced settings window
        private void OnAdvanced(int WindowID)
        {
            //Radar Altimeter Settings
            GUILayout.Label("Radar Altimeter Settings", _boldStyle, GUILayout.Width(500));  //Hopefully set the width of the window betterer
            GUILayout.BeginHorizontal();
            GUILayout.Label("Altitude Lights: G, Y, R", GUILayout.Width(200));
            radarAltimeter.setGreen(int.Parse(GUILayout.TextField(radarAltimeter.getGreenLight().ToString())));
            radarAltimeter.setYellow(int.Parse(GUILayout.TextField(radarAltimeter.getYellowLight().ToString())));
            radarAltimeter.setRed(int.Parse(GUILayout.TextField(radarAltimeter.getRedLight().ToString())));
            GUILayout.Label("Calibration (meters):", GUILayout.Width(200));
            radarAltimeter.calibration = int.Parse(GUILayout.TextField(radarAltimeter.calibration.ToString(), GUILayout.Width(100)));
            GUILayout.Label("Cutoff Alt: ", GUILayout.Width(150));
            radarAltimeter.contact_alt = int.Parse(GUILayout.TextField(radarAltimeter.contact_alt.ToString(), GUILayout.Width(100)));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Scale", GUILayout.Width(50));            //It would be nice to make this dynamic
            radarAltimeter.setScale(GUILayout.HorizontalSlider(radarAltimeter.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            int s = (int)(radarAltimeter.getScale() * 100);           //0.5 to 50

            GUILayout.Label(s.ToString() + '%', GUILayout.Width(50)); //Show, but don't allow editing of scale value
            GUILayout.EndHorizontal();
            //Compass/Electrical/Temp
            GUILayout.BeginHorizontal();
            GUILayout.Label("Magnetic Compass Settings", _boldStyle, GUILayout.Width(300));
            GUILayout.Label("Electrical Gauge Settings", _boldStyle, GUILayout.Width(300));
            GUILayout.Label("Temperature Gauge Settings", _boldStyle, GUILayout.Width(300));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Scale", GUILayout.Width(50));
            s = (int)(compassGauge.getScale() * 100);
            compassGauge.setScale(GUILayout.HorizontalSlider(compassGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(50));    //Show, but don't allow editing of scale value
            GUILayout.Label("Scale", GUILayout.Width(50));
            electricalGauge.setScale(GUILayout.HorizontalSlider(electricalGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            s = (int)(electricalGauge.getScale() * 100);
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(50));    //Show, but don't allow editing of scale value
            GUILayout.Label("Scale", GUILayout.Width(50));
            tempGauge.setScale(GUILayout.HorizontalSlider(tempGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            s = (int)(tempGauge.getScale() * 100);
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(50));    //Show, but don't allow editing of scale value
            GUILayout.EndHorizontal();
            //Fuel Gauge
            GUILayout.Label("Fuel Gauge Settings", _boldStyle);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Fuel Lights: R, Y, G", GUILayout.Width(200));
            fuelGauge.setFuelRed(float.Parse(GUILayout.TextField(fuelGauge.getFuelRed().ToString())));
            fuelGauge.setFuelYellow(float.Parse(GUILayout.TextField(fuelGauge.getFuelYellow().ToString())));
            fuelGauge.setFuelGreen(float.Parse(GUILayout.TextField(fuelGauge.getFuelGreen().ToString())));
            GUILayout.Label("Mono Lights: R, Y, G", GUILayout.Width(200));
            fuelGauge.setMonoRed(float.Parse(GUILayout.TextField(fuelGauge.getMonoRed().ToString())));
            fuelGauge.setMonoYellow(float.Parse(GUILayout.TextField(fuelGauge.getMonoYellow().ToString())));
            fuelGauge.setMonoGreen(float.Parse(GUILayout.TextField(fuelGauge.getMonoGreen().ToString())));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Scale", GUILayout.Width(50));
            fuelGauge.setScale(GUILayout.HorizontalSlider(fuelGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            s = (int)(fuelGauge.getScale() * 100);
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(50));    //Show, but don't allow editing of scale value
            GUILayout.EndHorizontal();
            //Orbital Gauge
            GUILayout.Label("Orbital Gauge Settings", _boldStyle);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Safe Altitude", GUILayout.Width(200));
            orbitGauge.setGreenAlt(double.Parse(GUILayout.TextField(orbitGauge.getGreenAlt().ToString(), GUILayout.Width(100))));
            GUILayout.Label("Circularization Threshold", GUILayout.Width(200));
            orbitGauge.setCircleThresh(double.Parse(GUILayout.TextField(orbitGauge.getCircleThresh().ToString(), GUILayout.Width(100))));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Burn Window", GUILayout.Width(200));
            orbitGauge.setBurnWindow(int.Parse(GUILayout.TextField(orbitGauge.getBurnWindow().ToString(), GUILayout.Width(100))));
            GUILayout.Label("Scale", GUILayout.Width(50));
            orbitGauge.setScale(GUILayout.HorizontalSlider(orbitGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            s = (int)(orbitGauge.getScale() * 100);
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(50));    //Show, but don't allow editing of scale value
            String text = "Negative Pe";

            if (!orbitGauge.showNegativePe)
            {
                text = "Zero Pe";
            }
            if (GUILayout.Button(text, _buttonStyle, GUILayout.Width(100)))
            {
                orbitGauge.showNegativePe = !orbitGauge.showNegativePe;
            }
            GUILayout.EndHorizontal();
            //RZ Gauge
            GUILayout.Label("Rendezvous Gauge Settings", _boldStyle);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Distance Lights: R, Y, G", GUILayout.Width(200));
            rzGauge.setRed(int.Parse(GUILayout.TextField(rzGauge.getRed().ToString())));
            rzGauge.setYellow(int.Parse(GUILayout.TextField(rzGauge.getYellow().ToString())));
            rzGauge.setGreen(int.Parse(GUILayout.TextField(rzGauge.getGreen().ToString())));
            GUILayout.Label("Scale", GUILayout.Width(50));
            rzGauge.setScale(GUILayout.HorizontalSlider(rzGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            s = (int)(rzGauge.getScale() * 100);
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(50));    //Show, but don't allow editing of scale value
            GUILayout.EndHorizontal();
            //Node Gauge
            GUILayout.Label("Maneuver Node Gauge Settings", _boldStyle);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Throttle Delay");
            nodeGauge.setThrottleDelay(int.Parse(GUILayout.TextField(nodeGauge.getThrottleDelay().ToString(), GUILayout.Width(100))));
            nodeGauge.setUseCalcBurn(GUILayout.Toggle(nodeGauge.getUseCalcBurn(), "Use Calculated Burn Time", _toggleStyle, GUILayout.Width(300)));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Scale", GUILayout.Width(50));
            nodeGauge.setScale(GUILayout.HorizontalSlider(nodeGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            s = (int)(nodeGauge.getScale() * 100);
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(50));
            GUILayout.EndHorizontal();
            //Air Gauge/Nav Gauge
            GUILayout.BeginHorizontal();
            GUILayout.Label("Air Gauge Settings", _boldStyle, GUILayout.Width(400));
            GUILayout.Label("Nav Gauge Settings", _boldStyle);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Scale", GUILayout.Width(50));
            airGauge.setScale(GUILayout.HorizontalSlider(airGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            s = (int)(airGauge.getScale() * 100);
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(35));
            GUILayout.Label("Stall AoA", GUILayout.Width(100));
            airGauge.criticalAOA = (int.Parse(GUILayout.TextField(airGauge.criticalAOA.ToString(), GUILayout.Width(25))));
            GUILayout.Label("Scale", GUILayout.Width(50));
            navGauge.setScale(GUILayout.HorizontalSlider(navGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            s = (int)(navGauge.getScale() * 100);
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(35));
            GUILayout.EndHorizontal();
            //HUD Gauge
            GUILayout.Label("HUD Settings", _boldStyle);
            //HUD color
            GUILayout.BeginHorizontal();
            Color tmp = GUI.color;

            GUI.color = new Color((float)hudGauge.Red / 255f, (float)hudGauge.Green / 255f, (float)hudGauge.Blue / 255f);
            GUILayout.Label("HUD Color: ", GUILayout.Width(75), GUILayout.Height(40));
            GUI.color = tmp;
            GUILayout.Label("     Red", GUILayout.Width(50), GUILayout.Height(40));
            hudGauge.Red = (int)GUILayout.HorizontalSlider(hudGauge.Red, 0, 255, GUILayout.Width(100), GUILayout.Height(40));
            GUILayout.Label("   Green", GUILayout.Width(50), GUILayout.Height(40));
            hudGauge.Green = (int)GUILayout.HorizontalSlider(hudGauge.Green, 0, 255, GUILayout.Width(100), GUILayout.Height(40));
            GUILayout.Label("     Blue", GUILayout.Width(50), GUILayout.Height(40));
            hudGauge.Blue = (int)GUILayout.HorizontalSlider(hudGauge.Blue, 0, 255, GUILayout.Width(100), GUILayout.Height(40));
            GUILayout.EndHorizontal();
            if (GUILayout.Button("Use High Contrast Color in HUD"))
            {
                hudGauge.color_center = !hudGauge.color_center;
            }
            //HUD Inverse color
            GUILayout.BeginHorizontal();
            tmp = GUI.color;
            if (hudGauge.color_center)
            {
                GUI.color = new Color((float)hudGauge.cRed / 255f, (float)hudGauge.cGreen / 255f, (float)hudGauge.cBlue / 255f);
            }
            else
            {
                GUI.enabled = false;
            }
            GUILayout.Label("HUD Contrast Color: ", GUILayout.Width(75), GUILayout.Height(40));
            GUI.color = tmp;
            GUILayout.Label("     Red", GUILayout.Width(50), GUILayout.Height(40));
            hudGauge.cRed = (int)GUILayout.HorizontalSlider(hudGauge.cRed, 0, 255, GUILayout.Width(100), GUILayout.Height(40));
            GUILayout.Label("   Green", GUILayout.Width(50), GUILayout.Height(40));
            hudGauge.cGreen = (int)GUILayout.HorizontalSlider(hudGauge.cGreen, 0, 255, GUILayout.Width(100), GUILayout.Height(40));
            GUILayout.Label("     Blue", GUILayout.Width(50), GUILayout.Height(40));
            hudGauge.cBlue = (int)GUILayout.HorizontalSlider(hudGauge.cBlue, 0, 255, GUILayout.Width(100), GUILayout.Height(40));
            GUI.enabled    = true;
            GUILayout.EndHorizontal();
            int selected = -1;

            selected = GUILayout.SelectionGrid(selected, buttonNames, 4, _buttonStyle, GUILayout.Width(600));
            switch (selected)
            {
            case 0:
                //Orbital toggle
                hudGauge.drawOrbital = !hudGauge.drawOrbital;
                break;

            case 1:
                //Throttle toggle
                hudGauge.drawThrottle = !hudGauge.drawThrottle;
                break;

            case 2:
                //Indicator Toggle
                hudGauge.drawIndicators = !hudGauge.drawIndicators;
                break;

            case 3:
                //Target Info
                hudGauge.drawTargetInfo = !hudGauge.drawTargetInfo;
                break;

            case 4:
                //Node Info
                hudGauge.drawNodeInfo = !hudGauge.drawNodeInfo;
                break;

            case 5:
                //Rotate Pitch Ladder
                hudGauge.rotatePitch = !hudGauge.rotatePitch;
                break;

            case 6:
                //Draw speed/alt
                hudGauge.drawSpdAlt = !hudGauge.drawSpdAlt;
                break;

            case 7:
                //GPWS
                hudGauge.useGPWS = !hudGauge.useGPWS;
                break;

            case 8:
                //Center HUD
                hudGauge.centerWindow();
                break;

            case 9:
                //Toggle Oribtal mode
                hudGauge.orbitalMode = !hudGauge.orbitalMode;
                break;

            case 10:
                //Toggle Warning flags
                hudGauge.drawWarnings = !hudGauge.drawWarnings;
                break;

            case 11:
                //Toggle EAS/TAS
                hudGauge.useEAS = !hudGauge.useEAS;
                break;

            default:
                break;
            }
            if (hudGauge.drawOrbital)
            {
                buttonNames[0] = "Orbital Info Off";
            }
            else
            {
                buttonNames[0] = "Orbital Info On";
            }
            if (hudGauge.drawThrottle)
            {
                buttonNames[1] = "Throttle Off";
            }
            else
            {
                buttonNames[1] = "Throttle On";
            }
            if (hudGauge.drawIndicators)
            {
                buttonNames[2] = "Indicators Off";
            }
            else
            {
                buttonNames[2] = "Indicators On";
            }
            if (hudGauge.drawTargetInfo)
            {
                buttonNames[3] = "Target Info Off";
            }
            else
            {
                buttonNames[3] = "Target Info On";
            }
            if (hudGauge.drawNodeInfo)
            {
                buttonNames[4] = "Node Info Off";
            }
            else
            {
                buttonNames[4] = "Node Info On";
            }
            if (hudGauge.rotatePitch)
            {
                buttonNames[5] = "Rotate Pitch Off";
            }
            else
            {
                buttonNames[5] = "Rotate Pitch On";
            }
            if (hudGauge.drawSpdAlt)
            {
                buttonNames[6] = "Central Spd/Alt Off";
            }
            else
            {
                buttonNames[6] = "Central Spd/Alt On";
            }
            if (hudGauge.useGPWS)
            {
                buttonNames[7] = "GPWS Off";
            }
            else
            {
                buttonNames[7] = "GPWS On";
            }
            //Center HUD botton doesn't change when you click on it.
            if (hudGauge.orbitalMode)
            {
                buttonNames[9] = "Oribital Mode Off";
            }
            else
            {
                buttonNames[9] = "Orbital Mode On";
            }
            if (hudGauge.drawWarnings)
            {
                buttonNames[10] = "Warnings Off";
            }
            else
            {
                buttonNames[10] = "Warnings On";
            }
            buttonNames[11] = hudGauge.useEAS ? "Use TAS" : "Use EAS";
            GUILayout.BeginHorizontal();
            //IVA Only
            hudGauge.ivaOnly = GUILayout.Toggle(hudGauge.ivaOnly, "IVA Only", _toggleStyle, GUILayout.Width(150));
            //Mouse Input
            hudGauge.mouseInput = GUILayout.Toggle(hudGauge.mouseInput, "Mouse Input", _toggleStyle, GUILayout.Width(150));
            GUI.enabled         = hudGauge.mouseInput;
            hudGauge.planeMode  = GUILayout.Toggle(hudGauge.planeMode, hudGauge.planeMode ? "Plane" : "Rocket", _buttonStyle, GUILayout.Width(150));
            GUI.enabled         = true; //hmm
            GUILayout.Label("HUD Key:");
            String key = "";

            foreach (KeyCode code in hudGauge.hudKeys)
            {
                key = key + code.ToString() + " ";
            }
            GUILayout.TextArea(key);

            /*if (GUILayout.Button("Assign Key", _buttonStyle, GUILayout.Width(100)))
             * {
             *  //This is terrible right now, you pretty much have to hold down the key, then press the button.
             *  if (Input.anyKey)
             *  {
             *      key = Input.inputString;
             *      if (Event.current.shift)
             *          key = key + " shift";
             *      if (Event.current.alt)
             *          key = key + " alt";
             *      if (Event.current.control)
             *          key = key + " ctrl";
             *      Debug.Log("Found keys: " + key);
             *  }
             * } */
            GUILayout.EndHorizontal();
            //Scale
            GUILayout.BeginHorizontal();
            GUILayout.Label("Scale", GUILayout.Width(50));
            hudGauge.setScale(GUILayout.HorizontalSlider(hudGauge.getScale(), 0.12f, 1f, GUILayout.Width(150)));
            s = (int)(hudGauge.getScale() * 100);
            GUILayout.Label(s.ToString() + '%', GUILayout.Width(50));
            GUILayout.EndHorizontal();
            if (_allToolbar)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Transparencey:", _labelStyle, GUILayout.Width(130));
                Alpha = GUILayout.HorizontalSlider(Alpha, 0.1f, 1f, GUILayout.Width(130));
                //Update red for alpha
                Red = new Color(1, 0, 0, Alpha);
                GUILayout.Label("HUD opacity:", _labelStyle, GUILayout.Width(130));
                hudGauge.Alpha = (int)GUILayout.HorizontalSlider(hudGauge.Alpha, 1f, 255f, GUILayout.Width(130));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                drawBezels = GUILayout.Toggle(drawBezels, "Draw Large Bezels", _toggleStyle, GUILayout.Width(250));
                windowLock = GUILayout.Toggle(windowLock, "Lock Gauge Posistions", _toggleStyle, GUILayout.Width(250));
                GUILayout.EndHorizontal();
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Close", _buttonStyle))
            {
                advMinimized = true;
            }
            String capt = "Use Toolbar for gauge toggle";

            if (_allToolbar == true)
            {
                capt = "Use window for gauge toggle";
            }
            if (GUILayout.Button(capt, _buttonStyle))
            {
                toolbarToggle();
            }
            GUILayout.EndHorizontal();
            if (GUI.changed)
            {
                SaveMe();
            }
            //Make it dragable
            GUI.DragWindow();
        }
Exemplo n.º 7
0
    private void Draw()
    {
        Vector3    startPoint        = circlePath.Evaluate(0f);
        Vector3    endPoint          = circlePath.Evaluate(1f);
        CirclePath reducedCirclePath = new CirclePath(
            circlePath.LocalSpaceTransform,
            new Circle(circlePath.LocalCircle.Center, circlePath.LocalCircle.Radius),
            circlePath.MaxAngle % Circle.TwoPI // remove loops
            );

        if (circlePath.MaxAngle >= Circle.TwoPI) // add back a single loop if it loops
        {
            reducedCirclePath.MaxAngle += Circle.TwoPI;
        }
        else if (Mathf.Abs(circlePath.MaxAngle) >= Circle.TwoPI) // if negative maxAngle and is still at least one loop
        {
            reducedCirclePath.MaxAngle -= Circle.TwoPI;
        }

        // draw circle
        var cPointCache = new EvaluationCache(reducedCirclePath, 128).Values;

        /*Handles.color = Color.yellow;
         * Handles.DrawAAPolyLine(cPointCache);
         */
        for (int i = 0; i < cPointCache.Length - 1; i++)
        {
            Handles.color = Color.Lerp(Color.yellow, Color.magenta, (float)i / cPointCache.Length);
            var lineSegment = new Vector3[2];
            lineSegment[0] = cPointCache[i];
            lineSegment[1] = cPointCache[i + 1];
            Handles.DrawAAPolyLine(lineSegment);
        }

        // draw direction cone cap
        if (!settings.HideDirectionCones &&
            circlePath.LocalSpaceTransform.lossyScale != Vector3.zero &&
            circlePath.LocalCircle.Radius != 0f &&
            Mathf.Abs(reducedCirclePath.MaxAngle * Mathf.Rad2Deg) > 10.0f)    // also hide cones if virtually a dot
        {
            float startConeSize = PathEditorUtility.Nice3DHandleSize(startPoint);
            float endConeSize   = PathEditorUtility.Nice3DHandleSize(endPoint);

            Handles.color = Color.yellow;
            Handles.ConeCap(0, startPoint, Quaternion.LookRotation(circlePath.Tangent(0f)), startConeSize);
            Handles.color = Color.magenta;
            Handles.ConeCap(0, endPoint, Quaternion.LookRotation(circlePath.Tangent(1f)), endConeSize);
        }

        // test t
        if (settings.TestInterpolate)
        {
            PathEditorUtility.DrawTestInterpolate(circlePath, settings.EditorData.T);
        }

        #region Scene View GUI

        Handles.BeginGUI(); //Note: GUILayout.BeginArea() deprecates Handles, however it behaves incorrectly (debug lines offset)
        {
            GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
            {
                GUILayout.Space(20.0f);
                targetScript.EditorOnlyToolSettings.TestInterpolate
                    = GUILayout.Toggle(targetScript.EditorOnlyToolSettings.TestInterpolate, "Test Interpolate", GUILayout.ExpandWidth(false));
                if (targetScript.EditorOnlyToolSettings.TestInterpolate)
                {
                    settings.EditorData.T
                        = GUILayout.HorizontalSlider(settings.EditorData.T, 0f, 1.0f, GUILayout.Width(100.0f));
                    GUILayout.Label(settings.EditorData.T.ToString(), GUILayout.Width(75.0f));
                    GUILayout.Label("Custom: ", GUILayout.Width(60.0f));
                    settings.EditorData.CustomT
                        = GUILayout.TextField(settings.EditorData.CustomT, GUILayout.Width(100.0f));
                    if (Event.current.keyCode == KeyCode.Return)
                    {
                        float tempT;
                        if (System.Single.TryParse(settings.EditorData.CustomT, out tempT))
                        {
                            settings.EditorData.T = tempT;
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
        }

        Handles.EndGUI();

        #endregion Scene View GUI

        ToolShelf();
    }
Exemplo n.º 8
0
    public override void OnInspectorGUI()
    {
        MapIO script = (MapIO)target;

        GUILayout.Label("Load Map", EditorStyles.boldLabel);
        if (GUILayout.Button("Import .map file"))
        {
            loadFile = UnityEditor.EditorUtility.OpenFilePanel("Import Map File", loadFile, "map");

            var blob = new WorldSerialization();
            Debug.Log("Importing map " + loadFile);
            blob.Load(loadFile);
            script.Load(blob);
        }

        GUILayout.Label("Save Map", EditorStyles.boldLabel);
        if (GUILayout.Button("Export .map file"))
        {
            saveFile = UnityEditor.EditorUtility.SaveFilePanel("Export Map File", saveFile, mapName, "map");
            Debug.Log("Exported map " + saveFile);
            script.Save(saveFile);
        }

/*
 *      GUILayout.Label("Select Bundle file", EditorStyles.boldLabel);
 *
 *      bundleFile = GUILayout.TextField(bundleFile);
 *      if (GUILayout.Button("Select Bundle file (Rust\\Bundles\\Bundles)"))
 *      {
 *          bundleFile = UnityEditor.EditorUtility.OpenFilePanel("Select Bundle file (Rust\\Bundles\\Bundles)", bundleFile, "map");
 *      }
 */

        GUILayout.Label("Land Option", EditorStyles.boldLabel);

        GUILayout.Label("Land Heightmap Offset");
        script.offset = float.Parse(GUILayout.TextField(script.offset + ""));
        script.offset = GUILayout.HorizontalSlider(script.offset, -500, 500);
        if (GUILayout.Button("Offset Map"))
        {
            script.offsetHeightmap();
            script.offset = 0;
        }

        /*
         * if (GUILayout.Button("Rotate CW"))
         * {
         *  script.rotateHeightmap(true);
         * }
         * if (GUILayout.Button("Rotate CCW"))
         * {
         *  script.rotateHeightmap(false);
         * }
         *
         * if (GUILayout.Button("Flip Heightmap"))
         * {
         *  script.flipHeightmap();
         * }
         * if (GUILayout.Button("Transpose Heightmap"))
         * {
         *  script.transposeHeightmap();
         * }
         *
         */
        string oldLandLayer = script.landLayer;

        string[] options = { "Ground", "Biome", "Alpha", "Topology" };
        script.landSelectIndex = EditorGUILayout.Popup("Select Land Layer:", script.landSelectIndex, options);
        script.landLayer       = options[script.landSelectIndex];
        if (script.landLayer != oldLandLayer)
        {
            script.changeLandLayer();
            Repaint();
        }
        if (script.landLayer.Equals("Topology"))
        {
            GUILayout.Label("Topology Option", EditorStyles.boldLabel);
            script.oldTopologyLayer = script.topologyLayer;
            script.topologyLayer    = (TerrainTopology.Enum)EditorGUILayout.EnumPopup("Select Topology Layer:", script.topologyLayer);
            if (script.topologyLayer != script.oldTopologyLayer)
            {
                //script.saveTopologyLayer();
                script.changeLandLayer();
                Repaint();
            }
        }
    }
Exemplo n.º 9
0
    private void DrawCustomAttributes(VideoGlitchBase imageEffect)
    {
        PropertyInfo[] properties = imageEffect.GetType().GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.DeclaredOnly);
        if (properties.Length > 0)
        {
            for (int i = 0; i < properties.Length; ++i)
            {
                object[] rangeAtts = properties[i].GetCustomAttributes(typeof(EnumAttribute), false);
                if (rangeAtts.Length > 0)
                {
                    EnumAttribute attb = rangeAtts[0] as EnumAttribute;
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(@" " + properties[i].GetGetMethod().Name.Replace(@"get_", string.Empty), GUILayout.Width(125));

                        int value = (int)properties[i].GetValue(imageEffect, null);
                        for (int j = 0; j < attb.enumNames.Count; ++j)
                        {
                            if (GUILayout.Button(attb.enumNames[j]) == true)
                            {
                                value = j;

                                break;
                            }
                        }

                        properties[i].SetValue(imageEffect, value, null);
                    }
                    GUILayout.EndHorizontal();
                }

                rangeAtts = properties[i].GetCustomAttributes(typeof(RangeIntAttribute), false);
                if (rangeAtts.Length > 0)
                {
                    RangeIntAttribute attb = rangeAtts[0] as RangeIntAttribute;
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(@" " + properties[i].GetGetMethod().Name.Replace(@"get_", string.Empty), GUILayout.Width(125));

                        int value = (int)GUILayout.HorizontalSlider((int)properties[i].GetValue(imageEffect, null), attb.min, attb.max, GUILayout.ExpandWidth(true));
                        properties[i].SetValue(imageEffect, value, null);
                    }
                    GUILayout.EndHorizontal();
                }

                rangeAtts = properties[i].GetCustomAttributes(typeof(RangeFloatAttribute), false);
                if (rangeAtts.Length > 0)
                {
                    RangeFloatAttribute attb = rangeAtts[0] as RangeFloatAttribute;
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(@" " + properties[i].GetGetMethod().Name.Replace(@"get_", string.Empty), GUILayout.Width(125));

                        float value = GUILayout.HorizontalSlider((float)properties[i].GetValue(imageEffect, null), attb.min, attb.max, GUILayout.ExpandWidth(true));
                        properties[i].SetValue(imageEffect, value, null);
                    }
                    GUILayout.EndHorizontal();
                }

                rangeAtts = properties[i].GetCustomAttributes(typeof(RangeVector2Attribute), false);
                if (rangeAtts.Length > 0)
                {
                    RangeVector2Attribute attb = rangeAtts[0] as RangeVector2Attribute;

                    Vector2 value = (Vector2)properties[i].GetValue(imageEffect, null);

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(@" " + properties[i].GetGetMethod().Name.Replace(@"get_", string.Empty), GUILayout.Width(125));

                        value.x = GUILayout.HorizontalSlider(value.x, attb.min.x, attb.max.x, GUILayout.ExpandWidth(true));
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(string.Empty, GUILayout.Width(125));

                        value.y = GUILayout.HorizontalSlider(value.y, attb.min.y, attb.max.y, GUILayout.ExpandWidth(true));
                    }
                    GUILayout.EndHorizontal();

                    properties[i].SetValue(imageEffect, value, null);
                }

                rangeAtts = properties[i].GetCustomAttributes(typeof(RangeVector3Attribute), false);
                if (rangeAtts.Length > 0)
                {
                    RangeVector3Attribute attb = rangeAtts[0] as RangeVector3Attribute;
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label(@" " + properties[i].GetGetMethod().Name.Replace(@"get_", string.Empty), GUILayout.Width(125));

                        Vector3 value = (Vector3)properties[i].GetValue(imageEffect, null);

                        value.x = GUILayout.HorizontalSlider(value.x, attb.min.x, attb.max.x, GUILayout.ExpandWidth(true));
                        value.y = GUILayout.HorizontalSlider(value.y, attb.min.y, attb.max.y, GUILayout.ExpandWidth(true));
                        value.z = GUILayout.HorizontalSlider(value.z, attb.min.z, attb.max.z, GUILayout.ExpandWidth(true));

                        properties[i].SetValue(imageEffect, value, null);
                    }
                    GUILayout.EndHorizontal();
                }
            }

            if (GUILayout.Button(@"Reset") == true)
            {
                imageEffect.ResetDefaultValues();
            }
        }
    }
Exemplo n.º 10
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var showAdvancedControls = serializedObject.FindProperty("_showAdvancedControls").boolValue;

            // preamble - styles for toggle buttons. this code and the below was based off the useful info provided by user Lasse here:
            // https://gamedev.stackexchange.com/questions/98920/how-do-i-create-a-toggle-button-in-unity-inspector
            if (ToggleButtonStyleNormal == null)
            {
                ToggleButtonStyleNormal  = "Button";
                ToggleButtonStyleToggled = new GUIStyle(ToggleButtonStyleNormal);
                ToggleButtonStyleToggled.normal.background = ToggleButtonStyleToggled.active.background;
            }

            EditorGUILayout.Space();

            var spDisabled = serializedObject.FindProperty("_powerDisabled");

            UpgradeSpectrum(spDisabled, false);
            EditorGUILayout.BeginHorizontal();
            bool allEnabled = true;

            for (int i = 0; i < spDisabled.arraySize; i++)
            {
                if (spDisabled.GetArrayElementAtIndex(i).boolValue)
                {
                    allEnabled = false;
                }
            }
            bool toggle = allEnabled;

            if (toggle != EditorGUILayout.Toggle(toggle, GUILayout.Width(13f)))
            {
                for (int i = 0; i < spDisabled.arraySize; i++)
                {
                    spDisabled.GetArrayElementAtIndex(i).boolValue = toggle;
                }
            }
            EditorGUILayout.LabelField("Spectrum", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();

            var spec = target as OceanWaveSpectrum;

            var spPower = serializedObject.FindProperty("_powerLog");

            UpgradeSpectrum(spPower, OceanWaveSpectrum.MIN_POWER_LOG);
            var spChopScales = serializedObject.FindProperty("_chopScales");

            UpgradeSpectrum(spChopScales, 1f);
            var spGravScales = serializedObject.FindProperty("_gravityScales");

            UpgradeSpectrum(spGravScales, 1f);

            for (int i = 0; i < spPower.arraySize; i++)
            {
                EditorGUILayout.BeginHorizontal();

                var spDisabled_i = spDisabled.GetArrayElementAtIndex(i);
                spDisabled_i.boolValue = !EditorGUILayout.Toggle(!spDisabled_i.boolValue, GUILayout.Width(15f));

                float smallWL   = OceanWaveSpectrum.SmallWavelength(i);
                var   spPower_i = spPower.GetArrayElementAtIndex(i);

                if (showAdvancedControls)
                {
                    EditorGUILayout.LabelField(string.Format("{0}", smallWL), EditorStyles.boldLabel);
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Slider(spPower_i, OceanWaveSpectrum.MIN_POWER_LOG, OceanWaveSpectrum.MAX_POWER_LOG, "    Power");
                }
                else
                {
                    EditorGUILayout.LabelField(string.Format("{0}", smallWL), GUILayout.Width(30f));
                    spPower_i.floatValue = GUILayout.HorizontalSlider(spPower_i.floatValue, OceanWaveSpectrum.MIN_POWER_LOG, OceanWaveSpectrum.MAX_POWER_LOG);
                    EditorGUILayout.EndHorizontal();
                }

                if (showAdvancedControls)
                {
                    EditorGUILayout.Slider(spChopScales.GetArrayElementAtIndex(i), 0f, 4f, "    Chop Scale");
                    EditorGUILayout.Slider(spGravScales.GetArrayElementAtIndex(i), 0f, 4f, "    Grav Scale");
                }
            }


            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Empirical Spectra", EditorStyles.boldLabel);

            var labelWidth = 170f;

            EditorGUILayout.BeginHorizontal();
            float spd_kmh = spec._windSpeed * 3.6f;

            EditorGUILayout.LabelField("Wind speed (km/h)", GUILayout.Width(labelWidth));
            spd_kmh         = EditorGUILayout.Slider(spd_kmh, 0f, 120f);
            spec._windSpeed = spd_kmh / 3.6f;
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(s_labelSWM, GUILayout.Width(labelWidth));
            spec._smallWavelengthMultiplier = EditorGUILayout.Slider(spec._smallWavelengthMultiplier, 0f, 10f);
            EditorGUILayout.EndHorizontal();

            // descriptions from this very useful paper: https://hal.archives-ouvertes.fr/file/index/docid/307938/filename/frechot_realistic_simulation_of_ocean_surface_using_wave_spectra.pdf

            if (GUILayout.Button(s_labelPhillips, _applyPhillipsSpectrum ? ToggleButtonStyleToggled : ToggleButtonStyleNormal))
            {
                _applyPhillipsSpectrum = !_applyPhillipsSpectrum;
            }
            if (_applyPhillipsSpectrum)
            {
                _applyJONSWAPSpectrum = _applyPiersonMoskowitzSpectrum = false;

                Undo.RecordObject(this, "Apply Phillips Spectrum");

                spec.ApplyPhillipsSpectrum(spec._windSpeed, spec._smallWavelengthMultiplier);
            }

            if (GUILayout.Button(s_labelPiersonMoskowitz, _applyPiersonMoskowitzSpectrum ? ToggleButtonStyleToggled : ToggleButtonStyleNormal))
            {
                _applyPiersonMoskowitzSpectrum = !_applyPiersonMoskowitzSpectrum;
            }
            if (_applyPiersonMoskowitzSpectrum)
            {
                _applyPhillipsSpectrum = _applyJONSWAPSpectrum = false;

                Undo.RecordObject(this, "Apply Pierson-Moskowitz Spectrum");

                spec.ApplyPiersonMoskowitzSpectrum(spec._windSpeed, spec._smallWavelengthMultiplier);
            }

            spec._fetch = EditorGUILayout.Slider(s_labelFetch, spec._fetch, 0f, 1000000f);

            if (GUILayout.Button(s_labelJONSWAP, _applyJONSWAPSpectrum ? ToggleButtonStyleToggled : ToggleButtonStyleNormal))
            {
                _applyJONSWAPSpectrum = !_applyJONSWAPSpectrum;
            }
            if (_applyJONSWAPSpectrum)
            {
                _applyPhillipsSpectrum = _applyPiersonMoskowitzSpectrum = false;

                Undo.RecordObject(this, "Apply JONSWAP Spectrum");

                spec.ApplyJONSWAPSpectrum(spec._windSpeed, spec._fetch, spec._smallWavelengthMultiplier);
            }

            serializedObject.ApplyModifiedProperties();
        }
Exemplo n.º 11
0
            private void DrawTab(int tabId, ref UnityAction buttons)
            {
                var minWidth = GUILayout.MinWidth(mWindowSize.x);

                switch (tabs[tabId])
                {
                case "Mods":
                {
                    mScrollPosition[tabId] = GUILayout.BeginScrollView(mScrollPosition[tabId], minWidth, GUILayout.ExpandHeight(false));

                    var amountWidth = mColumns.Where(x => !x.skip).Sum(x => x.width);
                    var expandWidth = mColumns.Where(x => x.expand && !x.skip).Sum(x => x.width);

                    var mods     = modEntries;
                    var colWidth = mColumns.Select(x =>
                                                   x.expand
                                    ? GUILayout.Width(x.width / expandWidth * (mWindowSize.x - 60 + expandWidth - amountWidth))
                                    : GUILayout.Width(x.width)).ToArray();

                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal("box");
                    for (int i = 0; i < mColumns.Count; i++)
                    {
                        if (mColumns[i].skip)
                        {
                            continue;
                        }
                        GUILayout.Label(mColumns[i].name, colWidth[i]);
                    }

                    GUILayout.EndHorizontal();

                    for (int i = 0, c = mods.Count; i < c; i++)
                    {
                        int col = -1;
                        GUILayout.BeginVertical("box");
                        GUILayout.BeginHorizontal();

                        GUILayout.BeginHorizontal(colWidth[++col]);
                        if (mods[i].OnGUI != null || mods[i].CanReload)
                        {
                            if (GUILayout.Button(mods[i].Info.DisplayName, GUI.skin.label, GUILayout.ExpandWidth(true)))
                            {
                                ShowModSettings = (ShowModSettings == i) ? -1 : i;
                            }

                            if (GUILayout.Button(ShowModSettings == i ? Textures.SettingsActive : Textures.SettingsNormal, settings))
                            {
                                ShowModSettings = (ShowModSettings == i) ? -1 : i;
                            }
                        }
                        else
                        {
                            GUILayout.Label(mods[i].Info.DisplayName);
                        }

                        if (!string.IsNullOrEmpty(mods[i].Info.HomePage))
                        {
                            GUILayout.Space(10);
                            if (GUILayout.Button(Textures.WWW, www))
                            {
                                Application.OpenURL(mods[i].Info.HomePage);
                            }
                        }

                        if (mods[i].NewestVersion != null)
                        {
                            GUILayout.Space(10);
                            GUILayout.Box(Textures.Updates, updates);
                        }

                        GUILayout.Space(20);

                        GUILayout.EndHorizontal();

                        GUILayout.BeginHorizontal(colWidth[++col]);
                        GUILayout.Label(mods[i].Info.Version, GUILayout.ExpandWidth(false));
                        //                            if (string.IsNullOrEmpty(mods[i].Info.Repository))
                        //                            {
                        //                                GUI.color = new Color32(255, 81, 83, 255);
                        //                                GUILayout.Label("*");
                        //                                GUI.color = Color.white;
                        //                            }
                        GUILayout.EndHorizontal();

                        if (mods[i].ManagerVersion > GetVersion())
                        {
                            GUILayout.Label("<color=\"#CD5C5C\">Manager-" + mods[i].Info.ManagerVersion + "</color>", colWidth[++col]);
                        }
                        else if (gameVersion != VER_0 && mods[i].GameVersion > gameVersion)
                        {
                            GUILayout.Label("<color=\"#CD5C5C\">Game-" + mods[i].Info.GameVersion + "</color>", colWidth[++col]);
                        }
                        else if (mods[i].Requirements.Count > 0)
                        {
                            foreach (var item in mods[i].Requirements)
                            {
                                var id  = item.Key;
                                var mod = FindMod(id);
                                GUILayout.Label(((mod == null || item.Value != null && item.Value > mod.Version || !mod.Active) && mods[i].Active) ? "<color=\"#CD5C5C\">" + id + "</color>" : id, colWidth[++col]);
                            }
                        }
                        else if (!string.IsNullOrEmpty(mods[i].CustomRequirements))
                        {
                            GUILayout.Label(mods[i].CustomRequirements, colWidth[++col]);
                        }
                        else
                        {
                            GUILayout.Label("-", colWidth[++col]);
                        }

                        if (!forbidDisableMods)
                        {
                            var action = mods[i].Enabled;
                            action = GUILayout.Toggle(action, "", colWidth[++col]);
                            if (action != mods[i].Enabled)
                            {
                                mods[i].Enabled = action;
                                if (mods[i].Toggleable)
                                {
                                    mods[i].Active = action;
                                }
                                else if (action && !mods[i].Loaded)
                                {
                                    mods[i].Active = action;
                                }
                            }
                        }
                        else
                        {
                            GUILayout.Label("", colWidth[++col]);
                        }

                        if (mods[i].Active)
                        {
                            GUILayout.Box(mods[i].Enabled ? Textures.StatusActive : Textures.StatusNeedRestart, status);
                        }
                        else
                        {
                            GUILayout.Box(!mods[i].Enabled ? Textures.StatusInactive : Textures.StatusNeedRestart, status);
                        }
                        if (mods[i].ErrorOnLoading)
                        {
                            GUILayout.Label("!!!");
                        }

                        GUILayout.EndHorizontal();

                        if (ShowModSettings == i)
                        {
                            if (mods[i].CanReload)
                            {
                                GUILayout.Label("Debug", h2);
                                if (GUILayout.Button("Reload", button, GUILayout.ExpandWidth(false)))
                                {
                                    mods[i].Reload();
                                }
                                GUILayout.Space(5);
                            }
                            if (mods[i].Active && mods[i].OnGUI != null)
                            {
                                GUILayout.Label("Options", h2);
                                try
                                {
                                    mods[i].OnGUI(mods[i]);
                                }
                                //catch (ExitGUIException e)
                                //{
                                //    throw e;
                                //}
                                catch (Exception e)
                                {
                                    mods[i].Logger.LogException("OnGUI", e);
                                    ShowModSettings = -1;
                                    GUIUtility.ExitGUI();
                                }
                            }
                        }

                        GUILayout.EndVertical();
                    }

                    GUILayout.EndVertical();

                    GUILayout.EndScrollView();

                    GUILayout.Space(10);

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(10);
                    GUILayout.Box(Textures.SettingsNormal, settings);
                    GUILayout.Space(3);
                    GUILayout.Label("Options", GUILayout.ExpandWidth(false));
                    GUILayout.Space(15);
                    GUILayout.Box(Textures.WWW, www);
                    GUILayout.Space(3);
                    GUILayout.Label("Home page", GUILayout.ExpandWidth(false));
                    GUILayout.Space(15);
                    GUILayout.Box(Textures.Updates, updates);
                    GUILayout.Space(3);
                    GUILayout.Label("Available update", GUILayout.ExpandWidth(false));
                    GUILayout.Space(15);
                    GUILayout.Box(Textures.StatusActive, status);
                    GUILayout.Space(3);
                    GUILayout.Label("Active", GUILayout.ExpandWidth(false));
                    GUILayout.Space(10);
                    GUILayout.Box(Textures.StatusInactive, status);
                    GUILayout.Space(3);
                    GUILayout.Label("Inactive", GUILayout.ExpandWidth(false));
                    GUILayout.Space(10);
                    GUILayout.Box(Textures.StatusNeedRestart, status);
                    GUILayout.Space(3);
                    GUILayout.Label("Need restart", GUILayout.ExpandWidth(false));
                    GUILayout.Space(10);
                    GUILayout.Label("!!!", GUILayout.ExpandWidth(false));
                    GUILayout.Space(3);
                    GUILayout.Label("Errors", GUILayout.ExpandWidth(false));
                    GUILayout.Space(10);
                    GUILayout.Label("[CTRL + LClick]", bold, GUILayout.ExpandWidth(false));
                    GUILayout.Space(3);
                    GUILayout.Label("Drag window", GUILayout.ExpandWidth(false));
                    //                        GUILayout.Space(10);
                    //                        GUI.color = new Color32(255, 81, 83, 255);
                    //                        GUILayout.Label("*", bold, GUILayout.ExpandWidth(false));
                    //                        GUI.color = Color.white;
                    //                        GUILayout.Space(3);
                    //                        GUILayout.Label("Not support updates", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    if (GUI.changed)
                    {
                    }

                    break;
                }

                case "Logs":
                {
                    mScrollPosition[tabId] = GUILayout.BeginScrollView(mScrollPosition[tabId], minWidth);

                    GUILayout.BeginVertical("box");

                    for (int c = Logger.history.Count, i = Mathf.Max(0, c - Logger.historyCapacity); i < c; i++)
                    {
                        GUILayout.Label(Logger.history[i]);
                    }

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

                    buttons += delegate
                    {
                        if (GUILayout.Button("Clear", button, GUILayout.ExpandWidth(false)))
                        {
                            Logger.Clear();
                        }
                        if (GUILayout.Button("Open detailed log", button, GUILayout.ExpandWidth(false)))
                        {
                            OpenUnityFileLog();
                        }
                    };

                    break;
                }

                case "Settings":
                {
                    mScrollPosition[tabId] = GUILayout.BeginScrollView(mScrollPosition[tabId], minWidth);

                    GUILayout.BeginVertical("box");

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Hotkey (default Ctrl+F10)", GUILayout.ExpandWidth(false));
                    DrawKeybinding(ref Params.Hotkey, null, GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    GUILayout.Space(5);

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Check updates", GUILayout.ExpandWidth(false));
                    ToggleGroup(Params.CheckUpdates, mCheckUpdateStrings, i => { Params.CheckUpdates = i; }, null, GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    GUILayout.Space(5);

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Show this window on startup", GUILayout.ExpandWidth(false));
                    ToggleGroup(Params.ShowOnStart, mShowOnStartStrings, i => { Params.ShowOnStart = i; }, null, GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();

                    GUILayout.Space(5);

                    GUILayout.BeginVertical("box");
                    GUILayout.Label("Window size", bold, GUILayout.ExpandWidth(false));
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Width ", GUILayout.ExpandWidth(false));
                    mExpectedWindowSize.x = GUILayout.HorizontalSlider(mExpectedWindowSize.x, Mathf.Min(Screen.width, 960), Screen.width, GUILayout.Width(200));
                    GUILayout.Label(" " + mExpectedWindowSize.x.ToString("f0") + " px ", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Height", GUILayout.ExpandWidth(false));
                    mExpectedWindowSize.y = GUILayout.HorizontalSlider(mExpectedWindowSize.y, Mathf.Min(Screen.height, 720), Screen.height, GUILayout.Width(200));
                    GUILayout.Label(" " + mExpectedWindowSize.y.ToString("f0") + " px ", GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();
                    if (GUILayout.Button("Apply", button, GUILayout.ExpandWidth(false)))
                    {
                        mWindowSize.x = Mathf.Floor(mExpectedWindowSize.x) % 2 > 0 ? Mathf.Ceil(mExpectedWindowSize.x) : Mathf.Floor(mExpectedWindowSize.x);
                        mWindowSize.y = Mathf.Floor(mExpectedWindowSize.y) % 2 > 0 ? Mathf.Ceil(mExpectedWindowSize.y) : Mathf.Floor(mExpectedWindowSize.y);
                        CalculateWindowPos();
                        Params.WindowWidth  = mWindowSize.x;
                        Params.WindowHeight = mWindowSize.y;
                    }
                    GUILayout.EndVertical();

                    GUILayout.Space(5);

                    GUILayout.BeginVertical("box");
                    GUILayout.Label("UI", bold, GUILayout.ExpandWidth(false));
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Scale", GUILayout.ExpandWidth(false), GUILayout.ExpandWidth(false));
                    mExpectedUIScale = GUILayout.HorizontalSlider(mExpectedUIScale, 0.5f, 2f, GUILayout.Width(200));
                    GUILayout.Label(" " + mExpectedUIScale.ToString("f2"), GUILayout.ExpandWidth(false));
                    GUILayout.EndHorizontal();
                    if (GUILayout.Button("Apply", button, GUILayout.ExpandWidth(false)))
                    {
                        if (mUIScale != mExpectedUIScale)
                        {
                            mUIScaleChanged = true;
                            mUIScale        = mExpectedUIScale;
                            Params.UIScale  = mUIScale;
                        }
                    }
                    GUILayout.EndVertical();

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

                    break;
                }
                }
            }
Exemplo n.º 12
0
        public void DoWindow(int window)
        {
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUI.Button(new Rect(windowRect.width - 24, 4, 20, 20), "X")

                //if (GUILayout.Button("X", GUILayout.Height(16))
                || m_Controller == null || m_Controller.iface == null)
            {
                shouldBeDestroyed = true;
                if (m_Controller != null)
                {
                    m_Controller.controllerConfigurationOpen = false;
                    AdvancedFlyByWire.Instance.SaveState(null);
                }

                return;
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Show additional options");
            m_ShowOptions = GUILayout.Toggle(m_ShowOptions, "");
            GUILayout.EndHorizontal();

            if (m_ShowOptions)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Discrete action step");
                GUILayout.FlexibleSpace();
                FloatField(m_Controller.discreteActionStep, out m_Controller.discreteActionStep);
                GUILayout.EndHorizontal();

                GUILayout.Space(8);

                GUILayout.BeginHorizontal();
                GUILayout.Label("Incremental action sensitivity");
                GUILayout.FlexibleSpace();
                FloatField(m_Controller.incrementalActionSensitivity, out m_Controller.incrementalActionSensitivity);
                GUILayout.EndHorizontal();

                GUILayout.Space(8);

                GUILayout.BeginHorizontal();
                GUILayout.Label("Camera sensitivity");
                GUILayout.FlexibleSpace();
                FloatField(m_Controller.cameraSensitivity, out m_Controller.cameraSensitivity);
                GUILayout.EndHorizontal();

                GUILayout.Space(8);

                GUILayout.BeginHorizontal();
                GUILayout.Label("Analog input curve");
                GUILayout.FlexibleSpace();

                string curveLabel = "Quadratic";
                if (m_Controller.analogInputCurve == CurveType.Identity)
                {
                    curveLabel = "Linear";
                }
                else if (m_Controller.analogInputCurve == CurveType.SqrtX)
                {
                    curveLabel = "Quadratic (Inverted)";
                }

                if (GUILayout.Button(curveLabel))
                {
                    if (m_Controller.analogInputCurve == CurveType.Identity)
                    {
                        m_Controller.SetAnalogInputCurveType(CurveType.XSquared);
                    }
                    else if (m_Controller.analogInputCurve == CurveType.XSquared)
                    {
                        m_Controller.SetAnalogInputCurveType(CurveType.SqrtX);
                    }
                    else
                    {
                        m_Controller.SetAnalogInputCurveType(CurveType.Identity);
                    }
                }

                GUILayout.EndHorizontal();

                GUILayout.Space(8);

                GUILayout.BeginHorizontal();
                GUILayout.Label("Treat hats as buttons (requires restart)");
                GUILayout.FlexibleSpace();
                var state = GUILayout.Toggle(m_Controller.treatHatsAsButtons, "");
                if (state != m_Controller.treatHatsAsButtons)
                {
                    m_Controller.treatHatsAsButtons = state;
                    AdvancedFlyByWire.Instance.SaveState(null);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(8);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Manual dead-zones");
                GUILayout.FlexibleSpace();
                state = GUILayout.Toggle(m_Controller.manualDeadZones, "");
                if (state != m_Controller.manualDeadZones)
                {
                    m_Controller.SetManualDeadZones(state);
                    AdvancedFlyByWire.Instance.SaveState(null);
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Label("If some axes below are not displaying 0.0 when the controller is left untouched then it needs calibration.");
            GUILayout.Label("Leave the controller and press calibrate, then move around all the axes");

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Calibrate"))
            {
                m_Controller.SetManualDeadZones(false);

                for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++)
                {
                    float value = m_Controller.iface.GetRawAxisState(i);
                    m_Controller.iface.axisStates[i].m_Left             = value - 1e-4f;
                    m_Controller.iface.axisStates[i].m_Identity         = value;
                    m_Controller.iface.axisStates[i].m_Right            = value + 1e-4f;
                    m_Controller.iface.axisStates[i].m_NegativeDeadZone = float.MaxValue;
                    m_Controller.iface.axisStates[i].m_PositiveDeadZone = float.MaxValue;
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);

            GUILayout.Label("Axes");

            for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++)
            {
                GUILayout.BeginHorizontal();

                string label = "";
                float  value = m_Controller.iface.GetAxisState(i);
                label += m_Controller.iface.GetAxisName(i) + " ";
                GUILayout.Label(label);

                GUILayout.FlexibleSpace();

                label = value.ToString("0.000");
                if (value >= 0.0f)
                {
                    label += " ";
                }

                GUILayout.Label(label);

                GUI.enabled = false;
                GUILayout.HorizontalSlider(value, -1.0f, 1.0f, GUILayout.Width(150));
                GUI.enabled = true;

                GUILayout.EndHorizontal();

                if (m_ShowOptions || m_Controller.manualDeadZones)
                {
                    if (!m_Controller.manualDeadZones)
                    {
                        GUI.enabled = false;
                    }

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Negative dead-zone");
                    GUILayout.FlexibleSpace();

                    var negativeDeadZone = Mathf.Clamp(m_Controller.iface.axisStates[i].m_NegativeDeadZone, 0.0f, 1.0f);
                    var positiveDeadZone = Mathf.Clamp(m_Controller.iface.axisStates[i].m_PositiveDeadZone, 0.0f, 1.0f);

                    GUILayout.Label(negativeDeadZone.ToString("0.000"));
                    m_Controller.iface.axisStates[i].m_NegativeDeadZone = GUILayout.HorizontalSlider(negativeDeadZone, 0.0f, 1.0f, GUILayout.Width(150));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Positive dead-zone");

                    GUILayout.FlexibleSpace();
                    GUILayout.Label(positiveDeadZone.ToString("0.000"));
                    m_Controller.iface.axisStates[i].m_PositiveDeadZone = GUILayout.HorizontalSlider(positiveDeadZone, 0.0f, 1.0f, GUILayout.Width(150));

                    GUILayout.EndHorizontal();

                    GUILayout.Space(32);

                    GUI.enabled = true;
                }
            }

            GUILayout.Label("Buttons");

            for (int i = 0; i < m_Controller.iface.GetButtonsCount(); i++)
            {
                GUILayout.Label(m_Controller.iface.GetButtonName(i) + ": " + m_Controller.iface.GetButtonState(i).ToString());
            }

            GUILayout.EndScrollView();
            GUI.DragWindow();
        }
Exemplo n.º 13
0
    void OnGUI()
    {
        float     originalScreenWidth  = 400f;
        float     originalScreenHeight = (originalScreenWidth / Screen.width) * Screen.height;
        float     scale = Screen.width / originalScreenWidth;
        Matrix4x4 svMat = GUI.matrix; // save current matrix

        GUI.matrix = Matrix4x4.Scale(Vector3.one * scale);

        GUI.skin.label.fontStyle = FontStyle.Bold;
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;
        GUI.Label(new Rect(0f, 0f, originalScreenWidth, originalScreenHeight * 0.05f), "Android TTS Plugin");

        GUI.skin.label.fontStyle = FontStyle.Normal;
        GUI.skin.label.alignment = TextAnchor.LowerLeft;
        GUI.skin.horizontalSliderThumb.fixedWidth  = 30;
        GUI.skin.horizontalSliderThumb.fixedHeight = 30;
        Rect layoutRect = new Rect(originalScreenWidth * 0.05f, originalScreenHeight * 0.1f, originalScreenWidth * 0.9f, originalScreenHeight * 0.85f);

        GUILayout.BeginArea(layoutRect, GUI.skin.box);

        GUILayout.BeginVertical();

        GUILayout.Space(25f);

        GUILayout.Label("Initialized: " + TTSManager.IsInitialized());

        GUILayout.Space(35f);

        if (TTSManager.IsInitialized())
        {
            _inputText = GUILayout.TextArea(_inputText);

            if (GUILayout.Button("Speak"))
            {
                TTSManager.Speak(_inputText, false, TTSManager.STREAM.Music, 1f, 0f, transform.name, "OnSpeechCompleted", "speech_" + (++_speechId));
            }

            if (GUILayout.Button("Add to Queue"))
            {
                TTSManager.Speak(_inputText, true, TTSManager.STREAM.Music, 1f, 0f, transform.name, "OnSpeechCompleted", "speech_" + (++_speechId));
            }

            if (GUILayout.Button("Synthesize to SDCard root folder"))
            {
                TTSManager.SynthesizeToFile(_inputText, "/mnt/sdcard/speech_" + (++_speechId) + ".wav", transform.name, "OnSynthesizeCompleted", "speech_" + (++_speechId));
            }

            if (GUILayout.Button("Stop"))
            {
                TTSManager.Stop();
            }

            GUILayout.Space(25f);

            GUILayout.Label("Device Supported Languages:");

            if (_localeStrings != null && _localeStrings.Length > 0)
            {
                _selectedLocale = GUILayout.SelectionGrid(_selectedLocale, _localeStrings, 10);
                // _selectedLocale = GUILayout.SelectionGrid(_selectedLocale, _localeStrings, 3);
                TTSManager.SetLanguage(TTSManager.JAPANESE);
            }

            GUILayout.Space(25f);

            GUILayout.BeginHorizontal();

            GUILayout.Label("Pitch: ");

            _pitch = GUILayout.HorizontalSlider(_pitch, 0f, 2f);
            TTSManager.SetPitch(_pitch);

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Label("Speech Rate: ");

            _speechRate = GUILayout.HorizontalSlider(_speechRate, 0f, 2f);
            TTSManager.SetSpeechRate(_speechRate);

            GUILayout.EndHorizontal();
        }
        else if (_initializeError)
        {
            GUI.contentColor = Color.red;
            GUILayout.Label("Error during initialization of TTS.\nIs it installed on your device?");
        }

        GUILayout.EndVertical();

        GUILayout.EndArea();

        GUI.matrix = svMat;
    }
Exemplo n.º 14
0
        public void editor(int windowID)
        {
            editorScrollPosition = GUILayout.BeginScrollView(editorScrollPosition);
            List <ProtoCrewMember> kerbs = new List <ProtoCrewMember>(HighLogic.CurrentGame.CrewRoster.Crew);

            for (int i = kerbs.Count - 1; i >= 0; --i)
            {
                ProtoCrewMember kerb = kerbs[i];

                if (GUILayout.Button(kerb.name))
                {
                    kerbalToEdit  = kerb;
                    editCourage   = kerb.courage;
                    editStupidity = kerb.stupidity;
                    editBadS      = kerb.isBadass;
                    editName      = kerb.name;
                    if (kerb.gender == ProtoCrewMember.Gender.Female)
                    {
                        editGender = "Female";
                        editMale   = false;
                    }
                    else
                    {
                        editGender = "Male";
                        editMale   = true;
                    }
                    editTrait   = kerb.trait;
                    editVeteran = kerb.veteran;
                    if (editTrait == "Pilot")
                    {
                        editTraitInt = 0;
                    }
                    else if (editTrait == "Engineer")
                    {
                        editTraitInt = 1;
                    }
                    else
                    {
                        editTraitInt = 2;
                    }
                }
            }
            GUILayout.EndScrollView();

            //Field to type in kerbal's name.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Name:");
            editName = GUILayout.TextField(editName, 50);
            GUILayout.EndHorizontal();

            //Toggle female/male
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(editGender))
            {
                editMale = !editMale;
            }
            if (GUILayout.Button(editTrait))
            {
                if (editTraitInt < 2)
                {
                    editTraitInt += 1;
                }
                else
                {
                    editTraitInt = 0;
                }
            }

            GUILayout.EndHorizontal();

            //Sets kerbal's courage.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Courage:");
            editCourage = GUILayout.HorizontalSlider(editCourage, 0.0f, 1.0f);
            GUILayout.EndHorizontal();

            //Sets kerbal's stupidity.
            GUILayout.BeginHorizontal();
            GUILayout.Label("Stupidity:");
            editStupidity = GUILayout.HorizontalSlider(editStupidity, 0.0f, 1.0f);
            GUILayout.EndHorizontal();

            //Toggles BadS state.
            GUILayout.BeginHorizontal();
            editBadS = GUILayout.Toggle(editBadS, "BadS: " + editBadS);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            editVeteran = GUILayout.Toggle(editVeteran, "Veteran: " + editVeteran);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            editFloat = GUILayout.Toggle(editFloat, "Float window");
            GUILayout.EndHorizontal();

            if (editExists)
            {
                GUILayout.BeginHorizontal();
                editOverride = GUILayout.Toggle(editOverride, "Override existing Kerbal check");
                GUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Edit Kerbal"))
            {
                if (kerbalToEdit == null)
                {
                    ScreenMessages.PostScreenMessage("You must select a Kerbal first!", 1);
                }
                else
                {
                    if (editExists)
                    {
                        if (editOverride)
                        {
                            kerbalToEdit.ChangeName(editName);
                            if (editGender == "Female")
                            {
                                kerbalToEdit.gender = ProtoCrewMember.Gender.Female;
                            }
                            else
                            {
                                kerbalToEdit.gender = ProtoCrewMember.Gender.Male;
                            }

                            KerbalRoster.SetExperienceTrait(kerbalToEdit, editTrait);

                            kerbalToEdit.courage   = editCourage;
                            kerbalToEdit.stupidity = editStupidity;

                            kerbalToEdit.isBadass = editBadS;
                            kerbalToEdit.veteran  = editVeteran;

                            ScreenMessages.PostScreenMessage(kerbalToEdit.name + " has been edited!", 1, ScreenMessageStyle.UPPER_CENTER);
                        }
                        else
                        {
                            ScreenMessages.PostScreenMessage("A Kerbal with the name " + kerbalToEdit.name + " already exists.  If you would like to continue, enable override existing Kerbal ckeck.", 1, ScreenMessageStyle.UPPER_CENTER);
                        }
                    }
                    else
                    {
                        kerbalToEdit.ChangeName(editName);
                        if (editGender == "Female")
                        {
                            kerbalToEdit.gender = ProtoCrewMember.Gender.Female;
                        }
                        else
                        {
                            kerbalToEdit.gender = ProtoCrewMember.Gender.Male;
                        }

                        KerbalRoster.SetExperienceTrait(kerbalToEdit, editTrait);

                        kerbalToEdit.courage   = editCourage;
                        kerbalToEdit.stupidity = editStupidity;

                        kerbalToEdit.isBadass = editBadS;

                        ScreenMessages.PostScreenMessage(kerbalToEdit.name + " has been edited!", 1, ScreenMessageStyle.UPPER_CENTER);
                    }
                }
            }

            if (GUILayout.Button("Close"))
            {
                editorEnabled = false;
            }

            if (editFloat)
            {
                GUI.DragWindow();
            }
        }
Exemplo n.º 15
0
        public void BlendShapeTreeGUI()
        {
            var e = Event.current;

            GUIStyleReady();

            EditorGUILayout.BeginVertical(vaw.guiStyleSkinBox);
            if (blendShapeMode == BlendShapeMode.Slider)
            {
                #region Slider
                const int IndentWidth = 15;

                #region SetBlendShapeFoldout
                Action <BlendShapeNode, bool> SetBlendShapeFoldout = null;
                SetBlendShapeFoldout = (mg, foldout) =>
                {
                    mg.foldout = foldout;
                };
                #endregion

                var mgRoot = blendShapeNodes;

                #region Top
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Select All", GUILayout.Width(100)))
                    {
                        if (Shortcuts.IsKeyControl(e) || e.shift)
                        {
                            var combineGoList      = new HashSet <GameObject>(va.selectionGameObjects);
                            var combineVirtualList = new HashSet <HumanBodyBones>();
                            if (va.selectionHumanVirtualBones != null)
                            {
                                combineVirtualList.UnionWith(va.selectionHumanVirtualBones);
                            }
                            var combineBindings = new HashSet <EditorCurveBinding>(va.uAw.GetCurveSelection());
                            foreach (var root in mgRoot)
                            {
                                if (root.renderer != null && root.renderer.gameObject != null)
                                {
                                    combineGoList.Add(root.renderer.gameObject);
                                }
                                if (root.infoList != null && root.infoList.Length > 0)
                                {
                                    foreach (var info in root.infoList)
                                    {
                                        combineBindings.Add(va.AnimationCurveBindingBlendShape(root.renderer, info.blendShapeName));
                                    }
                                }
                            }
                            va.SelectGameObjects(combineGoList.ToArray(), combineVirtualList.ToArray());
                            va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                        }
                        else
                        {
                            var combineGoList   = new List <GameObject>();
                            var combineBindings = new List <EditorCurveBinding>();
                            foreach (var root in mgRoot)
                            {
                                if (root.renderer != null && root.renderer.gameObject != null)
                                {
                                    combineGoList.Add(root.renderer.gameObject);
                                }
                                if (root.infoList != null && root.infoList.Length > 0)
                                {
                                    foreach (var info in root.infoList)
                                    {
                                        combineBindings.Add(va.AnimationCurveBindingBlendShape(root.renderer, info.blendShapeName));
                                    }
                                }
                            }
                            va.SelectGameObjects(combineGoList.ToArray());
                            va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                        }
                    }
                    EditorGUILayout.Space();
                    if (GUILayout.Button("Reset All", GUILayout.Width(100)))
                    {
                        Undo.RecordObject(vae, "Reset All BlendShape Group");
                        for (int i = 0; i < blendShapeGroupValues.Length; i++)
                        {
                            blendShapeGroupValues[i] = 0f;
                        }
                        foreach (var root in mgRoot)
                        {
                            if (root.infoList != null && root.infoList.Length > 0)
                            {
                                foreach (var info in root.infoList)
                                {
                                    va.SetAnimationValueBlendShapeIfNotOriginal(root.renderer, info.blendShapeName, va.blendShapeWeightSave.GetDefaultWeight(root.renderer, info.blendShapeName));
                                }
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                #endregion

                EditorGUILayout.Space();

                #region BlendShape
                BlendShapeRootNode rootNode = null;
                int RowCount = 0;
                Action <BlendShapeNode, int, int> BlendShapeTreeNodeGUI = null;
                BlendShapeTreeNodeGUI = (mg, level, brotherMaxLevel) =>
                {
                    const int FoldoutWidth    = 22;
                    const int FoldoutSpace    = 17;
                    const int FloatFieldWidth = 44;
                    var       indentSpace     = IndentWidth * level;
                    EditorGUILayout.BeginHorizontal(RowCount++ % 2 == 0 ? vaw.guiStyleAnimationRowEvenStyle : vaw.guiStyleAnimationRowOddStyle);
                    {
                        {
                            var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(FoldoutWidth));
                            EditorGUI.BeginChangeCheck();
                            mg.foldout = EditorGUI.Foldout(rect, mg.foldout, "", true);
                            if (EditorGUI.EndChangeCheck())
                            {
                                if (e.alt)
                                {
                                    SetBlendShapeFoldout(mg, mg.foldout);
                                }
                            }
                        }
                        if (GUILayout.Button(new GUIContent(mg.name, mg.name), GUILayout.Width(vaw.editorSettings.settingEditorNameFieldWidth)))
                        {
                            if (Shortcuts.IsKeyControl(e) || e.shift)
                            {
                                var combineGoList      = new HashSet <GameObject>(va.selectionGameObjects);
                                var combineVirtualList = new HashSet <HumanBodyBones>();
                                if (va.selectionHumanVirtualBones != null)
                                {
                                    combineVirtualList.UnionWith(va.selectionHumanVirtualBones);
                                }
                                var combineBindings = new HashSet <EditorCurveBinding>(va.uAw.GetCurveSelection());
                                if (rootNode.renderer != null && rootNode.renderer.gameObject != null)
                                {
                                    combineGoList.Add(rootNode.renderer.gameObject);
                                }
                                if (rootNode.infoList != null && rootNode.infoList.Length > 0)
                                {
                                    foreach (var info in rootNode.infoList)
                                    {
                                        combineBindings.Add(va.AnimationCurveBindingBlendShape(rootNode.renderer, info.blendShapeName));
                                    }
                                }
                                va.SelectGameObjects(combineGoList.ToArray(), combineVirtualList.ToArray());
                                va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                            }
                            else
                            {
                                var combineGoList   = new List <GameObject>();
                                var combineBindings = new List <EditorCurveBinding>();
                                if (rootNode.renderer != null && rootNode.renderer.gameObject != null)
                                {
                                    combineGoList.Add(rootNode.renderer.gameObject);
                                }
                                if (rootNode.infoList != null && rootNode.infoList.Length > 0)
                                {
                                    foreach (var info in rootNode.infoList)
                                    {
                                        combineBindings.Add(va.AnimationCurveBindingBlendShape(rootNode.renderer, info.blendShapeName));
                                    }
                                }
                                va.SelectGameObjects(combineGoList.ToArray());
                                va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                            }
                        }
                        {
                            GUILayout.Space(FoldoutSpace);
                        }
                        {
                            EditorGUI.BeginChangeCheck();
                            var value = GUILayout.HorizontalSlider(blendShapeGroupValues[blendShapeGroupTreeTable[mg]], 0f, 100f);
                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObject(vae, "Change BlendShape Group");
                                blendShapeGroupValues[blendShapeGroupTreeTable[mg]] = value;
                                if (mg.infoList != null && mg.infoList.Length > 0)
                                {
                                    foreach (var info in mg.infoList)
                                    {
                                        va.SetAnimationValueBlendShape(rootNode.renderer, info.blendShapeName, value);
                                    }
                                }
                            }
                        }
                        {
                            var width = FloatFieldWidth + IndentWidth * Math.Max(0, brotherMaxLevel);
                            EditorGUI.BeginChangeCheck();
                            var value = EditorGUILayout.FloatField(blendShapeGroupValues[blendShapeGroupTreeTable[mg]], GUILayout.Width(width));
                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObject(vae, "Change BlendShape Group");
                                blendShapeGroupValues[blendShapeGroupTreeTable[mg]] = value;
                                if (mg.infoList != null && mg.infoList.Length > 0)
                                {
                                    foreach (var info in mg.infoList)
                                    {
                                        va.SetAnimationValueBlendShape(rootNode.renderer, info.blendShapeName, value);
                                    }
                                }
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    if (mg.foldout)
                    {
                        if (mg.infoList != null && mg.infoList.Length > 0)
                        {
                            #region BlendShape
                            foreach (var info in mg.infoList)
                            {
                                var blendShapeValue = va.GetAnimationValueBlendShape(rootNode.renderer, info.blendShapeName);
                                EditorGUILayout.BeginHorizontal(RowCount++ % 2 == 0 ? vaw.guiStyleAnimationRowEvenStyle : vaw.guiStyleAnimationRowOddStyle);
                                {
                                    EditorGUILayout.GetControlRect(false, GUILayout.Width(indentSpace + FoldoutWidth));
                                    if (GUILayout.Button(new GUIContent(info.blendShapeName, info.blendShapeName), GUILayout.Width(vaw.editorSettings.settingEditorNameFieldWidth)))
                                    {
                                        if (Shortcuts.IsKeyControl(e) || e.shift)
                                        {
                                            var combineGoList      = new HashSet <GameObject>(va.selectionGameObjects);
                                            var combineVirtualList = new HashSet <HumanBodyBones>();
                                            if (va.selectionHumanVirtualBones != null)
                                            {
                                                combineVirtualList.UnionWith(va.selectionHumanVirtualBones);
                                            }
                                            var combineBindings = new HashSet <EditorCurveBinding>(va.uAw.GetCurveSelection());
                                            if (rootNode.renderer != null && rootNode.renderer.gameObject != null)
                                            {
                                                combineGoList.Add(rootNode.renderer.gameObject);
                                            }
                                            combineBindings.Add(va.AnimationCurveBindingBlendShape(rootNode.renderer, info.blendShapeName));
                                            va.SelectGameObjects(combineGoList.ToArray(), combineVirtualList.ToArray());
                                            va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                                        }
                                        else
                                        {
                                            if (rootNode.renderer != null && rootNode.renderer.gameObject != null)
                                            {
                                                va.SelectGameObject(rootNode.renderer.gameObject);
                                            }
                                            va.SetAnimationWindowSynchroSelection(new EditorCurveBinding[] { va.AnimationCurveBindingBlendShape(rootNode.renderer, info.blendShapeName) });
                                        }
                                    }
                                }
                                {
                                    var mirrorName = va.GetMirrorBlendShape(rootNode.renderer, info.blendShapeName);
                                    if (!string.IsNullOrEmpty(mirrorName))
                                    {
                                        if (GUILayout.Button(new GUIContent("", string.Format("Mirror: '{0}'", mirrorName)), vaw.guiStyleMirrorButton, GUILayout.Width(vaw.mirrorTex.width), GUILayout.Height(vaw.mirrorTex.height)))
                                        {
                                            if (rootNode.renderer != null && rootNode.renderer.gameObject != null)
                                            {
                                                va.SelectGameObject(rootNode.renderer.gameObject);
                                            }
                                            va.SetAnimationWindowSynchroSelection(new EditorCurveBinding[] { va.AnimationCurveBindingBlendShape(rootNode.renderer, mirrorName) });
                                        }
                                    }
                                    else
                                    {
                                        GUILayout.Space(FoldoutSpace);
                                    }
                                    if (blendShapeMirrorName)
                                    {
                                        var mirrorIndex = EditorCommon.ArrayIndexOf(rootNode.blendShapeNames, mirrorName);
                                        EditorGUI.BeginChangeCheck();
                                        mirrorIndex = EditorGUILayout.Popup(mirrorIndex, rootNode.blendShapeNames);
                                        if (EditorGUI.EndChangeCheck())
                                        {
                                            string newMirrorName = mirrorIndex > 0 ? rootNode.blendShapeNames[mirrorIndex] : null;
                                            if (info.blendShapeName == newMirrorName)
                                            {
                                                newMirrorName = null;
                                            }
                                            va.ChangeBlendShapeMirror(rootNode.renderer, info.blendShapeName, newMirrorName);
                                            if (!string.IsNullOrEmpty(newMirrorName))
                                            {
                                                va.ChangeBlendShapeMirror(rootNode.renderer, newMirrorName, info.blendShapeName);
                                            }
                                        }
                                    }
                                }
                                {
                                    EditorGUI.BeginChangeCheck();
                                    var value2 = GUILayout.HorizontalSlider(blendShapeValue, 0f, 100f);
                                    if (EditorGUI.EndChangeCheck())
                                    {
                                        va.SetAnimationValueBlendShape(rootNode.renderer, info.blendShapeName, value2);
                                    }
                                }
                                {
                                    EditorGUI.BeginChangeCheck();
                                    var value2 = EditorGUILayout.FloatField(blendShapeValue, GUILayout.Width(FloatFieldWidth));
                                    if (EditorGUI.EndChangeCheck())
                                    {
                                        va.SetAnimationValueBlendShape(rootNode.renderer, info.blendShapeName, value2);
                                    }
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                            #endregion
                        }
                    }
                };
                {
                    int maxLevel = 0;
                    foreach (var root in mgRoot)
                    {
                        if (root.renderer != null && root.mesh != null && root.renderer.sharedMesh == root.mesh)
                        {
                            if (root.foldout)
                            {
                                maxLevel = Math.Max(maxLevel, 1);
                            }
                        }
                    }
                    foreach (var root in mgRoot)
                    {
                        if (root.renderer != null && root.mesh != null && root.renderer.sharedMesh == root.mesh)
                        {
                            rootNode = root;
                            BlendShapeTreeNodeGUI(root, 1, maxLevel);
                        }
                    }
                }
                #endregion
                #endregion
            }
            else if (blendShapeMode == BlendShapeMode.List)
            {
                #region List
                if (e.type == EventType.Layout)
                {
                    UpdateBlendShapeSetListReorderableList();
                }
                if (blendShapeSetListReorderableList != null)
                {
                    blendShapeSetListReorderableList.DoLayoutList();
                }
                #endregion
            }
            else if (blendShapeMode == BlendShapeMode.Icon)
            {
                #region Icon
                if (e.type == EventType.Layout)
                {
                    UpdateBlendShapeSetIcon();
                }
                {
                    EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
                    {
                        EditorGUI.BeginChangeCheck();
                        blendShapeSetIconCameraMode = (IconCameraMode)EditorGUILayout.EnumPopup(blendShapeSetIconCameraMode, EditorStyles.toolbarDropDown, GUILayout.Width(80f));
                        if (EditorGUI.EndChangeCheck())
                        {
                            blendShapeSetIconUpdate = true;
                        }
                    }
                    EditorGUILayout.Space();
                    blendShapeSetIconShowName = GUILayout.Toggle(blendShapeSetIconShowName, "Show Name", EditorStyles.toolbarButton);
                    EditorGUILayout.Space();
                    blendShapeSetIconSize = EditorGUILayout.Slider(blendShapeSetIconSize, 32f, IconTextureSize);
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.Space();
                if (va.blendShapeSetList.Count > 0)
                {
                    float areaWidth = vae.position.width - 16f;
                    int   countX    = Math.Max(1, Mathf.FloorToInt(areaWidth / blendShapeSetIconSize));
                    int   countY    = Mathf.CeilToInt(va.blendShapeSetList.Count / (float)countX);
                    for (int i = 0; i < countY; i++)
                    {
                        EditorGUILayout.BeginHorizontal();
                        for (int j = 0; j < countX; j++)
                        {
                            var index = i * countX + j;
                            if (index >= va.blendShapeSetList.Count)
                            {
                                break;
                            }
                            var rect = EditorGUILayout.GetControlRect(false, blendShapeSetIconSize, guiStyleIconButton, GUILayout.Width(blendShapeSetIconSize), GUILayout.Height(blendShapeSetIconSize));
                            if (GUI.Button(rect, va.blendShapeSetList[index].icon, guiStyleIconButton))
                            {
                                var poseTemplate = va.blendShapeSetList[index].poseTemplate;
                                va.LoadPoseTemplate(poseTemplate, false, false, VeryAnimation.PoseTemplateFlags.BlendShape);
                            }
                            if (blendShapeSetIconShowName)
                            {
                                GUI.Label(rect, va.blendShapeSetList[index].poseTemplate.name, guiStyleNameLabel);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("List is Empty", EditorStyles.centeredGreyMiniLabel);
                }
                #endregion
            }
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 16
0
        private void MainWindow(int id)
        {
            Trajectory traj = Trajectory.fetch;

            GUILayout.BeginHorizontal();

            Settings.fetch.DisplayTrajectories = GUILayout.Toggle(Settings.fetch.DisplayTrajectories, "Show trajectory", GUILayout.Width(125));

            Settings.fetch.DisplayTrajectoriesInFlight = GUILayout.Toggle(Settings.fetch.DisplayTrajectoriesInFlight, "In-Flight");

            // check that we have patched conics. If not, apologize to the user and return.
            if (Settings.fetch.DisplayTrajectories && !Util.IsPatchedConicsAvailable)
            {
                ScreenMessages.PostScreenMessage(
                    "Can't show trajectory because patched conics are not available." +
                    " Please update your tracking station facility.");
                Settings.fetch.DisplayTrajectories = false;
                return;
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            Settings.fetch.BodyFixedMode = GUILayout.Toggle(Settings.fetch.BodyFixedMode, "Body-fixed mode");

            if (Settings.fetch.DisplayTrajectories)
            {
                Settings.fetch.DisplayCompleteTrajectory = GUILayout.Toggle(Settings.fetch.DisplayCompleteTrajectory, "complete", GUILayout.Width(70));
            }

            GUILayout.EndHorizontal();

            GUILayout.Label("Max G-force: " + guistring_gForce);

            GUILayout.Label(guistring_impactVelocity);
            GUILayout.Space(10);


            if (Settings.fetch.DisplayTargetGUI = ToggleGroup(Settings.fetch.DisplayTargetGUI, "Target"))
            {
                GUI.enabled = Trajectory.Target.WorldPosition.HasValue;

                GUILayout.Label(guistring_targetDistance);

                if (GUILayout.Button("Unset target"))
                {
                    Trajectory.Target.Set();
                }
                GUI.enabled = true;

                GUILayout.BeginHorizontal();
                var patch = traj.Patches.LastOrDefault();
                GUI.enabled = (patch != null && patch.ImpactPosition.HasValue);
                if (GUILayout.Button("Set current impact", GUILayout.Width(150)))
                {
                    Trajectory.Target.Set(patch.StartingState.ReferenceBody, patch.ImpactPosition);
                }
                GUI.enabled = true;
                if (GUILayout.Button("Set KSC", GUILayout.Width(70)))
                {
                    var body = FlightGlobals.Bodies.SingleOrDefault(b => b.isHomeWorld);
                    if (body != null)
                    {
                        Vector3d worldPos = body.GetWorldSurfacePosition(-0.04860002, -74.72425635, 2.0);
                        Trajectory.Target.Set(body, worldPos - body.position);
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();

                Vessel targetVessel = FlightGlobals.fetch.VesselTarget?.GetVessel();
                GUI.enabled = (patch != null && targetVessel != null && targetVessel.Landed
                               // && targetVessel.lastBody == patch.startingState.referenceBody
                               );
                if (GUILayout.Button("Target vessel"))
                {
                    Trajectory.Target.Set(targetVessel.lastBody, targetVessel.GetWorldPos3D() - targetVessel.lastBody.position);
                    ScreenMessages.PostScreenMessage("Targeting vessel " + targetVessel.GetName());
                }

                FinePrint.Waypoint navigationWaypoint = FlightGlobals.ActiveVessel?.navigationWaypoint;
                GUI.enabled = (navigationWaypoint != null);
                if (GUILayout.Button("Active waypoint"))
                {
                    Trajectory.Target.Set(navigationWaypoint.celestialBody, navigationWaypoint.celestialBody.
                                          GetWorldSurfacePosition(navigationWaypoint.latitude, navigationWaypoint.longitude, navigationWaypoint.altitude)
                                          - navigationWaypoint.celestialBody.position);
                    ScreenMessages.PostScreenMessage("Targeting waypoint " + navigationWaypoint.name);
                }
                GUILayout.EndHorizontal();

                GUI.enabled = true;

                GUILayout.BeginHorizontal();
                coords = GUILayout.TextField(Trajectory.Target.ManualText, GUILayout.Width(170));
                if (coords != Trajectory.Target.ManualText)
                {
                    Trajectory.Target.ManualText = coords;
                    Trajectory.Target.Save();
                }
                if (GUILayout.Button(new GUIContent("Set",
                                                    "Enter target latitude and longitude, separated by a comma, in decimal format (with a dot for decimal separator)"),
                                     GUILayout.Width(50)))
                {
                    string[] latLng = coords.Split(new char[] { ',', ';' });
                    var      body   = FlightGlobals.currentMainBody;
                    if (latLng.Length == 2 && body != null)
                    {
                        double lat;
                        double lng;
                        if (double.TryParse(latLng[0].Trim(), out lat) && double.TryParse(latLng[1].Trim(), out lng))
                        {
                            Vector3d relPos   = body.GetWorldSurfacePosition(lat, lng, 2.0) - body.position;
                            double   altitude = Trajectory.GetGroundAltitude(body, relPos) + body.Radius;
                            Trajectory.Target.Set(body, relPos * (altitude / relPos.magnitude));
                        }
                    }
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            bool descentProfileGroup = Settings.fetch.DisplayDescentProfileGUI = ToggleGroup(Settings.fetch.DisplayDescentProfileGUI, "Descent profile", 120);

            DescentProfile.fetch.DoQuickControlsGUI();
            GUILayout.EndHorizontal();
            if (descentProfileGroup)
            {
                DescentProfile.fetch.DoGUI();
            }
            GUILayout.Space(10);

            if (Settings.fetch.DisplaySettingsGUI = ToggleGroup(Settings.fetch.DisplaySettingsGUI, "Settings"))
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Max patches", GUILayout.Width(100));
                Settings.fetch.MaxPatchCount = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)Settings.fetch.MaxPatchCount, 3, 10, GUILayout.Width(100)));
                GUILayout.Label(Settings.fetch.MaxPatchCount.ToString(), GUILayout.Width(15));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Max frames per patch", GUILayout.Width(100));
                Settings.fetch.MaxFramesPerPatch = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)Settings.fetch.MaxFramesPerPatch, 1, 50, GUILayout.Width(100)));
                GUILayout.Label(Settings.fetch.MaxFramesPerPatch.ToString(), GUILayout.Width(15));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                Settings.fetch.UseCache = GUILayout.Toggle(Settings.fetch.UseCache, new GUIContent("Use Cache", "Toggle cache usage. Trajectory will be more precise when cache disabled, but computation time will be higher. It's not recommended to keep it unchecked, unless your CPU can handle the load."), GUILayout.Width(80));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                Settings.fetch.AutoUpdateAerodynamicModel = GUILayout.Toggle(Settings.fetch.AutoUpdateAerodynamicModel, new GUIContent("Auto update", "Auto-update of the aerodynamic model. For example if a part is decoupled, the model needs to be updated. This is independent from trajectory update."));
                if (GUILayout.Button("Update now"))
                {
                    traj.InvalidateAerodynamicModel();
                }
                GUILayout.EndHorizontal();

                if (ToolbarManager.ToolbarAvailable)
                {
                    Settings.fetch.UseBlizzyToolbar = GUILayout.Toggle(Settings.fetch.UseBlizzyToolbar, new GUIContent("Use Blizzy's toolbar", "Will take effect after restart"));
                }

                if (FlightGlobals.ActiveVessel != null)
                {
                    GUILayout.Label("Position:");
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("lat=" + guistring_Latitude, GUILayout.Width(110));
                    GUILayout.Label("lng=" + guistring_Longitude, GUILayout.Width(110));
                    GUILayout.EndHorizontal();
                }

                GUILayout.Label("Aerodynamic model: " + traj.AerodynamicModelName);
                GUILayout.BeginHorizontal();
                GUILayout.Label(String.Format("Perf: {0,5:F1}ms ({1,4:F1})%",
                                              traj.ComputationTime * 1000.0f,
                                              traj.ComputationTime / traj.GameFrameTime * 100.0f
                                              ), GUILayout.Width(130));
                GUILayout.Label(traj.ErrorCount + " error(s)", GUILayout.Width(80));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                if (GUILayout.Toggle(Settings.fetch.NewGui, new GUIContent("New Gui", "Swap to the New Gui")))
                {
                    Settings.fetch.NewGui         = true;
                    Settings.fetch.MainGUIEnabled = true;
                    Settings.fetch.GUIEnabled     = false;
                    InputLockManager.RemoveControlLock("TrajectoriesFlightLock");
                    clickThroughLocked = false;
                }
                else
                {
                    Settings.fetch.NewGui         = false;
                    Settings.fetch.MainGUIEnabled = false;
                    Settings.fetch.GUIEnabled     = true;
                }
                GUILayout.EndHorizontal();
            }

            tooltip = GUI.tooltip;

            GUI.DragWindow();
        }
Exemplo n.º 17
0
    void OnGUI()
    {
        if (Input.GetKeyDown(KeyCode.R))
        {
            //Application.LoadLevel(Application.loadedLevel);
            //SceneManager.LoadScene();
        }

        Slider s = delegate(float val, string prefix, float min, float max, int pad)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label(prefix, GUILayout.MaxWidth(pad));
            val = GUILayout.HorizontalSlider(val, min, max);
            GUILayout.Label(val.ToString("F2"), GUILayout.MaxWidth(50));
            GUILayout.EndHorizontal();
            return(val);
        };

        GUI.Box(new Rect(10, 10, 250, Screen.height - 15), "Make-A-Shake");
        GUILayout.BeginArea(new Rect(29f, 40, 215, Screen.height - 40));

        GUILayout.Label("--Position Infleunce--");
        posInf.x = s(posInf.x, "X", 0, 4, 25);
        posInf.y = s(posInf.y, "Y", 0, 4, 25);
        posInf.z = s(posInf.z, "Z", 0, 4, 25);

        GUILayout.Label("--Rotation Infleunce--");
        rotInf.x = s(rotInf.x, "X", 0, 4, 25);
        rotInf.y = s(rotInf.y, "Y", 0, 4, 25);
        rotInf.z = s(rotInf.z, "Z", 0, 4, 25);

        GUILayout.Label("--Other Properties--");

        magn  = s(magn, "Magnitude:", 0, 10, 75);
        rough = s(rough, "Roughness:", 0, 20, 75);

        fadeIn  = s(fadeIn, "Fade In:", 0, 10, 75);
        fadeOut = s(fadeOut, "Fade Out:", 0, 10, 75);

        GUILayout.Label("--Saved Shake Instance--");
        GUILayout.Label("You can save shake instances and modify their properties at runtime.");

        if (shake == null && GUILayout.Button("Create Shake Instance"))
        {
            shake = CameraShaker.Instance.StartShake(magn, rough, fadeIn);
            shake.DeleteOnInactive = false;
        }

        if (shake != null)
        {
            if (GUILayout.Button("Delete Shake Instance"))
            {
                shake.DeleteOnInactive = true;
                shake.StartFadeOut(fadeOut);
                shake = null;
            }

            if (shake != null)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Fade Out"))
                {
                    shake.StartFadeOut(fadeOut);
                }
                if (GUILayout.Button("Fade In"))
                {
                    shake.StartFadeIn(fadeIn);
                }
                GUILayout.EndHorizontal();

                modValues = GUILayout.Toggle(modValues, "Modify Instance Values");

                if (modValues)
                {
                    shake.ScaleMagnitude    = magn;
                    shake.ScaleRoughness    = rough;
                    shake.PositionInfluence = posInf;
                    shake.RotationInfluence = rotInf;
                }
            }
        }

        GUILayout.Label("--Shake Once--");
        GUILayout.Label("You can simply have a shake that automatically starts and stops too.");

        if (GUILayout.Button("Shake!"))
        {
            CameraShakeInstance c = CameraShaker.Instance.ShakeOnce(magn, rough, fadeIn, fadeOut);
            c.PositionInfluence = posInf;
            c.RotationInfluence = rotInf;
        }

        GUILayout.EndArea();

        float height;

        if (!showList)
        {
            height = 120;
        }
        else
        {
            height = 120 + CameraShaker.Instance.ShakeInstances.Count * 130f;
        }

        GUI.Box(new Rect(Screen.width - 310, 10, 300, height), "Shake Instance List");
        GUILayout.BeginArea(new Rect(Screen.width - 285, 40, 255, Screen.height - 40));

        GUILayout.Label("All shake instances are saved and stacked as long as they are active.");

        showList = GUILayout.Toggle(showList, "Show List");

        if (showList)
        {
            int index = 1;
            foreach (CameraShakeInstance c in CameraShaker.Instance.ShakeInstances)
            {
                string state = c.CurrentState.ToString();

                GUILayout.Label("#" + index + ": Magnitude: " + c.Magnitude.ToString("F2") + ", Roughness: " + c.Roughness.ToString("F2"));
                GUILayout.Label("      Position Influence: " + c.PositionInfluence);
                GUILayout.Label("      Rotation Influence: " + c.RotationInfluence);
                GUILayout.Label("      State: " + state);
                GUILayout.Label("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
                index++;
            }
        }
        GUILayout.EndArea();
    }
Exemplo n.º 18
0
        internal static void Display(Vector2 displayViewerPosition)
        {
            // Reset Tooltip active flag...
            ToolTipActive    = false;
            _canShowToolTips = WindowSettings.ShowToolTips && ShowToolTips;

            Position = WindowSettings.Position;
            int scrollX = 20;

            GUILayout.Label(SmUtils.Localize("#smloc_settings_sounds_000"), SMStyle.LabelTabHeader);
            GUILayout.Label("____________________________________________________________________________________________",
                            SMStyle.LabelStyleHardRule, GUILayout.Height(10), GUILayout.Width(350));

            GUILayout.Label($"{SmUtils.Localize("#smloc_settings_sounds_001")}:", GUILayout.Height(20)); //"Transfer Pump:"

            // Pump Start Sound
            GUILayout.BeginHorizontal();
            //_label = "Pump Starting: ";
            //_toolTip = "Folder location where Pump Starting sound is stored.";
            //_toolTip += "\r\nChange to point to your own custom sounds if desired.";
            _label    = $"{SmUtils.Localize("#smloc_settings_sounds_002")}:";
            _toolTip  = SmUtils.Localize("#smloc_settings_sounds_tt_001");
            _guiLabel = new GUIContent(_label, _toolTip);
            GUILayout.Label(_guiLabel, GUILayout.Width(100));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }
            SMSettings.PumpSoundStart = GUILayout.TextField(SMSettings.PumpSoundStart, GUILayout.Width(220));
            GUILayout.EndHorizontal();

            // Pump Run Sound
            GUILayout.BeginHorizontal();
            //_label = "Pump Running: ";
            //_toolTip = "Folder location where Pump Running sound is stored.";
            //_toolTip += "\r\nChange to point to your own custom sounds if desired.";
            _label    = $"{SmUtils.Localize("#smloc_settings_sounds_003")}:";
            _toolTip  = SmUtils.Localize("#smloc_settings_sounds_tt_002");
            _guiLabel = new GUIContent(_label, _toolTip);
            GUILayout.Label(_guiLabel, GUILayout.Width(100));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }
            SMSettings.PumpSoundRun = GUILayout.TextField(SMSettings.PumpSoundRun, GUILayout.Width(220));
            GUILayout.EndHorizontal();

            // Pump Stop Sound
            GUILayout.BeginHorizontal();
            //_label = "Pump Stopping: ";
            //_toolTip = "Folder location where Pump Stopping sound is stored.";
            //_toolTip += "\r\nChange to point to your own custom sounds if desired.";
            _label    = $"{SmUtils.Localize("#smloc_settings_sounds_004")}:";
            _toolTip  = SmUtils.Localize("#smloc_settings_sounds_tt_003");
            _guiLabel = new GUIContent(_label, _toolTip);
            GUILayout.Label(_guiLabel, GUILayout.Width(100));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }
            SMSettings.PumpSoundStop = GUILayout.TextField(SMSettings.PumpSoundStop, GUILayout.Width(220));
            GUILayout.EndHorizontal();

            // Pump Sound Volume
            GUILayout.BeginHorizontal();
            //_label = "Pump Volume: ";
            //_toolTip = "How loud do you want it?";
            //_toolTip += "\r\nMove slider to change volume.";
            _label    = $"{SmUtils.Localize("#smloc_settings_sounds_005")}:";
            _toolTip  = SmUtils.Localize("#smloc_settings_sounds_tt_004");
            _guiLabel = new GUIContent(_label, _toolTip);
            GUILayout.Label(_guiLabel, GUILayout.Width(100));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }

            // Volume Slider Control
            //GUILayout.Label("Min", GUILayout.Width(40), GUILayout.Height(20));
            GUILayout.Label(SmUtils.Localize("#smloc_settings_sounds_006"), GUILayout.Width(40), GUILayout.Height(20)); // "Min"
            SMSettings.PumpSoundVol = GUILayout.HorizontalSlider((float)SMSettings.PumpSoundVol, 0f, 1f, GUILayout.Width(140), GUILayout.Height(20));
            //_label = "Max";
            //_toolTip = "Slide control to change the volume above.";
            _label   = SmUtils.Localize("#smloc_settings_sounds_007");
            _toolTip = SmUtils.Localize("#smloc_settings_sounds_004");
            GUILayout.Label(new GUIContent(_label, _toolTip), GUILayout.Width(40), GUILayout.Height(20));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }
            GUILayout.EndHorizontal();

            GUILayout.Label(" ", GUILayout.Height(10));
            //GUILayout.Label("Crew:", GUILayout.Height(20));
            GUILayout.Label($"{SmUtils.Localize("#smloc_settings_sounds_008")}:", GUILayout.Height(20));
            // Crew Start Sound
            GUILayout.BeginHorizontal();
            //_label = "Crew Exiting: ";
            //_toolTip = "Folder location where Crew Exiting their seat sound is stored.";
            //_toolTip += "\r\nChange to point to your own custom sounds if desired.";
            _label    = $"{SmUtils.Localize("#smloc_settings_sounds_009")}:";
            _toolTip  = SmUtils.Localize("#smloc_settings_sounds_tt_005");
            _guiLabel = new GUIContent(_label, _toolTip);
            GUILayout.Label(_guiLabel, GUILayout.Width(100));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }
            SMSettings.CrewSoundStart = GUILayout.TextField(SMSettings.CrewSoundStart, GUILayout.Width(220));
            GUILayout.EndHorizontal();

            // Crew Run Sound
            GUILayout.BeginHorizontal();
            //_label = "Crew Xfering: ";
            //_toolTip = "Folder location where Crew transferring sound is stored.";
            //_toolTip += "\r\nChange to point to your own custom sounds if desired.";
            _label    = $"{SmUtils.Localize("#smloc_settings_sounds_010")}:";
            _toolTip  = SmUtils.Localize("#smloc_settings_sounds_tt_006");
            _guiLabel = new GUIContent(_label, _toolTip);
            GUILayout.Label(_guiLabel, GUILayout.Width(100));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }
            SMSettings.CrewSoundRun = GUILayout.TextField(SMSettings.CrewSoundRun, GUILayout.Width(220));
            GUILayout.EndHorizontal();

            // Crew Stop Sound
            GUILayout.BeginHorizontal();
            //_label = "Crew Entering: ";
            //_toolTip = "Folder location where Crew Entering sound is stored.";
            //_toolTip += "\r\nChange to point to your own custom sounds if desired.";
            _label    = $"{SmUtils.Localize("#smloc_settings_sounds_011")}:";
            _toolTip  = SmUtils.Localize("#smloc_settings_sounds_tt_007");
            _guiLabel = new GUIContent(_label, _toolTip);
            GUILayout.Label(_guiLabel, GUILayout.Width(100));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }
            SMSettings.CrewSoundStop = GUILayout.TextField(SMSettings.CrewSoundStop, GUILayout.Width(220));
            GUILayout.EndHorizontal();

            // Crew Sound Volume
            GUILayout.BeginHorizontal();
            //_label = "Crew Volume: ";
            //_toolTip = "How loud do you want it?";
            //_toolTip += "\r\nMove slider to change volume.";
            _label    = $"{SmUtils.Localize("#smloc_settings_sounds_012")}:";
            _toolTip  = SmUtils.Localize("#smloc_settings_sounds_tt_004");
            _guiLabel = new GUIContent(_label, _toolTip);
            GUILayout.Label(_guiLabel, GUILayout.Width(100));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }

            // Volume Slider Control
            //GUILayout.Label("Min", GUILayout.Width(40), GUILayout.Height(20));
            GUILayout.Label(SmUtils.Localize("#smloc_settings_sounds_006"), GUILayout.Width(40), GUILayout.Height(20)); // "Min"
            SMSettings.CrewSoundVol = GUILayout.HorizontalSlider((float)SMSettings.CrewSoundVol, 0f, 1f, GUILayout.Width(140), GUILayout.Height(20));
            //_label = "Max";
            //_toolTip = "Slide control to change the volume above.";
            _label   = SmUtils.Localize("#smloc_settings_sounds_007");
            _toolTip = SmUtils.Localize("#smloc_settings_sounds_tt_004");
            GUILayout.Label(new GUIContent(_label, _toolTip), GUILayout.Width(40), GUILayout.Height(20));
            _rect = GUILayoutUtility.GetLastRect();
            if (Event.current.type == EventType.Repaint && _canShowToolTips)
            {
                ToolTip = SMToolTips.SetActiveToolTip(_rect, GUI.tooltip, ref ToolTipActive, scrollX);
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 19
0
        //basically, the layout function, but also adds dragability
        private void OnWindow(int WindowID)
        {
            //Directions
            GUILayout.Label("Please select the desired gauges:", _labelStyle);
            //Buttons for each of the gauges
            GUILayout.BeginHorizontal();                            //Arrange buttons side-by-side
            if (WindowToggle(!radarAltimeter.isMinimized, "Radar Altimeter", 130))
            {
                radarAltimeter.toggle();
                SaveMe();
            }
            if (WindowToggle(!compassGauge.isMinimized, "Magnetic Compass", 130))
            {
                compassGauge.toggle();
                SaveMe();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (WindowToggle(!electricalGauge.isMinimized, "Electrical Gauge", 130))
            {
                electricalGauge.toggle();
                SaveMe();
            }
            if (WindowToggle(!fuelGauge.isMinimized, "Fuel Gauge", 130))
            {
                fuelGauge.toggle();
                SaveMe();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (WindowToggle(!orbitGauge.isMinimized, "Orbital Gauge", 130))
            {
                orbitGauge.toggle();
                SaveMe();
            }
            if (WindowToggle(!rzGauge.isMinimized, "Rendezvous Gauge", 130))
            {
                rzGauge.toggle();
                SaveMe();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (WindowToggle(!nodeGauge.isMinimized, "Node Gauge", 130))
            {
                nodeGauge.toggle();
                SaveMe();
            }
            bool miniHud = hudGauge.mouseInput && hudGauge.mouseInputOnly;

            if (WindowToggle(!hudGauge.isMinimized, miniHud ? "HUD (Mini)" : "HUD", 130))
            {
                hudGauge.toggle();
                SaveMe();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (WindowToggle(!airGauge.isMinimized, "Air Gauge", 130))
            {
                airGauge.toggle();
                SaveMe();
            }
            if (hudGauge.mouseInput && WindowToggle(hudGauge.planeMode, hudGauge.planeMode ? "Mouse: Plane" : "Mouse: Rocket", 130))
            {
                hudGauge.planeMode = !hudGauge.planeMode;
                SaveMe();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (WindowToggle(!navGauge.isMinimized, "Nav Guage", 130))
            {
                navGauge.toggle();
                SaveMe();
            }
            GUILayout.EndHorizontal();
            //Alpha transparency control
            GUILayout.BeginHorizontal();
            GUILayout.Label("Transparencey:", _labelStyle, GUILayout.Width(130));
            Alpha = GUILayout.HorizontalSlider(Alpha, 0.1f, 1f, GUILayout.Width(130));
            //Update red for alpha
            Red = new Color(1, 0, 0, Alpha);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("HUD opacity:", _labelStyle, GUILayout.Width(130));
            hudGauge.Alpha = (int)GUILayout.HorizontalSlider(hudGauge.Alpha, 1f, 255f, GUILayout.Width(130));
            GUILayout.EndHorizontal();
            drawBezels = GUILayout.Toggle(drawBezels, "Draw Large Bezels", _toggleStyle);
            windowLock = GUILayout.Toggle(windowLock, "Lock Gauge Posistions", _toggleStyle);
            GUILayout.BeginHorizontal();
            if (WindowToggle(!advMinimized, "Advanced Settings", 130))
            {
                advMinimized = !advMinimized;
                SaveMe();
            }
            if (WindowToggle(isMinimized, "Close", 130))
            {
                isMinimized = !isMinimized;
                SaveMe();
            }
            GUILayout.EndHorizontal();
            //make it dragable
            GUI.DragWindow();
        }
Exemplo n.º 20
0
 private void Slider(string label, ref float valueRef, float min, float max)
 {
     GUILayout.Label(label);
     UpdateValue(ref valueRef, GUILayout.HorizontalSlider(valueRef, min, max));
 }
Exemplo n.º 21
0
        protected override void WindowGUI(int windowID)
        {
            if (path == null)
            {
                GUILayout.Label("Path is null!!!1!!1!1!1111!11eleven");
                base.WindowGUI(windowID);
                return;
            }

            if (lastMaxAtmosphereAltitude != mainBody.RealMaxAtmosphereAltitude())
            {
                lastMaxAtmosphereAltitude = mainBody.RealMaxAtmosphereAltitude();
                UpdateAtmoTexture(pathTexture, mainBody, path.autoPath ? path.autoTurnEndAltitude : path.turnEndAltitude);
            }

            GUILayout.BeginVertical();

            double oldTurnShapeExponent = path.turnShapeExponent;

            path.autoPath = GUILayout.Toggle(path.autoPath, "Automatic Altitude Turn", GUILayout.ExpandWidth(false));
            if (path.autoPath)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Altitude: ", GUILayout.Width(60));
                // 1 to 200 / 200 = 0.5% to 105%, without this mess would the slider cause lots of garbage floats like 0.9999864
                path.autoTurnPerc = Mathf.Floor(GUILayout.HorizontalSlider(path.autoTurnPerc * 200f, 1f, 210.5f)) / 200f;
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label("Velocity: ", GUILayout.Width(60));
                path.autoTurnSpdFactor = Mathf.Floor(GUILayout.HorizontalSlider(path.autoTurnSpdFactor * 2f, 8f, 160f)) / 2f;
                GUILayout.EndHorizontal();
            }

            if (path.autoPath)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Turn start when Altitude is ", GUILayout.ExpandWidth(false));
                GUILayout.Label(MuUtils.ToSI(path.autoTurnStartAltitude, -1, 2) + "m", GUILayout.ExpandWidth(false));
                GUILayout.Label("or Velocity reach ", GUILayout.ExpandWidth(false));
                GUILayout.Label(MuUtils.ToSI(path.autoTurnStartVelocity, -1, 3) + "m/s", GUILayout.ExpandWidth(false));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label("Turn end altitude: ");
                GUILayout.Label(MuUtils.ToSI(path.autoTurnEndAltitude, -1, 2) + "m", new GUIStyle(GUI.skin.label)
                {
                    alignment = TextAnchor.MiddleRight
                }, GUILayout.ExpandWidth(true));
                GUILayout.EndHorizontal();
            }
            else
            {
                GuiUtils.SimpleTextBox("Turn start altitude:", path.turnStartAltitude, "km");
                GuiUtils.SimpleTextBox("Turn start velocity:", path.turnStartVelocity, "m/s");
                GuiUtils.SimpleTextBox("Turn end altitude:", path.turnEndAltitude, "km");
            }

            GuiUtils.SimpleTextBox("Final flight path angle:", path.turnEndAngle, "°");
            GuiUtils.SimpleTextBox("Turn shape:", path.turnShapeExponent, "%");

            // Round the slider's value (0..1) to sliderPrecision decimal places.
            const int sliderPrecision = 3;

            double sliderTurnShapeExponent = GUILayout.HorizontalSlider((float)path.turnShapeExponent, 0.0F, 1.0F);

            if (Math.Round(Math.Abs(sliderTurnShapeExponent - oldTurnShapeExponent), sliderPrecision) > 0)
            {
                path.turnShapeExponent = new EditableDoubleMult(Math.Round(sliderTurnShapeExponent, sliderPrecision), 0.01);
            }

            GUILayout.Box(pathTexture);

            if (Event.current.type == EventType.Repaint)
            {
                Rect r = GUILayoutUtility.GetLastRect();
                r.xMin += GUI.skin.box.margin.left;
                r.yMin += GUI.skin.box.margin.top;

                r.xMax -= GUI.skin.box.margin.right;
                r.yMax -= GUI.skin.box.margin.bottom;

                float scale = (float)((path.autoPath ? path.autoTurnEndAltitude : path.turnEndAltitude) / r.height);

                DrawnPath(r, scale, scale, path, Color.red);
                DrawnTrajectory(r, path, recorder);
            }

            GUILayout.EndVertical();

            base.WindowGUI(windowID);
        }
Exemplo n.º 22
0
    private void GUIPanel()
    {
        GUI.DrawTexture(mainToolbarArea, (Texture)Resources.Load("Fondo2"));
        GUILayout.BeginArea(mainToolbarArea);
        GUILayout.Button((Texture)Resources.Load("LogoCompleto"), new GUIStyle(), GUILayout.Width(300), GUILayout.Height(50));
        var rec = EditorGUILayout.BeginVertical();

        //GUI.Box(rec, GUIContent.none);
        GUI.color = new Color32(255, 102, 102, 255);

        GUI.color = Color.white;
        GUILayout.BeginHorizontal();
        GUILayout.Label("Speed", StylePresets.SUBTITLE);
        _typeOfSpeed = (TypeOfSpeed)EditorGUILayout.EnumPopup(_typeOfSpeed);
        GUI.color    = scriptTarget.implosiveSpeed >= 0 ? Color.green : Color.red;
        GUILayout.Label(scriptTarget.implosiveSpeed.ToString("F2"), StylePresets.SUBTITLE);
        GUILayout.EndHorizontal();
        switch (_typeOfSpeed)
        {
        case TypeOfSpeed.Implosive:
            if (scriptTarget.implosiveSpeed > 0)
            {
                scriptTarget.implosiveSpeed = -1;
            }
            scriptTarget.implosiveSpeed = GUILayout.HorizontalSlider(scriptTarget.implosiveSpeed, 0, -100);
            break;

        case TypeOfSpeed.Explosive:
            if (scriptTarget.implosiveSpeed < 0)
            {
                scriptTarget.implosiveSpeed = 1;
            }
            scriptTarget.implosiveSpeed = GUILayout.HorizontalSlider(scriptTarget.implosiveSpeed, 0, 100);
            break;

        case TypeOfSpeed.Both:
            scriptTarget.implosiveSpeed = GUILayout.HorizontalSlider(scriptTarget.implosiveSpeed, -100, 100);
            break;
        }

        GUI.color = Color.white;

        GUILayout.Label("Noise Amount", StylePresets.COMMON);
        scriptTarget.randomNoise      = GUILayout.HorizontalSlider(scriptTarget.randomNoise, 0, 30);
        scriptTarget.active           = GUILayout.Toggle(scriptTarget.active, scriptTarget.active ? "Activate" : "Deactivate");
        scriptTarget.distanceGradient = GUILayout.Toggle(scriptTarget.distanceGradient,
                                                         scriptTarget.distanceGradient ? "Activate Distance Gradient" : "Deactivate Distance Gradient");
        GUILayout.FlexibleSpace();
        float buttonSize = 50;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();
        GUILayout.Label("Advanced", StylePresets.COMMON);
        if (GUILayout.Button((Texture)Resources.Load("settings"), GUILayout.MaxHeight(buttonSize), GUILayout.MaxWidth(buttonSize)))
        {
            if (_myAdvancedSettingsWIndow == null)
            {
                _myAdvancedSettingsWIndow = new AdvancedSettingsWindow();
            }
            AdvancedSettingsWindow.OpenWindow(this);
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();
        GUILayout.Label("Aesthetics", StylePresets.COMMON);
        if (GUILayout.Button((Texture)Resources.Load("Color"), GUILayout.MaxHeight(buttonSize), GUILayout.MaxWidth(buttonSize)))
        {
            if (_myColorWindow == null)
            {
                _myColorWindow = new ColorSelectorWindow();
            }
            ColorSelectorWindow.OpenWindow(this);
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();
        GUILayout.Label("Save/Load", StylePresets.COMMON);
        if (GUILayout.Button((Texture)Resources.Load("Search"), GUILayout.MaxHeight(buttonSize), GUILayout.MaxWidth(buttonSize)))
        {
            if (_mySaveLoadWindow == null)
            {
                _mySaveLoadWindow = new SaveLoadSettings();
            }
            SaveLoadSettings.OpenWindow(this);
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
        GUI.color = Color.white;

        GUILayout.EndArea();
    }
Exemplo n.º 23
0
        //Info window GUI
        internal void UpdateGUI()
        {
            //Initial label
            StringBuilder builder = new StringBuilder();

            builder.Append("Material: ").AppendLine(this.mat.name);
            builder.Append("Drag coefficient: ").AppendLine(this.mat.dragCoefficient.ToString("0.00#"));
            builder.Append("Predeployed diameter: ").Append(this.preDeployedDiameter).Append("m\n    area: ").Append(this.preDeployedArea.ToString("0.###")).AppendLine("m²");
            builder.Append("Deployed diameter: ").Append(this.deployedDiameter).Append("m\n    area: ").Append(this.deployedArea.ToString("0.###")).Append("m²");
            GUILayout.Label(builder.ToString(), this.skins.label);

            if (HighLogic.LoadedSceneIsFlight)
            {
                //Temperature info
                builder = new StringBuilder();
                builder.Append("Chute max temperature: ").Append(this.mat.maxTemp + RCUtils.absoluteZero).AppendLine("°C");
                builder.Append("Current chute temperature: ").Append(Math.Round(this.chuteTemperature + RCUtils.absoluteZero, 1, MidpointRounding.AwayFromZero)).Append("°C");
                GUILayout.Label(builder.ToString(), this.chuteTemperature / this.mat.maxTemp > 0.85 ? GUIUtils.redLabel : this.skins.label);


                //Pressure/altitude predeployment toggle
                GUILayout.BeginHorizontal();
                GUILayout.Label("Predeployment:", this.skins.label);
                if (GUILayout.Toggle(!this.minIsPressure, "altitude", this.skins.toggle))
                {
                    this.minIsPressure = false;
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Toggle(this.minIsPressure, "pressure", this.skins.toggle))
                {
                    this.minIsPressure = true;
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }

            //Predeployment pressure selection
            if (this.minIsPressure)
            {
                GUILayout.Label("Predeployment pressure: " + this.minPressure + "atm", this.skins.label);
                if (HighLogic.LoadedSceneIsFlight)
                {
                    //Predeployment pressure slider
                    this.minPressure = GUILayout.HorizontalSlider(this.minPressure, 0.005f, 1, this.skins.horizontalSlider, this.skins.horizontalSliderThumb);

                    //Copy to symmetry counterparts button
                    CopyToOthers(p =>
                    {
                        p.minIsPressure = this.minIsPressure;
                        p.minPressure   = this.minPressure;
                    });
                }
            }

            //Predeployment altitude selection
            else
            {
                GUILayout.Label("Predeployment altitude: " + this.minDeployment + "m", this.skins.label);
                if (HighLogic.LoadedSceneIsFlight)
                {
                    //Predeployment altitude slider
                    this.minDeployment = GUILayout.HorizontalSlider(this.minDeployment, 100, 20000, this.skins.horizontalSlider, this.skins.horizontalSliderThumb);

                    //Copy to symmetry counterparts button
                    CopyToOthers(p =>
                    {
                        p.minIsPressure = this.minIsPressure;
                        p.minDeployment = this.minDeployment;
                    });
                }
            }

            //Deployment altitude selection
            GUILayout.Label("Deployment altitude: " + this.deploymentAlt + "m", this.skins.label);
            if (HighLogic.LoadedSceneIsFlight)
            {
                //Deployment altitude slider
                this.deploymentAlt = GUILayout.HorizontalSlider(this.deploymentAlt, 50, 10000, this.skins.horizontalSlider, this.skins.horizontalSliderThumb);

                //Copy to symmetry counterparts button
                CopyToOthers(p => p.deploymentAlt = this.deploymentAlt);
            }

            //Other labels
            builder = new StringBuilder();
            if (this.cutAlt > 0)
            {
                builder.Append("Autocut altitude: ").Append(this.cutAlt).AppendLine("m");
            }
            builder.Append("Predeployment speed: ").Append(this.preDeploymentSpeed).AppendLine("s");
            builder.Append("Deployment speed: ").Append(this.deploymentSpeed).Append("s");
            GUILayout.Label(builder.ToString(), this.skins.label);
        }
Exemplo n.º 24
0
        static void OnGUI(UnityModManager.ModEntry modEntry)
        {
            float bgR;
            float bgG;
            float bgB;

            float handR;
            float handG;
            float handB;


            int handWidth;


            GUILayout.Label(title, GUILayout.Width(300));
            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("<color=#{0}{1}{2}>■■■■■■■■</color>底色"
                                          , (Main.settings.bgR * 255 > 16 ? "" : "0") + Convert.ToString((int)(Main.settings.bgR * 255), 16)
                                          , (Main.settings.bgG * 255 > 16 ? "" : "0") + Convert.ToString((int)(Main.settings.bgG * 255), 16)
                                          , (Main.settings.bgB * 255 > 16 ? "" : "0") + Convert.ToString((int)(Main.settings.bgB * 255), 16)));
            bgR = GUILayout.HorizontalSlider(Main.settings.bgR, 0, 1); GUILayout.Label("R:" + (Main.settings.bgR * 255).ToString("000").ToUpper());
            bgG = GUILayout.HorizontalSlider(Main.settings.bgG, 0, 1); GUILayout.Label("G:" + (Main.settings.bgG * 255).ToString("000").ToUpper());
            bgB = GUILayout.HorizontalSlider(Main.settings.bgB, 0, 1); GUILayout.Label("B:" + (Main.settings.bgB * 255).ToString("000").ToUpper());
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("<color=#{0}{1}{2}>■■■■■■■■</color>前色"
                                          , (Main.settings.handR * 255 > 16 ? "" : "0") + Convert.ToString((int)(Main.settings.handR * 255), 16)
                                          , (Main.settings.handG * 255 > 16 ? "" : "0") + Convert.ToString((int)(Main.settings.handG * 255), 16)
                                          , (Main.settings.handB * 255 > 16 ? "" : "0") + Convert.ToString((int)(Main.settings.handB * 255), 16)));
            handR = GUILayout.HorizontalSlider(Main.settings.handR, 0, 1); GUILayout.Label("R:" + (Main.settings.handR * 255).ToString("000").ToUpper());
            handG = GUILayout.HorizontalSlider(Main.settings.handG, 0, 1); GUILayout.Label("G:" + (Main.settings.handG * 255).ToString("000").ToUpper());
            handB = GUILayout.HorizontalSlider(Main.settings.handB, 0, 1); GUILayout.Label("B:" + (Main.settings.handB * 255).ToString("000").ToUpper());
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label(string.Format("设置滑动条宽度{0}", Main.settings.handWidth));
            handWidth = (int)GUILayout.HorizontalSlider(Main.settings.handWidth, 5, 30);
            GUILayout.Space(100);
            if (GUILayout.Button("使用鬼的配色"))
            {
                bgR = 0.9490196f;
                bgG = 0.509803951f;
                bgB = 0.503921571f;

                handR = 0.5882353f;
                handG = 0.807843149f;
                handB = 0.8156863f;

                handWidth = 20;
            }
            GUILayout.Space(100);
            if (GUILayout.Button("使用太吾配色"))
            {
                bgR = 0.164705882f;
                bgG = 0.164705882f;
                bgB = 0.164705882f;

                handR = 0.282352941f;
                handG = 0.094117647f;
                handB = 0.094117647f;

                handWidth = 10;
            }
            GUILayout.Space(100);
            GUILayout.EndHorizontal();


            if (
                Main.settings.bgR != bgR ||
                Main.settings.bgG != bgG ||
                Main.settings.bgB != bgB ||
                Main.settings.handR != handR ||
                Main.settings.handG != handG ||
                Main.settings.handB != handB ||
                Main.settings.handWidth != handWidth
                )
            {
                Main.settings.bgR       = bgR;
                Main.settings.bgG       = bgG;
                Main.settings.bgB       = bgB;
                Main.settings.handR     = handR;
                Main.settings.handG     = handG;
                Main.settings.handB     = handB;
                Main.settings.handWidth = handWidth;

                List <HandData> res = new List <HandData>();
                foreach (var item in hands)
                {
                    if (item.bg == null || item.hand == null || item.bgtf == null || item.handtf == null)
                    {
                        res.Add(item);
                    }
                    else
                    {
                        item.bg.color         = new Color(bgR, bgG, bgB);
                        item.hand.color       = new Color(handR, handG, handB);
                        item.bgtf.sizeDelta   = new Vector2(handWidth, 0);
                        item.handtf.sizeDelta = new Vector2(20, 20);
                    }
                }
                foreach (var item in res)
                {
                    hands.Remove(item);
                }
            }
        }
Exemplo n.º 25
0
        static void OnGUI(UnityModManager.ModEntry modEntry)
        {
            var instance     = DateFile.instance;
            var SaveDataLoad = instance != null && GameData.Characters.HasChar(instance.mianActorId);

            GUILayout.BeginVertical("Box");
            GUILayout.Label("☆ 童子之身 ★",
                            new GUIStyle {
                normal = { textColor = new Color(0.999999f, 0.537255f, 0.537255f) }
            });
            settings.featureLock = GUILayout.Toggle(settings.featureLock, "锁定太吾童子之身");
            if (SaveDataLoad)
            {
                if (GUILayout.Button("点击恢复太吾童子之身", new GUILayoutOption[] { GUILayout.Width(200f) }))
                {
                    RunningFeatureChange();
                }
            }
            else
            {
                GUILayout.Label("存档未载入");
            }
            GUILayout.EndVertical();

            GUILayout.BeginVertical("Box");
            GUILayout.Label("★ 魅惑之术 ☆",
                            new GUIStyle {
                normal = { textColor = new Color(0.999999f, 0.5647058f, 0.3411764f) }
            });
            GUILayout.BeginHorizontal();
            settings.bonusOfBonus = (int)GUILayout.HorizontalSlider(settings.bonusOfBonus, -100, 100);
            GUILayout.Label(string.Format("魅惑之术成功率修正:{0}%", settings.bonusOfBonus),
                            new GUIStyle {
                normal = { textColor = new Color(0.999999f, 0.537255f, 0.537255f) }
            });
            GUILayout.EndHorizontal();
            settings.checkSexuality = GUILayout.Toggle(settings.checkSexuality, "色诱前检验性取向");
            settings.manToPregnant  = GUILayout.Toggle(settings.manToPregnant, "男性也可怀孕(仅限太吾交换功法时)");
            settings.debug          = GUILayout.Toggle(settings.debug, "Debug");
            GUILayout.EndVertical();

            if (SaveDataLoad)
            {
                var taiwu = DateFile.instance.MianActorID();
                if (GUILayout.Button("点击清除新增的名誉", new GUILayoutOption[] { GUILayout.Width(200f) }))
                {
                    if (DateFile.instance.actorFame[taiwu].ContainsKey(399))
                    {
                        DateFile.instance.actorFame[taiwu].Remove(399);
                    }
                    if (DateFile.instance.actorFame[taiwu].ContainsKey(400))
                    {
                        DateFile.instance.actorFame[taiwu].Remove(400);
                    }
                }
                if (!DateFile.instance.actorFame[taiwu].ContainsKey(399) && !DateFile.instance.actorFame[taiwu].ContainsKey(400))
                {
                    GUILayout.Label("现在存档之后,可以安全地卸载本MOD了",
                                    new GUIStyle {
                        normal = { textColor = new Color(0.999999f, 0, 0) }
                    });
                }
            }
        }
    void DoWin(int id)
    {
        GUILayout.BeginHorizontal();
        if (GUILayout.Button(new GUIContent("Ins Before", "Shift-G")))
        {
            InsBefore();
        }

        if (GUILayout.Button(new GUIContent("Ins After", "G")))
        {
            InsAfter();
        }

        if (GUILayout.Button(new GUIContent("Delete", "H")))
        {
            Delete();
        }

        if (Target)
        {
            if (Target.PreviousTransform && GUILayout.Button(new GUIContent("Prev", "Shift-T")))
            {
                Selection.activeTransform = Target.PreviousTransform;
            }
            if (Target.NextTransform && GUILayout.Button(new GUIContent("Next", "T")))
            {
                Selection.activeTransform = Target.NextTransform;
            }
            if (GUILayout.Button("Spline"))
            {
                Selection.activeTransform = Target.Spline.transform;
            }
        }
        GUILayout.EndHorizontal();
        // TCB
        if (Target.Spline.Interpolation == CurvyInterpolation.TCB)
        {
            GUILayout.BeginHorizontal();
            Target.OverrideGlobalTension = GUILayout.Toggle(Target.OverrideGlobalTension, "T", GUILayout.ExpandWidth(false));
            if (Target.OverrideGlobalTension)
            {
                Target.StartTension = GUILayout.HorizontalSlider(Target.StartTension, -1, 1);
                if (!Target.SynchronizeTCB)
                {
                    Target.EndTension = GUILayout.HorizontalSlider(Target.EndTension, -1, 1);
                }
                else
                {
                    Target.EndTension = Target.StartTension;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            Target.OverrideGlobalContinuity = GUILayout.Toggle(Target.OverrideGlobalContinuity, "C", GUILayout.ExpandWidth(false));

            if (Target.OverrideGlobalContinuity)
            {
                Target.StartContinuity = GUILayout.HorizontalSlider(Target.StartContinuity, -1, 1);
                if (!Target.SynchronizeTCB)
                {
                    Target.EndContinuity = GUILayout.HorizontalSlider(Target.EndContinuity, -1, 1);
                }
                else
                {
                    Target.EndContinuity = Target.StartContinuity;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            Target.OverrideGlobalBias = GUILayout.Toggle(Target.OverrideGlobalBias, "B", GUILayout.ExpandWidth(false));
            if (Target.OverrideGlobalBias)
            {
                Target.StartBias = GUILayout.HorizontalSlider(Target.StartBias, -1, 1);
                if (!Target.SynchronizeTCB)
                {
                    Target.EndBias = GUILayout.HorizontalSlider(Target.EndBias, -1, 1);
                }
                else
                {
                    Target.EndBias = Target.StartBias;
                }
            }
            GUILayout.EndHorizontal();
        }

        if (GUI.changed && Target)
        {
            EditorUtility.SetDirty(Target);
            Target.Spline.Refresh(true, true, false);
            SceneView.RepaintAll();
        }
    }
Exemplo n.º 27
0
        public void BlendShapeTreeGUI()
        {
            var e = Event.current;

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                const int IndentWidth = 15;

                #region GetBlendShapeLevel
                Func <BlendShapeNode, int, int> GetBlendShapeLevel = null;
                GetBlendShapeLevel = (mg, level) =>
                {
                    if (mg.foldout)
                    {
                        if (mg.infoList != null && mg.infoList.Length > 0)
                        {
                            level++;
                        }
                    }
                    return(level);
                };
                #endregion
                #region SetBlendShapeFoldout
                Action <BlendShapeNode, bool> SetBlendShapeFoldout = null;
                SetBlendShapeFoldout = (mg, foldout) =>
                {
                    mg.foldout = foldout;
                };
                #endregion

                var mgRoot = blendShapeNodes;

                #region Reset All
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Select All", GUILayout.Width(100)))
                    {
                        if (va.IsKeyControl(e) || e.shift)
                        {
                            var combineGoList   = new List <GameObject>(va.selectionGameObjects);
                            var combineBindings = new List <EditorCurveBinding>(va.uAw.GetCurveSelection());
                            foreach (var root in mgRoot)
                            {
                                if (root.renderer != null && root.renderer.gameObject != null)
                                {
                                    combineGoList.Add(root.renderer.gameObject);
                                }
                                if (root.infoList != null && root.infoList.Length > 0)
                                {
                                    foreach (var info in root.infoList)
                                    {
                                        combineBindings.Add(va.AnimationCurveBindingBlendShape(root.renderer, info.blendShapeName));
                                    }
                                }
                            }
                            va.SelectGameObjects(combineGoList.ToArray());
                            va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                        }
                        else
                        {
                            var combineGoList   = new List <GameObject>();
                            var combineBindings = new List <EditorCurveBinding>();
                            foreach (var root in mgRoot)
                            {
                                if (root.renderer != null && root.renderer.gameObject != null)
                                {
                                    combineGoList.Add(root.renderer.gameObject);
                                }
                                if (root.infoList != null && root.infoList.Length > 0)
                                {
                                    foreach (var info in root.infoList)
                                    {
                                        combineBindings.Add(va.AnimationCurveBindingBlendShape(root.renderer, info.blendShapeName));
                                    }
                                }
                            }
                            va.SelectGameObjects(combineGoList.ToArray());
                            va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                        }
                    }
                    EditorGUILayout.Space();
                    if (GUILayout.Button("Reset All", GUILayout.Width(100)))
                    {
                        Undo.RecordObject(vae, "Reset All BlendShape Group");
                        for (int i = 0; i < blendShapeGroupValues.Length; i++)
                        {
                            blendShapeGroupValues[i] = 0f;
                        }
                        foreach (var root in mgRoot)
                        {
                            if (root.infoList != null && root.infoList.Length > 0)
                            {
                                foreach (var info in root.infoList)
                                {
                                    va.SetAnimationValueBlendShapeIfNotOriginal(root.renderer, info.blendShapeName, va.blendShapeWeightSave.GetOriginalWeight(root.renderer, info.blendShapeName));
                                }
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                #endregion

                EditorGUILayout.Space();

                #region BlendShape
                BlendShapeRootNode rootNode = null;
                int RowCount = 0;
                Action <BlendShapeNode> BlendShapeTreeGUI = null;
                BlendShapeTreeGUI = (mg) =>
                {
                    const int FoldoutWidth = 22;
                    const int FoldoutSpace = 10;
                    EditorGUILayout.BeginHorizontal(RowCount++ % 2 == 0 ? vaw.guiStyleAnimationRowEvenStyle : vaw.guiStyleAnimationRowOddStyle);
                    {
                        var rect = EditorGUILayout.GetControlRect();
                        {
                            var r = rect;
                            r.width = FoldoutWidth;
                            EditorGUI.BeginChangeCheck();
                            mg.foldout = EditorGUI.Foldout(r, mg.foldout, "", true);
                            if (EditorGUI.EndChangeCheck())
                            {
                                if (e.alt)
                                {
                                    SetBlendShapeFoldout(mg, mg.foldout);
                                }
                            }
                        }
                        {
                            var r = rect;
                            r.x      += FoldoutWidth;
                            r.y      += 1;
                            r.width  -= FoldoutWidth;
                            r.height += 1;
                            if (GUI.Button(r, new GUIContent(mg.name, blendShapeGroupValues[blendShapeGroupTreeTable[mg]].ToString())))
                            {
                                if (va.IsKeyControl(e) || e.shift)
                                {
                                    var combineGoList   = new List <GameObject>(va.selectionGameObjects);
                                    var combineBindings = new List <EditorCurveBinding>(va.uAw.GetCurveSelection());
                                    if (rootNode.renderer != null && rootNode.renderer.gameObject != null)
                                    {
                                        combineGoList.Add(rootNode.renderer.gameObject);
                                    }
                                    if (rootNode.infoList != null && rootNode.infoList.Length > 0)
                                    {
                                        foreach (var info in rootNode.infoList)
                                        {
                                            combineBindings.Add(va.AnimationCurveBindingBlendShape(rootNode.renderer, info.blendShapeName));
                                        }
                                    }
                                    va.SelectGameObjects(combineGoList.ToArray());
                                    va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                                }
                                else
                                {
                                    var combineGoList   = new List <GameObject>();
                                    var combineBindings = new List <EditorCurveBinding>();
                                    if (rootNode.renderer != null && rootNode.renderer.gameObject != null)
                                    {
                                        combineGoList.Add(rootNode.renderer.gameObject);
                                    }
                                    if (rootNode.infoList != null && rootNode.infoList.Length > 0)
                                    {
                                        foreach (var info in rootNode.infoList)
                                        {
                                            combineBindings.Add(va.AnimationCurveBindingBlendShape(rootNode.renderer, info.blendShapeName));
                                        }
                                    }
                                    va.SelectGameObjects(combineGoList.ToArray());
                                    va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                                }
                            }
                        }
                        GUILayout.Space(FoldoutSpace);
                    }
                    {
                        EditorGUI.BeginChangeCheck();
                        var value = GUILayout.HorizontalSlider(blendShapeGroupValues[blendShapeGroupTreeTable[mg]], 0f, 100f, GUILayout.Width(vaw.editorSettings.settingEditorSliderSize));
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObject(vae, "Change BlendShape Group");
                            blendShapeGroupValues[blendShapeGroupTreeTable[mg]] = value;
                            if (mg.infoList != null && mg.infoList.Length > 0)
                            {
                                foreach (var info in mg.infoList)
                                {
                                    va.SetAnimationValueBlendShape(rootNode.renderer, info.blendShapeName, value);
                                }
                            }
                        }
                    }
                    GUILayout.Space(IndentWidth * GetBlendShapeLevel(mg, 0));
                    if (GUILayout.Button("Reset", GUILayout.Width(44)))
                    {
                        Undo.RecordObject(vae, "Reset BlendShape Group");
                        blendShapeGroupValues[blendShapeGroupTreeTable[mg]] = 0f;
                        if (mg.infoList != null && mg.infoList.Length > 0)
                        {
                            foreach (var info in mg.infoList)
                            {
                                va.SetAnimationValueBlendShapeIfNotOriginal(rootNode.renderer, info.blendShapeName, va.blendShapeWeightSave.GetOriginalWeight(rootNode.renderer, info.blendShapeName));
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    if (mg.foldout)
                    {
                        EditorGUI.indentLevel++;
                        if (mg.infoList != null && mg.infoList.Length > 0)
                        {
                            #region BlendShape
                            foreach (var info in mg.infoList)
                            {
                                var blendShapeValue = va.GetAnimationValueBlendShape(rootNode.renderer, info.blendShapeName);
                                EditorGUILayout.BeginHorizontal(RowCount++ % 2 == 0 ? vaw.guiStyleAnimationRowEvenStyle : vaw.guiStyleAnimationRowOddStyle);
                                EditorGUI.indentLevel++;
                                var rect = EditorGUILayout.GetControlRect();
                                {
                                    var offset = IndentWidth * EditorGUI.indentLevel + FoldoutWidth - IndentWidth;
                                    rect.x      += offset;
                                    rect.width  -= offset;
                                    rect.y      += 1;
                                    rect.height += 1;
                                }
                                if (GUI.Button(rect, new GUIContent(info.blendShapeName)))
                                {
                                    if (va.IsKeyControl(e) || e.shift)
                                    {
                                        var combineGoList   = new List <GameObject>(va.selectionGameObjects);
                                        var combineBindings = new List <EditorCurveBinding>(va.uAw.GetCurveSelection());
                                        if (rootNode.renderer != null && rootNode.renderer.gameObject != null)
                                        {
                                            combineGoList.Add(rootNode.renderer.gameObject);
                                        }
                                        combineBindings.Add(va.AnimationCurveBindingBlendShape(rootNode.renderer, info.blendShapeName));
                                        va.SelectGameObjects(combineGoList.ToArray());
                                        va.SetAnimationWindowSynchroSelection(combineBindings.ToArray());
                                    }
                                    else
                                    {
                                        if (rootNode.renderer != null && rootNode.renderer.gameObject != null)
                                        {
                                            va.SelectGameObject(rootNode.renderer.gameObject);
                                        }
                                        va.SetAnimationWindowSynchroSelection(new EditorCurveBinding[] { va.AnimationCurveBindingBlendShape(rootNode.renderer, info.blendShapeName) });
                                    }
                                }
                                GUILayout.Space(FoldoutSpace);
                                {
                                    EditorGUI.BeginChangeCheck();
                                    var value2 = GUILayout.HorizontalSlider(blendShapeValue, 0f, 100f, GUILayout.Width(vaw.editorSettings.settingEditorSliderSize));
                                    if (EditorGUI.EndChangeCheck())
                                    {
                                        va.SetAnimationValueBlendShape(rootNode.renderer, info.blendShapeName, value2);
                                    }
                                }
                                if (GUILayout.Button("Reset", GUILayout.Width(44)))
                                {
                                    va.SetAnimationValueBlendShapeIfNotOriginal(rootNode.renderer, info.blendShapeName, va.blendShapeWeightSave.GetOriginalWeight(rootNode.renderer, info.blendShapeName));
                                }
                                EditorGUI.indentLevel--;
                                EditorGUILayout.EndHorizontal();
                            }
                            #endregion
                        }
                        EditorGUI.indentLevel--;
                    }
                };
                foreach (var root in mgRoot)
                {
                    if (root.renderer != null && root.mesh != null && root.renderer.sharedMesh == root.mesh)
                    {
                        rootNode = root;
                        BlendShapeTreeGUI(root);
                    }
                }
                #endregion
            }
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 28
0
    void OnGUI()
    {
        // Tells us about the current network connection
        GUILayout.Label("Status: " + PhotonNetwork.connectionStateDetailed.ToString());
        GUILayout.Label("Player Count:" + PhotonNetwork.playerList.Length);
        GUILayout.Label("Handle: " + player.Handle);
        GUILayout.Label("Team: " + player.Team);
        GUILayout.Label("Id: " + PhotonNetwork.player.ID);
        GUILayout.Label("Are You Master Client?? " + PhotonNetwork.isMasterClient);

        //Checks state of connection: Look up PeerState
        if (PhotonNetwork.connectionStateDetailed == PeerState.Joined)
        {
            //Chat Box
            this.scrollPositionChat = GUILayout.BeginScrollView(this.scrollPositionChat, GUILayout.Width(Screen.width / 4), GUILayout.MaxHeight(190), GUILayout.ExpandHeight(false));
            GUI.skin.box.alignment  = TextAnchor.UpperLeft;
            GUILayout.Box(this.chatBox, this.styleChat, GUILayout.ExpandHeight(true));
            GUILayout.EndScrollView();


            GUI.SetNextControlName("ChatBox");
            textField = GUILayout.TextField(textField, 100);
            if ((GUILayout.Button("Send") ||
                 (Event.current.type == EventType.keyDown &&
                  Event.current.character == '\n' &&
                  GUI.GetNameOfFocusedControl() == "ChatBox")) &&
                textField != "")
            {
                photonView.RPC("recieveMessage", PhotonTargets.AllBuffered, (this.player.Handle + ": " + textField + "\n"));
                textField = "";
                this.scrollPositionChat.y = Mathf.Infinity;
            }
            if (GUILayout.Button("Leave Room"))
            {
                PhotonNetwork.LeaveRoom();
                Application.LoadLevel("MainMenu");
            }
            if (GUILayout.Button("Play as Spy"))
            {
                player.Team = "Spy";
            }
            if (GUILayout.Button("Play as Guard"))
            {
                player.Team = "Guard";
            }
            if (PhotonNetwork.isMasterClient)
            {
                player.Guests = Mathf.RoundToInt(GUILayout.HorizontalSlider(player.Guests, 0.0f, 15.0f));
                GUILayout.Label("Number of Guests: " + player.Guests);
                if ((readyCount == PhotonNetwork.playerList.Length - 1) && player.Team != "" && GUILayout.Button("PLAY INTRIGUE"))
                {
                    photonView.RPC("go", PhotonTargets.AllBuffered);
                }
            }
            else if (player.Team != "" && !isReady)
            {
                if (GUILayout.Button("Ready"))
                {
                    isReady = true;
                    photonView.RPC("ready", PhotonTargets.MasterClient, 1);
                }
            }
            else if (isReady)
            {
                if (GUILayout.Button("Not Ready?"))
                {
                    isReady = false;
                    photonView.RPC("ready", PhotonTargets.MasterClient, -1);
                }
            }
        }
    }
Exemplo n.º 29
0
        void OnWindowGUI(int id)
        {
            GUI.skin = HighLogic.Skin;
            var historian     = Historian.Instance;
            var configuration = historian.GetConfiguration();

            // column one
            using (var columnOne = new GUILayout.AreaScope(new Rect(15, 20, 380, 550)))
            {
                using (var col = new GUILayout.VerticalScope())
                {
                    GUILayout.Space(20);
                    historian.Suppressed     = GUILayout.Toggle(historian.Suppressed, "Suppressed");
                    historian.AlwaysActive   = GUILayout.Toggle(historian.AlwaysActive, "Always Active");
                    historian.AutoHideUI     = GUILayout.Toggle(historian.AutoHideUI, "Auto hide UI");
                    configuration.AutoHideUI = historian.AutoHideUI;

                    configuration.PersistentConfigurationWindow = GUILayout.Toggle(configuration.PersistentConfigurationWindow, "Always Display Configuration Window");
                    enableLauncherButton = GUILayout.Toggle(enableLauncherButton, "Use Stock Launcher");
                    enableToolberButton  = GUILayout.Toggle(enableToolberButton, "Use Blizzy's Toolbar");
                    GUILayout.Space(10);

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

                    ManageButtons();

                    GUILayout.Space(10);
                    using (var layout = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Layout");
                        GUILayout.Space(10);
                        var 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 (var customHead = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Custom Text:");
                        GUILayout.FlexibleSpace();
                        configuration.PersistentCustomText = GUILayout.Toggle(configuration.PersistentCustomText, "Persistent", GUILayout.Width(120));
                    }
                    configuration.CustomText = GUILayout.TextArea(configuration.CustomText, GUI.skin.textArea, GUILayout.Height(60));

                    GUILayout.Space(10);
                    using (var spaceCentre = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Default Space Center Name:");
                        GUILayout.FlexibleSpace();
                        configuration.DefaultSpaceCenterName = GUILayout.TextField(configuration.DefaultSpaceCenterName, GUI.skin.textArea, GUILayout.Width(150));
                    }


                    GUILayout.Space(10);
                    GUILayout.Label($"Time to remember action key press: {configuration.TimeToRememberLastAction} ms");
                    configuration.TimeToRememberLastAction = (int)GUILayout.HorizontalSlider(configuration.TimeToRememberLastAction, 250, 10000, GUILayout.ExpandWidth(true));
                }
            }

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

                    GUILayout.Space(50);
                    GUILayout.Label("Default empty crew slot labels:");
                    GUILayout.Space(10);
                    using (var noCrewLabel = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Crewed:");
                        GUILayout.FlexibleSpace();
                        configuration.DefaultNoCrewLabel = GUILayout.TextField(configuration.DefaultNoCrewLabel, GUI.skin.textArea, GUILayout.Width(120));
                    }
                    using (var noCrewLabel = new GUILayout.HorizontalScope())
                    {
                        GUILayout.Label("Uncrewed:");
                        GUILayout.FlexibleSpace();
                        configuration.DefaultUnmannedLabel = GUILayout.TextField(configuration.DefaultUnmannedLabel, GUI.skin.textArea, GUILayout.Width(120));
                    }
                }
            }

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

            // bottom bar
            using (var buttonBar = new GUILayout.AreaScope(new Rect(5, 525, 890, 30)))
            {
                using (var layout = new GUILayout.HorizontalScope())
                {
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Load", GUILayout.Width(100.0f)))
                    {
                        historian.Reload();
                    }
                    if (GUILayout.Button("Save", GUILayout.Width(100.0f)))
                    {
                        configuration.Layout = historian.GetCurrentLayoutName();
                        configuration.EnableLauncherButton = enableLauncherButton;
                        configuration.EnableToolbarButton  = enableToolberButton;

                        historian.SetConfiguration(configuration);
                        if (!configuration.PersistentConfigurationWindow)
                        {
                            Toggle();
                        }
                    }
                    GUILayout.Space(20);
                    // GUILayout.FlexibleSpace();
                }
            }

            GUI.DragWindow();
        }
Exemplo n.º 30
0
        //The function that actually draws all the gui elements. I use GUILayout for doing everything because it's easy to use.
        private void DrawSettingsGUI(int windowID)
        {
            //We start by begining a vertical segment. All new elements will be placed below the previous one.
            GUILayout.BeginVertical();

            //Whether the mod is enabled or not
            enabled = GUILayout.Toggle(enabled, " Mod Enabled");

            //A global modifier that affects returns
            GUILayout.Label("Global Modifier: " + Math.Round(100 * globMod) + "%");
            globMod = (float)Math.Round(GUILayout.HorizontalSlider(globMod, 0, 1), 3);

            //We can toggle the Flat Rate Model on and off with a toggle
            flatRate = GUILayout.Toggle(flatRate, flatRate ? "Flat Rate Model" : "Variable Rate Model");
            //If Flat Rate is on we show this info
            if (flatRate)
            {
                //First off is a label saying what the modifier is (in percent)
                GUILayout.Label("Recovery Modifier: " + Math.Round(100 * recMod) + "%");
                //Then we have a slider that goes between 0 and 1 that sets the recMod
                recMod = GUILayout.HorizontalSlider(recMod, 0, 1);
                //We round the recMod for two reasons: it looks better and it makes it easier to select specific values.
                //In this case it limits it to whole percentages
                recMod = (float)Math.Round(recMod, 2);

                //We do a similar thing for the cutoff velocity, limiting it to between 2 and 12 m/s
                GUILayout.Label("Cutoff Velocity: " + cutoff + "m/s");
                cutoff = GUILayout.HorizontalSlider(cutoff, 2, 12);
                cutoff = (float)Math.Round(cutoff, 1);
            }
            //If we're using the Variable Rate Model we have to show other info
            else
            {
                //Like for the flat rate recovery modifier and cutoff, we present a label and a slider for the low cutoff velocity
                GUILayout.Label("Low Cutoff Velocity: " + lowCut + "m/s");
                lowCut = GUILayout.HorizontalSlider(lowCut, 0, 10);
                lowCut = (float)Math.Round(lowCut, 1);

                //And another slider for the high cutoff velocity (with limits between lowCut and 16)
                GUILayout.Label("High Cutoff Velocity: " + highCut + "m/s");
                highCut = GUILayout.HorizontalSlider(highCut, lowCut + 0.1f, 16);
                highCut = (float)Math.Max(Math.Round(highCut, 1), lowCut + 0.1);
            }

            //We begin a horizontal, meaning new elements will be placed to the right of previous ones
            GUILayout.BeginHorizontal();
            //First element is a label
            GUILayout.Label("DR Velocity");
            //Followed by a text field where we can set the DRMaxVel value (as a string for the moment)
            DRMaxVel = GUILayout.TextField(DRMaxVel, 6);
            //Ending the horizontal means new elements will now be placed below previous ones (so these two will be side by side with things above and below too)
            //Make sure to End anything you Begin!
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Powered TWR");
            minTWR = GUILayout.TextField(minTWR, 4);
            GUILayout.EndHorizontal();

            //The rest are just toggles and are put one after the other
            preRecover      = GUILayout.Toggle(preRecover, "Pre-Recover Vessels");
            showFail        = GUILayout.Toggle(showFail, "Failure Messages");
            showSuccess     = GUILayout.Toggle(showSuccess, "Success Messages");
            poweredRecovery = GUILayout.Toggle(poweredRecovery, "Try Powered Recovery");
            recoverClamps   = GUILayout.Toggle(recoverClamps, "Recover Clamps");
            useUpgrades     = GUILayout.Toggle(useUpgrades, "Tie Into Upgrades");
            useToolbar      = GUILayout.Toggle(useToolbar, "Use Toolbar Mod");

            if (GUILayout.Button("Edit Ignore List"))
            {
                showBlacklist = true;
            }

            //We then provide a single button to save the settings. The window can be closed by clicking on the toolbar button, which cancels any changes
            if (GUILayout.Button("Save"))
            {
                //When the button is clicked then this all is executed.
                //This all sets the settings to the GUI version's values
                Settings.Instance.SREnabled        = enabled;
                Settings.Instance.FlatRateModel    = flatRate;
                Settings.Instance.LowCut           = lowCut;
                Settings.Instance.HighCut          = highCut;
                Settings.Instance.RecoveryModifier = recMod;
                Settings.Instance.CutoffVelocity   = cutoff;
                //Strings must be parsed into the correct type. Using TryParse returns a bool stating whether it was sucessful. The value is saved in the out if it works
                //Otherwise we set the value to the default
                if (!float.TryParse(DRMaxVel, out Settings.Instance.DeadlyReentryMaxVelocity))
                {
                    Settings.Instance.DeadlyReentryMaxVelocity = 2000f;
                }

                Settings.Instance.ShowFailureMessages = showFail;
                Settings.Instance.ShowSuccessMessages = showSuccess;
                Settings.Instance.PoweredRecovery     = poweredRecovery;
                Settings.Instance.RecoverClamps       = recoverClamps;
                Settings.Instance.UseUpgrades         = useUpgrades;
                Settings.Instance.PreRecover          = preRecover;
                Settings.Instance.UseToolbarMod       = useToolbar;
                if (!float.TryParse(minTWR, out Settings.Instance.MinTWR))
                {
                    Settings.Instance.MinTWR = 1.0f;
                }

                Settings.Instance.GlobalModifier = globMod;
                //Finally we save the settings to the file
                Settings.Instance.Save();
            }

            //The last GUI element is added, so now we close the Vertical with EndVertical(). If you don't close all the things you open, the GUI will not display any elements
            GUILayout.EndVertical();

            //This last thing checks whether the right mouse button or middle mouse button are clicked on the window. If they are, we ignore it, otherwise we GUI.DragWindow()
            //Calling that allows the window to be moved by clicking it (anywhere empty on the window) with the left mouse button and dragging it to wherever you want.
            if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2))
            {
                GUI.DragWindow();
            }
        }