Exemple #1
0
        public void LoadPresets()
        {
            Presets.Clear();

            // foreach (string file in System.IO.Directory.GetFiles(PresetPath, "*.cfg"))
            foreach (string file in PresetPaths)
            {
                try
                {
                    KCT_Preset newPreset = new KCT_Preset(file);
                    if (KCT_Utilities.CurrentGameIsCareer() && !newPreset.CareerEnabled)
                    {
                        continue;                                                                  //Don't display presets that aren't designed for this game mode
                    }
                    if (HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX && !newPreset.ScienceEnabled)
                    {
                        continue;
                    }
                    if (KCT_Utilities.CurrentGameIsSandbox() && !newPreset.SandboxEnabled)
                    {
                        continue;
                    }
                    KCT_Preset existing = FindPresetByShortName(newPreset.shortName);
                    if (existing != null) //Ensure there is only one preset with a given name. Take the last one found as the final one.
                    {
                        Presets.Remove(existing);
                    }
                    Presets.Add(newPreset);
                }
                catch
                {
                    Debug.LogError("[KCT] Could not load preset at " + file);
                }
            }
        }