private static void LoadConfig(KSPe.IO.ReadableConfigNode configNode) { KSPe.ConfigNodeWithSteroids settings = KSPe.ConfigNodeWithSteroids.from(configNode.Node); GlobalRange = settings.GetValue <int>("GlobalRange", GlobalRange); CamFixMultiplier = settings.GetValue <float>("CamFixMultiplier", CamFixMultiplier); ModEnabled = settings.GetValue <bool>("ModEnabled", ModEnabled); }
private static void LoadConstants(KSPe.ConfigNodeWithSteroids config) { reinforceAttachNodes = config.GetValue <bool>("reinforceAttachNodes", reinforceAttachNodes); multiPartAttachNodeReinforcement = config.GetValue <bool>("multiPartAttachNodeReinforcement", multiPartAttachNodeReinforcement); reinforceDecouplersFurther = config.GetValue <bool>("reinforceDecouplersFurther", reinforceDecouplersFurther); reinforceLaunchClampsFurther = config.GetValue <bool>("reinforceLaunchClampsFurther", reinforceLaunchClampsFurther); useVolumeNotArea = config.GetValue <bool>("useVolumeNotArea", useVolumeNotArea); angularDriveSpring = config.GetValue <float>("angularDriveSpring", angularDriveSpring); angularDriveDamper = config.GetValue <float>("angularDriveDamper", angularDriveDamper); angularMaxForceFactor = config.GetValue <float>("angularMaxForceFactor", angularMaxForceFactor); if (angularMaxForceFactor < 0) { angularMaxForceFactor = float.MaxValue; } breakForceMultiplier = config.GetValue <float>("breakForceMultiplier", breakForceMultiplier); breakTorqueMultiplier = config.GetValue <float>("breakTorqueMultiplier", breakTorqueMultiplier); breakStrengthPerArea = config.GetValue <float>("breakStrengthPerArea", breakStrengthPerArea); breakTorquePerMOI = config.GetValue <float>("breakTorquePerMOI", breakTorquePerMOI); decouplerAndClampJointStrength = config.GetValue <float>("decouplerAndClampJointStrength", decouplerAndClampJointStrength); if (decouplerAndClampJointStrength < 0) { decouplerAndClampJointStrength = float.PositiveInfinity; } stiffeningExtensionMassRatioThreshold = config.GetValue <float>("stiffeningExtensionMassRatioThreshold", stiffeningExtensionMassRatioThreshold); massForAdjustment = config.GetValue <float>("massForAdjustment", massForAdjustment); foreach (ConfigNode c in config.GetNodes("Exempt")) { KSPe.ConfigNodeWithSteroids node = KSPe.ConfigNodeWithSteroids.from(c); if (node.HasValue("PartType")) { exemptPartTypes.Add(node.GetValue <string>("PartType")); } if (node.HasValue("ModuleType")) { exemptModuleTypes.Add(node.GetValue <string>("ModuleType")); } if (node.HasValue("DecouplerStiffeningExtensionType")) { decouplerStiffeningExtensionType.Add(node.GetValue <string>("DecouplerStiffeningExtensionType")); } } ; debug = config.GetValue <bool>("debug", debug); }
private bool IsPartMatchesPrefab(KSPe.ConfigNodeWithSteroids node) { float prefabDefaultScale = this.scaler.prefab.Modules.GetModule <TweakScale>(0).defaultScale; float currentDefaultScale = node.GetValue <float>("defaultScale", prefabDefaultScale); return(Math.Abs(prefabDefaultScale - currentDefaultScale) < 0.001f); }
// ConfigNodeWithSteroids is not complete yet, lots of work to do! // So I had to give the source node to be fixed together the fancy one with some nice helpers, // as it currently doesn't updates the node used to create it (by design, the idea is to create an // "commit" command - so exception handling would be made easier. private ConfigNode FixPartScaling(ConfigNode source, KSPe.ConfigNodeWithSteroids node) { float prefabDefaultScale = this.scaler.prefab.Modules.GetModule <TweakScale>(0).defaultScale; float craftDefaultScale = node.GetValue <float>("defaultScale", prefabDefaultScale); float craftScale = node.GetValue <float>("currentScale", prefabDefaultScale); float craftRelativeScale = craftScale / craftDefaultScale; float newCurrentScale = prefabDefaultScale * craftRelativeScale; source.SetValue("currentScale", newCurrentScale); source.SetValue("defaultScale", prefabDefaultScale); Log.warn("Invalid defaultScale! Craft {0} had the part {1} defaultScale changed from {2:F3} to {3:F3} and was rescaled to {4:F3}" , this.scaler.part.craftID, this.InstanceID , craftDefaultScale, prefabDefaultScale, newCurrentScale ); return(source); }
public static void LoadSettings() { Log.info("NavUtil: Loading Settings"); if (SETTINGS.IsLoadable) { SETTINGS.Load(); } KSPe.ConfigNodeWithSteroids settings = SETTINGS.NodeWithSteroids; GlobalVariables.Settings.hsiGUIscale = settings.GetValue <float>("guiScale", 0.5f); GlobalVariables.Settings.enableFineLoc = settings.GetValue <bool>("enableFineLoc", true); GlobalVariables.Settings.enableWindowsInIVA = settings.GetValue <bool>("enableWindowsInIVA", true); GlobalVariables.Settings.loadCustom_rwyCFG = settings.GetValue <bool>("loadCustom_rwyCFG", true); GlobalVariables.Settings.useBlizzy78ToolBar = settings.GetValue <bool>("useBlizzy78ToolBar", false); GlobalVariables.Settings.hsiPosition.x = settings.GetValue <float>("hsiPositionX", 220f); GlobalVariables.Settings.hsiPosition.y = settings.GetValue <float>("hsiPositionY", 500f); //GlobalVariables.Settings.hsiPosition.width = settings.GetValue<float>("hsiPositionWidth",???f); //GlobalVariables.Settings.hsiPosition.height = settings.GetValue<float>("hsiPositionHeight", ???f); GlobalVariables.Settings.rwyEditorGUI.x = settings.GetValue <float>("rwyEditorGUIX", 387f); GlobalVariables.Settings.rwyEditorGUI.y = settings.GetValue <float>("rwyEditorGUIY", 132f); //GlobalVariables.Settings.rwyEditorGUI.width = settings.GetValue<float>("rwyEditorGUIWidth", ???f); //GlobalVariables.Settings.rwyEditorGUI.height = settings.GetValue<float>("rwyEditorGUIHeight", ???f); GlobalVariables.Settings.settingsGUI.x = settings.GetValue <float>("settingsGUIX", 75f); GlobalVariables.Settings.settingsGUI.y = settings.GetValue <float>("settingsGUIY", 75f); GlobalVariables.Settings.hideNavBallWaypoint = settings.GetValue <bool>("hideNavBallWaypoint", false); //GlobalVariables.Settings.settingsGUI.width = settings.GetValue<float>("settingsGUIWidth", ???f); //GlobalVariables.Settings.settingsGUI.height = settings.GetValue<float>("settingsGUIHeight", ???f); { #if DEBUG bool debugMode = settings.GetValue <bool>("debug", true); #else bool debugMode = settings.GetValue <bool>("debug", false); #endif Log.debuglevel = debugMode ? 5 : 3; } }