示例#1
0
文件: Dialog.cs 项目: Makrond/BARIS
        //Note: parent object needs to call DrawWindow in its OnGUI method.
        public virtual void DrawWindow()
        {
            if (visible)
            {
                bool paused = false;
                if (HighLogic.LoadedSceneIsFlight)
                {
                    try
                    {
                        paused = PauseMenu.isOpen || FlightResultsDialog.isDisplaying;
                    }
                    catch (Exception)
                    {
                        // ignore the error and assume the pause menu is not open
                    }
                }

                if (!paused)
                {
                    GUI.skin = HighLogic.Skin;
                    ConfigureStyles();

                    windowPos = DialogUtils.EnsureVisible(windowPos);
                    windowPos = GUILayout.Window(windowId, windowPos, PreDrawWindowContents, WindowTitle, GUILayout.ExpandWidth(true),
                                                 GUILayout.ExpandHeight(true), GUILayout.MinWidth(64), GUILayout.MinHeight(64));
                }

                Vector3 mousePosition = Input.mousePosition;
                if (windowPos.Contains(mousePosition))
                {
                    InputLockManager.SetControlLock(ControlTypes.All, "WindowLock" + this.windowId);
                    if (HighLogic.LoadedSceneIsEditor)
                    {
                        EditorLogic.fetch.Lock(true, true, true, "WindowLock" + this.windowId);
                    }
                }
                else
                {
                    InputLockManager.SetControlLock(ControlTypes.None, "WindowLock" + this.windowId);
                    if (HighLogic.LoadedSceneIsEditor)
                    {
                        EditorLogic.fetch.Unlock("WindowLock" + this.windowId);
                    }
                }
            }
        }