/// <summary>
        /// Initializes the addon if it hasn't already been loaded.
        /// Callback from onGUIApplicationLauncherReady
        /// </summary>
        private void Load( )
        {
            _logger.Trace("Load");
            if (!GameHelper.AllowWindow( ))
            {
                _logger.Trace("Not Now");
                return;
            }

            if (_active)
            {
                _logger.Info("Already loaded.");
                return;
            }

            if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER && HighLogic.CurrentGame.Mode != Game.Modes.SCIENCE_SANDBOX)
            {
                _logger.Info("Game type is " + HighLogic.CurrentGame.Mode + ". Deactivating.");
                _active = false;
                return;
            }
            _logger.Info("Game type is " + HighLogic.CurrentGame.Mode + ". Activating.");
            _active = true;

            InitializeButton( );
            _launcherVisible = true;
            ApplicationLauncher.Instance.AddOnShowCallback(Launcher_Show);
            ApplicationLauncher.Instance.AddOnHideCallback(Launcher_Hide);
        }
        private void OnGameSceneSwitch(GameEvents.FromToAction <GameScenes, GameScenes> Data)
        {
            if (GameHelper.AllowWindow(Data.from))
            {
                WindowSettings W = _window.BuildSettings( );
                Config.SetWindowConfig(W, Data.from);
            }

            if (GameHelper.AllowWindow(Data.to))
            {
                WindowSettings W = Config.GetWindowConfig("ScienceCheckList", Data.to);
                _window.ApplySettings(W);
            }

            _vExperimentsRefreshPending = true;
        }
示例#3
0
        /// <summary>
        /// Draws the window if it is visible.
        /// </summary>
        public void Draw( )
        {
            if (!IsVisible)
            {
                return;
            }
            if (!GameHelper.AllowWindow( ))
            {
                IsVisible = false;
                OnCloseEvent(this, EventArgs.Empty);
            }

            if (_skin == null)
            {
                // Initialize our skin and styles.
                _skin = GameObject.Instantiate(HighLogic.Skin) as GUISkin;

                _skin.horizontalScrollbarThumb.fixedHeight = 13;
                _skin.horizontalScrollbar.fixedHeight      = 13;

                _labelStyle = new GUIStyle(_skin.label)
                {
                    fontSize  = 11,
                    fontStyle = FontStyle.Italic,
                };

                _progressLabelStyle = new GUIStyle(_skin.label)
                {
                    fontStyle = FontStyle.BoldAndItalic,
                    alignment = TextAnchor.MiddleCenter,
                    fontSize  = 11,
                    normal    =
                    {
                        textColor = new Color(0.322f, 0.298f, 0.004f),
                    },
                };

                _situationStyle = new GUIStyle(_progressLabelStyle)
                {
                    fontSize      = 13,
                    alignment     = TextAnchor.MiddleCenter,
                    fontStyle     = FontStyle.Normal,
                    fixedHeight   = 25,
                    contentOffset = new Vector2(0, 6),
                    wordWrap      = true,
                    normal        =
                    {
                        textColor = new Color(0.7f, 0.8f, 0.8f),
                    }
                };

                _experimentProgressLabelStyle = new GUIStyle(_skin.label)
                {
                    padding = new RectOffset(0, 0, 4, 0),
                };

                _horizontalScrollbarOnboardStyle = new GUIStyle(_skin.horizontalScrollbar)
                {
                    normal =
                    {
                        background = _emptyTexture,
                    },
                };

                _compactWindowStyle = new GUIStyle(_skin.window)
                {
                    padding = new RectOffset(0, 4, 4, 4),
                };

                _compactLabelStyle = new GUIStyle(_labelStyle)
                {
                    fontSize = 9,
                };

                _compactSituationStyle = new GUIStyle(_situationStyle)
                {
                    fontSize      = 11,
                    contentOffset = new Vector2(0, -3),
                };

                _compactButtonStyle = new GUIStyle(_skin.button)
                {
                    padding     = new RectOffset(),
                    fixedHeight = 16
                };
                _closeButtonStyle = new GUIStyle(_skin.button)
                {
                    // int left, int right, int top, int bottom
                    padding = new RectOffset(2, 2, 6, 2)
                };
            }

            var oldSkin = GUI.skin;

            GUI.skin = _skin;

            if (_compactMode)
            {
                _rect3 = GUILayout.Window(_window3Id, _rect3, DrawCompactControls, string.Empty, _compactWindowStyle);
            }
            else
            {
                _rect = GUILayout.Window(_windowId, _rect, DrawControls, "[x] Science!");
            }



            if (!string.IsNullOrEmpty(_lastTooltip))
            {
                _tooltipStyle = _tooltipStyle ?? new GUIStyle(_skin.window)
                {
                    normal =
                    {
                        background = GUI.skin.window.normal.background
                    },
                    wordWrap = true
                };

                _tooltipBoxStyle = _tooltipBoxStyle ?? new GUIStyle(_skin.box)
                {
                    // int left, int right, int top, int bottom
                    padding  = new RectOffset(4, 4, 4, 4),
                    wordWrap = true
                };

                float boxHeight = _tooltipBoxStyle.CalcHeight(new GUIContent(_lastTooltip), 190);
                GUI.Window(_window2Id, new Rect(Mouse.screenPos.x + 15, Mouse.screenPos.y + 15, 200, boxHeight + 10), x =>
                {
                    GUI.Box(new Rect(5, 5, 190, boxHeight), _lastTooltip, _tooltipBoxStyle);
                }, string.Empty, _tooltipStyle);
            }

            GUI.skin = oldSkin;
        }