// This is the GUI callback that actually draws the GUI void WindowFunction(int windowID) { // Display the toggles and controls to read the new settings newSettings.ManualFailures = GUILayout.Toggle(newSettings.ManualFailures, "Manual failures"); newSettings.Glow = GUILayout.Toggle(newSettings.Glow, "Glow"); newSettings.Messages = GUILayout.Toggle(newSettings.Messages, "Messages"); GUILayout.BeginHorizontal(); GUILayout.Label("Max EVA distance: "); evaDistanceString = GUILayout.TextField(evaDistanceString); GUILayout.EndHorizontal(); // Creates the button and returns true when it is pressed if (GUILayout.Button("OK")) { // Parse the string this.newSettings.MaxDistance = DangIt.Parse <float>(evaDistanceString, defaultTo: 2f); this.Log("Applying the new settings selected from GUI. New settings:\n" + newSettings.ToNode().ToString()); DangIt.Instance.CurrentSettings = this.newSettings; //showGUI = false; // "Click" on the app button to close the window appBtn.SetFalse(makeCall: true); } // This call allows the user to drag the window around the screen GUI.DragWindow(); }
/// <summary> /// Load the values from the config node of the persistence file. /// Put your loading logic in DI_OnLoad() /// </summary> public override void OnLoad(ConfigNode node) { try { // Load all the internal state variables this.HasInitted = DangIt.Parse <bool>(node.GetValue("HasInitted"), false); this.Age = DangIt.Parse <float>(node.GetValue("Age"), defaultTo: 0f); this.TimeOfLastReset = DangIt.Parse <float>(node.GetValue("TimeOfLastReset"), defaultTo: float.PositiveInfinity); this.TimeOfLastInspection = DangIt.Parse <float>(node.GetValue("TimeOfLastInspection"), defaultTo: float.NegativeInfinity); this.LastFixedUpdate = DangIt.Parse <float>(node.GetValue("LastFixedUpdate"), defaultTo: 0f); this.CurrentMTBF = DangIt.Parse <float>(node.GetValue("CurrentMTBF"), defaultTo: float.PositiveInfinity); this.LifeTimeSecs = DangIt.Parse <float>(node.GetValue("LifeTimeSecs"), defaultTo: float.PositiveInfinity); this.HasFailed = DangIt.Parse <bool>(node.GetValue("HasFailed"), defaultTo: false); print("FailureModule.OnLoad"); // Run the subclass' custom onload this.DI_OnLoad(node); // If OnLoad is called during flight, call the start again // so that modules can be rescanned if (HighLogic.LoadedSceneIsFlight) { this.DI_Start(StartState.Flying); } base.OnLoad(node); } catch (Exception e) { this.OnError(e); } }
// Get the max servicing temp from DANGIT_SETTINGS public int GetMaxServicingTemp(){ UrlDir.UrlConfig[] node = GameDatabase.Instance.GetConfigs ("DANGIT_SETTINGS"); foreach (UrlDir.UrlConfig curSet in node) { int val = DangIt.Parse<int> (curSet.config.GetValue ("MaxServicingTemp"), 400); DangIt.Instance.Log ("Found a DANGIT_SETTINGS, its MaxServiceTemp is " + val.ToString ()); return val; } return 400; }
protected override void DI_OnLoad(ConfigNode node) { this.pole = DangIt.Parse <float>("pole", 0.01f); this.leakName = node.GetValue("leakName"); if (string.IsNullOrEmpty(leakName)) { leakName = null; } this.Log("OnLoad: loaded leakName " + ((leakName == null) ? "null" : leakName)); }
public Settings(ConfigNode node) { if (node != null && node.name == "SETTINGS") { ManualFailures = DangIt.Parse <bool>(node.GetValue("ManualFailures"), false); MaxDistance = DangIt.Parse <float>(node.GetValue("MaxDistance"), 1f); Messages = DangIt.Parse <bool>(node.GetValue("Messages"), true); Glow = DangIt.Parse <bool>(node.GetValue("Glow"), true); } else { throw new Exception("Invalid node!"); } }
public Settings(ConfigNode node) { if (node != null && node.name == "SETTINGS") { EnabledForSave = DangIt.Parse<bool>(node.GetValue("EnabledForSave"), true); ManualFailures = DangIt.Parse<bool>(node.GetValue("ManualFailures"), false); MaxDistance = DangIt.Parse<float>(node.GetValue("MaxDistance"), 1f); Messages = DangIt.Parse<bool>(node.GetValue("Messages"), true); Glow = DangIt.Parse<bool>(node.GetValue("Glow"), true); Pri_Low_SoundLoops = DangIt.Parse<int>(node.GetValue("Pri_Low_Loops"), 0); Pri_Medium_SoundLoops = DangIt.Parse<int>(node.GetValue("Pri_Medium_Loops"), 0); Pri_High_SoundLoops = DangIt.Parse<int>(node.GetValue("Pri_High_Loops"), 0); AlarmVolume = DangIt.Parse<int>(node.GetValue("AlarmVolume"), 100); RequireExperience = DangIt.Parse<bool>(node.GetValue("RequireExperience"), true); DebugStats = DangIt.Parse<bool>(node.GetValue("DebugStats"), false); } else throw new Exception("Invalid node!"); }
protected override void DI_OnLoad(ConfigNode node) { if (part != null && part.partInfo != null) { Logger.Info("ModuleTankReliability.DI_OnLoad, part: " + part.partInfo.title); } else { Logger.Info("ModuleTankReliability.DI_OnLoad, no part"); } this.pole = DangIt.Parse <float>("pole", 0.01f); this.leakName = node.GetValue("leakName"); if (string.IsNullOrEmpty(leakName)) { leakName = "none"; // null;; } this.FailureLog("OnLoad: loaded leakName " + ((leakName == null) ? "none" : leakName)); }
void SettingsWindowFcn(int windowID) { if (waitingForConfirm) { GUILayout.BeginVertical(); GUILayout.Label("WARNING! Changing the state of DangIt! while ships are in flight is not supported."); GUILayout.Label("There is no gaurentee that ships will remain in a stable state after toggle, ESPECIALLY if they currently have failed parts."); GUILayout.Label("It is reccomended that this option is only changed immediatley after the start of a game AND while no ships are in flight"); GUILayout.Label("You currently have " + (FlightGlobals.Vessels.Count - 1).ToString() + " vessels in flight. Are you sure you want to proceed?"); GUILayout.Space(50); GUILayout.BeginHorizontal(); if (GUILayout.Button("Yes")) { lastEnabledValue = newSettings.EnabledForSave; waitingForConfirm = false; DangIt.Instance.CurrentSettings = this.newSettings; } if (GUILayout.Button("No")) { newSettings.EnabledForSave = lastEnabledValue; waitingForConfirm = false; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } else { // Display the toggles and controls to read the new settings newSettings.EnabledForSave = GUILayout.Toggle(newSettings.EnabledForSave, "Enable"); if (newSettings.EnabledForSave != this.lastEnabledValue) { waitingForConfirm = true; } if (newSettings.EnabledForSave) { newSettings.ManualFailures = GUILayout.Toggle(newSettings.ManualFailures, "Manual failures"); newSettings.DebugStats = GUILayout.Toggle(newSettings.DebugStats, "Show Debug Stats"); newSettings.Glow = GUILayout.Toggle(newSettings.Glow, "Glow"); newSettings.RequireExperience = GUILayout.Toggle(newSettings.RequireExperience, "Check Experience"); newSettings.Messages = GUILayout.Toggle(newSettings.Messages, "Messages"); GUILayout.BeginHorizontal(); GUILayout.Label("Max EVA distance: "); evaDistanceString = GUILayout.TextField(evaDistanceString); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Alarm Volume (0-100): "); SoundVolumeString = GUILayout.TextField(SoundVolumeString); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("# Times to beep for Priorities (-1=>Inf) of Failures"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("LOW: "); SoundLoopsString_Low = GUILayout.TextField(SoundLoopsString_Low); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("MEDIUM: "); SoundLoopsString_Medium = GUILayout.TextField(SoundLoopsString_Medium); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("HIGH: "); SoundLoopsString_High = GUILayout.TextField(SoundLoopsString_High); GUILayout.EndHorizontal(); } else { GUILayout.Label("DangIt! is disabled"); } // Creates the button and returns true when it is pressed if (GUILayout.Button("Apply")) { // Parse the strings this.newSettings.MaxDistance = DangIt.Parse <float> (evaDistanceString, defaultTo: 2f); this.newSettings.Pri_Low_SoundLoops = DangIt.Parse <int> (SoundLoopsString_Low, defaultTo: 0); this.newSettings.Pri_Medium_SoundLoops = DangIt.Parse <int> (SoundLoopsString_Medium, defaultTo: 2); this.newSettings.Pri_High_SoundLoops = DangIt.Parse <int> (SoundLoopsString_High, defaultTo: -1); int av = DangIt.Parse <int> (SoundVolumeString, defaultTo: 100); //av = (av < 0) ? 0 : (av > 100) ? 100 : av; //This clamps it between 0 and 100 (or not) if (av < 1) { av = 1; } else if (av > 100) { av = 100; } this.newSettings.AlarmVolume = av; DangIt.Instance.CurrentSettings = this.newSettings; ReInitilize(); //Reinit string data in case you entered a invalid value (or went over cap in volume) } } // This call allows the user to drag the window around the screen GUI.DragWindow(); }
protected override void DI_OnLoad(ConfigNode node) { this.ignorePitch = DangIt.Parse <bool>(node.GetValue("ignorePitch"), defaultTo: false); this.ignoreRoll = DangIt.Parse <bool>(node.GetValue("ignoreRoll"), defaultTo: false); this.ignoreYaw = DangIt.Parse <bool>(node.GetValue("ignoreYaw"), defaultTo: false); }