internal void DoIt() { this.icon = this.GenIcons("Impossible Innovations", "SmallLogo", "SmallLogoON"); if (KSPe.Util.KSP.Version.Current >= KSPe.Util.KSP.Version.FindByVersion(1, 3, 0)) { AssetIO.ConfigNode defaults = AssetIO.ConfigNode.ForType <ImpossibleInnovations.II_Icons>("ImpossibleInnovations", "defaults.cfg"); DataIO.ConfigNode user = DataIO.ConfigNode.ForType <ImpossibleInnovations.II_Icons>("ImpossibleInnovations", "user.cfg"); if (!user.IsLoadable) { user.Clear(); string v = defaults.Load().Node.GetValue("CategoryFilter"); user.Node.SetValue("CategoryFilter", v, true); user.Save(); } { user.Load(); string CategoryFilter = user.Node.GetValue("CategoryFilter"); switch (CategoryFilter) { case "CLASSIC": GameEvents.onGUIEditorToolbarReady.Add(addIIfilter); break; case "NONE": break; default: Log.warn("CategoryFilter [{0}] unrecognized on user settings file!", CategoryFilter); break; } } } }
public void Awake() { this.icon = this.GenIcons("Impossible Innovations", "SmallLogo", "SmallLogoON"); if (Versioning.version_major >= 1 && Versioning.version_minor >= 3) { AssetIO.ConfigNode defaults = AssetIO.ConfigNode.ForType <II_Icons>("ImpossibleInnovations", "defaults.cfg"); DataIO.ConfigNode user = DataIO.ConfigNode.ForType <II_Icons>("ImpossibleInnovations", "user.cfg"); if (!user.IsLoadable) { user.Clear(); string v = defaults.Load().Node.GetValue("CategoryFilter"); user.Node.SetValue("CategoryFilter", v, true); user.Save(); } { user.Load(); string CategoryFilter = user.Node.GetValue("CategoryFilter"); switch (CategoryFilter) { case "CLASSIC": GameEvents.onGUIEditorToolbarReady.Add(addIIfilter); break; case "NONE": break; default: Log.warn("CategoryFilter [{0}] unrecognized on user settings file!", CategoryFilter); break; } } } }
public static void LoadConstants() { ClearConstants(); if (CONFIG.exists()) { try { LoadConstants(CONFIG.load()); Log.info("Configuration file loaded."); } catch (System.Exception e) { Log.err("Configuration file has an error! Plugin will not work properly due {0}!", e.Message); } } else { Log.err("Configuration file does not exist - KJR will continue with default values!"); } if (USERCFG.IsLoadable) { try { LoadConstants(USERCFG.Load().NodeWithSteroids); Log.info("User customizable file loaded."); if (USERXML.exists()) { Log.info("Legacy (xml) User customizable file was *IGNORED*."); } } catch (System.Exception e) { Log.err("User customizable file has an error! Plugin will not work properly due {0}!", e.Message); } } else if (USERXML.exists()) { try { LoadConstants(USERXML.load()); Log.info("Legacy (xml) User customizable file loaded."); } catch (System.Exception e) { Log.err("Legacy (xml) User customizable file has an error! Plugin will not work properly due {0}!", e.Message); } } else { Log.err("User customizable file does not exist. Only Stock values are in use."); } Log.debuglevel = debug ? 5 : 3; if (Log.debuglevel > 3) { LoadConstants_Debug(); } }
private ConfigNode loadSettings() { try { if (settings.IsLoadable) { settings.Load(); } else { settings.Clear(); } } catch (Exception e) // Corrupted Savefile? { Log.error(e, "ToolbarManager.loadSettings: Recreating settings file due error."); settings.Clear(); } convertSettings(); return(settings.Node); }
public static void loadPresetsFromFile() { APPreset asstDefault = null; Presets.Load(); foreach (ConfigNode node in Presets.Node.GetNodes(apPresetNodeName)) { if (node == null) { continue; } List <double[]> gains = new List <double[]>(); gains.Add(controllerGains(node.GetNode(hdgCtrlr), AsstList.HdgBank)); gains.Add(controllerGains(node.GetNode(yawCtrlr), AsstList.BankToYaw)); gains.Add(controllerGains(node.GetNode(aileronCtrlr), AsstList.Aileron)); gains.Add(controllerGains(node.GetNode(rudderCtrlr), AsstList.Rudder)); gains.Add(controllerGains(node.GetNode(altCtrlr), AsstList.Altitude)); gains.Add(controllerGains(node.GetNode(vertCtrlr), AsstList.VertSpeed)); gains.Add(controllerGains(node.GetNode(elevCtrlr), AsstList.Elevator)); gains.Add(controllerGains(node.GetNode(speedCtrlr), AsstList.Speed)); gains.Add(controllerGains(node.GetNode(accelCtrlr), AsstList.Acceleration)); gains.Add(controllerGains(node.GetNode(cdiCtrlr), AsstList.CdiVelocity)); string name = node.GetValue("name"); if (name == apDefaultName) { asstDefault = new APPreset(gains, name); } else if (!instance.APPresetList.Any(p => p.name == name)) { instance.APPresetList.Add(new APPreset(gains, name)); } } /* * foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes(sasPresetNodeName)) * { * if (node == null || node.GetValue("stock") == "false") * continue; * * List<double[]> gains = new List<double[]>(); * gains.Add(controllerSASGains(node.GetNode(elevCtrlr), SASList.Pitch)); * gains.Add(controllerSASGains(node.GetNode(aileronCtrlr), SASList.Bank)); * gains.Add(controllerSASGains(node.GetNode(rudderCtrlr), SASList.Hdg)); * * string name = node.GetValue("name"); * if (name == SASDefaultName) * SASDefault = new SASPreset(gains, name); * else if (!instance.SASPresetList.Any(p => p.name == name)) * instance.SASPresetList.Add(new SASPreset(gains, name)); * } */ foreach (ConfigNode node in Presets.Node.GetNodes(craftPresetNodeName)) { if (node == null || instance.craftPresetDict.ContainsKey(node.GetValue("name"))) { continue; } string name = node.GetValue("name"); if (name == craftDefaultName) { instance.craftPresetDict.Add(craftDefaultName, new CraftPreset(craftDefaultName, asstDefault)); } else { CraftPreset cP = new CraftPreset(name, instance.APPresetList.FirstOrDefault(p => p.name == node.GetValue(craftAPKey))); instance.craftPresetDict.Add(cP.Name, cP); } } }