public void InitNewConfig() { if (FlightGlobals.ActiveVessel != null && !ConfigInfo.Instance.Sequences.ContainsKey(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel))) { Log.Info("InitNewConfig for " + ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel)); Sequences.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), Enumerable.Repeat(-1, 10).ToArray()); VesselOptions.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), new PerVesselOptions()); } }
public ConfigNode Load() { LoadSounds(); Log.Info("ConfigInfo.Load"); ConfigNode settingsFile = ConfigNode.Load(PLUGINDATA); ConfigNode node = null; if (settingsFile != null) { node = settingsFile.GetNode(SETTINGSNAME); if (node != null) { if (node.HasValue("soundEnabled")) { IsSoundEnabled = bool.Parse(node.GetValue("soundEnabled")); } if (node.HasValue("abort")) { AbortExecuted = bool.Parse(node.GetValue("abort")); } if (node.HasValue("scale")) { Scale = float.Parse(node.GetValue("scale")); } if (node.HasValue("soundSet")) { SoundSet = node.GetValue("soundSet"); } if (node.HasValue("position")) { WindowPosition = _wrapper.ToRect(node.GetValue("position")); Debug.LogWarning("Position is" + WindowPosition); } if (node.HasNode("sequence")) { var sequences = node.GetNodes("sequence"); Sequences.Clear(); VesselOptions.Clear(); foreach (var sequence in sequences) { PerVesselOptions pvo = new PerVesselOptions(); if (sequence.HasValue("LaunchSequenceControl")) { pvo.LaunchSequenceControl = bool.Parse(sequence.GetValue("LaunchSequenceControl")); } if (sequence.HasValue("enableSAS")) { pvo.enableSAS = bool.Parse(sequence.GetValue("enableSAS")); } if (sequence.HasValue("defaultInitialThrottle")) { pvo.defaultInitialThrottle = float.Parse(sequence.GetValue("defaultInitialThrottle")); } if (sequence.HasValue("defaultThrottle")) { pvo.defaultThrottle = float.Parse(sequence.GetValue("defaultThrottle")); } if (sequence.HasValue("useGravityTurn")) { pvo.useGravityTurn = bool.Parse(sequence.GetValue("useGravityTurn")); } VesselOptions.Add(sequence.GetValue("id"), pvo); int[] ar = Enumerable.Repeat(-1, 10).ToArray(); var d = sequence.GetValue("stages").Split(',').Select(int.Parse).ToArray(); for (int i = 0; i < d.Length; i++) { //Log.Info("Load, i: " + i + ", " + d[i]); ar[i] = d[i]; } Sequences.Add(sequence.GetValue("id"), ar); } } else { Sequences.Clear(); VesselOptions.Clear(); if (FlightGlobals.ActiveVessel != null && !ConfigInfo.Instance.Sequences.ContainsKey(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel))) { Sequences.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), Enumerable.Repeat(-1, 10).ToArray()); VesselOptions.Add(ModuleNASACountdown.CraftName(FlightGlobals.ActiveVessel), new PerVesselOptions()); } } IsLoaded = true; } } else { Sequences.Clear(); VesselOptions.Clear(); } return(node); }