private void gameSceneChanged(ToolbarGameScene scene) { if (isRelevantGameScene(scene)) { loadSettings(scene); } }
private void loadSettings(ToolbarGameScene scene) { Log.info("loading settings (game scene: {0})", scene); foreach (Toolbar toolbar in toolbars.Values) { toolbar.destroy(); } toolbars.Clear(); WindowList.Instance.destroyDialogs(); bool checkForUpdates = true; ConfigNode root = loadSettings(); if (root.HasNode("toolbars")) { ConfigNode toolbarsNode = root.GetNode("toolbars"); Log.Level = (LogLevel)int.Parse(toolbarsNode.get("logLevel", ((int) #if DEBUG LogLevel.INFO #else LogLevel.WARN #endif ).ToString())); checkForUpdates = toolbarsNode.get("checkForUpdates", true); string[] kspVersions = toolbarsNode.get("kspVersions", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (kspVersions.Length > 0) { UpdateChecker.KspVersions = kspVersions; UpdateChecker.KspVersionsFromConfig = true; } if (toolbarsNode.HasNode(scene.ToString())) { ConfigNode sceneNode = toolbarsNode.GetNode(scene.ToString()); foreach (ConfigNode toolbarNode in sceneNode.nodes) { Toolbar toolbar = addToolbar(toolbarNode.name); toolbar.loadSettings(toolbarNode); } } } // ensure there is at least one toolbar in the scene if (ToolbarsCount == 0) { Log.info("no toolbars in current game scene, adding default toolbar"); addToolbar(); } Log.info("update check {0}", checkForUpdates ? "enabled" : "disabled"); UpdateChecker.CheckForUpdates = checkForUpdates; }
private void handleGameSceneChange() { ToolbarGameScene scene = ToolbarGameScenes.getCurrent(); if (scene != gameScene) { gameScene = scene; gameSceneChanged(scene); } }
private void saveSettings(ToolbarGameScene scene) { Log.info("saving settings (game scene: {0})", scene); ConfigNode toolbarsNode = settings.Node; ConfigNode sceneNode = toolbarsNode.getOrCreateNode(scene.ToString()); foreach (KeyValuePair <string, Toolbar> entry in toolbars) { ConfigNode toolbarNode = sceneNode.getOrCreateNode(entry.Key); entry.Value.saveSettings(toolbarNode); } settings.Save(); }
private void saveSettings(ToolbarGameScene scene) { Log.info("saving settings (game scene: {0})", scene); ConfigNode root = loadSettings(); ConfigNode toolbarsNode = root.getOrCreateNode("toolbars"); ConfigNode sceneNode = toolbarsNode.getOrCreateNode(scene.ToString()); foreach (KeyValuePair <string, Toolbar> entry in toolbars) { ConfigNode toolbarNode = sceneNode.getOrCreateNode(entry.Key); entry.Value.saveSettings(toolbarNode); } root.Save(SETTINGS_FILE); }
private void loadSettings(ToolbarGameScene scene) { Log.info("loading settings (game scene: {0})", scene); foreach (Toolbar toolbar in toolbars.Values) { toolbar.destroy(); } toolbars.Clear(); WindowList.Instance.destroyDialogs(); bool checkForUpdates = true; ConfigNode root = loadSettings(); if (root.HasNode("toolbars")) { ConfigNode toolbarsNode = root.GetNode("toolbars"); Log.Level = (LogLevel)int.Parse(toolbarsNode.get("logLevel", ((int) #if DEBUG LogLevel.INFO #else LogLevel.WARN #endif ).ToString())); checkForUpdates = toolbarsNode.get("checkForUpdates", true); if (toolbarsNode.HasNode(scene.ToString())) { ConfigNode sceneNode = toolbarsNode.GetNode(scene.ToString()); foreach (ConfigNode toolbarNode in sceneNode.nodes) { Toolbar toolbar = addToolbar(toolbarNode.name); toolbar.loadSettings(toolbarNode); } } } // ensure there is at least one toolbar in the scene if (ToolbarsCount == 0) { Log.info("no toolbars in current game scene, adding default toolbar"); addToolbar(); } }
private void saveSettings(ToolbarGameScene scene) { Log.info("saving settings (game scene: {0})", scene); ConfigNode root = loadSettings(); ConfigNode toolbarsNode = root.getOrCreateNode("toolbars"); if (UpdateChecker.Done && (UpdateChecker.KspVersions != null) && (UpdateChecker.KspVersions.Length > 0)) { toolbarsNode.overwrite("kspVersions", string.Join(",", UpdateChecker.KspVersions)); } ConfigNode sceneNode = toolbarsNode.getOrCreateNode(scene.ToString()); foreach (KeyValuePair <string, Toolbar> entry in toolbars) { ConfigNode toolbarNode = sceneNode.getOrCreateNode(entry.Key); entry.Value.saveSettings(toolbarNode); } root.Save(SETTINGS_FILE); }
private void saveSettings(ToolbarGameScene scene) { Log.info("saving settings (game scene: {0})", scene); ConfigNode root = loadSettings(); ConfigNode toolbarsNode = root.getOrCreateNode("toolbars"); if (UpdateChecker.Done && (UpdateChecker.KspVersions != null) && (UpdateChecker.KspVersions.Length > 0)) { toolbarsNode.overwrite("kspVersions", string.Join(",", UpdateChecker.KspVersions)); } ConfigNode sceneNode = toolbarsNode.getOrCreateNode(scene.ToString()); foreach (KeyValuePair<string, Toolbar> entry in toolbars) { ConfigNode toolbarNode = sceneNode.getOrCreateNode(entry.Key); entry.Value.saveSettings(toolbarNode); } root.Save(SETTINGS_FILE); }
private void loadSettings(ToolbarGameScene scene) { Log.info("loading settings (game scene: {0})", scene); foreach (Toolbar toolbar in toolbars.Values) { toolbar.destroy(); } toolbars.Clear(); WindowList.Instance.destroyDialogs(); bool checkForUpdates = true; ConfigNode root = loadSettings(); if (root.HasNode("toolbars")) { ConfigNode toolbarsNode = root.GetNode("toolbars"); Log.Level = (LogLevel) int.Parse(toolbarsNode.get("logLevel", ((int) #if DEBUG LogLevel.INFO #else LogLevel.WARN #endif ).ToString())); checkForUpdates = toolbarsNode.get("checkForUpdates", true); string[] kspVersions = toolbarsNode.get("kspVersions", string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (kspVersions.Length > 0) { UpdateChecker.KspVersions = kspVersions; UpdateChecker.KspVersionsFromConfig = true; } if (toolbarsNode.HasNode(scene.ToString())) { ConfigNode sceneNode = toolbarsNode.GetNode(scene.ToString()); foreach (ConfigNode toolbarNode in sceneNode.nodes) { Toolbar toolbar = addToolbar(toolbarNode.name); toolbar.loadSettings(toolbarNode); } } } // ensure there is at least one toolbar in the scene if (ToolbarsCount == 0) { Log.info("no toolbars in current game scene, adding default toolbar"); addToolbar(); } Log.info("update check {0}", checkForUpdates ? "enabled" : "disabled"); UpdateChecker.CheckForUpdates = checkForUpdates; }
private bool isRelevantGameScene(ToolbarGameScene scene) { return (scene != ToolbarGameScene.LOADING) && (scene != ToolbarGameScene.LOADINGBUFFER) && (scene != ToolbarGameScene.MAINMENU) && (scene != ToolbarGameScene.PSYSTEM) && (scene != ToolbarGameScene.CREDITS); }
private bool isRelevantGameScene(ToolbarGameScene scene) { return((scene != ToolbarGameScene.LOADING) && (scene != ToolbarGameScene.LOADINGBUFFER) && (scene != ToolbarGameScene.MAINMENU) && (scene != ToolbarGameScene.PSYSTEM) && (scene != ToolbarGameScene.CREDITS)); }
private void saveSettings(ToolbarGameScene scene) { Log.info("saving settings (game scene: {0})", scene); ConfigNode root = loadSettings(); ConfigNode toolbarsNode = root.getOrCreateNode("toolbars"); ConfigNode sceneNode = toolbarsNode.getOrCreateNode(scene.ToString()); foreach (KeyValuePair<string, Toolbar> entry in toolbars) { ConfigNode toolbarNode = sceneNode.getOrCreateNode(entry.Key); entry.Value.saveSettings(toolbarNode); } root.Save(SETTINGS_FILE); }
private void loadSettings(ToolbarGameScene scene) { Log.info("loading settings (game scene: {0})", scene); foreach (Toolbar toolbar in toolbars.Values) { toolbar.destroy(); } toolbars.Clear(); WindowList.Instance.destroyDialogs(); bool checkForUpdates = true; ConfigNode root = loadSettings(); if (root.HasNode("toolbars")) { ConfigNode toolbarsNode = root.GetNode("toolbars"); Log.Level = (LogLevel) int.Parse(toolbarsNode.get("logLevel", ((int) LogLevel.WARN).ToString())); checkForUpdates = toolbarsNode.get("checkForUpdates", true); if (toolbarsNode.HasNode(scene.ToString())) { ConfigNode sceneNode = toolbarsNode.GetNode(scene.ToString()); foreach (ConfigNode toolbarNode in sceneNode.nodes) { Toolbar toolbar = addToolbar(toolbarNode.name); toolbar.loadSettings(toolbarNode); } } } // ensure there is at least one toolbar in the scene if (ToolbarsCount == 0) { Log.info("no toolbars in current game scene, adding default toolbar"); addToolbar(); } if (updateChecker != null) { Log.info("update check {0}", checkForUpdates ? "enabled" : "disabled"); updateChecker.CheckForUpdates = checkForUpdates; } }