Exemple #1
0
        public void LoadConfig(KSP.IO.PluginConfiguration config, string keyPrefix)
        {
            VOID_PanelLine line = this;

            string lineLabelPrecisionKey;
            string lineValuePrecisionKey;

            if (line.LabelIsVarPrecision)
            {
                lineLabelPrecisionKey = string.Format(
                    "{0}_Line{1}_LabelDigits",
                    keyPrefix,
                    line.LineNumber
                    );

                line.LabelVarPrecisionDigits = config.GetValue(lineLabelPrecisionKey, line.LabelVarPrecisionDigits);
            }

            if (line.ValueIsVarPrecision)
            {
                lineValuePrecisionKey = string.Format(
                    "{0}_Line{1}_ValueDigits",
                    keyPrefix,
                    line.LineNumber
                    );

                line.ValueVarPrecisionDigits = config.GetValue(lineValuePrecisionKey, line.ValueVarPrecisionDigits);
            }
        }
Exemple #2
0
 void LoadConfigs()
 {
     KSP.IO.PluginConfiguration config = FARDebugAndSettings.config;
     mainGuiRect     = config.GetValue("flight_mainGuiRect", new Rect());
     dataGuiRect     = config.GetValue("flight_dataGuiRect", new Rect());
     settingsGuiRect = config.GetValue("flight_settingsGuiRect", new Rect());
 }
        /*
         * Called when plug in loaded
         */
        public void Awake()
        {
            _state = DisplayState.none;
            RenderingManager.AddToPostDrawQueue(0, OnDraw);
            KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <UbioZurWeldingLtd>();
            config.load();
            //TODO: manage the case there is no config file (and so no values)

            /* Save the value to create the config file
             * config.SetValue(Constants.settingEdiButX, 190);
             * config.SetValue(Constants.settingEdiButY, 50);
             * config.SetValue(Constants.settingDbAutoReload, true);
             * config.SetValue(Constants.settingAllNodes, false);
             * config.SetValue(Constants.settingAllowCareer, false);
             * config.save();
             */

            int editorButx = config.GetValue <int>(Constants.settingEdiButX);
            int editorButy = config.GetValue <int>(Constants.settingEdiButY);

            _databaseAutoReload    = config.GetValue <bool>(Constants.settingDbAutoReload);
            Welder.IncludeAllNodes = config.GetValue <bool>(Constants.settingAllNodes);
            _allowCareerMode       = config.GetValue <bool>(Constants.settingAllowCareer);
            _editorButton          = new Rect(Screen.width - editorButx, editorButy, Constants.guiWeldButWidth, Constants.guiWeldButHeight);
            _editorErrorDial       = new Rect(Screen.width / 2 - Constants.guiDialogX, Screen.height / 2 - Constants.guiDialogY, Constants.guiDialogW, Constants.guiDialogH);
            _editorWarningDial     = new Rect(Screen.width / 2 - Constants.guiDialogX, Screen.height / 2 - Constants.guiDialogY, Constants.guiDialogW, Constants.guiDialogH);
            _editorInfoWindow      = new Rect(Screen.width / 2 - Constants.guiInfoWindowX, Screen.height / 2 - Constants.guiInfoWindowY, Constants.guiInfoWindowW, Constants.guiInfoWindowH);
            _editorOverwriteDial   = new Rect(Screen.width / 2 - Constants.guiDialogX, Screen.height / 2 - Constants.guiDialogY, Constants.guiDialogW, Constants.guiDialogH);
            _editorSavedDial       = new Rect(Screen.width / 2 - Constants.guiDialogX, Screen.height / 2 - Constants.guiDialogY, Constants.guiDialogW, Constants.guiDialogH);
        }
Exemple #4
0
 void addTriggers()
 {
     triggerList.AddRange(new[] {
         new Trigger("THROTTLE_TO_100", KeyCode.Z, () => FlightInputHandler.state.mainThrottle          = 1, "Throttle to 100%"),
         new Trigger("INCREMENT_BY_X", KeyCode.KeypadPlus, () => FlightInputHandler.state.mainThrottle += (float)configFile.GetValue("INCREMENT_AMOUNT", .25), "Increment throttle by X")
         {
             InitEvent = delegate { configFile.GetValue("INCREMENT_AMOUNT", .25); }
         },
         new Trigger("DECREMENT_BY_X", KeyCode.KeypadEnter, () => FlightInputHandler.state.mainThrottle -= (float)configFile.GetValue("DECREMENT_AMOUNT", .25), "Decrement throttle by X")
         {
             InitEvent = delegate { configFile.GetValue("DECREMENT_AMOUNT", .25); }
         },
         new Trigger("SET_CUSTOM_1", KeyCode.KeypadDivide, () => FlightInputHandler.state.mainThrottle = (float)configFile.GetValue("CUSTOM_1_VALUE", .25), "Set custom value (key 1)")
         {
             InitEvent = delegate { configFile.GetValue("CUSTOM_1_VALUE", .25); }
         },
         new Trigger("SET_CUSTOM_2", KeyCode.KeypadMultiply, () => FlightInputHandler.state.mainThrottle = (float)configFile.GetValue("CUSTOM_2_VALUE", .5), "Set custom value (key 2)")
         {
             InitEvent = delegate { configFile.GetValue("CUSTOM_2_VALUE", .5); }
         },
         new Trigger("SET_CUSTOM_3", KeyCode.KeypadMinus, () => FlightInputHandler.state.mainThrottle = (float)configFile.GetValue("CUSTOM_3_VALUE", .75), "Set custom value (key 3)")
         {
             InitEvent = delegate { configFile.GetValue("CUSTOM_3_VALUE", .75); }
         }
     });
 }
Exemple #5
0
 private static void LoadFromXml()
 {
     KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <SettingsLoader>(); // why use template T?
     config.load();
     guiwindowPosition = config.GetValue <Rect>("guiwindowPosition", guiwindowPosition);
     showConfigs       = config.GetValue <bool>("showConfig", showConfigs);
     guiIsActive       = config.GetValue <bool>("guiIsActive", guiIsActive);
 }
 void LoadConfigs()
 {
     KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <FlightGUI>();
     config.load();
     mainGuiRect     = config.GetValue("flight_mainGuiRect", new Rect());
     dataGuiRect     = config.GetValue("flight_dataGuiRect", new Rect());
     settingsGuiRect = config.GetValue("flight_settingsGuiRect", new Rect());
 }
        public void Awake()
        {
            // load XML config file, set default values if file doesnt exist
            KSP.IO.PluginConfiguration cfg = KSP.IO.PluginConfiguration.CreateForType <GenesisRage.SafeChuteModule>(null);
            cfg.load();

            deWarpGrnd = (float)cfg.GetValue <double>("DeWarpGround", 15.0f);
            maxAlt     = (double)cfg.GetValue <double>("MaxAltitude", 10000.0f);
            SCprint(String.Format("DeWarpGround = {0}, MaxAltitude = {1}", deWarpGrnd, maxAlt));
        }
        private void LoadSettings()
        {
            KSPLog.print("[kalculator.dll] Loading Config...");
            KSP.IO.PluginConfiguration _configfile = KSP.IO.PluginConfiguration.CreateForType <Kalculator>();
            _configfile.load();

            _calcsize       = _configfile.GetValue("windowpos", new Rect(360, 20, 308, 365));
            _keybind        = _configfile.GetValue("keybind", "k");
            _versionlastrun = _configfile.GetValue <string>("version");
            _useKspSkin     = _configfile.GetValue <bool>("KSPSkin", false);

            KSPLog.print("[kalculator.dll] Config Loaded Successfully");
        }
        public static void LoadConfigs()
        {
            config = KSP.IO.PluginConfiguration.CreateForType <FARDebugOptions>();
            config.load();
            FARDebugValues.displayForces               = Convert.ToBoolean(config.GetValue("displayForces", "false"));
            FARDebugValues.displayCoefficients         = Convert.ToBoolean(config.GetValue("displayCoefficients", "false"));
            FARDebugValues.displayShielding            = Convert.ToBoolean(config.GetValue("displayShielding", "false"));
            FARDebugValues.useSplinesForSupersonicMath = Convert.ToBoolean(config.GetValue("useSplinesForSupersonicMath", "true"));
            FARDebugValues.allowStructuralFailures     = Convert.ToBoolean(config.GetValue("allowStructuralFailures", "true"));

            FARAeroStress.LoadStressTemplates();
            FARPartClassification.LoadClassificationTemplates();
            FARAeroUtil.LoadAeroDataFromConfig();
        }
        public void Load()
        {
            KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <EnhancedNavBall>();
            configfile.load();

            IconPos = configfile.GetValue(_iconpos, new Rect(184, 0, 32, 32));
            WindowVisibleByActiveScene = configfile.GetValue(_windowvisiblebyactivescene, false);
            NavballPosition            = HandleFloatLoad(configfile.GetValue(_navballposition, GetDefaultNavballPosition()));
            NavballScale  = HandleFloatLoad(configfile.GetValue(_navballscale, GetDefaultNavballScale()));
            GhostPosition = HandleFloatLoad(configfile.GetValue(_ghostposition, (0.1f).ToString()));
            ProRetColour  = configfile.GetValue(_proRetColour, Color.white);
            NormalColour  = configfile.GetValue(_normalColour, Color.white);
            RadialColour  = configfile.GetValue(_radialColour, Color.white);
            ENBManeuver   = configfile.GetValue(_enbManeuver, false);
            RadialNormalDuringManeuver = configfile.GetValue(_radialNormalDuringManeuver, false);
        }
        public static float LoadStep <T>(float defStep = 1f)
        {
            double stepMult;

            stepMult = (double)defStep;

            try
            {
                KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <T>();

                config.load();

                stepMult = config.GetValue("stepMult", stepMult);

                config.save();
            }
            catch (Exception e)
            {
                Logging.PostErrorMessage(
                    "{0} handled while loading PluginData for type {1}: do you have a malformed XML file?",
                    e.GetType().FullName,
                    typeof(T).Name
                    );

                Logging.PostDebugMessage(e.ToString());
            }

            return((float)stepMult);
        }
        public static Vector2 LoadBounds <T>()
        {
            Vector2 bounds = new Vector2(float.NegativeInfinity, float.PositiveInfinity);

            try
            {
                KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <T>();

                config.load();

                bounds = config.GetValue("bounds", bounds);

                config.save();
            }
            catch (Exception e)
            {
                Logging.PostErrorMessage(
                    "{0} handled while loading PluginData for type {1}: do you have a malformed XML file?",
                    e.GetType().FullName,
                    typeof(T).Name
                    );

                Logging.PostDebugMessage(e.ToString());
            }

            return(bounds);
        }
        /// <summary>
        /// Loads the config for the Welding or prepares default values and generates a new config
        /// </summary>
        private void initConfig()
        {
            string xmlOldConfigFile = FileManager.FULLPATHNAME(Constants.settingXmlFilePath, Constants.settingXmlOldConfigFileName);

            KSP.IO.PluginConfiguration oldConfig = KSP.IO.PluginConfiguration.CreateForType <OldWeldingPluginConfig>();
            bool oldConfigFound = File.Exists(xmlOldConfigFile);

            if (oldConfigFound)
            {
                oldConfig = KSP.IO.PluginConfiguration.CreateForType <OldWeldingPluginConfig>();
                oldConfig.load();
                File.Delete(xmlOldConfigFile);
                Log.dbg("old configfile found and deleted");
            }

            if (!File.Exists(FileManager.CONFIG_FULLPATHNAME))
            {
                _config = new WeldingConfiguration();
                FileManager.saveConfig(_config);
                _config.vector2CurveModules       = Constants.basicVector2CurveModules;
                _config.vector4CurveModules       = Constants.basicVector4CurveModules;
                _config.subModules                = Constants.basicSubModules;
                _config.modulesToIgnore           = Constants.basicModulesToIgnore;
                _config.averagedModuleAttributes  = Constants.basicAveragedModuleAttributes;
                _config.unchangedModuleAttributes = Constants.basicUnchangedModuleAttributes;
                _config.breakingModuleAttributes  = Constants.basicBreakingModuleAttributes;
            }
            else
            {
                _config = FileManager.loadConfig();
            }

            _config.dataBaseAutoReload      = oldConfigFound ? oldConfig.GetValue <bool>(Constants.settingDbAutoReload) : _config.dataBaseAutoReload;
            _config.allowCareerMode         = oldConfigFound ? oldConfig.GetValue <bool>(Constants.settingAllowCareer) : _config.allowCareerMode;
            Welder.includeAllNodes          = oldConfigFound ? oldConfig.GetValue <bool>(Constants.settingAllNodes) : _config.includeAllNodes;
            Welder.dontProcessMasslessParts = oldConfigFound ? oldConfig.GetValue <bool>(Constants.settingDontProcessMasslessParts) : _config.dontProcessMasslessParts;

            Welder.StrengthCalcMethod = oldConfigFound ? StrengthParamsCalcMethod.ArithmeticMean : _config.StrengthCalcMethod;
            Welder.MaxTempCalcMethod  = oldConfigFound ? MaxTempCalcMethod.ArithmeticMean : _config.MaxTempCalcMethod;
            Welder.runInTestMode      = oldConfigFound ? false : _config.runInTestMode;
            Welder.precisionDigits    = oldConfigFound ? 6 : _config.precisionDigits;
            Welder.fileSimplification = oldConfigFound ? false : _config.fileSimplification;
        }
Exemple #14
0
        public static void LoadSettings(ref KSP.IO.PluginConfiguration config)
        {
            UnitsSettingsWindowPos = config.GetValue("unitsSettingsWindowPos", new Rect());

            PressureUnits    = GUIUnits.UnitsFromConfig <GUIUnits.Pressure>(ref config, GUIUnits.Pressure.kPa);
            TemperatureUnits = GUIUnits.UnitsFromConfig <GUIUnits.Temperature>(ref config, GUIUnits.Temperature.kelvin);
            ForceUnits       = GUIUnits.UnitsFromConfig <GUIUnits.Force>(ref config, GUIUnits.Force.kN);
            IspUnits         = GUIUnits.UnitsFromConfig <GUIUnits.Isp>(ref config, GUIUnits.Isp.s);
            TSFCUnits        = GUIUnits.UnitsFromConfig <GUIUnits.TSFC>(ref config, GUIUnits.TSFC.kg__kgf_h);
        }
        public void LoadSettingsFromConfig()
        {
            KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <EnginesFlightGUI>();
            config.load();

            FlightWindowPos = config.GetValue("flightWindowPos", new Rect());
            //FlightGUI.ShowFlightGUIWindow = config.GetValue("showFlightWindow", false);

            FlightGUISettings.LoadSettings(ref config);
            GUIUnitsSettings.LoadSettings(ref config);
        }
        private void LoadState(ConfigNode configNode)
        {
            KSP.IO.PluginConfiguration pluginConfig = KSP.IO.PluginConfiguration.CreateForType <AdvancedFlyByWire>();
            if (pluginConfig != null)
            {
                pluginConfig.load();
                this.m_UseKSPSkin             = pluginConfig.GetValue <bool>("useStockSkin", true);
                this.m_UseOldPresetsWindow    = pluginConfig.GetValue <bool>("useOldPresetEditor", false);
                this.m_UsePrecisionModeFactor = pluginConfig.GetValue <bool>("usePrecisionModeFactor", false);
                this.m_PrecisionModeFactor    = float.Parse(pluginConfig.GetValue <string>("precisionModeFactor", "0.5"));
            }

            m_Configuration = Configuration.Deserialize(GetAbsoluteConfigurationPath());
            if (m_Configuration == null)
            {
                m_Configuration = new Configuration();
                Configuration.Serialize(GetAbsoluteConfigurationPath(), m_Configuration);
            }

            m_FlightManager.m_Configuration = m_Configuration;
        }
        /// <summary>
        /// Loads the config for the Welding or prepares default values and generates a new config
        /// </summary>
        private void initConfig()
        {
            KSP.IO.PluginConfiguration oldConfig = KSP.IO.PluginConfiguration.CreateForType <OldWeldingPluginConfig>();
            bool oldConfigFound = System.IO.File.Exists(string.Concat(Constants.settingRuntimeDirectory, Constants.settingXmlFilePath, Constants.settingXmlOldConfigFileName));

            if (oldConfigFound)
            {
                oldConfig = KSP.IO.PluginConfiguration.CreateForType <OldWeldingPluginConfig>();
                oldConfig.load();
                System.IO.File.Delete(string.Concat(Constants.settingRuntimeDirectory, Constants.settingXmlFilePath, Constants.settingXmlOldConfigFileName));
                Debug.Log(string.Format("{0}old configfile found and deleted", Constants.logPrefix));
            }

            if (!System.IO.File.Exists(string.Concat(Constants.settingRuntimeDirectory, Constants.settingXmlFilePath, Constants.settingXmlConfigFileName)))
            {
                _config = new WeldingConfiguration();
                FileManager.saveConfig(_config);
                _config.vector2CurveModules       = Constants.basicVector2CurveModules;
                _config.vector4CurveModules       = Constants.basicVector4CurveModules;
                _config.subModules                = Constants.basicSubModules;
                _config.modulesToIgnore           = Constants.basicModulesToIgnore;
                _config.averagedModuleAttributes  = Constants.basicAveragedModuleAttributes;
                _config.unchangedModuleAttributes = Constants.basicUnchangedModuleAttributes;
                _config.breakingModuleAttributes  = Constants.basicBreakingModuleAttributes;
            }
            else
            {
                _config = FileManager.loadConfig();
            }

            _config.dataBaseAutoReload      = oldConfigFound ? oldConfig.GetValue <bool>(Constants.settingDbAutoReload) : _config.dataBaseAutoReload;
            _config.allowCareerMode         = oldConfigFound ? oldConfig.GetValue <bool>(Constants.settingAllowCareer) : _config.allowCareerMode;
            Welder.includeAllNodes          = oldConfigFound ? oldConfig.GetValue <bool>(Constants.settingAllNodes) : _config.includeAllNodes;
            Welder.dontProcessMasslessParts = oldConfigFound ? oldConfig.GetValue <bool>(Constants.settingDontProcessMasslessParts) : _config.dontProcessMasslessParts;

            Welder.StrengthCalcMethod = oldConfigFound ? StrengthParamsCalcMethod.ArithmeticMean : _config.StrengthCalcMethod;
            Welder.MaxTempCalcMethod  = oldConfigFound ? MaxTempCalcMethod.ArithmeticMean : _config.MaxTempCalcMethod;
            Welder.runInTestMode      = oldConfigFound ? false : _config.runInTestMode;
            Welder.precisionDigits    = oldConfigFound ? 6 : _config.precisionDigits;
        }
Exemple #18
0
        public void LoadConfig()
        {
            if (config == null)
            {
                config = KSP.IO.PluginConfiguration.CreateForType <SaturableRW> ();
            }

            config.load();

            if (!config.GetValue("DefaultStateIsActive", true) && vessel.atmDensity > 0.001)
            {
                wheelRef.State = ModuleReactionWheel.WheelState.Disabled;
            }

            if (!config.GetValue("DisplayCurrentTorque", false))
            {
                Fields ["availablePitchTorque"].guiActive = false;
                Fields ["availableRollTorque"].guiActive  = false;
                Fields ["availableYawTorque"].guiActive   = false;
            }

            dischargeTorque |= config.GetValue("dischargeTorque", false);

            // Save the file so it can be activated by anyone.

            config ["DefaultStateIsActive"] = config.GetValue("DefaultStateIsActive", true);
            config ["DisplayCurrentTorque"] = config.GetValue("DisplayCurrentTorque", false);
            config ["dischargeTorque"]      = config.GetValue("dischargeTorque", false);

            config.save();
        }
 public void LoadConfig()
 {
     Config = KSP.IO.PluginConfiguration.CreateForType <AtmosphericSoundEnhancement>();
     Config.load();
     InteriorVolumeScale        = Config.GetValue <float>("InteriorVolumeScale", InteriorVolumeScale);
     InteriorMaxFreq            = Config.GetValue <float>("InteriorMaxFreq", InteriorMaxFreq);
     LowerMachThreshold         = Config.GetValue <float>("LowerMachThreshold", LowerMachThreshold);
     UpperMachThreshold         = Config.GetValue <float>("UpperMachThreshold", UpperMachThreshold);
     MaxDistortion              = Config.GetValue <float>("MaxDistortion", MaxDistortion);
     CondensationEffectStrength = Config.GetValue <float>("CondensationEffectStrength"
                                                          , CondensationEffectStrength
                                                          );
     MaxVacuumFreq     = Config.GetValue <float>("MaxVacuumFreq", MaxVacuumFreq);
     MaxSupersonicFreq = Config.GetValue <float>("MaxSupersonicFreq", MaxSupersonicFreq);
     Log.dbg("Loaded settings: {0} {1} {2} {3} {4} {5} {6} {7}", InteriorVolumeScale, InteriorMaxFreq, LowerMachThreshold, UpperMachThreshold, MaxDistortion, CondensationEffectStrength, MaxVacuumFreq, MaxSupersonicFreq);
 }
Exemple #20
0
        private void Start()
        {
            instance = this;

            if (config == null)
            {
                config = KSP.IO.PluginConfiguration.CreateForType <LINEARWindow>();
            }

            config.load();

            windowRect           = config.GetValue("windowRect", new Rect(500, 500, 300, 0));
            config["windowRect"] = windowRect;
        }
 public void LoadConfig()
 {
     Config = KSP.IO.PluginConfiguration.CreateForType <AtmosphericSoundEnhancement>();
     Config.load();
     InteriorVolumeScale        = Config.GetValue <float>("InteriorVolumeScale", InteriorVolumeScale);
     InteriorMaxFreq            = Config.GetValue <float>("InteriorMaxFreq", InteriorMaxFreq);
     LowerMachThreshold         = Config.GetValue <float>("LowerMachThreshold", LowerMachThreshold);
     UpperMachThreshold         = Config.GetValue <float>("UpperMachThreshold", UpperMachThreshold);
     MaxDistortion              = Config.GetValue <float>("MaxDistortion", MaxDistortion);
     CondensationEffectStrength = Config.GetValue <float>("CondensationEffectStrength"
                                                          , CondensationEffectStrength
                                                          );
     MaxVacuumFreq     = Config.GetValue <float>("MaxVacuumFreq", MaxVacuumFreq);
     MaxSupersonicFreq = Config.GetValue <float>("MaxSupersonicFreq", MaxSupersonicFreq);
     Debug.Log("ASE -- Loaded settings: " + InteriorVolumeScale + " " + InteriorMaxFreq + " " + LowerMachThreshold + " " + UpperMachThreshold + " " + MaxDistortion + " " + CondensationEffectStrength + " " + MaxVacuumFreq + " " + MaxSupersonicFreq);
 }
 private void LoadConfig()
 {
     Debug.Log("[Adjustable Mod Panel] Loading settings.");
     KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <AdjustableModPanel> (null);
     config.load();
     try {
         int count = config.GetValue <int> ("count");
         for (int i = 1; i <= count; i++)
         {
             string        key  = config.GetValue <string> ("mod" + i.ToString(), "");
             ModDescriptor desc = null;
             if (key != "")
             {
                 var vals = key.Split('+');
                 desc = new ModDescriptor()
                 {
                     module            = vals[0],
                     method            = vals[1],
                     textureHash       = 0,
                     textureHashNeeded = false,
                     unmanageable      = false,
                     modIcon           = null,
                     defaultScenes     = ApplicationLauncher.AppScenes.NEVER,
                     requiredScenes    = ApplicationLauncher.AppScenes.NEVER
                 };
             }
             else
             {
                 desc = new ModDescriptor()
                 {
                     module            = config.GetValue <string> ("module" + i.ToString()),
                     method            = config.GetValue <string> ("method" + i.ToString()),
                     textureHashNeeded = config.GetValue <bool> ("hashNeeded" + i.ToString()),
                     textureHash       = (uint)config.GetValue <long> ("hash" + i.ToString(), 0u),
                     unmanageable      = false,
                     modIcon           = null,
                     defaultScenes     = ApplicationLauncher.AppScenes.NEVER,
                     requiredScenes    = ApplicationLauncher.AppScenes.NEVER
                 };
             }
             ApplicationLauncher.AppScenes value = (ApplicationLauncher.AppScenes)config.GetValue <int> ("scenes" + i.ToString());
             descriptors.Add(desc);
             currentScenes[desc] = value;
             pinnedMods[desc]    = config.GetValue <bool> ("pinned" + i.ToString(), false);
         }
     } catch (System.Exception e) {
         Debug.Log("[Adjustable Mod Panel] There was an error reading config: " + e);
     }
 }
Exemple #23
0
        public override void LoadConfig(KSP.IO.PluginConfiguration config)
        {
            base.LoadConfig(config);

            config.load();

            HUDWindow window;

            for (int idx = 0; idx < this.Windows.Count; idx++)
            {
                window = this.Windows[idx];

                string saveName  = string.Format("{0}_{1}", this.GetType().Name, window.WindowName);
                Rect   loadedPos = config.GetValue(saveName, window.defaultWindowPos);

                window.WindowPos = loadedPos;
            }
        }
Exemple #24
0
        public override void LoadConfig(KSP.IO.PluginConfiguration config)
        {
            base.LoadConfig(config);

            config.load();

            VOID_PanelLineGroup group;
            VOID_PanelLine      line;

            string groupKeyPrefix;
            string groupIsShownKey;

            for (int lIdx = 0; lIdx < this.PanelLines.Count; lIdx++)
            {
                line = this.PanelLines[lIdx];

                line.LoadConfig(config, this.saveKeyName);
            }

            for (int gIdx = 0; gIdx < this.lineGroups.Count; gIdx++)
            {
                group = this.lineGroups[gIdx];

                groupKeyPrefix = string.Format("{0}_{1}", this.saveKeyName, group.Name);

                groupIsShownKey = string.Format("{0}_{1}{2}",
                                                this.saveKeyName, group.Name, VOID_PanelLineGroup.ISSHOWN_KEY);

                group.IsShown = config.GetValue(groupIsShownKey, group.IsShown);

                for (int lIdx = 0; lIdx < this.PanelLines.Count; lIdx++)
                {
                    line = this.PanelLines[lIdx];

                    line.LoadConfig(config, groupKeyPrefix);
                }
            }
        }
Exemple #25
0
        private void Serialize(bool write)
        {
            var props = from p in this.GetType().GetProperties()
                        let attr = p.GetCustomAttributes(typeof(Persistent), true)
                                   where attr.Length == 1
                                   select new { Property = p, Attribute = attr.First() as Persistent };

            foreach (var prop in props)
            {
                if (write)
                {
                    config.SetValue(prop.Property.Name, prop.Property.GetValue(this, null));
                }
                else
                {
                    prop.Property.SetValue(this, config.GetValue <object>(prop.Property.Name, prop.Attribute.DefaultValue), null);
                }
            }

            if (write)
            {
                config.save();
            }
        }
        public static void LoadConfigs()
        {
            config = KSP.IO.PluginConfiguration.CreateForType <FARDebugOptions>();
            config.load();
            FARDebugValues.displayForces               = Convert.ToBoolean(config.GetValue("displayForces", "false"));
            FARDebugValues.displayCoefficients         = Convert.ToBoolean(config.GetValue("displayCoefficients", "false"));
            FARDebugValues.displayShielding            = Convert.ToBoolean(config.GetValue("displayShielding", "false"));
            FARDebugValues.useSplinesForSupersonicMath = Convert.ToBoolean(config.GetValue("useSplinesForSupersonicMath", "true"));
            FARDebugValues.allowStructuralFailures     = Convert.ToBoolean(config.GetValue("allowStructuralFailures", "true"));

            FARDebugValues.useBlizzyToolbar      = Convert.ToBoolean(config.GetValue("useBlizzyToolbar", "false"));
            FARDebugValues.aeroFailureExplosions = Convert.ToBoolean(config.GetValue("aeroFailureExplosions", "true"));

            FARAeroStress.LoadStressTemplates();
            FARPartClassification.LoadClassificationTemplates();
            FARAeroUtil.LoadAeroDataFromConfig();
            FARActionGroupConfiguration.LoadConfiguration();
            FAREditorGUI.LoadColors();
            ReColorTexture(ref FAREditorGUI.clColor, ref cLTexture);
            ReColorTexture(ref FAREditorGUI.cdColor, ref cDTexture);
            ReColorTexture(ref FAREditorGUI.cmColor, ref cMTexture);
            ReColorTexture(ref FAREditorGUI.l_DColor, ref l_DTexture);
        }
Exemple #27
0
        public void Load()
        {
            try
            {
                KACWorker.DebugLogFormatted("Loading Config");
                KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <KerbalAlarmClock>();
                configfile.load();

                this.DailyVersionCheck = configfile.GetValue("DailyUpdateCheck", true);

                try { this.VersionCheckDate_Attempt = DateTime.ParseExact(configfile.GetValue("VersionCheckDate_Attempt", ""), "yyyy-MM-dd", CultureInfo.CurrentCulture); }
                catch (Exception) { this.VersionCheckDate_Attempt = new DateTime(); }

                try { this.VersionCheckDate_Success = DateTime.ParseExact(configfile.GetValue("VersionCheckDate_Success", ""), "yyyy-MM-dd", CultureInfo.CurrentCulture); }
                catch (Exception) { this.VersionCheckDate_Success = new DateTime(); }

                this.VersionWeb = configfile.GetValue("VersionWeb", "");

                this.WindowVisible   = configfile.GetValue("WindowVisible", false);
                this.WindowMinimized = configfile.GetValue("WindowMinimized", false);
                this.WindowPos       = configfile.GetValue <Rect>("WindowPos", new Rect(3, 55, 300, 45));

                this.WindowVisible_SpaceCenter   = configfile.GetValue("WindowVisible_SpaceCenter", false);
                this.WindowMinimized_SpaceCenter = configfile.GetValue("WindowMinimized_SpaceCenter", false);
                this.WindowPos_SpaceCenter       = configfile.GetValue <Rect>("WindowPos_SpaceCenter", new Rect(3, 36, 300, 45));

                this.WindowVisible_TrackingStation   = configfile.GetValue("WindowVisible_TrackingStation", false);
                this.WindowMinimized_TrackingStation = configfile.GetValue("WindowMinimized_TrackingStation", false);
                this.WindowPos_TrackingStation       = configfile.GetValue <Rect>("WindowPos_TrackingStation", new Rect(202, 45, 300, 45));

                this.IconPos                        = configfile.GetValue <Rect>("IconPos", new Rect(152, 0, 32, 32));
                this.IconPos.height                 = 32; this.IconPos.width = 32;
                this.IconPos_SpaceCenter            = configfile.GetValue <Rect>("IconPos_SpaceCenter", new Rect(3, 3, 32, 32));
                this.IconPos_SpaceCenter.height     = 32; this.IconPos_TrackingStation.width = 32;
                this.IconPos_TrackingStation        = configfile.GetValue <Rect>("IconPos_TrackingStation", new Rect(196, 0, 32, 32));
                this.IconPos_TrackingStation.height = 32; this.IconPos_TrackingStation.width = 32;

                this.IconShow_SpaceCenter     = configfile.GetValue("IconShow_SpaceCenter", true);
                this.IconShow_TrackingStation = configfile.GetValue("IconShow_TrackingStation", true);

                this.UseBlizzyToolbarIfAvailable = configfile.GetValue <Boolean>("UseBlizzyToolbarIfAvailable", true);
                this.WindowMinimizedType         = (MiminalDisplayType)configfile.GetValue("WindowMinimizedType", 0);

                this.KSCUIBlockersEnabled = configfile.GetValue <Boolean>("UIBlockersEnabled", true);

                this.BehaviourChecksPerSec        = configfile.GetValue("BehaviourChecksPerSec", 10);
                this.BehaviourChecksPerSec_Custom = configfile.GetValue("BehaviourChecksPerSecCustom", 40);

                this.BackupSaves       = configfile.GetValue("BackupSaves", true);
                this.BackupSavesToKeep = configfile.GetValue("BackupSavesToKeep", 20);
                this.CancelFlightModeJumpOnBackupFailure = configfile.GetValue("CancelFlightModeJumpOnBackupFailure", false);

                this.AllowJumpFromViewOnly = configfile.GetValue("AllowJumpFromViewOnly", true);
                this.AllowJumpToAsteroid   = configfile.GetValue("AllowJumpToAsteroid", false);

                this.AlarmListMaxAlarms = configfile.GetValue("AlarmListMaxAlarms", "10");
                this.AlarmDefaultAction = configfile.GetValue <int>("AlarmDefaultAction", 1);
                this.AlarmDefaultMargin = configfile.GetValue <Double>("AlarmDefaultMargin", 60);
                this.AlarmPosition      = configfile.GetValue <int>("AlarmPosition", 1);
                this.AlarmDeleteOnClose = configfile.GetValue("AlarmDeleteOnClose", false);
                this.ShowTooltips       = configfile.GetValue("ShowTooltips", true);
                this.ShowEarthTime      = configfile.GetValue("ShowEarthTime", false);
                this.HideOnPause        = configfile.GetValue("HideOnPause", true);
                String strTimeFormat = configfile.GetValue("TimeFormat", "KSPString");
                //KACWorker.DebugLogFormatted("{0}",strTimeFormat);
                this.TimeFormat = (KACTime.PrintTimeFormat)Enum.Parse(typeof(KACTime.PrintTimeFormat), strTimeFormat);
                //this.TimeFormat = configfile.GetValue<KACTime.PrintTimeFormat>("TimeFormat", KACTime.PrintTimeFormat.KSPString);
                //KACWorker.DebugLogFormatted("{0}",this.TimeFormat.ToString());
                if (configfile.GetValue <bool>("TimeAsUT", false) == true)
                {
                    KACWorker.DebugLogFormatted("Forcing New Format");
                    this.TimeFormat = KACTime.PrintTimeFormat.TimeAsUT;
                    configfile.SetValue("TimeAsUT", false);
                    configfile.SetValue("TimeFormat", Enum.GetName(typeof(KACTime.PrintTimeFormat), this.TimeFormat));
                    configfile.save();
                }

                this.AlarmXferRecalc          = configfile.GetValue("AlarmXferRecalc", true);
                this.AlarmXferRecalcThreshold = configfile.GetValue <Double>("AlarmXferRecalcThreshold", 180);
                this.AlarmXferDisplayList     = configfile.GetValue("AlarmXferDisplayList", false);
                this.XferUseModelData         = configfile.GetValue("XferUseModelData", false);

                this.AlarmNodeRecalc          = configfile.GetValue("AlarmNodeRecalc", false);
                this.AlarmNodeRecalcThreshold = configfile.GetValue <Double>("AlarmNodeRecalcThreshold", 180);

                this.AlarmAddSOIAuto          = configfile.GetValue("AlarmAddSOIAuto", false);
                this.AlarmAddSOIAutoThreshold = configfile.GetValue <Double>("AlarmAddSOIAutoThreshold", 180);
                //this.AlarmAddSOIMargin = configfile.GetValue("AlarmAddSOIMargin", 120);
                this.AlarmAutoSOIMargin         = configfile.GetValue <Double>("AlarmAutoSOIMargin", 900);
                this.AlarmAddSOIAuto_ExcludeEVA = configfile.GetValue("AlarmAddSOIAuto_ExcludeEVA", true);
                this.AlarmCatchSOIChange        = configfile.GetValue("AlarmOnSOIChange", false);
                this.AlarmOnSOIChange_Action    = configfile.GetValue("AlarmOnSOIChange_Action", 1);

                this.AlarmSOIRecalc          = configfile.GetValue("AlarmSOIRecalc", false);
                this.AlarmSOIRecalcThreshold = configfile.GetValue <Double>("AlarmSOIRecalcThreshold", 180);

                this.AlarmAddManAuto           = configfile.GetValue("AlarmAddManAuto", false);
                this.AlarmAddManAuto_andRemove = configfile.GetValue("AlarmAddManAuto_andRemove", false);
                this.AlarmAddManAutoThreshold  = configfile.GetValue <Double>("AlarmAddManAutoThreshold", 180);
                this.AlarmAddManAutoMargin     = configfile.GetValue <Double>("AlarmAddManAutoMargin", 180);
                this.AlarmAddManAuto_Action    = configfile.GetValue("AlarmAddManAuto_Action", 1);

                this.AlarmCrewDefaultStoreNode = configfile.GetValue("AlarmCrewDefaultStoreNode", false);

                this.LoadManNode      = configfile.GetValue("LoadManNode", "");
                this.LoadVesselTarget = configfile.GetValue("LoadVesselTarget", "");

                if (KSP.IO.File.Exists <KerbalAlarmClock>(String.Format("Alarms-{0}.txt", HighLogic.CurrentGame.Title)))
                {
                    KACWorker.DebugLogFormatted("Trying New Alarms file...");
                    LoadAlarms();
                }
                else
                {
                    //Loop through numbers to Load Alarms
                    Alarms = new KACAlarmList();
                    int    intAlarm = 0;
                    String strAlarm = "";
                    do
                    {
                        strAlarm = configfile.GetValue("Alarm_" + intAlarm, "");
                        KACWorker.DebugLogFormatted(strAlarm);
                        if (strAlarm != "")
                        {
                            KACAlarm tmpAlarm = new KACAlarm();
                            tmpAlarm.LoadFromString(strAlarm);
                            Alarms.Add(tmpAlarm);
                            intAlarm++;
                        }
                    } while (strAlarm != "");
                }
                KACWorker.DebugLogFormatted("Config Loaded Successfully");
            }

            catch (Exception ex)
            {
                KACWorker.DebugLogFormatted("Failed To Load Config");
                KACWorker.DebugLogFormatted(ex.Message);
            }
        }
 public void LoadConfig()
 {
     Config = KSP.IO.PluginConfiguration.CreateForType<AtmosphericSoundEnhancement>();
     Config.load();
     InteriorVolumeScale = Config.GetValue<float>("InteriorVolumeScale", InteriorVolumeScale);
     InteriorMaxFreq = Config.GetValue<float>("InteriorMaxFreq", InteriorMaxFreq);
     LowerMachThreshold = Config.GetValue<float>("LowerMachThreshold", LowerMachThreshold);
     UpperMachThreshold = Config.GetValue<float>("UpperMachThreshold", UpperMachThreshold);
     MaxDistortion = Config.GetValue<float>("MaxDistortion", MaxDistortion);
     CondensationEffectStrength = Config.GetValue<float>( "CondensationEffectStrength"
                                                        , CondensationEffectStrength
                                                        );
     MaxVacuumFreq = Config.GetValue<float>("MaxVacuumFreq", MaxVacuumFreq);
     MaxSupersonicFreq = Config.GetValue<float>("MaxSupersonicFreq", MaxSupersonicFreq);
     Debug.Log("ASE -- Loaded settings: " + InteriorVolumeScale + " " + InteriorMaxFreq + " " + LowerMachThreshold + " " + UpperMachThreshold + " " + MaxDistortion + " " + CondensationEffectStrength + " " + MaxVacuumFreq + " " + MaxSupersonicFreq);
 }
        public static void LoadConfigs()
        {
            config = KSP.IO.PluginConfiguration.CreateForType<FARDebugOptions>();
            config.load();
            FARDebugValues.displayForces = Convert.ToBoolean(config.GetValue("displayForces", "false"));
            FARDebugValues.displayCoefficients = Convert.ToBoolean(config.GetValue("displayCoefficients", "false"));
            FARDebugValues.displayShielding = Convert.ToBoolean(config.GetValue("displayShielding", "false"));
            FARDebugValues.useSplinesForSupersonicMath = Convert.ToBoolean(config.GetValue("useSplinesForSupersonicMath", "true"));
            FARDebugValues.allowStructuralFailures = Convert.ToBoolean(config.GetValue("allowStructuralFailures", "true"));

            FARDebugValues.useBlizzyToolbar = Convert.ToBoolean(config.GetValue("useBlizzyToolbar", "false"));

            FARAeroStress.LoadStressTemplates();
            FARPartClassification.LoadClassificationTemplates();
            FARAeroUtil.LoadAeroDataFromConfig();
        }
        public static void LoadConfiguration()
        {
            string[]         names   = Enum.GetNames(typeof(KSPActionGroup));
            KSPActionGroup[] agTypes = new KSPActionGroup[names.Length];
            actionGroupDropDown = new GUIDropDown <KSPActionGroup> [3];

            for (int i = 0; i < agTypes.Length; i++)
            {
                agTypes[i] = (KSPActionGroup)Enum.Parse(typeof(KSPActionGroup), names[i]);
            }

            // straight forward, reading the (action name, action group) tuples
            KSP.IO.PluginConfiguration config = FARDebugAndSettings.config;
            for (int i = 0; i < ACTION_COUNT; ++i)
            {
                try
                {
                    id2actionGroup[i]    = (KSPActionGroup)Enum.Parse(typeof(KSPActionGroup), config.GetValue(configKeys[i], id2actionGroup[i].ToString()));;
                    currentGuiStrings[i] = id2actionGroup[i].ToString(); // don't forget to initialize the gui
                    Debug.Log(String.Format("FAR: loaded AG {0} as {1}", configKeys[i], id2actionGroup[i]));
                }
                catch (Exception e)
                {
                    Debug.LogWarning("FAR: error reading config key '" + configKeys[i] + "' with value '" + config.GetValue(configKeys[i], "n/a") + "' gave " + e.ToString());
                }
                int initIndex = 0;
                for (int j = 0; j < agTypes.Length; j++)
                {
                    if (id2actionGroup[i] == agTypes[j])
                    {
                        initIndex = j;
                        break;
                    }
                }
                GUIDropDown <KSPActionGroup> dropDown = new GUIDropDown <KSPActionGroup>(names, agTypes, initIndex);
                actionGroupDropDown[i] = dropDown;
            }
        }
        public static void LoadConfigs()
        {
            config = KSP.IO.PluginConfiguration.CreateForType<WingProceduralManager> ();
            config.load ();

            WingProceduralManager.uiRectWindowEditor = config.GetValue("uiRectWindowEditor", UIUtility.SetToScreenCenterAlways(new Rect()));
            WingProceduralManager.uiRectWindowDebug = config.GetValue<Rect> ("uiRectWindowDebug", UIUtility.SetToScreenCenterAlways(new Rect()));

            WPDebug.logCAV = Convert.ToBoolean (config.GetValue ("logCAV", "false"));
            WPDebug.logUpdate = Convert.ToBoolean (config.GetValue ("logUpdate", "false"));
            WPDebug.logUpdateGeometry = Convert.ToBoolean (config.GetValue ("logUpdateGeometry", "false"));

            WPDebug.logUpdateMaterials = Convert.ToBoolean (config.GetValue ("logUpdateMaterials", "false"));
            WPDebug.logMeshReferences = Convert.ToBoolean (config.GetValue ("logMeshReferences", "false"));
            WPDebug.logCheckMeshFilter = Convert.ToBoolean (config.GetValue ("logCheckMeshFilter", "false"));

            WPDebug.logPropertyWindow = Convert.ToBoolean (config.GetValue ("logPropertyWindow", "false"));
            WPDebug.logFlightSetup = Convert.ToBoolean (config.GetValue ("logFlightSetup", "false"));
            WPDebug.logFieldSetup = Convert.ToBoolean (config.GetValue ("logFieldSetup", "false"));

            WPDebug.logFuel = Convert.ToBoolean (config.GetValue ("logFuel", "false"));
            WPDebug.logLimits = Convert.ToBoolean (config.GetValue ("logLimits", "false"));
            WPDebug.logEvents = Convert.ToBoolean (config.GetValue ("logEvents", "false"));
        }
        private void LoadPresets()
        {
            config = KSP.IO.PluginConfiguration.CreateForType<IspAdjustmentGUIController>();
            config.load();
            int presetNum = 0;
            do
            {
                string tmpName;
                tmpName = config.GetValue("IspPreset" + presetNum + "Name", "NothingHere");
                //IspPreset tmp = config.GetValue("IspPreset" + presetNum, new IspPreset("NothingHere", "", 1, 1, false));
                if (tmpName == "NothingHere")
                    break;

                IspPreset tmp = new IspPreset();
                tmp.presetName = tmpName;
                tmp.presetDescription = config.GetValue<string>("IspPreset" + presetNum + "Description");
                tmp.vacIspMult = Convert.ToSingle(config.GetValue<string>("IspPreset" + presetNum + "Vac"));
                tmp.atmIspMult = Convert.ToSingle(config.GetValue<string>("IspPreset" + presetNum + "Atm"));

                tmp.extendToZero = config.GetValue<bool>("IspPreset" + presetNum + "Extend");
                tmp.thrustCorrection = config.GetValue<bool>("IspPreset" + presetNum + "ThrustCorrection");

                tmp.ratingIspCutoff = Convert.ToSingle(config.GetValue<string>("IspPreset" + presetNum + "RatingIspCutoff", "385"));
                tmp.ratingThrustCutoff = Convert.ToSingle(config.GetValue<string>("IspPreset" + presetNum + "RatingThrustCutoff", "300"));

                presetNum++;
                IspPresetList.Add(tmp);

            } while (true);

            string gameName = HighLogic.CurrentGame.Title;

            int selectedPresetNum = Convert.ToInt32(config.GetValue("SelectedPreset" + gameName, "0"));

            selectedPreset = IspPresetList[selectedPresetNum];

            print("Presets Loaded...");
        }
Exemple #33
0
 virtual public void LoadSettings()
 {
     configfile.load();
     gui_enabled = configfile.GetValue <bool>(mangleName("gui_enabled"), true);
 }
 private void LoadVersion()
 {
     KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <Kalculator>();
     configfile.load();
     _versionlastrun = configfile.GetValue <string>("version");
 }