// Initializes the addon if it hasn't already been loaded. // Callback from onGUIApplicationLauncherReady private void Load( ) { _logger.Trace("Load"); if (!GameHelper.AllowChecklistWindow( )) { _logger.Trace("Ui is hidden in this scene"); _active = false; RemoveButtons( ); 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; // _logger.Info( "Adding Buttons" ); InitButtons( ); // _logger.Info( "Buttons Added" ); _launcherVisible = true; ApplicationLauncher.Instance.AddOnShowCallback(Launcher_Show); ApplicationLauncher.Instance.AddOnHideCallback(Launcher_Hide); }
// Save and load checklist window config when the game scene is changed private void OnGameSceneSwitch(GameEvents.FromToAction <GameScenes, GameScenes> Data) { if (GameHelper.AllowChecklistWindow(Data.from)) { WindowSettings W = _checklistWindow.BuildSettings( ); Config.SetWindowConfig(W, Data.from); } if (GameHelper.AllowChecklistWindow(Data.to)) { WindowSettings W = Config.GetWindowConfig(WINDOW_NAME_CHECKLIST, Data.to); _checklistWindow.ApplySettings(W); } /* if( GameHelper.AllowStatusWindow( Data.from ) ) * { * // WindowSettings W =_statusWindow.BuildSettings( ); * // Config.SetWindowConfig( W, Data.from ); * } * * if( GameHelper.AllowStatusWindow( Data.to ) ) * { * // WindowSettings W = Config.GetWindowConfig( WINDOW_NAME_CHECKLIST, Data.to ); * // _statusWindow.ApplySettings( W ); * } */ }
// Let a window suggest settings are saved. public void OnSettingsDirty(object sender, EventArgs e) { if (GameHelper.AllowChecklistWindow( )) { WindowSettings W = _checklistWindow.BuildSettings( ); W._scene = HighLogic.LoadedScene; Config.SetWindowConfig(W); } }
private void SwitchingGameScene(GameScenes From, GameScenes To) { HammerMusicMute( ); // Ensure we enforce music volume anyway // Checklist window settings if (GameHelper.AllowChecklistWindow(From)) { WindowSettings W = _checklistWindow.BuildSettings( ); W._scene = From; Config.SetWindowConfig(W); } if (GameHelper.AllowChecklistWindow(To)) { WindowSettings W = Config.GetWindowConfig(WINDOW_NAME_CHECKLIST, To); _checklistWindow.ApplySettings(W); } // Status window settings if (GameHelper.AllowStatusWindow(From)) { WindowSettings W = _statusWindow.BuildSettings( ); W._scene = From; Config.SetWindowConfig(W); } if (GameHelper.AllowStatusWindow(To)) { WindowSettings W = Config.GetWindowConfig(WINDOW_NAME_STATUS, To); _statusWindow.ApplySettings(W); } // Selected Object window settings if (GameScenes.TRACKSTATION == From) { WindowSettings W = _shipStateWindow.BuildSettings( ); W._scene = From; Config.SetWindowConfig(W); } if (GameScenes.TRACKSTATION == To) { WindowSettings W = Config.GetWindowConfig(WINDOW_NAME_SHIP_STATE, To); _shipStateWindow.ApplySettings(W); } }
// Initializes the addon if it hasn't already been loaded. // Callback from onGUIApplicationLauncherReady private void Load( ) { HammerMusicMute( ); // Ensure we enforce music volume anyway _logger.Trace("Load"); if (!GameHelper.AllowChecklistWindow( )) { // _logger.Info( "Ui is hidden in this scene" ); _active = false; RemoveButtons( ); return; } if (_active) { _logger.Trace("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; SwitchingGameScene(GameScenes.MAINMENU, HighLogic.LoadedScene); // Get correct visibility now we are active // _logger.Trace( "Adding Buttons" ); InitButtons( ); // _logger.Trace( "Buttons Added" ); _launcherVisible = true; ApplicationLauncher.Instance.AddOnShowCallback(Launcher_Show); ApplicationLauncher.Instance.AddOnHideCallback(Launcher_Hide); }
/// <summary> /// Draws the window if it is visible. /// </summary> public void Draw( ) { if (!IsVisible) { return; } if (!GameHelper.AllowChecklistWindow( )) { IsVisible = false; OnCloseEvent(this, EventArgs.Empty); } if (_skin == null) { // Initialize our skin and styles. _skin = GameObject.Instantiate(HighLogic.Skin) as GUISkin; _skin.horizontalScrollbarThumb.fixedHeight = wScale(13); _skin.horizontalScrollbar.fixedHeight = wScale(13); _labelStyle = new GUIStyle(_skin.label) { fontSize = wScale(11), fontStyle = FontStyle.Italic, }; _progressLabelStyle = new GUIStyle(_skin.label) { fontStyle = FontStyle.BoldAndItalic, alignment = TextAnchor.MiddleCenter, fontSize = wScale(11), normal = { textColor = new Color(0.322f, 0.298f, 0.004f), }, }; _situationStyle = new GUIStyle(_progressLabelStyle) { fontSize = wScale(13), alignment = TextAnchor.MiddleCenter, fontStyle = FontStyle.Normal, fixedHeight = wScale(25), contentOffset = wScale(new Vector2(0, 6)), wordWrap = true, normal = { textColor = new Color(0.7f, 0.8f, 0.8f), } }; _experimentProgressLabelStyle = new GUIStyle(_skin.label) { fontSize = wScale(16), alignment = TextAnchor.MiddleLeft, padding = wScale(new RectOffset(0, 0, 4, 0)) }; _textFieldStyle = new GUIStyle(_skin.textField) { fontSize = wScale(16), alignment = TextAnchor.MiddleLeft, }; _horizontalScrollbarOnboardStyle = new GUIStyle(_skin.horizontalScrollbar) { normal = { background = _emptyTexture, }, }; _compactWindowStyle = new GUIStyle(_skin.window) { padding = wScale(new RectOffset(0, 4, 4, 4)) }; _compactLabelStyle = new GUIStyle(_labelStyle) { fontSize = wScale(9) }; _compactSituationStyle = new GUIStyle(_situationStyle) { fontSize = wScale(11), contentOffset = wScale(new Vector2(0, 3)) }; _compactButtonStyle = new GUIStyle(_skin.button) { padding = new RectOffset(), fixedHeight = wScale(16) }; _closeButtonStyle = new GUIStyle(_skin.button) { // int left, int right, int top, int bottom padding = wScale(new RectOffset(2, 2, 2, 2)), margin = wScale(new RectOffset(1, 1, 1, 1)), stretchWidth = false, stretchHeight = false, alignment = TextAnchor.MiddleCenter, }; _windowStyle = new GUIStyle(_skin.window) { fontSize = (int)(_skin.window.fontSize * _parent.Config.UiScale), padding = wScale(_skin.window.padding), margin = wScale(_skin.window.margin), border = wScale(_skin.window.border), contentOffset = wScale(_skin.window.contentOffset), }; _skin.window = _windowStyle; } 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, Localizer.Format("#autoLOC_[x]_Science!_072") /*[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) { // fontSize = wScale(11), // int left, int right, int top, int bottom padding = wScale(new RectOffset(4, 4, 4, 4)), wordWrap = true }; float boxHeight = _tooltipBoxStyle.CalcHeight(new GUIContent(_lastTooltip), wScale(190)); GUI.Window(_window2Id, new Rect(Mouse.screenPos.x + wScale(15), Mouse.screenPos.y + wScale(15), wScale(200), boxHeight + wScale(10)), x => { GUI.Box(new Rect(wScale(5), wScale(5), wScale(190), boxHeight), _lastTooltip, _tooltipBoxStyle); }, string.Empty, _tooltipStyle); } GUI.skin = oldSkin; }
/// <summary> /// Draws the window if it is visible. /// </summary> public void Draw( ) { if (!IsVisible) { return; } if (!GameHelper.AllowChecklistWindow( )) { 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, 2, 2), margin = new RectOffset(1, 1, 1, 1), stretchWidth = false, stretchHeight = false, alignment = TextAnchor.MiddleCenter, }; } 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; }