示例#1
0
        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);
        }
示例#2
0
        public Settings()
        {
            config = KSP.IO.PluginConfiguration.CreateForType<Settings>();
            config.load();

            Serialize(false);
        }
示例#3
0
        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);
        }
        /*
         * 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);
        }
示例#5
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();
        }
示例#6
0
        public void LoadConfig()
        {
            KSP.IO.PluginConfiguration config = KSP.IO.PluginConfiguration.CreateForType <PartCatalog>();
            config.load();

            foreach (FieldInfo field in GetType().GetFields(BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Public))
            {
                foreach (Attribute at in field.GetCustomAttributes(false))
                {
                    if (at is SaveToConfig)
                    {
                        MethodInfo   getValueMethod = null;
                        MethodInfo[] methods        = typeof(KSP.IO.PluginConfiguration).GetMethods();
                        foreach (MethodInfo method in methods)
                        {
                            if (method.IsGenericMethodDefinition && method.ContainsGenericParameters && method.GetParameters().Length == 2)
                            {
                                getValueMethod = method.MakeGenericMethod(new Type[] { field.FieldType });
                                break;
                            }
                        }
                        if (getValueMethod != null)
                        {
                            object val = getValueMethod.Invoke(config, new object[] { field.Name, ((SaveToConfig)at).DefaultValue });
                            field.SetValue(this, val);
                        }
                    }
                }
            }
        }
示例#7
0
        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"));

            //prefs
            WingProcedural.sharedPropAnglePref = Convert.ToBoolean(config.GetValue("AnglePref", "false"));
            //WingProcedural.sharedPropEdgePref = Convert.ToBoolean(config.GetValue("EdgePref", "false"));
            WingProcedural.sharedPropEThickPref = Convert.ToBoolean(config.GetValue("ThickPref", "false"));
        }
示例#8
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());
 }
示例#10
0
        public Settings()
        {
            config = KSP.IO.PluginConfiguration.CreateForType <Settings>();
            try
            {
                config.load();
            }
            catch (System.Xml.XmlException e)
            {
                if (ConfigError)
                {
                    throw; // if previous error handling failed, we give up
                }
                ConfigError = true;

                Debug.Log("Error loading Trajectories config: " + e.ToString());

                string TrajPluginPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                Debug.Log("Trajectories is installed in: " + TrajPluginPath);
                TrajPluginPath += "/PluginData/" + System.Reflection.Assembly.GetExecutingAssembly().FullName + "/config.xml";
                if (System.IO.File.Exists(TrajPluginPath))
                {
                    Debug.Log("Clearing config file...");
                    int idx = 1;
                    while (System.IO.File.Exists(TrajPluginPath + ".bak." + idx))
                    {
                        ++idx;
                    }
                    System.IO.File.Move(TrajPluginPath, TrajPluginPath + ".bak." + idx);

                    Debug.Log("Creating new config...");
                    config.load();

                    Debug.Log("New config created");
                }
                else
                {
                    Debug.Log("No config file exists");
                    throw;
                }
            }

            Serialize(false);

            MapGUIWindowPos = new Rect(MapGUIWindowPos.xMin, MapGUIWindowPos.yMin, 1, MapGUIWindowPos.height); // width will be auto-sized to fit contents
        }
示例#11
0
        public Settings()
        {
            config = KSP.IO.PluginConfiguration.CreateForType<Settings>();
            config.load();

            Serialize(false);

            MapGUIWindowPos = new Rect(MapGUIWindowPos.xMin, MapGUIWindowPos.yMin, 1, MapGUIWindowPos.height); // width will be auto-sized to fit contents
        }
示例#12
0
        public Settings()
        {
            config = KSP.IO.PluginConfiguration.CreateForType <Settings>();
            config.load();

            Serialize(false);

            MapGUIWindowPos = new Rect(MapGUIWindowPos.xMin, MapGUIWindowPos.yMin, 1, MapGUIWindowPos.height); // width will be auto-sized to fit contents
        }
示例#13
0
 public void SaveLoadObjects()
 {
     KACWorker.DebugLogFormatted("Saving Load Objects");
     KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <KerbalAlarmClock>();
     configfile.load();
     configfile.SetValue("LoadManNode", this.LoadManNode);
     configfile.SetValue("LoadVesselTarget", this.LoadVesselTarget);
     configfile.save();
     KACWorker.DebugLogFormatted("Saved Load Objects");
 }
示例#14
0
        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));
        }
示例#15
0
        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);
        }
示例#16
0
        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();
        }
示例#18
0
        public void Awake()
        {
            //First, we need to look for the FloorIt slim plugin. It conflicts with this one. We'll throw an exception for it.
            if (Array.Find(AppDomain.CurrentDomain.GetAssemblies(), item => item.FullName == "FloorIt") != null)
            {
                print("ERROR: FloorIt slim edition found. Initialization aborted.");
                throw new Exception("FloorIt slim edition found.");
            }

            configFile = KSP.IO.PluginConfiguration.CreateForType <FloorItPlugin>();
            configFile.load();

            addTriggers();
        }
示例#19
0
        public static void LoadConfigs(ConfigNode node)
        {
            config = KSP.IO.PluginConfiguration.CreateForType <FARSettingsScenarioModule>();
            config.load();

            bool tmp;

            if (node.HasValue("allowStructuralFailures") && bool.TryParse(node.GetValue("allowStructuralFailures"), out tmp))
            {
                FARDebugValues.allowStructuralFailures = tmp;
            }
            else
            {
                FARDebugValues.allowStructuralFailures = true;
            }

            if (node.HasValue("showMomentArrows") && bool.TryParse(node.GetValue("showMomentArrows"), out tmp))
            {
                FARDebugValues.showMomentArrows = tmp;
            }
            else
            {
                FARDebugValues.showMomentArrows = false;
            }

            if (node.HasValue("useBlizzyToolbar") && bool.TryParse(node.GetValue("useBlizzyToolbar"), out tmp))
            {
                FARDebugValues.useBlizzyToolbar = tmp;
            }
            else
            {
                FARDebugValues.useBlizzyToolbar = false;
            }

            if (node.HasValue("aeroFailureExplosions") && bool.TryParse(node.GetValue("aeroFailureExplosions"), out tmp))
            {
                FARDebugValues.aeroFailureExplosions = tmp;
            }
            else
            {
                FARDebugValues.aeroFailureExplosions = true;
            }

            FARAeroStress.LoadStressTemplates();
            FARAeroUtil.LoadAeroDataFromConfig();
            FARActionGroupConfiguration.LoadConfiguration();
            FARAnimOverrides.LoadAnimOverrides();

            hasScenarioChanged = true;
        }
示例#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;
        }
 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);
     }
 }
 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 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 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);
 }
示例#25
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;
            }
        }
        /// <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;
        }
示例#27
0
        public Settings()
        {
            config = KSP.IO.PluginConfiguration.CreateForType<Settings>();
			try
			{
				config.load();
			}
			catch (System.Xml.XmlException e)
			{
				if (ConfigError)
					throw; // if previous error handling failed, we give up

				ConfigError = true;

				Debug.Log("Error loading Trajectories config: " + e.ToString());

				string TrajPluginPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
				Debug.Log("Trajectories installed in: " + TrajPluginPath);
				if (System.IO.File.Exists(TrajPluginPath + "/PluginData/Trajectories/config.xml"))
				{
					Debug.Log("Clearing config file...");
					int idx = 1;
					while (System.IO.File.Exists(TrajPluginPath + "/PluginData/Trajectories/config.xml.bak." + idx))
						++idx;
					System.IO.File.Move(TrajPluginPath + "/PluginData/Trajectories/config.xml", TrajPluginPath + "/PluginData/Trajectories/config.xml.bak." + idx);

					Debug.Log("Creating new config...");
					config.load();

					Debug.Log("New config created");
				}
				else
				{
					Debug.Log("No config file exists");
					throw;
				}
			}

            Serialize(false);

            MapGUIWindowPos = new Rect(MapGUIWindowPos.xMin, MapGUIWindowPos.yMin, 1, MapGUIWindowPos.height); // width will be auto-sized to fit contents
        }
        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;
        }
        //private static readonly Color _maneuverColour = new Color(0, 0.1137f, 1, _manueverAlpha);

        public void Save()
        {
            Utilities.DebugLogFormatted(LogLevel.Diagnostic, "Settings save");
            KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <EnhancedNavBall>();
            configfile.load();

            configfile.SetValue(_iconpos, IconPos);
            configfile.SetValue(_windowvisiblebyactivescene, WindowVisibleByActiveScene);
            configfile.SetValue(_navballposition, HandleFloatSave(NavballPosition));
            configfile.SetValue(_navballscale, HandleFloatSave(NavballScale));
            configfile.SetValue(_ghostposition, HandleFloatSave(GhostPosition));
            configfile.SetValue(_proRetColour, HandleColourSave(ProRetColour));
            configfile.SetValue(_normalColour, HandleColourSave(NormalColour));
            configfile.SetValue(_radialColour, HandleColourSave(RadialColour));
            configfile.SetValue(_enbManeuver, ENBManeuver);
            configfile.SetValue(_radialNormalDuringManeuver, RadialNormalDuringManeuver);
            //configfile.SetValue("");


            configfile.save();
        }
        /// <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;
        }
        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();
            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);
        }
示例#32
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);
                }
            }
        }
        public static void LoadConfigs(ConfigNode node)
        {
            config = KSP.IO.PluginConfiguration.CreateForType<FARSettingsScenarioModule>();
            config.load();

            bool tmp;
            if (node.HasValue("allowStructuralFailures") && bool.TryParse(node.GetValue("allowStructuralFailures"), out tmp))
                FARDebugValues.allowStructuralFailures = tmp;
            else
                FARDebugValues.allowStructuralFailures = true;

            if (node.HasValue("showMomentArrows") && bool.TryParse(node.GetValue("showMomentArrows"), out tmp))
                FARDebugValues.showMomentArrows = tmp;
            else
                FARDebugValues.showMomentArrows = false;

            if (node.HasValue("useBlizzyToolbar") && bool.TryParse(node.GetValue("useBlizzyToolbar"), out tmp))
                FARDebugValues.useBlizzyToolbar = tmp;
            else
                FARDebugValues.useBlizzyToolbar = false;

            if (node.HasValue("aeroFailureExplosions") && bool.TryParse(node.GetValue("aeroFailureExplosions"), out tmp))
                FARDebugValues.aeroFailureExplosions = tmp;
            else
                FARDebugValues.aeroFailureExplosions = true;

            FARAeroStress.LoadStressTemplates();
            FARAeroUtil.LoadAeroDataFromConfig();
            FARActionGroupConfiguration.LoadConfiguration();
            FARAnimOverrides.LoadAnimOverrides();

            Color tmpColor = GUIColors.Instance[0];
            ReColorTexture(ref tmpColor, ref cLTexture);
            GUIColors.Instance[0] = tmpColor;

            tmpColor = GUIColors.Instance[1];
            ReColorTexture(ref tmpColor, ref cDTexture);
            GUIColors.Instance[1] = tmpColor;

            tmpColor = GUIColors.Instance[2];
            ReColorTexture(ref tmpColor, ref cMTexture);
            GUIColors.Instance[2] = tmpColor;

            tmpColor = GUIColors.Instance[3];
            ReColorTexture(ref tmpColor, ref l_DTexture);
            GUIColors.Instance[3] = tmpColor;
        }
 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<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"));
        }
示例#36
0
        public void SaveConfig()
        {
            KACWorker.DebugLogFormatted("Saving Config");

            KSP.IO.PluginConfiguration configfile = KSP.IO.PluginConfiguration.CreateForType <KerbalAlarmClock>();
            configfile.load();

            configfile.SetValue("DailyUpdateCheck", this.DailyVersionCheck);
            configfile.SetValue("VersionCheckDate_Attempt", this.VersionCheckDate_AttemptString);
            configfile.SetValue("VersionCheckDate_Success", this.VersionCheckDate_SuccessString);
            configfile.SetValue("VersionWeb", this.VersionWeb);

            configfile.SetValue("WindowVisible", this.WindowVisible);
            configfile.SetValue("WindowMinimized", this.WindowMinimized);
            configfile.SetValue("WindowPos", this.WindowPos);

            configfile.SetValue("WindowVisible_SpaceCenter", this.WindowVisible_SpaceCenter);
            configfile.SetValue("WindowMinimized_SpaceCenter", this.WindowMinimized_SpaceCenter);
            configfile.SetValue("WindowPos_SpaceCenter", this.WindowPos_SpaceCenter);

            configfile.SetValue("WindowVisible_TrackingStation", this.WindowVisible_TrackingStation);
            configfile.SetValue("WindowMinimized_TrackingStation", this.WindowMinimized_TrackingStation);
            configfile.SetValue("WindowPos_TrackingStation", this.WindowPos_TrackingStation);

            configfile.SetValue("IconPos", this.IconPos);
            configfile.SetValue("IconPos_SpaceCenter", this.IconPos_SpaceCenter);
            configfile.SetValue("IconShow_SpaceCenter", this.IconShow_SpaceCenter);
            configfile.SetValue("IconPos_TrackingStation", this.IconPos_TrackingStation);
            configfile.SetValue("IconShow_TrackingStation", this.IconShow_TrackingStation);

            configfile.SetValue("UseBlizzyToolbarIfAvailable", this.UseBlizzyToolbarIfAvailable);
            configfile.SetValue("WindowMinimizedType", (int)this.WindowMinimizedType);

            configfile.SetValue("UIBlockersEnabled", this.KSCUIBlockersEnabled);

            configfile.SetValue("BehaviourChecksPerSec", this.BehaviourChecksPerSec);

            configfile.SetValue("BackupSaves", this.BackupSaves);
            configfile.SetValue("BackupSavesToKeep", this.BackupSavesToKeep);
            configfile.SetValue("CancelFlightModeJumpOnBackupFailure", this.CancelFlightModeJumpOnBackupFailure);

            configfile.SetValue("AllowJumpFromViewOnly", this.AllowJumpFromViewOnly);
            configfile.SetValue("AllowJumpToAsteroid", this.AllowJumpToAsteroid);

            configfile.SetValue("AlarmListMaxAlarms", this.AlarmListMaxAlarms);
            configfile.SetValue("AlarmPosition", this.AlarmPosition);
            configfile.SetValue("AlarmDefaultAction", this.AlarmDefaultAction);
            configfile.SetValue("AlarmDefaultMargin", this.AlarmDefaultMargin);
            configfile.SetValue("AlarmDeleteOnClose", this.AlarmDeleteOnClose);
            configfile.SetValue("ShowTooltips", this.ShowTooltips);
            configfile.SetValue("ShowEarthTime", this.ShowEarthTime);
            configfile.SetValue("HideOnPause", this.HideOnPause);
            configfile.SetValue("TimeFormat", Enum.GetName(typeof(KACTime.PrintTimeFormat), this.TimeFormat));

            configfile.SetValue("AlarmXferRecalc", this.AlarmXferRecalc);
            configfile.SetValue("AlarmXferRecalcThreshold", this.AlarmXferRecalcThreshold);
            configfile.SetValue("AlarmXferDisplayList", this.AlarmXferDisplayList);
            configfile.SetValue("XferUseModelData", this.XferUseModelData);

            configfile.SetValue("AlarmNodeRecalc", this.AlarmNodeRecalc);
            configfile.SetValue("AlarmNodeRecalcThreshold", this.AlarmNodeRecalcThreshold);

            configfile.SetValue("AlarmAddSOIAuto", this.AlarmAddSOIAuto);
            configfile.SetValue("AlarmAddSOIAutoThreshold", this.AlarmAddSOIAutoThreshold);
            //configfile.SetValue("AlarmAddSOIMargin", this.AlarmAddSOIMargin);
            configfile.SetValue("AlarmAutoSOIMargin", this.AlarmAutoSOIMargin);
            configfile.SetValue("AlarmAddSOIAuto_ExcludeEVA", this.AlarmAddSOIAuto_ExcludeEVA);
            configfile.SetValue("AlarmOnSOIChange", this.AlarmCatchSOIChange);
            configfile.SetValue("AlarmOnSOIChange_Action", this.AlarmOnSOIChange_Action);

            configfile.SetValue("AlarmSOIRecalc", this.AlarmSOIRecalc);
            configfile.SetValue("AlarmSOIRecalcThreshold", this.AlarmSOIRecalcThreshold);

            configfile.SetValue("AlarmAddManAuto", this.AlarmAddManAuto);
            configfile.SetValue("AlarmAddManAuto_andRemove", this.AlarmAddManAuto_andRemove);
            configfile.SetValue("AlarmAddManAutoThreshold", this.AlarmAddManAutoThreshold);
            configfile.SetValue("AlarmAddManAutoMargin", this.AlarmAddManAutoMargin);
            configfile.SetValue("AddManAutoMargin", this.AlarmAddManAutoMargin.ToString());
            configfile.SetValue("AlarmAddManAuto_Action", this.AlarmAddManAuto_Action);

            configfile.SetValue("AlarmCrewDefaultStoreNode", this.AlarmCrewDefaultStoreNode);

            configfile.save();
            KACWorker.DebugLogFormatted("Saved Config");
        }
        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();
        }
        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...");
        }