// 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); } }
public WindowSettings BuildSettings( ) { //_logger.Info( "BuildSettings" ); WindowSettings W = new WindowSettings( ScienceChecklistAddon.WINDOW_NAME_STATUS ); W.Set( "Top", (int)windowPos.yMin ); W.Set( "Left", (int)windowPos.xMin ); W.Set( "Visible", IsVisible( ) ); return W; }
public WindowSettings BuildSettings() { //_logger.Info( "BuildSettings" ); WindowSettings W = new WindowSettings(ScienceChecklistAddon.WINDOW_NAME_SHIP_STATE); W.Set("Top", (int)windowPos.yMin); W.Set("Left", (int)windowPos.xMin); W.Set("Width", (int)windowPos.width); W.Set("Height", (int)windowPos.height); return(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); } }
public WindowSettings BuildSettings( ) { WindowSettings W = new WindowSettings( ); W.Name = "ScienceCheckList"; W.Top = (int)_rect.yMin; W.Left = (int)_rect.xMin; W.CompactTop = (int)_rect3.yMin; W.CompactLeft = (int)_rect3.xMin; W.Visible = IsVisible; W.Compacted = _compactMode; return(W); }
public void ApplySettings( WindowSettings W ) { windowPos.yMin = W.GetInt( "Top", 40 ); windowPos.xMin = W.GetInt( "Left", 40 ); windowPos.yMax = windowPos.yMin + wScale( 30 ); windowPos.xMax = windowPos.xMin + wScale( 250 ); bool TempVisible = false; TempVisible = W.GetBool( "Visible", false ); if( TempVisible ) OnOpenEvent( this, EventArgs.Empty ); else OnCloseEvent( this, EventArgs.Empty ); }
public WindowSettings BuildSettings( ) { //_logger.Info( "BuildSettings" ); WindowSettings W = new WindowSettings(ScienceChecklistAddon.WINDOW_NAME_CHECKLIST); W.Set("Top", (int)_rect.yMin); W.Set("Left", (int)_rect.xMin); W.Set("CompactTop", (int)_rect3.yMin); W.Set("CompactLeft", (int)_rect3.xMin); W.Set("Visible", IsVisible); W.Set("Compacted", _compactMode); W.Set("FilterMode", _filter.DisplayMode.ToString( )); W.Set("FilterText", _filter.Text); return(W); }
public WindowSettings BuildSettings( ) { WindowSettings W = new WindowSettings( ); W.Name = ScienceChecklistAddon.WINDOW_NAME_CHECKLIST; W.Top = (int)_rect.yMin; W.Left = (int)_rect.xMin; W.CompactTop = (int)_rect3.yMin; W.CompactLeft = (int)_rect3.xMin; W.Visible = IsVisible; W.Compacted = _compactMode; W.FilterMode = _filter.DisplayMode; W.FilterText = _filter.Text; return(W); }
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; }
public void ApplySettings(WindowSettings W) { windowPos.yMin = W.GetInt("Top", 40); windowPos.xMin = W.GetInt("Left", 40); windowPos.width = W.GetInt("Width", 200); windowPos.height = W.GetInt("Height", 200); if (windowPos.width < 100) { windowPos.width = 100; } if (windowPos.width < 50) { windowPos.width = 50; } }
public static void SetWindowConfig(WindowSettings W, GameScenes Scene) { W.TestPosition( ); // Write if (!_windowSettings.ContainsKey(Scene)) { _windowSettings.Add(Scene, new Dictionary <string, WindowSettings>( )); } _windowSettings[Scene][W.Name] = W; // _logger.Trace( "Setting " + W.Name + " For " + Scene.ToString( ) ); /* if( W.Visible ) * _logger.Trace( "visible" ); * else * _logger.Trace( "closed!" ); */ Save( ); }
public void ApplySettings(WindowSettings W) { _rect.yMin = W.Top; _rect.xMin = W.Left; _rect.yMax = W.Top + 400; _rect.xMax = W.Left + 500; _rect3.yMin = W.CompactTop; _rect3.xMin = W.CompactLeft; _rect3.yMax = W.CompactTop + 200; _rect3.xMax = W.CompactLeft + 400; _compactMode = W.Compacted; if (W.Visible) { OnOpenEvent(this, EventArgs.Empty); } else { OnCloseEvent(this, EventArgs.Empty); } }
public static void Load( ) { HideCompleteExperiments = false; UseBlizzysToolbar = false; CompleteWithoutRecovery = false; CheckDebris = false; AllFilter = true; HideExperimentResultsDialog = false; try { if (File.Exists(_file)) { var node = ConfigNode.Load(_file); if (node == null) { return; } var root = node.GetNode("ScienceChecklist"); if (root == null) { return; } var settings = root.GetNode("Config"); if (settings == null) { return; } var V = settings.GetValue("HideCompleteExperiments"); if (V != null) { HideCompleteExperiments = bool.Parse(V); } V = settings.GetValue("UseBlizzysToolbar"); if (V != null) { UseBlizzysToolbar = bool.Parse(V); } V = settings.GetValue("CompleteWithoutRecovery"); if (V != null) { CompleteWithoutRecovery = bool.Parse(V); } V = settings.GetValue("CheckDebris"); if (V != null) { CheckDebris = bool.Parse(V); } V = settings.GetValue("AllFilter"); if (V != null) { AllFilter = bool.Parse(V); } V = settings.GetValue("HideExperimentResultsDialog"); if (V != null) { HideExperimentResultsDialog = bool.Parse(V); } var windowSettings = root.GetNode("Windows"); if (windowSettings == null) { return; } foreach (var N in windowSettings.nodes) { // _logger.Trace( "Window Node" ); if (N.GetType( ) == typeof(ConfigNode)) { ConfigNode SceneNode = (ConfigNode)N; GameScenes Scene = (GameScenes)Enum.Parse(typeof(GameScenes), SceneNode.name, true); if (!_windowSettings.ContainsKey(Scene)) { _windowSettings.Add(Scene, new Dictionary <string, WindowSettings>( )); } foreach (var W in SceneNode.nodes) { if (W.GetType( ) == typeof(ConfigNode)) { ConfigNode WindowNode = (ConfigNode)W; string WindowName = WindowNode.name; // _logger.Trace( "Loading " + WindowName + " For " + Scene.ToString( ) ); WindowSettings NewWindowSetting = new WindowSettings(WindowName); V = WindowNode.GetValue("Top"); if (V != null) { NewWindowSetting.Top = int.Parse(V); } V = WindowNode.GetValue("Left"); if (V != null) { NewWindowSetting.Left = int.Parse(V); } V = WindowNode.GetValue("CompactTop"); if (V != null) { NewWindowSetting.CompactTop = int.Parse(V); } V = WindowNode.GetValue("CompactLeft"); if (V != null) { NewWindowSetting.CompactLeft = int.Parse(V); } V = WindowNode.GetValue("Visible"); if (V != null) { NewWindowSetting.Visible = bool.Parse(V); } V = WindowNode.GetValue("Compacted"); if (V != null) { NewWindowSetting.Compacted = bool.Parse(V); } _windowSettings[Scene][NewWindowSetting.Name] = NewWindowSetting; } } } } // _logger.Info("Loaded successfully."); return; // <--- Return from here -------------------------------------- } } catch (Exception e) { _logger.Info("Unable to load config: " + e.ToString( )); } }
public void Load( ) { _hideCompleteExperiments = false; _useBlizzysToolbar = false; _completeWithoutRecovery = false; _checkDebris = false; _allFilter = true; _scienceThreshold = 0.1f; _stopTimeWarp = true; _playNoise = true; _showResultsWindow = true; _filterDifficultScience = true; _uiScale = 1f; _musicStartsMuted = false; _checkUnloadedVessels = false; _righClickMutesMusic = true; _selectedObjectWindow = true; try { if (File.Exists(_file)) { var node = ConfigNode.Load(_file); if (node == null) { return; } var root = node.GetNode("ScienceChecklist"); if (root == null) { return; } var settings = root.GetNode("Config"); if (settings == null) { return; } var V = settings.GetValue("HideCompleteExperiments"); if (V != null) { _hideCompleteExperiments = bool.Parse(V); } V = settings.GetValue("UseBlizzysToolbar"); if (V != null) { _useBlizzysToolbar = bool.Parse(V); } V = settings.GetValue("CompleteWithoutRecovery"); if (V != null) { _completeWithoutRecovery = bool.Parse(V); } V = settings.GetValue("CheckDebris"); if (V != null) { _checkDebris = bool.Parse(V); } V = settings.GetValue("AllFilter"); if (V != null) { _allFilter = bool.Parse(V); } V = settings.GetValue("ScienceThreshold"); if (V != null) { _scienceThreshold = float.Parse(V); } V = settings.GetValue("StopTimeWarp"); if (V != null) { _stopTimeWarp = bool.Parse(V); } V = settings.GetValue("PlayNoise"); if (V != null) { _playNoise = bool.Parse(V); } V = settings.GetValue("ShowResultsWindow"); if (V != null) { _showResultsWindow = bool.Parse(V); } V = settings.GetValue("FilterDifficultScience"); if (V != null) { _filterDifficultScience = bool.Parse(V); } V = settings.GetValue("UiScale"); if (V != null) { _uiScale = float.Parse(V); } V = settings.GetValue("MusicStartsMuted"); if (V != null) { _musicStartsMuted = bool.Parse(V); } V = settings.GetValue("RighClickMutesMusic"); if (V != null) { _righClickMutesMusic = bool.Parse(V); } V = settings.GetValue("SelectedObjectWindow"); if (V != null) { _selectedObjectWindow = bool.Parse(V); } V = settings.GetValue("CheckUnloadedVessels"); if (V != null) { _checkUnloadedVessels = bool.Parse(V); } var windowSettings = root.GetNode("Windows"); if (windowSettings == null) { return; } foreach (var N in windowSettings.nodes) { // _logger.Trace( "Window Node" ); if (N.GetType( ) == typeof(ConfigNode)) { ConfigNode SceneNode = (ConfigNode)N; GameScenes Scene = (GameScenes)Enum.Parse(typeof(GameScenes), SceneNode.name, true); if (!_windowSettings.ContainsKey(Scene)) { _windowSettings.Add(Scene, new Dictionary <string, WindowSettings>( )); } foreach (var W in SceneNode.nodes) { if (W.GetType( ) == typeof(ConfigNode)) { ConfigNode WindowNode = (ConfigNode)W; string WindowName = WindowNode.name; // _logger.Trace( "Loading " + WindowName + " For " + Scene.ToString( ) ); WindowSettings NewWindowSetting = new WindowSettings(WindowName); for (int x = 0; x < WindowNode.CountValues; x++) { NewWindowSetting._settings[WindowNode.values[x].name] = WindowNode.values[x].value; } _windowSettings[Scene][NewWindowSetting._windowName] = NewWindowSetting; } } } } // _logger.Info( "Loaded successfully." ); return; // <--- Return from here -------------------------------------- } } catch (Exception e) { _logger.Info("Unable to load config: " + e.ToString( )); } }
public void Load( ) { _hideCompleteExperiments = false; _useBlizzysToolbar = false; _completeWithoutRecovery = false; _checkDebris = false; _allFilter = true; _stopTimeWarp = true; _playNoise = true; _showResultsWindow = true; _filterDifficultScience = true; _uiScale = 1f; try { if (File.Exists(_file)) { var node = ConfigNode.Load(_file); if (node == null) { return; } var root = node.GetNode("ScienceChecklist"); if (root == null) { return; } var settings = root.GetNode("Config"); if (settings == null) { return; } var V = settings.GetValue("HideCompleteExperiments"); if (V != null) { _hideCompleteExperiments = bool.Parse(V); } V = settings.GetValue("UseBlizzysToolbar"); if (V != null) { _useBlizzysToolbar = bool.Parse(V); } V = settings.GetValue("CompleteWithoutRecovery"); if (V != null) { _completeWithoutRecovery = bool.Parse(V); } V = settings.GetValue("CheckDebris"); if (V != null) { _checkDebris = bool.Parse(V); } V = settings.GetValue("AllFilter"); if (V != null) { _allFilter = bool.Parse(V); } V = settings.GetValue("StopTimeWarp"); if (V != null) { _stopTimeWarp = bool.Parse(V); } V = settings.GetValue("PlayNoise"); if (V != null) { _playNoise = bool.Parse(V); } V = settings.GetValue("ShowResultsWindow"); if (V != null) { _showResultsWindow = bool.Parse(V); } V = settings.GetValue("FilterDifficultScience"); if (V != null) { _filterDifficultScience = bool.Parse(V); } V = settings.GetValue("UiScale"); if (V != null) { _uiScale = float.Parse(V); } var windowSettings = root.GetNode("Windows"); if (windowSettings == null) { return; } foreach (var N in windowSettings.nodes) { // _logger.Trace( "Window Node" ); if (N.GetType( ) == typeof(ConfigNode)) { ConfigNode SceneNode = (ConfigNode)N; GameScenes Scene = (GameScenes)Enum.Parse(typeof(GameScenes), SceneNode.name, true); if (!_windowSettings.ContainsKey(Scene)) { _windowSettings.Add(Scene, new Dictionary <string, WindowSettings>( )); } foreach (var W in SceneNode.nodes) { if (W.GetType( ) == typeof(ConfigNode)) { ConfigNode WindowNode = (ConfigNode)W; string WindowName = WindowNode.name; // _logger.Trace( "Loading " + WindowName + " For " + Scene.ToString( ) ); WindowSettings NewWindowSetting = new WindowSettings(WindowName); V = WindowNode.GetValue("Top"); if (V != null) { NewWindowSetting.Top = int.Parse(V); } V = WindowNode.GetValue("Left"); if (V != null) { NewWindowSetting.Left = int.Parse(V); } V = WindowNode.GetValue("CompactTop"); if (V != null) { NewWindowSetting.CompactTop = int.Parse(V); } V = WindowNode.GetValue("CompactLeft"); if (V != null) { NewWindowSetting.CompactLeft = int.Parse(V); } V = WindowNode.GetValue("Visible"); if (V != null) { NewWindowSetting.Visible = bool.Parse(V); } V = WindowNode.GetValue("Compacted"); if (V != null) { NewWindowSetting.Compacted = bool.Parse(V); } V = WindowNode.GetValue("FilterText"); if (V != null) { NewWindowSetting.FilterText = V; } V = WindowNode.GetValue("FilterMode"); if (V != null) { NewWindowSetting.FilterMode = (DisplayMode)Enum.Parse(typeof(DisplayMode), V, true); _logger.Info("FilterMode: " + V + " = " + NewWindowSetting.FilterMode.ToString( )); } _windowSettings[Scene][NewWindowSetting.Name] = NewWindowSetting; } } } } // _logger.Info("Loaded successfully."); return; // <--- Return from here -------------------------------------- } } catch (Exception e) { _logger.Info("Unable to load config: " + e.ToString( )); } }