public override void OnInspectorGUI()
    {
        _capture = (this.target) as AVProMovieCaptureFromScene;

        DrawDefaultInspector();
        //ConfigGUI();

        GUILayout.Space(8.0f);

        if (Application.isPlaying)
        {
            if (!_capture.IsCapturing())
            {
                GUI.backgroundColor = Color.green;
                if (GUILayout.Button("Start Recording"))
                {
                    _capture.SelectCodec(false);
                    _capture.SelectAudioDevice(false);
                    // We have to queue the start capture otherwise Screen.width and height aren't correct
                    _capture.QueueStartCapture();
                }
                GUI.backgroundColor = Color.white;
            }
            else
            {
                GUILayout.BeginHorizontal();
                if (_capture._fps > 0f)
                {
                    Color originalColor = GUI.color;
                    float fpsDelta      = (_capture._fps - (int)_capture._frameRate);
                    GUI.color = Color.red;
                    if (fpsDelta > -10)
                    {
                        GUI.color = Color.yellow;
                    }
                    if (fpsDelta > -2)
                    {
                        GUI.color = Color.green;
                    }
                    GUILayout.Label("Recording at " + _capture._fps.ToString("F1") + " fps");

                    GUI.color = originalColor;
                }
                else
                {
                    GUILayout.Label("Recording at ... fps");
                }

                if (!_capture.IsPaused())
                {
                    GUI.backgroundColor = Color.yellow;
                    if (GUILayout.Button("Pause Capture"))
                    {
                        _capture.PauseCapture();
                    }
                }
                else
                {
                    GUI.backgroundColor = Color.green;
                    if (GUILayout.Button("Resume Capture"))
                    {
                        _capture.ResumeCapture();
                    }
                }
                GUI.backgroundColor = Color.cyan;
                if (GUILayout.Button("Cancel"))
                {
                    _capture.CancelCapture();
                }
                GUI.backgroundColor = Color.red;
                if (GUILayout.Button("Stop Recording"))
                {
                    _capture.StopCapture();
                }
                GUILayout.EndHorizontal();

                GUI.backgroundColor = Color.white;

                GUILayout.Space(8.0f);
                GUILayout.Label("Recording at: " + _capture.GetRecordingWidth() + "x" + _capture.GetRecordingHeight() + " @ " + ((int)_capture._frameRate).ToString() + "fps");
                GUILayout.Space(8.0f);
                GUILayout.Label("Using video codec: '" + _capture._codecName + "'");
                GUILayout.Label("Using audio device: '" + _capture._audioDeviceName + "'");
            }
        }
    }
    void DrawBuildWallScreen()
    {
        EditorStyles.textField.wordWrap = true;
        EditorGUILayout.TextArea("Select ratio/scale and light and confirm to make a room");

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        //Ratio region
        #region
        GUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Select Wall ratio");
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Select 1:1", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight)))
        {
            levelCreator.SetWallRatio(1, 1);
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Select 7:8", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight)))
        {
            levelCreator.SetWallRatio(7, 8);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Select 3:4", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight)))
        {
            levelCreator.SetWallRatio(3, 4);
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Select 5:8", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight)))
        {
            levelCreator.SetWallRatio(5, 8);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Select 1:2", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight)))
        {
            levelCreator.SetWallRatio(1, 2);
        }
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Select 3:8", GUILayout.MinWidth(buttonWidth), GUILayout.MinHeight(buttonHeight)))
        {
            levelCreator.SetWallRatio(3, 8);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        #endregion
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        //Scale region
        #region

        float wallScale = EditorGUILayout.Slider("Wall size", levelCreator.setWallScale, 1, 120);
        levelCreator.setWallScale = wallScale;
        #endregion
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        if (GUILayout.Button("Rotate wall"))
        {
            levelCreator.ToggleRotateWall();
        }
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        //Confirm and deny region
        #region
        GUIContent confirmPlacement = new GUIContent("\u2611", "Confirm wall placement");
        GUIContent denyPlacement    = new GUIContent("\u2612", "deny wall placement");


        GUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Confirm or deny placement");
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUI.color = Color.green;
        GUILayout.FlexibleSpace();
        if (GUILayout.Button(confirmPlacement, EditorStyles.miniButtonLeft, GUILayout.MinWidth(buttonWidth / 2), GUILayout.MinHeight(buttonHeight / 2)))
        {
            levelCreator.ConfirmWallPlacement();
            currentState = MenuStates.mainMenu;
        }
        GUI.color = Color.red;
        if (GUILayout.Button(denyPlacement, EditorStyles.miniButtonRight, GUILayout.MinWidth(buttonWidth / 2), GUILayout.MinHeight(buttonHeight / 2)))
        {
            levelCreator.DenyWallPlacement();
            currentState = MenuStates.mainMenu;
            ActiveEditorTracker.sharedTracker.isLocked = false;
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        #endregion
    }
예제 #3
0
        void OnGUI()
        {
            try
            {
                this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, false, false, GUILayout.Width(position.width), GUILayout.Height(position.height));

                GUIStyle var_Style = new GUIStyle("button");
                var_Style.normal.background = null;
                var_Style.active.background = null;

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button((Texture)EditorGUIUtility.Load("Assets/OPS/Obfuscator.Free/Editor/Gui/Rate.png"), var_Style, GUILayout.MaxWidth(100), GUILayout.MaxHeight(26)))
                {
                    Application.OpenURL("https://assetstore.unity.com/packages/tools/utilities/obfuscator-free-89420");
                }
                if (GUILayout.Button((Texture)EditorGUIUtility.Load("Assets/OPS/Obfuscator.Free/Editor/Gui/BugQuestion.png"), var_Style, GUILayout.MaxWidth(200), GUILayout.MaxHeight(26)))
                {
                    Application.OpenURL("mailto:[email protected]?subject=OPS/Obfuscator.Free_Bug");
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label((Texture)EditorGUIUtility.Load("Assets/OPS/Obfuscator.Free/Editor/Gui/Header_Icon.png"), GUILayout.MaxWidth(24), GUILayout.MaxHeight(24), GUILayout.MinWidth(24), GUILayout.MinHeight(24));
                Text.GuiBold("Obfuscator", 150, 24);
                GUILayout.EndHorizontal();

                EditorGUILayout.HelpBox("De-/Activate Obfuscator here.", MessageType.Info);

                Row.GuiBold("Obfuscate Globally: ", ref Gui.GuiSettings.ObfuscateGlobally);

                GUILayout.Space(10);

                GUI.enabled = Gui.GuiSettings.ObfuscateGlobally;

                this.tabIndex = GUILayout.Toolbar(this.tabIndex, new Texture[] { (Texture)EditorGUIUtility.Load("Assets/OPS/Obfuscator.Free/Editor/Gui/General_T32x.png"), (Texture)EditorGUIUtility.Load("Assets/OPS/Obfuscator.Free/Editor/Gui/Advanced_T32x.png"), (Texture)EditorGUIUtility.Load("Assets/OPS/Obfuscator.Free/Editor/Gui/Security_T32x.png") });
                switch (this.tabIndex)
                {
                case 0:
                {
                    this.GeneralTab();
                    break;
                }

                case 1:
                {
                    this.AdvancedTab();
                    break;
                }

                case 2:
                {
                    this.SecurityTab();
                    break;
                }
                }

                GUI.enabled = true;

                GUILayout.EndScrollView();

                if (GUI.changed)
                {
                    GuiSettings.SaveSettings();
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.ToString());
                this.Close();
            }
        }
예제 #4
0
        private void OnGUI()
        {
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("选择Avatar:");
            avatar = (Avatar)EditorGUILayout.ObjectField(avatar, typeof(Avatar), true);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            animType = (AnimType)EditorGUILayout.EnumPopup("导出动画类型:", animType);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("资源路径:");
            if (GUILayout.Button(string.IsNullOrEmpty(animresPath) ? "选择路径" : animresPath))
            {
                animresPath = EditorUtility.OpenFolderPanel("资源路径", Application.dataPath, "");
                if (string.IsNullOrEmpty(animresPath))
                {
                    Debug.Log("取消选择路径");
                }
                else
                {
                    animresPath = PathHelper.ABSPath2AssetsPath(animresPath) + "/";
                }
            }
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label("输出路径:");
            if (GUILayout.Button(string.IsNullOrEmpty(outPutPath) ? "选择路径" : outPutPath))
            {
                outPutPath = EditorUtility.OpenFolderPanel("输出路径", Application.dataPath, "");
                if (string.IsNullOrEmpty(outPutPath))
                {
                    Debug.Log("取消选择路径");
                }
                else
                {
                    outPutPath = PathHelper.ABSPath2AssetsPath(outPutPath) + "/";
                }
            }
            GUILayout.EndHorizontal();

            // GUILayout.BeginHorizontal();
            if (GUILayout.Button("导出动画片段"))
            {
                Export();
            }
            if (GUILayout.Button("重命名FBX动画片段"))
            {
                Rename();
            }
            if (GUILayout.Button("清除进度条()"))
            {
                EditorUtility.ClearProgressBar();
            }
            // GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
예제 #5
0
        private void OnGUI()
        {
            GUI.skin = HighLogic.Skin;
            var roster = HighLogic.CurrentGame.CrewRoster;

            GUIContent[] KGendArray = new GUIContent[3] {
                KMale, KFemale, KGRandom
            };
            if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX)
            {
                hasKredits = false;
                ACLevel    = 5;
            }
            if (HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX)
            {
                hasKredits = false;
                ACLevel    = 5;
            }
            if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER)
            {
                hasKredits = true;
                ACLevel    = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);
            }

            GUILayout.BeginArea(_areaRect);
            {
                GUILayout.Label("The Read Panda Placement Services Center"); // Testing Renaming Label Works

                // Gender selection
                GUILayout.BeginHorizontal("box");
                KGender = GUILayout.Toolbar(KGender, KGendArray);
                GUILayout.EndHorizontal();

                // Career selection
                GUILayout.BeginVertical("box");
                KCareer = GUILayout.Toolbar(KCareer, KCareerStrings);
                // Adding a section for 'number/bulk hire' here using the int array kBulk
                if (cbulktest() < 1)
                {
                    GUILayout.Label("Bulk hire Option: You can not hire any more kerbals at this time!");
                }
                else
                {
                    GUILayout.Label("Bulk hire Selector: " + KBulki);
                    KBulk  = GUILayout.HorizontalSlider(KBulk, 1, cbulktest());
                    KBulki = Convert.ToInt32(KBulk);
                }

                GUI.contentColor = basecolor;
                GUILayout.EndVertical();

                // Courage Brains and BadS flag selections
                GUILayout.BeginVertical("box");
                GUILayout.Label("Courage:  " + Math.Truncate(KCourage));
                KCourage = GUILayout.HorizontalSlider(KCourage, 0, 100);
                GUILayout.Label("Stupidity:  " + Math.Truncate(KStupidity));
                KStupidity = GUILayout.HorizontalSlider(KStupidity, 0, 100);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Is this Kerbal Fearless?");
                KFearless = GUILayout.Toggle(KFearless, "Fearless");
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();

                // Level selection
                GUILayout.BeginVertical("box");
                GUILayout.Label("Select Your Level:");

                // If statements for level options
                if (ACLevel == 0)
                {
                    KLevel = GUILayout.Toolbar(KLevel, KLevelStringsZero);
                }
                if (ACLevel == 0.5)
                {
                    KLevel = GUILayout.Toolbar(KLevel, KLevelStringsOne);
                }
                if (ACLevel == 1)
                {
                    KLevel = GUILayout.Toolbar(KLevel, KLevelStringsTwo);
                }
                if (ACLevel == 5)
                {
                    GUILayout.Label("Level 5 - Manditory for Sandbox or Science Mode.");
                }
                GUILayout.EndVertical();

                if (hasKredits == true)
                {
                    GUILayout.BeginHorizontal("window");
                    GUILayout.BeginVertical();
                    GUILayout.FlexibleSpace();
                    if (costMath() <= Funding.Instance.Funds)
                    {
                        GUILayout.Label("Cost: " + costMath(), HighLogic.Skin.textField);
                    }
                    else
                    {
                        GUI.color = Color.red;
                        GUILayout.Label("Insufficient Funds - Cost: " + costMath(), HighLogic.Skin.textField);
                        GUI.color = basecolor;
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                if (hTest)
                {
                    if (GUILayout.Button(hireStatus(), GUILayout.Width(200f)))
                    {
                        kHire();
                    }
                }
                if (!hTest)
                {
                    GUILayout.Button(hireStatus(), GUILayout.Width(200f));
                }

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.EndArea();
            }
        }
예제 #6
0
        // ---------------------------- //
        // Draw GUI
        // ---------------------------- //
        void OnGUI()
        {
            Operation op = Operation.None;
            Sprite spriteToRemove = null;

            // Display selected textures
            // and sprites in output atlas
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Sprites");
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);


            GUILayout.BeginHorizontal();
            GUILayout.Space(3f);
            GUILayout.BeginVertical();

            mScroll = GUILayout.BeginScrollView(mScroll);

            // Show selected texture
            Sprite spriteInAtlas = null;
            foreach (KeyValuePair<Texture2D, string> keyValue in mSelectedTextures) {
                GUILayout.Space(-1f);
                GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                GUILayout.Label(keyValue.Key.name, GUILayout.Height(20f));

                // Display operation
                GUILayout.Label(keyValue.Value, GUILayout.Width(45));
                if (keyValue.Value == TEXTURE_OP_UPDATE) {                    
                    if (GUILayout.Button("X", GUILayout.Width(22f))) {
                        op = Operation.Delete;
                        spriteToRemove = spriteInAtlas;
                    }
                }
                GUILayout.EndHorizontal();
            }

            // Show sprites already in atlas
            foreach (Sprite s in mSpriteList) {
                GUILayout.Space(-1f);
                GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
                GUILayout.Label(s.name, GUILayout.Height(20f));

                // Display operation
                if (GUILayout.Button("X", GUILayout.Width(22f))) {
                    op = Operation.Delete;
                    spriteToRemove = s;
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();


            GUILayout.Space(10f);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Atlas", GUILayout.Width(45));
            // Define output texture
            Texture2D orgTexture = mOutputTexture;
            mOutputTexture = EditorGUILayout.ObjectField(mOutputTexture, typeof(Texture2D), false, GUILayout.MinWidth(200)) as Texture2D;
            if (mOutputTexture != orgTexture) {
                UpdateDisplayList();
            }

            // Display Update or Create button
            if (GUILayout.Button("Create", GUILayout.MaxWidth(80))) {
                op = Operation.Create;
            }

            if (mOutputTexture != null) {
                if (GUILayout.Button("Update", GUILayout.MaxWidth(80))) {
                    op = Operation.Update;
                }
            }
            GUILayout.EndHorizontal();


            // Process required operation
            switch (op) {
                case Operation.None:
                    // Do nothing
                    break;
                case Operation.Create:
                    CreateTexture();
                    break;
                case Operation.Update:
                    UpdateTexture();
                    break;
                case Operation.Delete:
                    DeleteTexture(spriteToRemove);
                    break;
                default:
                    Debug.LogError("Unexpected operation : " + op);
                    break;
            }
        }
예제 #7
0
        void WindowContent(int windowID)
        {
            GUILayout.BeginVertical("box");

            #region angle snap values settings

            try
            {
                foreach (float a in _config.AngleSnapValues)
                {
                    if (a != 0.0f)
                    {
                        GUILayout.BeginHorizontal();

                        if (GUILayout.Button(a.ToString()))
                        {
                            EditorLogic.fetch.srfAttachAngleSnap = a;
                        }
                        GUILayout.EndHorizontal();
                    }
                }
            }
#if DEBUG
            catch (Exception ex)
            {
                //potential for some intermittent locking/threading issues here
                //Debug only to avoid log spam
                Log.Error("Error updating AngleSnapValues: " + ex.Message);
            }
#else
            catch (Exception) {
                //just ignore the error and continue since it's non-critical
            }
#endif


            #endregion

            GUILayout.EndVertical();//end main content

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Close"))
            {
                //reload config to reset any unsaved changes?
                //_config = ConfigManager.LoadConfig (_configFilePath);
                CloseWindow();
            }
#if false
            if (GUILayout.Button("Defaults"))
            {
                _config = ConfigManager.CreateDefaultConfig(_configFilePath, _version);
            }

            if (GUILayout.Button("Save"))
            {
                ConfigManager.SaveConfig(_config, _configFilePath);
                CloseWindow();
            }
#endif
            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }
예제 #8
0
    protected override void DrawProperties()
    {
        SerializedProperty sp = serializedObject.FindProperty("dragHighlight");
        Highlight          ht = sp.boolValue ? Highlight.Press : Highlight.DoNothing;

        GUILayout.BeginHorizontal();
        bool highlight = (Highlight)EditorGUILayout.EnumPopup("Drag Over", ht) == Highlight.Press;

        NGUIEditorTools.DrawPadding();
        GUILayout.EndHorizontal();
        if (sp.boolValue != highlight)
        {
            sp.boolValue = highlight;
        }

        DrawTransition();
        DrawColors();

        UIButton btn = target as UIButton;

        if (btn.tweenTarget != null)
        {
            UISprite   sprite = btn.tweenTarget.GetComponent <UISprite>();
            UI2DSprite s2d    = btn.tweenTarget.GetComponent <UI2DSprite>();

            if (sprite != null)
            {
                if (NGUIEditorTools.DrawHeader("Sprites", "Sprites", false, true))
                {
                    NGUIEditorTools.BeginContents(true);
                    EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
                    {
                        SerializedObject obj = new SerializedObject(sprite);
                        obj.Update();
                        SerializedProperty atlas = obj.FindProperty("mAtlas");
                        NGUIEditorTools.DrawSpriteField("Normal", obj, atlas, obj.FindProperty("mSpriteName"));
                        obj.ApplyModifiedProperties();

                        NGUIEditorTools.DrawSpriteField("Hover", serializedObject, atlas, serializedObject.FindProperty("hoverSprite"), true);
                        NGUIEditorTools.DrawSpriteField("Pressed", serializedObject, atlas, serializedObject.FindProperty("pressedSprite"), true);
                        NGUIEditorTools.DrawSpriteField("Disabled", serializedObject, atlas, serializedObject.FindProperty("disabledSprite"), true);
                    }
                    EditorGUI.EndDisabledGroup();

                    NGUIEditorTools.DrawProperty("Pixel Snap", serializedObject, "pixelSnap");
                    NGUIEditorTools.EndContents();
                }
            }
            else if (s2d != null)
            {
                if (NGUIEditorTools.DrawHeader("Sprites", "Sprites", false, true))
                {
                    NGUIEditorTools.BeginContents(true);
                    EditorGUI.BeginDisabledGroup(serializedObject.isEditingMultipleObjects);
                    {
                        SerializedObject obj = new SerializedObject(s2d);
                        obj.Update();
                        NGUIEditorTools.DrawProperty("Normal", obj, "mSprite");
                        obj.ApplyModifiedProperties();

                        NGUIEditorTools.DrawProperty("Hover", serializedObject, "hoverSprite2D");
                        NGUIEditorTools.DrawProperty("Pressed", serializedObject, "pressedSprite2D");
                        NGUIEditorTools.DrawProperty("Disabled", serializedObject, "disabledSprite2D");
                    }
                    EditorGUI.EndDisabledGroup();

                    NGUIEditorTools.DrawProperty("Pixel Snap", serializedObject, "pixelSnap");
                    NGUIEditorTools.EndContents();
                }
            }
        }

        UIButton button = target as UIButton;

        NGUIEditorTools.DrawEvents("On Click", button, button.onClick, false);
    }
예제 #9
0
        override public void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUILayout.Space(3);
            EditorGUIUtils.SetGUIStyles();

            bool playMode = Application.isPlaying;

            _runtimeEditMode = _runtimeEditMode && playMode;

            GUILayout.BeginHorizontal();
            EditorGUIUtils.InspectorLogo();
            GUILayout.Label(_src.animationType.ToString() + (string.IsNullOrEmpty(_src.id) ? "" : " [" + _src.id + "]"), EditorGUIUtils.sideLogoIconBoldLabelStyle);
            // Up-down buttons
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("▲", DeGUI.styles.button.toolIco))
            {
                UnityEditorInternal.ComponentUtility.MoveComponentUp(_src);
            }
            if (GUILayout.Button("▼", DeGUI.styles.button.toolIco))
            {
                UnityEditorInternal.ComponentUtility.MoveComponentDown(_src);
            }
            GUILayout.EndHorizontal();

            if (playMode)
            {
                if (_runtimeEditMode)
                {
                }
                else
                {
                    GUILayout.Space(8);
                    GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle);
                    if (!_src.isActive)
                    {
                        GUILayout.Label("This animation has been toggled as inactive and won't be generated", EditorGUIUtils.wordWrapLabelStyle);
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button(new GUIContent("Activate Edit Mode", "Switches to Runtime Edit Mode, where you can change animations values and restart them")))
                    {
                        _runtimeEditMode = true;
                    }
                    GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle);
                    GUILayout.Space(10);
                    if (!_runtimeEditMode)
                    {
                        return;
                    }
                }
            }

            Undo.RecordObject(_src, "DOTween Animation");

//            _src.isValid = Validate(); // Moved down

            EditorGUIUtility.labelWidth = 110;

            if (playMode)
            {
                GUILayout.Space(4);
                DeGUILayout.Toolbar("Edit Mode Commands");
                DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("TogglePause"))
                {
                    _src.tween.TogglePause();
                }
                if (GUILayout.Button("Rewind"))
                {
                    _src.tween.Rewind();
                }
                if (GUILayout.Button("Restart"))
                {
                    _src.tween.Restart();
                }
                GUILayout.EndHorizontal();
                if (GUILayout.Button("Commit changes and restart"))
                {
                    _src.tween.Rewind();
                    _src.tween.Kill();
                    if (_src.isValid)
                    {
                        _src.CreateTween();
                        _src.tween.Play();
                    }
                }
                GUILayout.Label("To apply your changes when exiting Play mode, use the Component's upper right menu and choose \"Copy Component\", then \"Paste Component Values\" after exiting Play mode", DeGUI.styles.label.wordwrap);
                DeGUILayout.EndVBox();
            }
            else
            {
                bool hasManager = _src.GetComponent <DOTweenVisualManager>() != null;
                if (!hasManager)
                {
                    if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject")))
                    {
                        _src.gameObject.AddComponent <DOTweenVisualManager>();
                    }
                }
            }

            GUILayout.BeginHorizontal();
            DOTweenAnimationType prevAnimType = _src.animationType;

//                _src.animationType = (DOTweenAnimationType)EditorGUILayout.EnumPopup(_src.animationType, EditorGUIUtils.popupButton);
            _src.isActive      = EditorGUILayout.Toggle(new GUIContent("", "If unchecked, this animation will not be created"), _src.isActive, GUILayout.Width(16));
            GUI.enabled        = _src.isActive;
            _src.animationType = AnimationToDOTweenAnimationType(_AnimationType[EditorGUILayout.Popup(DOTweenAnimationTypeToPopupId(_src.animationType), _AnimationType)]);
            _src.autoPlay      = DeGUILayout.ToggleButton(_src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically"));
            _src.autoKill      = DeGUILayout.ToggleButton(_src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable"));
            GUILayout.EndHorizontal();
            if (prevAnimType != _src.animationType)
            {
                // Set default optional values based on animation type
                _src.endValueTransform = null;
                _src.useTargetAsV3     = false;
                switch (_src.animationType)
                {
                case DOTweenAnimationType.Move:
                case DOTweenAnimationType.LocalMove:
                case DOTweenAnimationType.Rotate:
                case DOTweenAnimationType.LocalRotate:
                case DOTweenAnimationType.Scale:
                    _src.endValueV3    = Vector3.zero;
                    _src.endValueFloat = 0;
                    _src.optionalBool0 = _src.animationType == DOTweenAnimationType.Scale;
                    break;

                case DOTweenAnimationType.UIWidthHeight:
                    _src.endValueV3    = Vector3.zero;
                    _src.endValueFloat = 0;
                    _src.optionalBool0 = _src.animationType == DOTweenAnimationType.UIWidthHeight;
                    break;

                case DOTweenAnimationType.Color:
                case DOTweenAnimationType.Fade:
                    _isLightSrc        = _src.GetComponent <Light>() != null;
                    _src.endValueFloat = 0;
                    break;

                case DOTweenAnimationType.Text:
                    _src.optionalBool0 = true;
                    break;

                case DOTweenAnimationType.PunchPosition:
                case DOTweenAnimationType.PunchRotation:
                case DOTweenAnimationType.PunchScale:
                    _src.endValueV3     = _src.animationType == DOTweenAnimationType.PunchRotation ? new Vector3(0, 180, 0) : Vector3.one;
                    _src.optionalFloat0 = 1;
                    _src.optionalInt0   = 10;
                    _src.optionalBool0  = false;
                    break;

                case DOTweenAnimationType.ShakePosition:
                case DOTweenAnimationType.ShakeRotation:
                case DOTweenAnimationType.ShakeScale:
                    _src.endValueV3     = _src.animationType == DOTweenAnimationType.ShakeRotation ? new Vector3(90, 90, 90) : Vector3.one;
                    _src.optionalInt0   = 10;
                    _src.optionalFloat0 = 90;
                    _src.optionalBool0  = false;
                    break;

                case DOTweenAnimationType.CameraAspect:
                case DOTweenAnimationType.CameraFieldOfView:
                case DOTweenAnimationType.CameraOrthoSize:
                    _src.endValueFloat = 0;
                    break;

                case DOTweenAnimationType.CameraPixelRect:
                case DOTweenAnimationType.CameraRect:
                    _src.endValueRect = new Rect(0, 0, 0, 0);
                    break;
                }
            }
            if (_src.animationType == DOTweenAnimationType.None)
            {
                _src.isValid = false;
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(_src);
                }
                return;
            }

            if (prevAnimType != _src.animationType || ComponentsChanged())
            {
                _src.isValid = Validate();
                // See if we need to choose between multiple targets
                if (_src.animationType == DOTweenAnimationType.Fade && _src.GetComponent <CanvasGroup>() != null && _src.GetComponent <Image>() != null)
                {
                    _chooseTargetMode = ChooseTargetMode.BetweenCanvasGroupAndImage;
                    // Reassign target and forcedTargetType if lost
                    if (_src.forcedTargetType == TargetType.Unset)
                    {
                        _src.forcedTargetType = _src.targetType;
                    }
                    switch (_src.forcedTargetType)
                    {
                    case TargetType.CanvasGroup:
                        _src.target = _src.GetComponent <CanvasGroup>();
                        break;

                    case TargetType.Image:
                        _src.target = _src.GetComponent <Image>();
                        break;
                    }
                }
                else
                {
                    _chooseTargetMode     = ChooseTargetMode.None;
                    _src.forcedTargetType = TargetType.Unset;
                }
            }

            if (!_src.isValid)
            {
                GUI.color = Color.red;
                GUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label("No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle);
                GUILayout.EndVertical();
                GUI.color = Color.white;
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(_src);
                }
                return;
            }

            // Special cases in which multiple target types could be used (set after validation)
            if (_chooseTargetMode == ChooseTargetMode.BetweenCanvasGroupAndImage && _src.forcedTargetType != TargetType.Unset)
            {
                FadeTargetType fadeTargetType = (FadeTargetType)Enum.Parse(typeof(FadeTargetType), _src.forcedTargetType.ToString());
                TargetType     prevTargetType = _src.forcedTargetType;
                _src.forcedTargetType = (TargetType)Enum.Parse(typeof(TargetType), EditorGUILayout.EnumPopup(_src.animationType + " Target", fadeTargetType).ToString());
                if (_src.forcedTargetType != prevTargetType)
                {
                    // Target type change > assign correct target
                    switch (_src.forcedTargetType)
                    {
                    case TargetType.CanvasGroup:
                        _src.target = _src.GetComponent <CanvasGroup>();
                        break;

                    case TargetType.Image:
                        _src.target = _src.GetComponent <Image>();
                        break;
                    }
                }
            }

            GUILayout.BeginHorizontal();
            _src.duration = EditorGUILayout.FloatField("Duration", _src.duration);
            if (_src.duration < 0)
            {
                _src.duration = 0;
            }
            _src.isSpeedBased = DeGUILayout.ToggleButton(_src.isSpeedBased, new GUIContent("SpeedBased", "If selected, the duration will count as units/degree x second"), DeGUI.styles.button.tool, GUILayout.Width(75));
            GUILayout.EndHorizontal();
            _src.delay = EditorGUILayout.FloatField("Delay", _src.delay);
            if (_src.delay < 0)
            {
                _src.delay = 0;
            }
            _src.isIndependentUpdate = EditorGUILayout.Toggle("Ignore TimeScale", _src.isIndependentUpdate);
            _src.easeType            = EditorGUIUtils.FilteredEasePopup(_src.easeType);
            if (_src.easeType == Ease.INTERNAL_Custom)
            {
                _src.easeCurve = EditorGUILayout.CurveField("   Ease Curve", _src.easeCurve);
            }
            _src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), _src.loops);
            if (_src.loops < -1)
            {
                _src.loops = -1;
            }
            if (_src.loops > 1 || _src.loops == -1)
            {
                _src.loopType = (LoopType)EditorGUILayout.EnumPopup("   Loop Type", _src.loopType);
            }
            _src.id = EditorGUILayout.TextField("ID", _src.id);

            bool canBeRelative = true;

            // End value and eventual specific options
            switch (_src.animationType)
            {
            case DOTweenAnimationType.Move:
            case DOTweenAnimationType.LocalMove:
                GUIEndValueV3(_src.animationType == DOTweenAnimationType.Move);
                _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                canBeRelative      = !_src.useTargetAsV3;
                break;

            case DOTweenAnimationType.Rotate:
            case DOTweenAnimationType.LocalRotate:
                if (_src.GetComponent <Rigidbody2D>())
                {
                    GUIEndValueFloat();
                }
                else
                {
                    GUIEndValueV3();
                    _src.optionalRotationMode = (RotateMode)EditorGUILayout.EnumPopup("    Rotation Mode", _src.optionalRotationMode);
                }
                break;

            case DOTweenAnimationType.Scale:
                if (_src.optionalBool0)
                {
                    GUIEndValueFloat();
                }
                else
                {
                    GUIEndValueV3();
                }
                _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0);
                break;

            case DOTweenAnimationType.UIWidthHeight:
                if (_src.optionalBool0)
                {
                    GUIEndValueFloat();
                }
                else
                {
                    GUIEndValueV2();
                }
                _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0);
                break;

            case DOTweenAnimationType.Color:
                GUIEndValueColor();
                canBeRelative = false;
                break;

            case DOTweenAnimationType.Fade:
                GUIEndValueFloat();
                if (_src.endValueFloat < 0)
                {
                    _src.endValueFloat = 0;
                }
                if (!_isLightSrc && _src.endValueFloat > 1)
                {
                    _src.endValueFloat = 1;
                }
                canBeRelative = false;
                break;

            case DOTweenAnimationType.Text:
                GUIEndValueString();
                _src.optionalBool0        = EditorGUILayout.Toggle("Rich Text Enabled", _src.optionalBool0);
                _src.optionalScrambleMode = (ScrambleMode)EditorGUILayout.EnumPopup("Scramble Mode", _src.optionalScrambleMode);
                _src.optionalString       = EditorGUILayout.TextField(new GUIContent("Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString);
                break;

            case DOTweenAnimationType.PunchPosition:
            case DOTweenAnimationType.PunchRotation:
            case DOTweenAnimationType.PunchScale:
                GUIEndValueV3();
                canBeRelative       = false;
                _src.optionalInt0   = EditorGUILayout.IntSlider(new GUIContent("    Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50);
                _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent("    Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1);
                if (_src.animationType == DOTweenAnimationType.PunchPosition)
                {
                    _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                }
                break;

            case DOTweenAnimationType.ShakePosition:
            case DOTweenAnimationType.ShakeRotation:
            case DOTweenAnimationType.ShakeScale:
                GUIEndValueV3();
                canBeRelative       = false;
                _src.optionalInt0   = EditorGUILayout.IntSlider(new GUIContent("    Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50);
                _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent("    Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90);
                if (_src.animationType == DOTweenAnimationType.ShakePosition)
                {
                    _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                }
                break;

            case DOTweenAnimationType.CameraAspect:
            case DOTweenAnimationType.CameraFieldOfView:
            case DOTweenAnimationType.CameraOrthoSize:
                GUIEndValueFloat();
                canBeRelative = false;
                break;

            case DOTweenAnimationType.CameraBackgroundColor:
                GUIEndValueColor();
                canBeRelative = false;
                break;

            case DOTweenAnimationType.CameraPixelRect:
            case DOTweenAnimationType.CameraRect:
                GUIEndValueRect();
                canBeRelative = false;
                break;
            }

            // Final settings
            if (canBeRelative)
            {
                _src.isRelative = EditorGUILayout.Toggle("    Relative", _src.isRelative);
            }


            // Events   注释掉,不需要事件的编辑窗口
//            AnimationInspectorGUI.AnimationEvents(this, _src);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_src);
            }
        }
예제 #10
0
		private void OnGUI ()
		{
			Color 	_oldColor 		= GUI.backgroundColor;

			// ******************
			// Menu Display
			// ******************
			GUILayout.BeginHorizontal();
			{
				for (int _iter = 0; _iter < kCompilerCount; _iter++)	
				{
					if (_iter == (int)m_compiler)
						GUI.backgroundColor = Color.gray;
					
					GUIStyle _style;

					switch(_iter)
					{
					case 0:
						_style = EditorStyles.miniButtonLeft;
						break;
					case (kCompilerCount - 1):
						_style = EditorStyles.miniButtonRight;
						break;
					default:
						_style = EditorStyles.miniButtonMid;
						break;
					}

					GlobalDefinesManager.eCompiler	_compiler	= (GlobalDefinesManager.eCompiler)_iter;

					if (GUILayout.Button(_compiler.ToString(), _style))
					{
						m_compiler	= _compiler;
					}
					
					GUI.backgroundColor = _oldColor;
				}
			}
			GUILayout.EndHorizontal();

			// ******************
			// Content Display
			// ******************
			GUILayout.Label(m_compiler.ToString() + " User Defines");
			
			m_scrollPostion	 				= GUILayout.BeginScrollView(m_scrollPostion);
			{
				List<string>	_definesList	= m_definesManager.GetDefinesList(m_compiler);

				for (int _iter = 0; _iter < _definesList.Count; _iter++)
				{
					GUILayout.BeginHorizontal();
					{
						_definesList[_iter] = EditorGUILayout.TextField(_definesList[_iter]);
						
						GUI.backgroundColor = Color.red;
						if (GUILayout.Button("x", GUIStyle.none, GUILayout.MaxWidth(18)))
							_definesList.RemoveAt(_iter);
						
						GUI.backgroundColor = _oldColor;
					}
					GUILayout.EndHorizontal();
				}
				
				GUILayout.Space(4);
				
				GUI.backgroundColor 	= Color.cyan;

				if (GUILayout.Button("Add"))	
					m_definesManager.AddNewDefineSymbol(m_compiler, "NEW_DEFINE");
			}
			GUILayout.EndScrollView();
			
			GUILayout.BeginHorizontal();
			{
				GUI.backgroundColor = Color.green;

				if (GUILayout.Button("Apply"))
				{
					m_definesManager.SaveCompiler(m_compiler);
				}
			
				GUI.backgroundColor = Color.red;
			
				if (GUILayout.Button("Apply All", GUILayout.MaxWidth(64)))
				{
					m_definesManager.SetAllCompilerDefines(m_compiler);
					m_definesManager.SaveAllCompilers();
				}
			}
			GUILayout.EndHorizontal();

			GUI.backgroundColor = _oldColor;
		}
예제 #11
0
        public static void OnSceneTreeReflectIEnumerable(SceneExplorerState state, ReferenceChain refChain, object myProperty, TypeUtil.SmartType elementSmartType = TypeUtil.SmartType.Undefined)
        {
            if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain))
            {
                return;
            }

            if (!(myProperty is IEnumerable enumerable))
            {
                return;
            }

            uint count       = 0;
            var  oldRefChain = refChain;

            foreach (var value in enumerable)
            {
                refChain = oldRefChain.Add(count);

                GUILayout.BeginHorizontal(GUIWindow.HighlightStyle);
                SceneExplorerCommon.InsertIndent(refChain.Indentation);

                var type = value?.GetType();
                if (type != null)
                {
                    GUIExpander.ExpanderControls(state, refChain, type);

                    GUI.contentColor = MainWindow.Instance.Config.TypeColor;

                    GUILayout.Label(type.ToString() + " ");
                }

                GUI.contentColor = MainWindow.Instance.Config.NameColor;

                GUILayout.Label($"{oldRefChain.LastItemName}.[{count}]");

                GUI.contentColor = Color.white;

                GUILayout.Label(" = ");

                GUI.contentColor = MainWindow.Instance.Config.ValueColor;

                GUILayout.Label(value == null ? "null" : value.ToString());

                GUI.contentColor = Color.white;

                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                if (type != null && !TypeUtil.IsSpecialType(type) && state.ExpandedObjects.Contains(refChain.UniqueId))
                {
                    GUIReflect.OnSceneTreeReflect(state, refChain, value, false, elementSmartType, string.Empty);
                }

                count++;
                if (count >= 128)
                {
                    SceneExplorerCommon.OnSceneTreeMessage(refChain, "Enumerable too large to display");
                    break;
                }
            }
        }
예제 #12
0
    public static bool EditFsmXpathQueryVariablesProperties(Fsm fsm, FsmXpathQuery target)
    {
        if (target == null)
        {
            target = new FsmXpathQuery();
        }

        bool edited = false;

        int count = 0;

        if (target.xPathVariables != null)
        {
            count = target.xPathVariables.Length;

            for (int i = 0; i < count; i++)
            {
                GUILayout.BeginHorizontal();

                bool fsmVariableChangedFlag;
                target.xPathVariables[i] = PlayMakerInspectorUtils.EditorGUILayout_FsmVarPopup("Variable _" + i + "_", fsm.Variables.GetAllNamedVariables(), target.xPathVariables[i], out fsmVariableChangedFlag);

                // PlayMaker api is now not working on 1.8 and shoudl become private
                //target.xPathVariables[i] = VariableEditor.FsmVarPopup(new GUIContent("Variable _"+i+"_"),fsm,target.xPathVariables[i]);

                edited = edited || fsmVariableChangedFlag;

                if (i + 1 == count)
                {
                    if (FsmEditorGUILayout.DeleteButton())
                    {
                        ArrayUtility.RemoveAt(ref target.xPathVariables, i);
                        return(true);                        // we must not continue, an entry is going to be deleted so the loop is broken here. next OnGui, all will be well.
                    }
                }
                else
                {
                    GUILayout.Space(21);
                }
                GUILayout.EndHorizontal();
            }
        }

        string _addButtonLabel = "Add a variable";

        if (count > 0)
        {
            _addButtonLabel = "Add another variable";
        }

        GUILayout.BeginHorizontal();
        GUILayout.Space(154);

        if (GUILayout.Button(_addButtonLabel))
        {
            if (target.xPathVariables == null)
            {
                target.xPathVariables = new FsmVar[0];
            }


            ArrayUtility.Add <FsmVar>(ref target.xPathVariables, new FsmVar());
            edited = true;
        }
        GUILayout.Space(21);
        GUILayout.EndHorizontal();

        return(edited || GUI.changed);
    }
예제 #13
0
    public static bool EditFsmXmlPropertiesTypes(Fsm fsm, FsmXmlPropertiesTypes target)
    {
        FsmEditorGUILayout.LightDivider();


        bool edited = false;

        int count = 0;

        if (target.properties != null && target.propertiesTypes != null)
        {
            count = target.properties.Length;


                        #if PLAYMAKER_1_8_OR_NEWER
            FieldInfo _fsmStringArray_FieldInfo = target.GetType().GetField("properties");
                        #endif


            for (int i = 0; i < count; i++)
            {
                GUILayout.BeginHorizontal();

                GUILayout.Label("Property item " + i);
                GUILayout.FlexibleSpace();


                if (FsmEditorGUILayout.DeleteButton())
                {
                    ArrayUtility.RemoveAt(ref target.properties, i);
                    ArrayUtility.RemoveAt(ref target.propertiesTypes, i);
                    return(true);                            // we must not continue, an entry is going to be deleted so the loop is broken here. next OnGui, all will be well.
                }

                GUILayout.EndHorizontal();

                                #if PLAYMAKER_1_8_OR_NEWER
                //PlayMakerInspectorUtils.SetActionEditorArrayVariableSelectionContext(target,i,_fsmStringArray_FieldInfo);
                                #endif

                target.properties[i]      = VariableEditor.FsmStringField(new GUIContent("Property"), fsm, target.properties[i], null);
                target.propertiesTypes[i] = (VariableType)EditorGUILayout.EnumPopup(new GUIContent("Type"), target.propertiesTypes[i]);
            }
        }

        string _addButtonLabel = "Define a Property";

        if (count > 0)
        {
            _addButtonLabel = "Define another Property";
        }

        GUILayout.BeginHorizontal();
        GUILayout.Space(154);

        if (GUILayout.Button(_addButtonLabel))
        {
            if (target.properties == null)
            {
                target.properties      = new FsmString[0];
                target.propertiesTypes = new VariableType[0];
            }


            ArrayUtility.Add <FsmString>(ref target.properties, new FsmString());
            ArrayUtility.Add <VariableType>(ref target.propertiesTypes, VariableType.Float);
            edited = true;
        }
        GUILayout.Space(21);
        GUILayout.EndHorizontal();

        return(edited || GUI.changed);
    }
    public void OnGUI()
    {
        if (!didInit)
        {
            saveLoadName = currentName;
            didInit      = true;
        }

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();

        // change saveLoadName with text area
        GUIStyle s = new GUIStyle(GUI.skin.textField);

        s.alignment = TextAnchor.UpperCenter;
        // name the control
        GUI.SetNextControlName("save_load_input_control");
        saveLoadName = GUILayout.TextField(saveLoadName, s, GUILayout.Width(120));

        if (GUILayout.Button("Save", GUILayout.Width(50)) && saveLoadName != "")
        {
            if (onSave != null)
            {
                onSave(saveLoadName);
            }
        }
        GUILayout.EndHorizontal();

        // load
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Load " + (_isLoadDialogue ? "↑" : "↓"), GUILayout.Width(50)))
        {
            _isLoadDialogue = !_isLoadDialogue;
        }
        GUILayout.EndHorizontal();


        Vector2 tmpScrollPosition = GUILayout.BeginScrollView(scrollPosition);

        if (_isLoadDialogue)
        {
            scrollPosition = tmpScrollPosition;

            foreach (string name in fileNames)
            {
                Color origColor = GUI.color;

                if (name == currentName)
                {
                    GUI.color = Color.cyan;
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(name, GUI.skin.box))
                {
                    onLoad(name);
                }

                GUI.color = origColor;
                GUILayout.EndHorizontal();
            }
        }
        GUILayout.EndScrollView();
    }
        protected override void OnGUIContent()
        {
            BeginColumns();

            // COLUMN 1

            BeginColumn(400);

            GUILayout.BeginHorizontal();
            FormLabel("Slug:", 40);
            FormLabel(text.slug, 300);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            FormLabel("Color:", 40);
            text.SetColor(FormColorField(text.GetColor(), 150));
            GUILayout.EndHorizontal();

            EndColumn();

            // COLUMN 2
            BeginColumn(300);

            GUILayout.BeginHorizontal();
            FormLabel("Syntheses:", 80);
            FormLabel(text.character_syntheses_count.ToString(), 40);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("View all", GUILayout.ExpandWidth(false)))
            {
                ViewHistory();
            }
            GUILayout.Space(10);
            if (GUILayout.Button("Resynthesize", GUILayout.ExpandWidth(false)))
            {
                Resynthesize();
                Close();
            }
            GUILayout.EndHorizontal();

            EndColumn();

            EndColumns();

            // MAIN SYNTHESIS

            BeginCenter();
            H2("Main synthesis");
            EndCenter();

            OnGUIContentMainSynthesis();

            // OTHER SYNTHESES

            BeginCenter();
            H2($"Latest other {LATEST_CHARACTER_SYNTHESES_COUNT} syntheses");
            EndCenter();

            OnGUIContentOtherSyntheses();
        }
예제 #16
0
    public void ShowGUI()
    {
        GUILayout.Label("Basic structure", EditorStyles.boldLabel);

        if (GUILayout.Button("Organise room objects"))
        {
            InitialiseObjects();
        }

        gameEngine = GameObject.FindWithTag(Tags.gameEngine);
        if (gameEngine)
        {
            GUILayout.BeginHorizontal();
            newFolderName = GUILayout.TextField(newFolderName);

            if (GUILayout.Button("Create new folder", buttonWidth))
            {
                if (newFolderName != "")
                {
                    Undo.RegisterSceneUndo("Create new folder");

                    GameObject newFolder = new GameObject();

                    if (!newFolderName.StartsWith("_"))
                    {
                        newFolder.name = "_" + newFolderName;
                    }
                    else
                    {
                        newFolder.name = newFolderName;
                    }

                    if (Selection.activeGameObject)
                    {
                        newFolder.transform.parent = Selection.activeGameObject.transform;
                    }

                    Selection.activeObject = newFolder;
                }
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            GUILayout.Label("Scene settings", EditorStyles.boldLabel);
            if (gameEngine.GetComponent <SceneSettings>())
            {
                gameEngine.GetComponent <SceneSettings>().navMesh            = (NavigationMesh)EditorGUILayout.ObjectField("Default NavMesh", gameEngine.GetComponent <SceneSettings>().navMesh, typeof(NavigationMesh), true);
                gameEngine.GetComponent <SceneSettings>().cutsceneOnStart    = (Cutscene)EditorGUILayout.ObjectField("Cutscene on start", gameEngine.GetComponent <SceneSettings>().cutsceneOnStart, typeof(Cutscene), true);
                gameEngine.GetComponent <SceneSettings>().cutsceneOnLoad     = (Cutscene)EditorGUILayout.ObjectField("Cutscene on load", gameEngine.GetComponent <SceneSettings>().cutsceneOnLoad, typeof(Cutscene), true);
                gameEngine.GetComponent <SceneSettings>().defaultPlayerStart = (PlayerStart)EditorGUILayout.ObjectField("Default PlayerStart", gameEngine.GetComponent <SceneSettings>().defaultPlayerStart, typeof(PlayerStart), true);
            }
            EditorGUILayout.Space();

            GUILayout.Label("Visibility", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Triggers", buttonWidth);
            if (GUILayout.Button("On"))
            {
                SetTriggerVisibility(true);
            }
            if (GUILayout.Button("Off"))
            {
                SetTriggerVisibility(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Collision", buttonWidth);
            if (GUILayout.Button("On"))
            {
                SetCollisionVisiblity(true);
            }
            if (GUILayout.Button("Off"))
            {
                SetCollisionVisiblity(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Hotspots", buttonWidth);
            if (GUILayout.Button("On"))
            {
                SetHotspotVisibility(true);
            }
            if (GUILayout.Button("Off"))
            {
                SetHotspotVisibility(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.Label("Create new object", EditorStyles.boldLabel);

            GUILayout.Label("Camera", EditorStyles.boldLabel);
            PrefabButton("Camera", "GameCamera");

            GUILayout.Label("Logic", EditorStyles.boldLabel);
            PrefabButton("Logic", "ArrowPrompt");
            PrefabButton("Logic", "Conversation");
            PrefabButton("Logic", "Cutscene");
            PrefabButton("Logic", "DialogueOption");
            PrefabButton("Logic", "Hotspot");
            PrefabButton("Logic", "Interaction");
            PrefabButton("Logic", "Sound");
            PrefabButton("Logic", "Trigger");

            GUILayout.Label("Navigation", EditorStyles.boldLabel);
            PrefabButton("Navigation", "CollisionCube");
            PrefabButton("Navigation", "CollisionCylinder");
            PrefabButton("Navigation", "Marker");
            PrefabButton("Navigation", "NavMesh");
            PrefabButton("Navigation", "Path");
            PrefabButton("Navigation", "PlayerStart");

            if (GUI.changed)
            {
                EditorUtility.SetDirty(gameEngine.GetComponent <SceneSettings>());
                EditorUtility.SetDirty(gameEngine.GetComponent <PlayerMovement>());
            }
        }
    }
예제 #17
0
    /// <summary>
    /// Draw the label's properties.
    /// </summary>

    protected override bool ShouldDrawProperties()
    {
        mLabel = mWidget as UILabel;

        GUILayout.BeginHorizontal();

#if DYNAMIC_FONT
        mFontType = (FontType)EditorGUILayout.EnumPopup(mFontType, "DropDown", GUILayout.Width(74f));
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(64f)))
#else
        mFontType = FontType.NGUI;
        if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(74f)))
#endif
        {
            if (mFontType == FontType.NGUI)
            {
                ComponentSelector.Show <UIFont>(OnNGUIFont);
            }
            else
            {
                ComponentSelector.Show <Font>(OnUnityFont, new string[] { ".ttf", ".otf" });
            }
        }

        bool isValid           = false;
        SerializedProperty fnt = null;
        SerializedProperty ttf = null;

        if (mFontType == FontType.NGUI)
        {
            fnt = NGUIEditorTools.DrawProperty("", serializedObject, "mFont", GUILayout.MinWidth(40f));

            if (fnt.objectReferenceValue != null)
            {
                NGUISettings.ambigiousFont = fnt.objectReferenceValue;
                isValid = true;
            }
        }
        else
        {
            ttf = NGUIEditorTools.DrawProperty("", serializedObject, "mTrueTypeFont", GUILayout.MinWidth(40f));

            if (ttf.objectReferenceValue != null)
            {
                NGUISettings.ambigiousFont = ttf.objectReferenceValue;
                isValid = true;
            }
        }

        GUILayout.EndHorizontal();

        if (mFontType == FontType.Unity)
        {
            EditorGUILayout.HelpBox("Dynamic fonts suffer from issues in Unity itself where your characters may disappear, get garbled, or just not show at times. Use this feature at your own risk.\n\n" +
                                    "When you do run into such issues, please submit a Bug Report to Unity via Help -> Report a Bug (as this is will be a Unity bug, not an NGUI one).", MessageType.Warning);
        }

        EditorGUI.BeginDisabledGroup(!isValid);
        {
            UIFont uiFont  = (fnt != null) ? fnt.objectReferenceValue as UIFont : null;
            Font   dynFont = (ttf != null) ? ttf.objectReferenceValue as Font : null;

            if (uiFont != null && uiFont.isDynamic)
            {
                dynFont = uiFont.dynamicFont;
                uiFont  = null;
            }

            if (dynFont != null)
            {
                GUILayout.BeginHorizontal();
                {
                    EditorGUI.BeginDisabledGroup((ttf != null) ? ttf.hasMultipleDifferentValues : fnt.hasMultipleDifferentValues);

                    SerializedProperty prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));
                    NGUISettings.fontSize = prop.intValue;

                    prop = NGUIEditorTools.DrawProperty("", serializedObject, "mFontStyle", GUILayout.MinWidth(40f));
                    NGUISettings.fontStyle = (FontStyle)prop.intValue;

                    NGUIEditorTools.DrawPadding();
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();

                NGUIEditorTools.DrawProperty("Material", serializedObject, "mMaterial");
            }
            else if (uiFont != null)
            {
                GUILayout.BeginHorizontal();
                SerializedProperty prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));

                EditorGUI.BeginDisabledGroup(true);
                if (!serializedObject.isEditingMultipleObjects)
                {
                    GUILayout.Label(" Default: " + mLabel.defaultFontSize);
                }
                EditorGUI.EndDisabledGroup();

                NGUISettings.fontSize = prop.intValue;
                GUILayout.EndHorizontal();
            }

            bool ww = GUI.skin.textField.wordWrap;
            GUI.skin.textField.wordWrap = true;
            SerializedProperty sp = serializedObject.FindProperty("mText");

            if (sp.hasMultipleDifferentValues)
            {
                NGUIEditorTools.DrawProperty("", sp, GUILayout.Height(128f));
            }
            else
            {
                GUIStyle style = new GUIStyle(EditorStyles.textField);
                style.wordWrap = true;

                float height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 100f);
                bool  offset = true;

                if (height > 90f)
                {
                    offset = false;
                    height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 20f);
                }
                else
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.BeginVertical(GUILayout.Width(76f));
                    GUILayout.Space(3f);
                    GUILayout.Label("Text");
                    GUILayout.EndVertical();
                    GUILayout.BeginVertical();
                }
                Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(height));

                GUI.changed = false;
                string text = EditorGUI.TextArea(rect, sp.stringValue, style);
                if (GUI.changed)
                {
                    sp.stringValue = text;
                }

                if (offset)
                {
                    GUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
            }

            GUI.skin.textField.wordWrap = ww;

            SerializedProperty ov = NGUIEditorTools.DrawPaddedProperty("Overflow", serializedObject, "mOverflow");
            NGUISettings.overflowStyle = (UILabel.Overflow)ov.intValue;

            NGUIEditorTools.DrawPaddedProperty("Alignment", serializedObject, "mAlignment");

            if (dynFont != null)
            {
                NGUIEditorTools.DrawPaddedProperty("Keep crisp", serializedObject, "keepCrispWhenShrunk");
            }

            EditorGUI.BeginDisabledGroup(mLabel.bitmapFont != null && mLabel.bitmapFont.packedFontShader);
            GUILayout.BeginHorizontal();
            SerializedProperty gr = NGUIEditorTools.DrawProperty("Gradient", serializedObject, "mApplyGradient",
                                                                 GUILayout.Width(95f));

            EditorGUI.BeginDisabledGroup(!gr.hasMultipleDifferentValues && !gr.boolValue);
            {
                NGUIEditorTools.SetLabelWidth(30f);
                NGUIEditorTools.DrawProperty("Top", serializedObject, "mGradientTop", GUILayout.MinWidth(40f));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                NGUIEditorTools.SetLabelWidth(50f);
                GUILayout.Space(79f);

                NGUIEditorTools.DrawProperty("Bottom", serializedObject, "mGradientBottom", GUILayout.MinWidth(40f));
                NGUIEditorTools.SetLabelWidth(80f);
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Effect", GUILayout.Width(76f));
            sp = NGUIEditorTools.DrawProperty("", serializedObject, "mEffectStyle", GUILayout.MinWidth(16f));

            EditorGUI.BeginDisabledGroup(!sp.hasMultipleDifferentValues && !sp.boolValue);
            {
                NGUIEditorTools.DrawProperty("", serializedObject, "mEffectColor", GUILayout.MinWidth(10f));
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label(" ", GUILayout.Width(56f));
                    NGUIEditorTools.SetLabelWidth(20f);
                    NGUIEditorTools.DrawProperty("X", serializedObject, "mEffectDistance.x", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawProperty("Y", serializedObject, "mEffectDistance.y", GUILayout.MinWidth(40f));
                    NGUIEditorTools.DrawPadding();
                    NGUIEditorTools.SetLabelWidth(80f);
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            sp = NGUIEditorTools.DrawProperty("Float spacing", serializedObject, "mUseFloatSpacing", GUILayout.Width(100f));

            if (!sp.boolValue)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Spacing", GUILayout.Width(56f));
                NGUIEditorTools.SetLabelWidth(20f);
                NGUIEditorTools.DrawProperty("X", serializedObject, "mSpacingX", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawProperty("Y", serializedObject, "mSpacingY", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawPadding();
                NGUIEditorTools.SetLabelWidth(80f);
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Spacing", GUILayout.Width(56f));
                NGUIEditorTools.SetLabelWidth(20f);
                NGUIEditorTools.DrawProperty("X", serializedObject, "mFloatSpacingX", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawProperty("Y", serializedObject, "mFloatSpacingY", GUILayout.MinWidth(40f));
                NGUIEditorTools.DrawPadding();
                NGUIEditorTools.SetLabelWidth(80f);
                GUILayout.EndHorizontal();
            }

            NGUIEditorTools.DrawProperty("Max Lines", serializedObject, "mMaxLineCount", GUILayout.Width(110f));

            GUILayout.BeginHorizontal();
            sp = NGUIEditorTools.DrawProperty("BBCode", serializedObject, "mEncoding", GUILayout.Width(100f));
            EditorGUI.BeginDisabledGroup(!sp.boolValue || mLabel.bitmapFont == null || !mLabel.bitmapFont.hasSymbols);
            NGUIEditorTools.SetLabelWidth(60f);
            NGUIEditorTools.DrawPaddedProperty("Symbols", serializedObject, "mSymbols");
            NGUIEditorTools.SetLabelWidth(80f);
            EditorGUI.EndDisabledGroup();
            GUILayout.EndHorizontal();
        }
        EditorGUI.EndDisabledGroup();
        return(isValid);
    }
    void OnGUI()
    {
        //if (isPaused)
        //{
        //    //If the button is pressed then isPaused becomes false so the game resumes. (Translated from French)
        //    if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 - 60, 100, 40), "Continue"))
        //    {
        //        isPaused = false;
        //    }

        //    //If the button is presser then we completely close the game or load the scene "Main Menu" (Translated from French)
        //    //In the case of the button to leave it is necessary to increase its postion Y so that it is lower. (Translated from French)
        //    if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 + 00, 150, 40), "Load a different level"))
        //    {
        //        // Application.Quit();
        //        Application.LoadLevel(""); //Loads a different level
        //    }



        //if (background != null)
        //    GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), background);

        //if (LOGO != null && clicked != "about")
        //    GUI.DrawTexture(new Rect((Screen.width / 2) - 100, 30, 200, 200), LOGO);

        GUI.skin = guiSkin;

        if (clicked == "" && isPaused)
        {
            WindowRect = GUI.Window(0, WindowRect, menuFunc, "Main Menu");
        }

        if (clicked == "options")
        {
            WindowRect = GUI.Window(1, WindowRect, optionsFunc, "Options");
        }

        //else if (clicked == "about")
        //{
        //    GUI.Box(new Rect(0, 0, Screen.width, Screen.height), MessageDisplayOnAbout);
        //}

        else if (clicked == "resolution")
        {
            GUILayout.BeginVertical();

            for (int x = 0; x < Screen.resolutions.Length; x++)
            {
                if (GUILayout.Button(Screen.resolutions[x].width + "X" + Screen.resolutions[x].height))
                {
                    Screen.SetResolution(Screen.resolutions[x].width, Screen.resolutions[x].height, true);
                }
            }

            GUILayout.EndVertical();
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Back"))
            {
                clicked = "options";
            }

            GUILayout.EndHorizontal();
        }

        //if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 60, 100, 40), "Settings"))
        //{
        //    if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2 + 60, 100, 40), "SFX volume"))
        //    {

        //    }

        //    if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2, 100, 40), "Music volume"))
        //    {

        //    }

        //    if (GUI.Button(new Rect(Screen.width / 2, Screen.height / 2 - 60, 150, 40), "Change Background Music"))
        //    {

        //    }
        //}

        //if (GUI.Button(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 120, 100, 40), "Quit"))
        //{
        //    Application.Quit();
        //    //Application.LoadLevel("");
        //}
    }
예제 #19
0
        //Info window GUI
        internal void UpdateGUI()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("Material: ").AppendLine(mat.name);
            builder.Append("Drag coefficient: ").AppendLine(mat.dragCoefficient.ToString("0.00#"));
            builder.Append("Predeployed diameter: ").Append(preDeployedDiameter).Append("m\t\tarea: ").Append(preDeployedArea.ToString("0.###")).AppendLine("m²");
            builder.Append("Deployed diameter: ").Append(deployedDiameter).Append("m\t\tarea: ").Append(deployedArea.ToString("0.###")).Append("m²");
            GUILayout.Label(builder.ToString(), skins.label);
            if (HighLogic.LoadedSceneIsFlight)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Predeployment:", skins.label);
                if (GUILayout.Toggle(!minIsPressure, "altitude", skins.toggle))
                {
                    minIsPressure = false;
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Toggle(minIsPressure, "pressure", skins.toggle))
                {
                    minIsPressure = true;
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            if (minIsPressure)
            {
                GUILayout.Label("Predeployment pressure: " + minPressure + "atm", skins.label);
                if (HighLogic.LoadedSceneIsFlight)
                {
                    minPressure = GUILayout.HorizontalSlider(minPressure, 0.005f, 1, skins.horizontalSlider, skins.horizontalSliderThumb);
                    if (this.module.secondaryChute)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Copy to others", skins.button, GUILayout.Height(20), GUILayout.Width(100)))
                        {
                            this.parachutes.ForEach(p => p.minIsPressure = this.minIsPressure);
                            this.parachutes.ForEach(p => p.minPressure   = this.minPressure);
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                }
            }
            else
            {
                GUILayout.Label("Predeployment altitude: " + minDeployment + "m", skins.label);
                if (HighLogic.LoadedSceneIsFlight)
                {
                    minDeployment = GUILayout.HorizontalSlider(minDeployment, 100, 20000, skins.horizontalSlider, skins.horizontalSliderThumb);
                    if (this.module.secondaryChute)
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Copy to others", skins.button, GUILayout.Height(20), GUILayout.Width(100)))
                        {
                            this.parachutes.ForEach(p => p.minIsPressure = this.minIsPressure);
                            this.parachutes.ForEach(p => p.minDeployment = this.minDeployment);
                        }
                        GUILayout.FlexibleSpace();
                        GUILayout.EndHorizontal();
                    }
                }
            }
            GUILayout.Label("Deployment altitude: " + deploymentAlt + "m", skins.label);
            if (HighLogic.LoadedSceneIsFlight)
            {
                deploymentAlt = GUILayout.HorizontalSlider(deploymentAlt, 50, 10000, skins.horizontalSlider, skins.horizontalSliderThumb);
                if (this.module.secondaryChute)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Copy to others", skins.button, GUILayout.Height(20), GUILayout.Width(100)))
                    {
                        this.parachutes.ForEach(p => p.deploymentAlt = this.deploymentAlt);
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
            }
            builder = new StringBuilder();
            if (cutAlt > 0)
            {
                builder.Append("Autocut altitude: ").Append(cutAlt).AppendLine("m");
            }
            builder.Append("Predeployment speed: ").Append(preDeploymentSpeed).AppendLine("s");
            builder.Append("Deployment speed: ").Append(deploymentSpeed).Append("s");
            GUILayout.Label(builder.ToString(), skins.label);
        }
예제 #20
0
		void OnGUI()
		{
			if (m_Info != null && m_DebugGui)
			{
				GUI.depth = -1;
				GUI.matrix = Matrix4x4.TRS(new Vector3(m_GuiPositionX, 10f, 0f), Quaternion.identity, new Vector3(s_GuiScale, s_GuiScale, 1.0f));

				GUILayout.BeginVertical("box", GUILayout.MaxWidth(s_GuiWidth));
				GUILayout.Label(System.IO.Path.GetFileName(m_VideoPath));
				GUILayout.Label("Dimensions: " + m_Info.GetVideoWidth() + "x" + m_Info.GetVideoHeight() + "@" + m_Info.GetVideoFrameRate().ToString("F2"));
				GUILayout.Label("Time: " + (m_Control.GetCurrentTimeMs() * 0.001f).ToString("F1") + "s / " + (m_Info.GetDurationMs() * 0.001f).ToString("F1") + "s");
				GUILayout.Label("Rate: " + m_Info.GetVideoDisplayRate().ToString("F2") + "Hz");

				if (TextureProducer != null && TextureProducer.GetTexture() != null)
				{
					// Show texture without and with alpha blending
					GUILayout.BeginHorizontal();
					Rect r1 = GUILayoutUtility.GetRect(32f, 32f);
					GUILayout.Space(8f);
					Rect r2 = GUILayoutUtility.GetRect(32f, 32f);
					Matrix4x4 prevMatrix = GUI.matrix;
					if (TextureProducer.RequiresVerticalFlip())
					{
						GUIUtility.ScaleAroundPivot(new Vector2(1f, -1f), new Vector2(0, r1.y + (r1.height / 2)));
					}
					GUI.DrawTexture(r1, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, false);
					GUI.DrawTexture(r2, TextureProducer.GetTexture(), ScaleMode.ScaleToFit, true);
					GUI.matrix = prevMatrix;
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
				}

#if AVPROVIDEO_DEBUG_DISPLAY_EVENTS
				// Dirty code to hack in an event monitor
				if (Event.current.type == EventType.Repaint)
				{
					this.Events.RemoveListener(OnMediaPlayerEvent);
					this.Events.AddListener(OnMediaPlayerEvent);
					UpdateEventLogs();
				}

				if (_eventLog != null && _eventLog.Count > 0)
				{
					GUILayout.Label("Recent Events: ");
					GUILayout.BeginVertical("box");
					int eventIndex = 0;
					foreach (string eventString in _eventLog)
					{
						GUI.color = Color.white;
						if (eventIndex == 0)
						{
							GUI.color = new Color(1f, 1f, 1f, _eventTimer);
						}
						GUILayout.Label(eventString);
						eventIndex++;
					}
					GUILayout.EndVertical();
					GUI.color = Color.white;
				}
#endif
				GUILayout.EndVertical();
			}
		}
        protected void doWindow(int windowID)
        {
            if (left_bold_label == null)
            {
                left_bold_label           = new GUIStyle(GUI.skin.label);
                left_bold_label.fontStyle = FontStyle.Bold;
                left_bold_label.font      = PluginHelper.MainFont;
            }

            if (right_bold_label == null)
            {
                right_bold_label           = new GUIStyle(GUI.skin.label);
                right_bold_label.fontStyle = FontStyle.Bold;
                right_bold_label.font      = PluginHelper.MainFont;
                right_bold_label.alignment = TextAnchor.MiddleRight;
            }

            if (green_label == null)
            {
                green_label = new GUIStyle(GUI.skin.label);
                green_label.normal.textColor = resource_name == ResourceManager.FNRESOURCE_WASTEHEAT ? Color.red : Color.green;
                green_label.font             = PluginHelper.MainFont;
                green_label.alignment        = TextAnchor.MiddleRight;
            }

            if (red_label == null)
            {
                red_label = new GUIStyle(GUI.skin.label);
                red_label.normal.textColor = resource_name == ResourceManager.FNRESOURCE_WASTEHEAT ? Color.green : Color.red;
                red_label.font             = PluginHelper.MainFont;
                red_label.alignment        = TextAnchor.MiddleRight;
            }

            if (left_aligned_label == null)
            {
                left_aligned_label           = new GUIStyle(GUI.skin.label);
                left_aligned_label.fontStyle = FontStyle.Normal;
                left_aligned_label.font      = PluginHelper.MainFont;
            }

            if (right_aligned_label == null)
            {
                right_aligned_label           = new GUIStyle(GUI.skin.label);
                right_aligned_label.fontStyle = FontStyle.Normal;
                right_aligned_label.font      = PluginHelper.MainFont;
                right_aligned_label.alignment = TextAnchor.MiddleRight;
            }

            if (render_window && GUI.Button(new Rect(windowPosition.width - 20, 2, 18, 18), "x"))
            {
                render_window = false;
            }

            GUILayout.Space(2);
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Theoretical Supply", left_bold_label, GUILayout.ExpandWidth(true));
            GUILayout.Label(getPowerFormatString(stored_stable_supply), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Current Supply", left_bold_label, GUILayout.ExpandWidth(true));
            GUILayout.Label(getPowerFormatString(stored_supply), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
            GUILayout.EndHorizontal();

            if (resource_name == ResourceManager.FNRESOURCE_MEGAJOULES)
            {
                var stored_supply_percentage = stored_supply != 0 ? stored_total_power_supplied / stored_supply * 100 : 0;

                GUILayout.BeginHorizontal();
                GUILayout.Label("Current Distribution", left_bold_label, GUILayout.ExpandWidth(true));
                GUILayout.Label(stored_supply_percentage.ToString("0.000") + "%", right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
                GUILayout.EndHorizontal();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Power Demand", left_bold_label, GUILayout.ExpandWidth(true));
            GUILayout.Label(getPowerFormatString(stored_resource_demand), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
            GUILayout.EndHorizontal();

            double new_power_supply       = getOverproduction();
            double net_utilisation_supply = getDemandStableSupply();

            GUIStyle net_poer_style    = new_power_supply < -0.001 ? red_label : green_label;
            GUIStyle utilisation_style = net_utilisation_supply > 1.001 ? red_label : green_label;

            GUILayout.BeginHorizontal();
            var new_power_label = (resource_name == ResourceManager.FNRESOURCE_WASTEHEAT) ? "Net Change" : "Net Power";

            GUILayout.Label(new_power_label, left_bold_label, GUILayout.ExpandWidth(true));
            GUILayout.Label(getPowerFormatString(new_power_supply), net_poer_style, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
            GUILayout.EndHorizontal();

            if (!double.IsNaN(net_utilisation_supply) && !double.IsInfinity(net_utilisation_supply))
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Utilisation", left_bold_label, GUILayout.ExpandWidth(true));
                GUILayout.Label((net_utilisation_supply).ToString("P3"), utilisation_style, GUILayout.ExpandWidth(false), GUILayout.MinWidth(overviewWidth));
                GUILayout.EndHorizontal();
            }

            if (power_supply_list_archive != null)
            {
                GUILayout.Space(5);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Producer Component", left_bold_label, GUILayout.ExpandWidth(true));
                GUILayout.Label("Supply", right_bold_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                GUILayout.Label("Max", right_bold_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                GUILayout.EndHorizontal();

                var groupedPowerSupply = power_supply_list_archive.GroupBy(m => m.Key.getResourceManagerDisplayName());

                List <PowerProduction> sumarizedList = new List <PowerProduction>();

                foreach (var group in groupedPowerSupply)
                {
                    var sumOfCurrentAverageSupply = group.Sum(m => m.Value.averageSupply);

                    // skip anything with less then 0.00 KW
                    if (sumOfCurrentAverageSupply < 0.00005)
                    {
                        continue;
                    }

                    var sumOfMaximumSupply = group.Sum(m => m.Value.maximumSupply);

                    string name  = group.Key;
                    var    count = group.Count();
                    if (count > 1)
                    {
                        name = count + " " + name;
                    }

                    sumarizedList.Add(new PowerProduction()
                    {
                        component = name, averageSupply = sumOfCurrentAverageSupply, maximumSupply = sumOfMaximumSupply
                    });
                }

                foreach (var production in sumarizedList.OrderByDescending(m => m.averageSupply))
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(production.component, left_aligned_label, GUILayout.ExpandWidth(true));
                    GUILayout.Label(getPowerFormatString(production.averageSupply), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                    GUILayout.Label(getPowerFormatString(production.maximumSupply), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                    GUILayout.EndHorizontal();
                }
            }

            if (power_draw_list_archive != null)
            {
                GUILayout.Space(5);
                GUILayout.BeginHorizontal();
                GUILayout.Label("Consumer Component", left_bold_label, GUILayout.ExpandWidth(true));
                GUILayout.Label("Demand", right_bold_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                GUILayout.Label("Rank", right_bold_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(priorityWidth));
                GUILayout.EndHorizontal();

                List <PowerConsumption> sumarizedList = new List <PowerConsumption>();

                var groupedPowerDraws = power_draw_list_archive.GroupBy(m => m.Key.getResourceManagerDisplayName());

                foreach (var group in groupedPowerDraws)
                {
                    var sumOfPowerDraw         = group.Sum(m => m.Value.Power_draw);
                    var sumOfPowerConsume      = group.Sum(m => m.Value.Power_consume);
                    var sumOfConsumePercentage = sumOfPowerDraw > 0 ? sumOfPowerConsume / sumOfPowerDraw * 100 : 0;

                    string name  = group.Key;
                    var    count = group.Count();
                    if (count > 1)
                    {
                        name = count + " " + name;
                    }
                    if (resource_name == ResourceManager.FNRESOURCE_MEGAJOULES && sumOfConsumePercentage < 99.5)
                    {
                        name = name + " " + sumOfConsumePercentage.ToString("0") + "%";
                    }

                    sumarizedList.Add(new PowerConsumption()
                    {
                        component = name, sum = sumOfPowerDraw, priority = group.First().Key.getPowerPriority()
                    });
                }

                foreach (var consumption in sumarizedList.OrderByDescending(m => m.sum))
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(consumption.component, left_aligned_label, GUILayout.ExpandWidth(true));
                    GUILayout.Label(getPowerFormatString(consumption.sum), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                    GUILayout.Label(consumption.priority.ToString(), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(priorityWidth));
                    GUILayout.EndHorizontal();
                }
            }

            if (resource_name == ResourceManager.FNRESOURCE_MEGAJOULES)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("DC Electrical System", left_aligned_label, GUILayout.ExpandWidth(true));
                GUILayout.Label(getPowerFormatString(stored_current_charge_demand), right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(valueWidth));
                GUILayout.Label("0", right_aligned_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(priorityWidth));
                GUILayout.EndHorizontal();
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
    void OnGUI()
    {
        GUILayout.BeginHorizontal();
        {
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            {
                GUILayout.FlexibleSpace();

                if (updateNeeded)
                {
                    EditorGUILayout.LabelField("A new version is available : " + version, EditorStyles.wordWrappedLabel);
                    GUILayout.Space(20);
                    if (_automaticUpdate)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            GUILayout.FlexibleSpace();
                            EditorPrefs.SetBool("PiXYZ.AutoUpdate", !EditorGUILayout.Toggle("Do not show Again", !EditorPrefs.GetBool("PiXYZ.AutoUpdate")));
                            GUILayout.FlexibleSpace();
                        }
                        EditorGUILayout.EndHorizontal();
                    }


                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Download"))
                    {
                        Application.OpenURL(link);
                        this.Close();
                    }
                    if (GUILayout.Button("Later"))
                    {
                        this.Close();
                    }
                    GUILayout.EndHorizontal();
                }
                else if (errorMessage == "")
                {
                    EditorGUILayout.LabelField("Your version is up to date", EditorStyles.wordWrappedLabel);
                    GUILayout.Space(20);
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Close"))
                    {
                        this.Close();
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.LabelField(errorMessage, EditorStyles.wordWrappedLabel);
                    GUILayout.Space(20);
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Retry"))
                    {
                        errorMessage = "";
                        checkForUpdate();
                    }

                    if (GUILayout.Button("Close"))
                    {
                        this.Close();
                        errorMessage = "";
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
        }
        GUILayout.EndHorizontal();
    }
예제 #23
0
파일: FSGUI.cs 프로젝트: m4gus88/RP-0
        protected void nautListRow(tabs currentTab, ProtoCrewMember student)
        {
            GUIStyle     style         = HighLogic.Skin.label;
            ActiveCourse currentCourse = null;

            if (activeMap.ContainsKey(student))
            {
                currentCourse = activeMap[student];
            }
            bool onSelectedCourse = selectedCourse != null && currentCourse != null && currentCourse.id == selectedCourse.id;

            if (onSelectedCourse)
            {
                style = boldLabel;
            }
            bool selectedForCourse = selectedCourse != null && selectedCourse.Students.Contains(student);

            GUILayout.BeginHorizontal();
            try {
                GUILayout.Label(String.Format("{0} {1}", student.trait.Substring(0, 1), student.experienceLevel), GUILayout.Width(24));
                if (currentCourse == null && selectedCourse != null && (selectedForCourse || selectedCourse.MeetsStudentReqs(student)))
                {
                    if (toggleButton(student.name, selectedForCourse, GUILayout.Width(96)))
                    {
                        if (selectedForCourse)
                        {
                            selectedCourse.RemoveStudent(student);
                        }
                        else
                        {
                            selectedCourse.AddStudent(student);
                        }
                    }
                }
                else if (currentTab == tabs.Training)
                {
                    if (GUILayout.Button(student.name, GUILayout.Width(96)))
                    {
                        selectedNaut = student;
                    }
                }
                else
                {
                    GUILayout.Label(student.name, GUILayout.Width(96));
                }
                string course, complete, retires;
                if (currentCourse == null)
                {
                    if (student.inactive)
                    {
                        course   = "(inactive)";
                        complete = KSPUtil.PrintDate(student.inactiveTimeEnd, false);
                    }
                    else
                    {
                        course   = "(free)";
                        complete = "(n/a)";
                    }
                }
                else
                {
                    course   = currentCourse.name;
                    complete = KSPUtil.PrintDate(currentCourse.CompletionTime(), false);
                }
                GUILayout.Label(course, GUILayout.Width(96));
                GUILayout.Label(complete, GUILayout.Width(80));
                if (CrewHandler.Instance.kerbalRetireTimes.ContainsKey(student.name))
                {
                    retires = CrewHandler.Instance.retirementEnabled ? KSPUtil.PrintDate(CrewHandler.Instance.kerbalRetireTimes[student.name], false) : "(n/a)";
                }
                else
                {
                    retires = "(unknown)";
                }
                GUILayout.Label(retires, GUILayout.Width(80));
                if (currentCourse != null)
                {
                    if (currentCourse.seatMin > 1)
                    {
                        if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                        {
                            cancelCourse(currentCourse);
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("X", GUILayout.ExpandWidth(false)))
                        {
                            leaveCourse(currentCourse, student);
                        }
                    }
                }
            } finally {
                GUILayout.EndHorizontal();
            }
        }
예제 #24
0
        private void EditorShipListWindow(int id)
        {
            GUIStyle guiStyleLabel;
            GUIStyle guiStyleLabelNorm = new GUIStyle(GUI.skin.GetStyle("Label"));
            GUIStyle guiStyleLabelBold = new GUIStyle(GUI.skin.GetStyle("Label"));

            guiStyleLabelBold.fontStyle = FontStyle.Bold;

            GUIStyle guiStyleButton;
            GUIStyle guiStyleButtonNorm = new GUIStyle(GUI.skin.GetStyle("Button"));
            GUIStyle guiStyleButtonBold = new GUIStyle(GUI.skin.GetStyle("Button"));

            guiStyleButtonBold.fontStyle = FontStyle.Bold;

            // Close Button
            if (GUI.Button(new Rect(rectEditorShipWindow.size.x - 22, 2, 20, 20), "X"))
            {
                editorShipWindowOn = false;
            }

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            if (editorShipVab)
            {
                guiStyleButton = guiStyleButtonBold;
            }
            else
            {
                guiStyleButton = guiStyleButtonNorm;
            }
            if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0019"), guiStyleButton))
            {
                editorShipVab = true;
            }

            if (editorShipVab)
            {
                guiStyleButton = guiStyleButtonNorm;
            }
            else
            {
                guiStyleButton = guiStyleButtonBold;
            }
            if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0020"), guiStyleButton))
            {
                editorShipVab = false;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(35f);
            if (editorShipRelay)
            {
                guiStyleButton = guiStyleButtonNorm;
            }
            else
            {
                guiStyleButton = guiStyleButtonBold;
            }
            if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0021"), guiStyleButton))
            {
                editorShipRelay = false;
            }

            if (editorShipRelay)
            {
                guiStyleButton = guiStyleButtonBold;
            }
            else
            {
                guiStyleButton = guiStyleButtonNorm;
            }
            if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0003"), guiStyleButton))
            {
                editorShipRelay = true;
            }
            GUILayout.Space(35f);
            GUILayout.EndHorizontal();

            if (editorShipVab)
            {
                if (editorShipRelay)
                {
                    guiListEditorShipDisplay = guiListEditorShipVabRelay;
                }
                else
                {
                    guiListEditorShipDisplay = guiListEditorShipVabAll;
                }
            }
            else
            {
                if (editorShipRelay)
                {
                    guiListEditorShipDisplay = guiListEditorShipSphRelay;
                }
                else
                {
                    guiListEditorShipDisplay = guiListEditorShipSphAll;
                }
            }

            scrollerEditorShipWindow = GUILayout.BeginScrollView(scrollerEditorShipWindow);

            foreach (Dictionary <string, string> vesselInfo in guiListEditorShipDisplay)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0022"), GUILayout.Width(60f)))
                {
                    targetPid = vesselInfo ["pid"];
                    ShowCircles();
                }

                if (targetPid == vesselInfo ["pid"])
                {
                    guiStyleLabel = guiStyleLabelBold;
                }
                else
                {
                    guiStyleLabel = guiStyleLabelNorm;
                }
                string power;
                if (editorShipRelay)
                {
                    power = AHUtil.TruePower(Double.Parse(vesselInfo ["powerRelay"])).ToString();
                }
                else
                {
                    power = AHUtil.TruePower(Double.Parse(vesselInfo ["powerTotal"])).ToString();
                }
                GUILayout.Label("(" + power + ")  " + vesselInfo ["name"], guiStyleLabel);

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
        public void drawStaticInfoWindow(int WindowID)
        {
            if (mModel == null)
            {
                return;
            }

            BoxNoBorder = new GUIStyle(GUI.skin.box);
            BoxNoBorder.normal.background = null;
            BoxNoBorder.normal.textColor  = Color.white;

            DeadButton = new GUIStyle(GUI.skin.button);
            DeadButton.normal.background  = null;
            DeadButton.hover.background   = null;
            DeadButton.active.background  = null;
            DeadButton.focused.background = null;
            DeadButton.normal.textColor   = Color.yellow;
            DeadButton.hover.textColor    = Color.white;
            DeadButton.active.textColor   = Color.yellow;
            DeadButton.focused.textColor  = Color.yellow;
            DeadButton.fontSize           = 14;
            DeadButton.fontStyle          = FontStyle.Normal;

            DeadButtonRed = new GUIStyle(GUI.skin.button);
            DeadButtonRed.normal.background  = null;
            DeadButtonRed.hover.background   = null;
            DeadButtonRed.active.background  = null;
            DeadButtonRed.focused.background = null;
            DeadButtonRed.normal.textColor   = Color.red;
            DeadButtonRed.hover.textColor    = Color.yellow;
            DeadButtonRed.active.textColor   = Color.red;
            DeadButtonRed.focused.textColor  = Color.red;
            DeadButtonRed.fontSize           = 12;
            DeadButtonRed.fontStyle          = FontStyle.Bold;

            if (currPreview != null)
            {
                double dTicker = Planetarium.GetUniversalTime();
                if ((dTicker - dUpdater) > 0.01)
                {
                    dUpdater = Planetarium.GetUniversalTime();

                    if (bSpinning)
                    {
                        SpinPreview(currPreview);
                    }
                }
            }

            bool               shouldUpdateSelection = false;
            string             smessage = "";
            ScreenMessageStyle smsStyle = (ScreenMessageStyle)2;

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUILayout.Button("Static Model Config Editor", DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21)))
                {
                    if (currPreview != null)
                    {
                        DestroyPreviewInstance(currPreview);
                    }

                    KerbalKonstructs.instance.showModelInfo = false;
                    mModel = null;
                    KerbalKonstructs.instance.selectedModel = null;
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            GUILayout.Box(" " + infTitle + " ");
            GUILayout.Space(3);
            GUILayout.Box("Mesh: " + infMesh + ".mu");

            GUILayout.Box("Manufacturer: " + infManufacturer);
            GUILayout.Box("Author: " + infAuthor);
            GUILayout.Space(3);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Category: ");
            GUILayout.FlexibleSpace();
            infCategory = GUILayout.TextField(infCategory, GUILayout.Width(150));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Cost: ");
            GUILayout.FlexibleSpace();
            infCost = GUILayout.TextField(infCost, GUILayout.Width(150));
            GUILayout.EndHorizontal();

            GUILayout.Label("Description");
            infDescription = GUILayout.TextArea(infDescription, GUILayout.Height(100));

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Save", GUILayout.Height(23)))
            {
                updateSettings(mModel);
                KerbalKonstructs.instance.saveObjects();
                smessage = "Saved all changes to all static models and instances.";
                ScreenMessages.PostScreenMessage(smessage, 10, smsStyle);
            }
            if (GUILayout.Button("Close", GUILayout.Height(23)))
            {
                if (currPreview != null)
                {
                    DestroyPreviewInstance(currPreview);
                }

                KerbalKonstructs.instance.showModelInfo = false;
                mModel = null;
                KerbalKonstructs.instance.selectedModel = null;
            }
            GUILayout.EndHorizontal();

            if (currPreview != null)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Delete Preview", GUILayout.Height(23)))
                {
                    DestroyPreviewInstance(currPreview);
                }

                if (bSpinning)
                {
                    if (GUILayout.Button("Stop Spin", GUILayout.Height(23)))
                    {
                        bSpinning = false;
                    }
                }
                else
                {
                    if (GUILayout.Button("Resume Spin", GUILayout.Height(23)))
                    {
                        bSpinning = true;
                    }
                }

                GUILayout.EndHorizontal();
            }

            if (Event.current.keyCode == KeyCode.Return)
            {
                ScreenMessages.PostScreenMessage("Applied changes to object.", 10, smsStyle);
                shouldUpdateSelection = true;
            }

            if (shouldUpdateSelection)
            {
                updateSettings(mModel);
                updateSelection(mModel);
            }

            GUILayout.Space(1);
            GUILayout.Box(tHorizontalSep, BoxNoBorder, GUILayout.Height(4));

            GUILayout.Space(2);

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
예제 #26
0
        /// <summary>
        /// Draws the controls inside the window.
        /// </summary>
        /// <param name="windowId"></param>
        private void DrawControls(int windowId)
        {
            DrawTitleBarButtons(_rect);


            GUILayout.BeginHorizontal( );

            GUILayout.BeginVertical(GUILayout.Width(480), GUILayout.ExpandHeight(true));

            ProgressBar(
                new Rect(10, 27, 480, 13),
                _filter.TotalCount == 0 ? 1 : _filter.CompleteCount,
                _filter.TotalCount == 0 ? 1 : _filter.TotalCount,
                0,
                false,
                false);

            GUILayout.Space(20);

            GUILayout.BeginHorizontal( );
            GUILayout.Label
            (
                new GUIContent(
                    string.Format("{0}/{1} complete.", _filter.CompleteCount, _filter.TotalCount),
                    string.Format("{0} remaining\n{1:0.#} mits", _filter.TotalCount - _filter.CompleteCount, _filter.TotalScience - _filter.CompletedScience)
                    ),
                _experimentProgressLabelStyle,
                GUILayout.Width(150)
            );
            GUILayout.FlexibleSpace();
            GUILayout.Label(new GUIContent(_searchTexture));
            _filter.Text = GUILayout.TextField(_filter.Text, GUILayout.Width(150));

            if (GUILayout.Button(new GUIContent(_clearSearchTexture, "Clear search"), GUILayout.Width(25), GUILayout.Height(23)))
            {
                _filter.Text = string.Empty;
            }

            GUILayout.EndHorizontal();

            _scrollPos = GUILayout.BeginScrollView(_scrollPos, _skin.scrollView);
            var i = 0;

            if (_filter.DisplayScienceInstances == null)
            {
                _logger.Trace("DisplayExperiments is null");
            }
            else
            {
                for ( ; i < _filter.DisplayScienceInstances.Count; i++)
                {
                    var rect = new Rect(5, 20 * i, _filter.DisplayScienceInstances.Count > 13 ? 490 : 500, 20);
                    if (rect.yMax < _scrollPos.y || rect.yMin > _scrollPos.y + 400)
                    {
                        continue;
                    }

                    var experiment = _filter.DisplayScienceInstances[i];
                    DrawExperiment(experiment, rect, false, _labelStyle);
                }
            }

            GUILayout.Space(20 * i);
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();


            var TextWidth  = 290;
            var NumButtons = 3;

            GUIContent[] FilterButtons =
            {
                new GUIContent(_currentSituationTexture, "Show experiments available right now"),
                new GUIContent(_currentVesselTexture,    "Show experiments available on this vessel"),
                new GUIContent(_unlockedTexture,         "Show all unlocked experiments")
            };
            if (_parent.Config.AllFilter)
            {
                Array.Resize(ref FilterButtons, 4);
                FilterButtons[3] = new GUIContent(_allTexture, "Show all experiments");
                TextWidth        = 260;
                NumButtons       = 4;
            }
            else
            {
                if (_filter.DisplayMode == DisplayMode.All)
                {
                    _filter.DisplayMode = DisplayMode.Unlocked;
                    _filter.UpdateFilter( );
                }
            }

            _filter.DisplayMode = (DisplayMode)GUILayout.SelectionGrid((int)_filter.DisplayMode, FilterButtons, NumButtons);

            GUILayout.FlexibleSpace();

            if (_filter.CurrentSituation != null)
            {
                var desc = _filter.CurrentSituation.Description;
                GUILayout.Box(char.ToUpper(desc[0]) + desc.Substring(1), _situationStyle, GUILayout.Width(TextWidth));
            }
            GUILayout.FlexibleSpace( );

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();
            GUI.DragWindow();

            if (Event.current.type == EventType.Repaint && GUI.tooltip != _lastTooltip)
            {
                _lastTooltip = GUI.tooltip;
            }

            // If this window gets focus, it pushes the tooltip behind the window, which looks weird.
            // Just hide the tooltip while mouse buttons are held down to avoid this.
            if (Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButton(2))
            {
                _lastTooltip = string.Empty;
            }
        }
예제 #27
0
        private void DrawGui(int window)
        {
            if (_bold_label == null)
            {
                _bold_label           = new GUIStyle(GUI.skin.label);
                _bold_label.fontStyle = FontStyle.Bold;
            }

            if (_normal_label == null)
            {
                _normal_label           = new GUIStyle(GUI.skin.label);
                _normal_label.fontStyle = FontStyle.Normal;
            }

            if (GUI.Button(new Rect(_window_position.width - 20, 2, 18, 18), "x"))
            {
                _render_window = false;
            }

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Drill parameters:", _bold_label, GUILayout.Width(labelWidth));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Size: " + drillSize.ToString("#.#") + " m\xB3", _normal_label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("MW Requirements: " + mwRequirements.ToString("#.#") + " MW", _normal_label);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Drill effectiveness: " + effectiveness.ToString("P1"), _normal_label);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Resources abundances:", _bold_label, GUILayout.Width(labelWidth));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Name", _bold_label, GUILayout.Width(valueWidth));
            GUILayout.Label("Abundance", _bold_label, GUILayout.Width(valueWidth));
            GUILayout.Label("Production per second", _bold_label, GUILayout.Width(valueWidth));
            GUILayout.Label("Production per hour", _bold_label, GUILayout.Width(valueWidth));
            GUILayout.Label("Spare Room", _bold_label, GUILayout.Width(valueWidth));
            GUILayout.Label("Stored", _bold_label, GUILayout.Width(valueWidth));
            GUILayout.Label("Max Capacity", _bold_label, GUILayout.Width(valueWidth));
            GUILayout.EndHorizontal();

            GetResourceData();

            if (localResources != null)
            {
                foreach (CrustalResource resource in localResources)
                {
                    CrustalResourceAbundance abundance;
                    CrustalResourceAbundanceDict.TryGetValue(resource.ResourceName, out abundance);
                    if (abundance == null)
                    {
                        continue;
                    }

                    GUILayout.BeginHorizontal();
                    GUILayout.Label(resource.DisplayName, _normal_label, GUILayout.Width(valueWidth));
                    GUILayout.Label(abundance.Local.ToString("##.######") + "%", _normal_label, GUILayout.Width(valueWidth));

                    if (resource.Definition != null)
                    {
                        if (resource.MaxAmount > 0)
                        {
                            if (resource.SpareRoom > 0)
                            {
                                GUILayout.Label(resource.Production.ToString("##.######") + " U/s", _normal_label, GUILayout.Width(valueWidth));
                                GUILayout.Label((resource.Production * resource.Definition.density * 3600).ToString("##.######") + " t/h", _normal_label, GUILayout.Width(valueWidth));
                                GUILayout.Label((resource.SpareRoom * resource.Definition.density).ToString("##.######") + " t", _normal_label, GUILayout.Width(valueWidth));
                            }
                            else
                            {
                                GUILayout.Label("", _normal_label, GUILayout.Width(valueWidth));
                                GUILayout.Label("", _normal_label, GUILayout.Width(valueWidth));
                                GUILayout.Label("full", _normal_label, GUILayout.Width(valueWidth));
                            }

                            GUILayout.Label((resource.Amount * resource.Definition.density).ToString("##.######") + " t", _normal_label, GUILayout.Width(valueWidth));
                            GUILayout.Label((resource.MaxAmount * resource.Definition.density).ToString("##.######") + " t", _normal_label, GUILayout.Width(valueWidth));
                        }
                        else
                        {
                            GUILayout.Label("", _normal_label, GUILayout.Width(valueWidth));
                            GUILayout.Label("", _normal_label, GUILayout.Width(valueWidth));
                            GUILayout.Label("missing", _normal_label, GUILayout.Width(valueWidth));
                        }
                    }

                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
예제 #28
0
        public tabs toolingTab()
        {
            MaybeUpdate();
            currentToolingType = null;
            GUILayout.BeginHorizontal();
            try {
                GUILayout.FlexibleSpace();
                GUILayout.Label("Tooling Types", HighLogic.Skin.label);
                GUILayout.FlexibleSpace();
            } finally {
                GUILayout.EndHorizontal();
            }
            int counter = 0;

            GUILayout.BeginHorizontal();
            try {
                foreach (string type in ToolingDatabase.toolings.Keys)
                {
                    if (counter % 3 == 0 && counter != 0)
                    {
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                    }
                    counter++;
                    if (GUILayout.Button(type))
                    {
                        currentToolingType = type;
                    }
                }
            } finally {
                GUILayout.EndHorizontal();
            }

            if (untooledParts.Count > 0)
            {
                GUILayout.BeginHorizontal();
                try {
                    GUILayout.Label("Untooled Parts:", HighLogic.Skin.label, GUILayout.Width(312));
                    GUILayout.Label("Tooling cost", rightLabel, GUILayout.Width(72));
                    GUILayout.Label("Untooled", rightLabel, GUILayout.Width(72));
                } finally {
                    GUILayout.EndHorizontal();
                }
                untooledTypesScroll = GUILayout.BeginScrollView(untooledTypesScroll, GUILayout.Height(144), GUILayout.Width(500));
                try {
                    foreach (untooledPart uP in untooledParts)
                    {
                        GUILayout.BeginHorizontal();
                        try {
                            GUILayout.Label(uP.name, boldLabel, GUILayout.Width(312));
                            GUILayout.Label(uP.toolingCost.ToString("N0") + "f", rightLabel, GUILayout.Width(72));
                            float untooledCost = uP.toolingCost * uP.untooledMultiplier;
                            GUILayout.Label(untooledCost.ToString("N0") + "f", rightLabel, GUILayout.Width(72));
                        } finally {
                            GUILayout.EndHorizontal();
                        }
                    }
                } finally {
                    GUILayout.EndScrollView();
                }
            }
            return(currentToolingType == null ? tabs.Tooling : tabs.ToolingType);
        }
예제 #29
0
        private void GeneralTab()
        {
            Text.GuiBold("Profile");

            EditorGUILayout.HelpBox("The three following buttons show your current level of obfuscation.\nAdditionally you can press on of those to activate a predefined obfuscation profile.", MessageType.Info);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            int  var_SecurityLevel    = this.securityLevel;
            bool var_Profile_Simple   = false;
            bool var_Profile_Standard = false;
            bool var_Profile_Optimal  = false;

            if (var_SecurityLevel == 1)
            {
                var_Profile_Simple = true;
            }
            if (var_SecurityLevel == 2)
            {
                var_Profile_Standard = true;
            }
            if (var_SecurityLevel == 3)
            {
                var_Profile_Optimal = true;
            }

            if (Switch.GuiNoRef(var_Profile_Simple, "Assets/OPS/Obfuscator.Free/Editor/Gui/Profile_Simple.png", "Assets/OPS/Obfuscator.Free/Editor/Gui/Profile_Simple_Unselect.png"))
            {
                this.securityLevel = 1;
            }
            if (Switch.GuiNoRef(var_Profile_Standard, "Assets/OPS/Obfuscator.Free/Editor/Gui/Profile_Standard.png", "Assets/OPS/Obfuscator.Free/Editor/Gui/Profile_Standard_Unselect.png"))
            {
                this.securityLevel = 2;
            }
            if (Obfuscator.Setting.InternalSettings.ObfuscatorType != Setting.EObfuscatorType.Pro)
            {
                GUI.enabled = false;
            }
            if (Switch.GuiNoRef(var_Profile_Optimal, "Assets/OPS/Obfuscator.Free/Editor/Gui/Profile_Optimal.png", "Assets/OPS/Obfuscator.Free/Editor/Gui/Profile_Optimal_Unselect.png"))
            {
                this.securityLevel = 3;
            }
            GUI.enabled = Gui.GuiSettings.ObfuscateGlobally;

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            Text.GuiBold("Obfuscation");

            EditorGUILayout.HelpBox("Define here generally what names shall get obfuscated!", MessageType.Info);

            Table.Gui("Obfuscate:", "Class", "Field", "Property", "Event", "Method", ref Gui.GuiSettings.ObfuscateClass, ref Gui.GuiSettings.ObfuscateField, ref Gui.GuiSettings.ObfuscateProperty, ref Gui.GuiSettings.ObfuscateEvent, ref Gui.GuiSettings.ObfuscateMethod);

            Text.GuiBold("Namespace");

            if (Obfuscator.Setting.InternalSettings.ObfuscatorType != Setting.EObfuscatorType.Pro)
            {
                GUI.enabled = false;
            }
            EditorGUILayout.HelpBox("Define here generally if namespace names shall get obfuscated.", MessageType.Info);
            Row.GuiGold("Namespace:", ref GuiSettings.ObfuscateNamespace);
            GUI.enabled = Gui.GuiSettings.ObfuscateGlobally;

            EditorGUILayout.HelpBox("To make Obfuscator Free ignore easily some Namespaces, enter it here. All Namespaces beginning like your entered one will get ignored. (Example the entry: 'UnityStandardAssets'. All Namespaces beginning with 'UnityStandardAssets' will get ignored (and so it's Content)).", MessageType.Info);

            //
            ScriptableObject   var_Target           = this;
            SerializedObject   var_SerializedObject = new SerializedObject(var_Target);
            SerializedProperty var_StringsProperty  = var_SerializedObject.FindProperty("NamespaceArray");

            EditorGUILayout.PropertyField(var_StringsProperty, new GUIContent("Namespaces"), true);
            var_SerializedObject.ApplyModifiedProperties();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add Line"))
            {
                List <String> var_TempList = new List <string>(this.NamespaceArray);
                var_TempList.Add("");
                this.NamespaceArray = var_TempList.ToArray();
            }
            if (GUILayout.Button("Remove Line"))
            {
                List <String> var_TempList = new List <string>(this.NamespaceArray);
                if (var_TempList.Count > 0)
                {
                    var_TempList.RemoveAt(var_TempList.Count - 1);
                }
                this.NamespaceArray = var_TempList.ToArray();
            }
            GUILayout.EndHorizontal();

            GuiSettings.NamespacesToIgnoreList = new List <string>(this.NamespaceArray);
            //

            EditorGUILayout.HelpBox("When you activate 'Vice Versa Namespace skipping', every content (class/methods/..) belonging to a namespace that is in the bottom list gets obfuscated. Every namespace that is not in the list will get skipped. The advantage is, if you use many external plugins that shall get skipped while obfuscation and you only want your namespaces to get obfuscated, it reduces your administration effort.", MessageType.Info);
            Row.Gui("Vice Versa Namespace skipping:", ref GuiSettings.NamespaceViceVersa);
        }
        void _drawGUI(int id)
        {
            UpArrow   = ResonantOrbitCalculator.Instance.upContent;
            DownArrow = ResonantOrbitCalculator.Instance.downContent;

            GUILayout.BeginHorizontal(GUILayout.Width(wnd_width));

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal(GUILayout.Width(wnd_width));
            GUILayout.BeginVertical(GUILayout.Width(GRAPH_WIDTH + 10));
            // draw graph box
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(OrbitCalc.header[0]);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Label(OrbitCalc.header[1]);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.Box(graph_texture);
            GUILayout.EndVertical();


            // draw side text
            GUILayout.BeginVertical(GUILayout.Width(wnd_width - GRAPH_WIDTH - 30));
            bool draw = false;

            if (firstTime)
            {
                firstTime = false;
                draw      = true;
            }
            // if (!PlanetSelection.isActive)
            {
                if (GUILayout.Button("Select Planet"))
                {
                    if (!PlanetSelection.isActive)
                    {
                        planetSelection = new GameObject().AddComponent <PlanetSelection>();
                    }
                    else
                    {
                        planetSelection.DestroyThis();
                    }
                }
            }

            GUILayout.BeginHorizontal();

            GUILayout.Label(new GUIContent("Number of satellites:", "Total number of satellites to arrange"));

            var newsNumSats = GUILayout.TextField(sNumSats);

            int butW = 19;

            if (GUILayout.Button(UpArrow, GUILayout.Width(butW)))
            {
                numSats++;
                sNumSats    = numSats.ToString();
                newsNumSats = sNumSats;
                draw        = true;
            }
            if (GUILayout.Button(DownArrow, GUILayout.Width(butW)))
            {
                if (numSats > 1)
                {
                    numSats--;
                }
                sNumSats    = numSats.ToString();
                newsNumSats = sNumSats;
                draw        = true;
            }
            if (sNumSats != newsNumSats)
            {
                bValidNumSats = int.TryParse(newsNumSats, out iTmp);
                if (!bValidNumSats)
                {
                    sNumSats = numSats.ToString();
                }
                else
                {
                    numSats  = iTmp;
                    sNumSats = newsNumSats;
                    draw     = true;
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label(new GUIContent("Altitude:", "Orbital altitude"));
            GUI.SetNextControlName("altitude");
            string newsOrbitAltitude = GUILayout.TextField(sOrbitAltitude);

            if (newsOrbitAltitude != sOrbitAltitude)
            {
                bValidOrbitAltitude = double.TryParse(newsOrbitAltitude, out dTmp);
                if (bValidOrbitAltitude)
                {
                    selectedOrbit = SelectedOrbit.None;
                    orbitAltitude = dTmp;
                }
                sOrbitAltitude = orbitAltitude.ToString("F0");
                draw           = true;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Orbital Period: ");
            GUILayout.FlexibleSpace();

            GUI.SetNextControlName("periodHour");
            string h = GUILayout.TextField(OrbitCalc.periodHour, bh ? textStyle : textErrorStyle, GUILayout.MinWidth(25));

            GUILayout.Label("h ");
            GUI.SetNextControlName("periodMin");
            string m = GUILayout.TextField(OrbitCalc.periodMin, bm ? textStyle : textErrorStyle, GUILayout.MinWidth(25));

            GUILayout.Label("m ");
            GUI.SetNextControlName("periodSec");
            string s = GUILayout.TextField(OrbitCalc.periodSec, bs ? textStyle : textErrorStyle, GUILayout.MinWidth(25));

            GUILayout.Label("s");
            OrbitCalc.periodEntry = GUI.GetNameOfFocusedControl() == "periodHour" ||
                                    GUI.GetNameOfFocusedControl() == "periodMin" ||
                                    GUI.GetNameOfFocusedControl() == "periodSec";


            bh = Double.TryParse(h, out dh);
            bm = Double.TryParse(m, out dm);
            bs = Double.TryParse(s, out ds);
            if (h != OrbitCalc.periodHour || m != OrbitCalc.periodMin || s != OrbitCalc.periodSec)
            {
                if (bh && bm && bs)
                {
                    double T = dh * 3600 + dm * 60 + ds;

                    orbitAltitude  = OrbitCalc.satelliteorbit.a(T);
                    sOrbitAltitude = orbitAltitude.ToString("F0");
                    draw           = true;
                }
                OrbitCalc.periodHour = h;
                OrbitCalc.periodMin  = m;
                OrbitCalc.periodSec  = s;
            }

            GUILayout.EndHorizontal();


            if (OrbitCalc.synchrorbit == "" || OrbitCalc.synchrorbit == "n/a")
            {
                GUI.enabled = false;
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Toggle(synchronousOrbit, new GUIContent("Synchronous orbit (" + OrbitCalc.synchrorbit + ")", "Set the altitude to have the satellites be in a geosynchronous orbit")))
            {
                selectedOrbit = SelectedOrbit.Synchronous;

                orbitAltitude         = OrbitCalc.body.geoAlt;
                sOrbitAltitude        = orbitAltitude.ToString();
                OrbitCalc.periodEntry = false;
                draw = true;
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            if (OrbitCalc.losorbit == "" || OrbitCalc.losorbit == "n/a")
            {
                GUI.enabled = false;
            }

            if (GUILayout.Toggle(minLOSorbit, new GUIContent("Minimum LOS orbit (" + OrbitCalc.losorbit + ")", "Set the altitude to the minimum altitude possible to maintain a Line of Sight"),
                                 OrbitCalc.losOrbitWarning ? toggleMinLOSWarning : toggleMinLOSNormal))
            {
                selectedOrbit         = SelectedOrbit.MinLOS;
                orbitAltitude         = OrbitCalc.minLOS;
                sOrbitAltitude        = orbitAltitude.ToString();
                OrbitCalc.periodEntry = false;
                draw = true;
            }
            GUILayout.EndHorizontal();
            GUI.enabled = true;
            if (HighLogic.LoadedSceneIsFlight)
            {
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                bool warning = false;
                warning = (FlightGlobals.activeTarget.orbit.ApA < FlightGlobals.ActiveVessel.mainBody.atmosphereDepth);

                if (GUILayout.Toggle(currentAp, new GUIContent("Current Ap (" + FlightGlobals.activeTarget.orbit.ApA.ToString("N0") + ")", "Set the altitude to the current vessel's Ap"),
                                     warning ? toggleMinLOSWarning : GUI.skin.toggle))
                {
                    selectedOrbit         = SelectedOrbit.Ap;
                    orbitAltitude         = Math.Round(FlightGlobals.activeTarget.orbit.ApA);
                    sOrbitAltitude        = orbitAltitude.ToString();
                    OrbitCalc.periodEntry = false;
                    draw = true;
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(10);
                GUILayout.BeginHorizontal();
                warning = (FlightGlobals.activeTarget.orbit.PeA < FlightGlobals.ActiveVessel.mainBody.atmosphereDepth);
                if (FlightGlobals.activeTarget.orbit.PeA < 1)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Toggle(currentPe, new GUIContent("Current Pe (" + FlightGlobals.activeTarget.orbit.PeA.ToString("N0") + ")", "Set the altitude to the current vessel's Pe"),
                                     OrbitCalc.losOrbitWarning ? toggleMinLOSWarning : GUI.skin.toggle))
                {
                    selectedOrbit         = SelectedOrbit.Pe;
                    orbitAltitude         = Math.Round(FlightGlobals.activeTarget.orbit.PeA);
                    sOrbitAltitude        = orbitAltitude.ToString();
                    OrbitCalc.periodEntry = false;
                    draw = true;
                }
                GUI.enabled = true;
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);
            GUILayout.BeginHorizontal();

            bool newshowLOSlines = GUILayout.Toggle(showLOSlines, new GUIContent("Show LOS lines", "Show the Line Of Sight lines"));

            if (newshowLOSlines != showLOSlines)
            {
                draw         = true;
                showLOSlines = newshowLOSlines;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            bool newocclusionModifiers = GUILayout.Toggle(occlusionModifiers, new GUIContent("Occlusion modifiers", "Enable occlusion modifiers for vacuum and atmospheres"));

            GUILayout.EndHorizontal();
            if (occlusionModifiers)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Atm:", "Occlusion atmospheric modifier"));
                var newsAtmOcclusion = GUILayout.TextField(sAtmOcclusion);
                if (GUILayout.Button(UpArrow, GUILayout.Width(butW)))
                {
                    if (atmOcclusion < 1.1)
                    {
                        atmOcclusion += 0.01f;
                    }
                    sAtmOcclusion    = atmOcclusion.ToString("F2");
                    newsAtmOcclusion = sAtmOcclusion;
                    draw             = true;
                }
                if (GUILayout.Button(DownArrow, GUILayout.Width(butW)))
                {
                    if (atmOcclusion > 0)
                    {
                        atmOcclusion -= 0.01f;
                    }
                    sAtmOcclusion    = atmOcclusion.ToString("F2");
                    newsAtmOcclusion = sAtmOcclusion;
                    draw             = true;
                }
                if (newsAtmOcclusion != sAtmOcclusion)
                {
                    bValidAtmOcclusion = double.TryParse(newsAtmOcclusion, out dTmp);
                    if (!bValidAtmOcclusion)
                    {
                        sAtmOcclusion = atmOcclusion.ToString("F2");
                    }
                    else
                    {
                        atmOcclusion  = dTmp;
                        sAtmOcclusion = newsAtmOcclusion;
                        draw          = true;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(new GUIContent("   Vac:", "Occlusion vacuum modifier"));
                var newsVacOcclusion = GUILayout.TextField(sVacOcclusion);
                if (GUILayout.Button(UpArrow, GUILayout.Width(butW)))
                {
                    if (vacOcclusion < 1.1)
                    {
                        vacOcclusion += 0.01f;
                    }
                    sVacOcclusion    = vacOcclusion.ToString("F2");
                    newsVacOcclusion = sVacOcclusion;
                    draw             = true;
                }
                if (GUILayout.Button(DownArrow, GUILayout.Width(butW)))
                {
                    if (vacOcclusion > 0)
                    {
                        vacOcclusion -= 0.01f;
                    }
                    sVacOcclusion    = vacOcclusion.ToString("F2");
                    newsVacOcclusion = sVacOcclusion;
                    draw             = true;
                }
                if (newsVacOcclusion != sVacOcclusion)
                {
                    bValidVacOcclusion = Double.TryParse(newsVacOcclusion, out dTmp);
                    if (!bValidVacOcclusion)
                    {
                        sVacOcclusion = vacOcclusion.ToString("F2");
                    }
                    else
                    {
                        vacOcclusion  = dTmp;
                        sVacOcclusion = newsVacOcclusion;
                        draw          = true;
                    }
                }
                GUILayout.EndHorizontal();
            }
            if (occlusionModifiers != newocclusionModifiers)
            {
                draw = true;
            }
            occlusionModifiers = newocclusionModifiers;

            GUILayout.Space(15);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Resonant Orbit", labelResonantOrbit);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            bool newflipOrbit = GUILayout.Toggle(flipOrbit, new GUIContent("Dive orbit", "Set Carrier orbit to be lower than target orbit"));

            if (newflipOrbit != flipOrbit)
            {
                draw      = true;
                flipOrbit = newflipOrbit;
            }
            GUILayout.EndHorizontal();

            if (draw)
            {
                UpdateGraph();
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Orbital Period: ");
            GUILayout.Label(OrbitCalc.carrierT);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Apoapsis: ");
            GUILayout.Label(OrbitCalc.carrierAp);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Periapsis: ");

            if (OrbitCalc.carrierPe != "")
            {
                GUILayout.Label(OrbitCalc.carrierPe, OrbitCalc.carrierPeWarning ? warningLabel : normalLabel);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Injection Δv: ");
            GUILayout.Label(OrbitCalc.burnDV);
            GUILayout.EndHorizontal();

            Log.Info("LoadedSceneIsFlight: " + HighLogic.LoadedSceneIsFlight + ",    patchedConicsUnlocked: " + FlightGlobals.ActiveVessel.patchedConicsUnlocked());
            if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel.patchedConicsUnlocked())
            {
                GUILayout.FlexibleSpace();
                Log.Info("selectedOrbit: " + selectedOrbit);
                if (selectedOrbit == SelectedOrbit.Ap)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(new GUIContent("Create Maneuver Node at Ap", "Creates a maneuver node to put the current vessel into the resonant orbit")))
                    {
                        Vector3d circularizeDv = VesselOrbitalCalc.CircularizeAtAP(FlightGlobals.ActiveVessel);
                        // If a flip, then  subtract
                        double UT = Planetarium.GetUniversalTime();
                        UT += FlightGlobals.ActiveVessel.orbit.timeToAp;
                        var o = FlightGlobals.ActiveVessel.orbit;
                        if (flipOrbit)
                        {
                            circularizeDv -= OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        else
                        {
                            circularizeDv += OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Clear();
                        VesselOrbitalCalc.PlaceManeuverNode(FlightGlobals.ActiveVessel, FlightGlobals.ActiveVessel.orbit, circularizeDv, UT);
                    }
                    GUILayout.EndHorizontal();
                }
                if (selectedOrbit == SelectedOrbit.Pe)
                {
                    if (OrbitCalc.carrierPeWarning)
                    {
                        buttonStyle = buttonRed;
                    }
                    else
                    {
                        buttonStyle = GUI.skin.button;
                    }
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button(new GUIContent("Create Maneuver Node at Pe", "Creates a maneuver node to put the current vessel into the resonant orbit"), buttonStyle))
                    {
                        double UT = Planetarium.GetUniversalTime();
                        UT += FlightGlobals.ActiveVessel.orbit.timeToPe;
                        var      o             = FlightGlobals.ActiveVessel.orbit;
                        Vector3d circularizeDv = VesselOrbitalCalc.CircularizeAtPE(FlightGlobals.ActiveVessel);
                        // If a flip, then  subtract
                        if (flipOrbit)
                        {
                            circularizeDv -= OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        else
                        {
                            circularizeDv += OrbitCalc.dBurnDV * o.Horizontal(UT);
                        }
                        FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Clear();
                        VesselOrbitalCalc.PlaceManeuverNode(FlightGlobals.ActiveVessel, FlightGlobals.ActiveVessel.orbit, circularizeDv, UT);
                    }
                    GUILayout.EndHorizontal();
                }
                Log.Info("FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count(): " + FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count());
                if (FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count() > 0)
                {
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("Clear all nodes"))
                    {
                        for (int i = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes.Count - 1; i >= 0; i--)
                        {
                            FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[i].RemoveSelf();
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (selectedOrbit == SelectedOrbit.Ap || selectedOrbit == SelectedOrbit.Pe)
                    {
                        if (KACWrapper.APIReady)
                        {
                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button("Add alarms to KAC"))
                            {
                                double timeToOrbit = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0].UT;
                                double period      = OrbitCalc.satelliteorbit.T;
                                String aID;
                                if (!ResonantOrbitCalculator.Instance.mucore.Available)
                                {
                                    aID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Maneuver, "Orbital Maneuver", timeToOrbit - 60);
                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).Notes       = "Put carrier craft into resonant orbit";
                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).AlarmMargin = 60;
                                }
                                timeToOrbit += period;
                                for (int i = 0; i < numSats; i++)
                                {
                                    aID = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, "Detachment # " + (i + 1).ToString(), timeToOrbit - 60);

                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).Notes       = "Detach satellite # " + (i + 1) + " and circularize it's orbit";
                                    KACWrapper.KAC.Alarms.First(z => z.ID == aID).AlarmMargin = 60;
                                    timeToOrbit += period;
                                }
                            }
                            GUILayout.EndHorizontal();
                        }

                        if (ResonantOrbitCalculator.Instance.mucore.Available)
                        {
                            GUILayout.BeginHorizontal();
                            if (GUILayout.Button("Execute maneuver"))
                            {
                                ResonantOrbitCalculator.Instance.mucore.ExecuteNode();
                            }
                            GUILayout.EndHorizontal();
                        }
                    }
                }
            }
            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(new GUIContent("Save Window", "Saves an image of the window to the Screenshots directory")))
            {
                saveScreen = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            if (Event.current.type == EventType.Repaint && GUI.tooltip != tooltip)
            {
                tooltip = GUI.tooltip;
            }

            GUI.DragWindow();
        }