示例#1
0
        //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 = WindowUtils.EnsureVisible(windowPos);
                    windowPos = GUILayout.Window(windowId, windowPos, PreDrawWindowContents, WindowTitle, GUILayout.ExpandWidth(true),
                                                 GUILayout.ExpandHeight(true), GUILayout.MinWidth(64), GUILayout.MinHeight(64));
                }
            }
        }
示例#2
0
        protected Window(string windowTitle, float defaultWidth, float defaultHeight)
        {
            this.WindowTitle = windowTitle;
            this.windowId    = windowTitle.GetHashCode() + new System.Random().Next(65536) + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.GetHashCode();

            configNodeName = windowTitle.Replace(" ", "");

            windowPos = new Rect((Screen.width - defaultWidth) / 2, (Screen.height - defaultHeight) / 2, defaultWidth, defaultHeight);
            mouseDown = false;
            visible   = false;

            var texture = WindowUtils.LoadImage <T>(IOUtils.GetFilePathFor(typeof(T), "resize.png"));

            resizeContent = (texture != null) ? new GUIContent(texture, "Drag to resize the window.") : new GUIContent("R", "Drag to resize the window.");

            Resizable       = true;
            HideCloseButton = false;
        }
示例#3
0
        public virtual ConfigNode Load(ConfigNode config)
        {
            if (config.HasNode(configNodeName))
            {
                ConfigNode windowConfig = config.GetNode(configNodeName);

                windowPos.x      = WindowUtils.GetValue(windowConfig, "x", windowPos.x);
                windowPos.y      = WindowUtils.GetValue(windowConfig, "y", windowPos.y);
                windowPos.width  = WindowUtils.GetValue(windowConfig, "width", windowPos.width);
                windowPos.height = WindowUtils.GetValue(windowConfig, "height", windowPos.height);

                bool newValue = WindowUtils.GetValue(windowConfig, "visible", visible);
                SetVisible(newValue);

                return(windowConfig);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        //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 = WindowUtils.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, kWindowLock + this.windowId);
                }
                else
                {
                    InputLockManager.SetControlLock(ControlTypes.None, kWindowLock + this.windowId);
                }
            }
        }