public void Load(ConfigNode node) { if (node.HasNode("PartCommanderGameSettings")) { SettingsNode = node.GetNode("PartCommanderGameSettings"); windowDefaultX = Mathf.Clamp(SettingsNode.GetValueOrDefault("windowDefaultX", windowDefaultX), 0, Screen.width - 50); windowDefaultY = Mathf.Clamp(SettingsNode.GetValueOrDefault("windowDefaultY", windowDefaultY), 0, Screen.height - 50); windowDefaultWidth = Mathf.Clamp(SettingsNode.GetValueOrDefault("windowDefaultWidth", windowDefaultWidth), 50, Screen.width); windowDefaultHeight = Mathf.Clamp(SettingsNode.GetValueOrDefault("windowDefaultHeight", windowDefaultHeight), 50, Screen.height); windowDefaultRect = new Rect(windowDefaultX, windowDefaultY, windowDefaultWidth, windowDefaultHeight); visibleWindow = SettingsNode.GetValueOrDefault("visibleWindow", visibleWindow); if (SettingsNode.HasNode("Vessels")) { foreach (ConfigNode vesselNode in SettingsNode.GetNode("Vessels").nodes) { Guid vesselId = new Guid(vesselNode.name); uint partId = vesselNode.GetValueOrDefault("currentPartId", 0u); foreach (Vessel v in FlightGlobals.Vessels) { if (v.id == vesselId) { vesselWindows[vesselId] = new PCWindow(vesselNode.GetValueOrDefault("windowX", windowDefaultX), vesselNode.GetValueOrDefault("windowY", windowDefaultY), vesselNode.GetValueOrDefault("windowWidth", windowDefaultWidth), vesselNode.GetValueOrDefault("windowHeight", windowDefaultHeight), false); vesselWindows[vesselId].symLock = vesselNode.GetValueOrDefault("symLock", true); vesselWindows[vesselId].showPartSelector = false; vesselWindows[vesselId].showResources = vesselNode.GetValueOrDefault("showResources", true); vesselWindows[vesselId].showTemp = vesselNode.GetValueOrDefault("showTemp", false); vesselWindows[vesselId].showAero = vesselNode.GetValueOrDefault("showAero", false); vesselWindows[vesselId].currentPartId = partId; if (vesselNode.HasNode("PartWindows")) { foreach (ConfigNode pwNode in vesselNode.GetNode("PartWindows").nodes) { int windowId = int.Parse(pwNode.name); PCWindow pow = new PCWindow(pwNode.GetValueOrDefault("windowX", windowDefaultX), pwNode.GetValueOrDefault("windowY", windowDefaultY), pwNode.GetValueOrDefault("windowWidth", windowDefaultWidth), pwNode.GetValueOrDefault("windowHeight", windowDefaultHeight), true); pow.windowId = windowId; pow.currentPartId = pwNode.GetValueOrDefault("currentPartId", 0u); pow.symLock = pwNode.GetValueOrDefault("symLock", true); pow.showResources = pwNode.GetValueOrDefault("showResources", true); pow.showTemp = pwNode.GetValueOrDefault("showTemp", false); pow.showAero = pwNode.GetValueOrDefault("showAero", false); vesselWindows[vesselId].partWindows.Add(windowId, pow); } } break; } } } } } else { windowDefaultRect = new Rect(windowDefaultX, windowDefaultY, windowDefaultWidth, windowDefaultHeight); } }
public void Load(ConfigNode node) { if (node.HasNode("PartCommanderGameSettings")) { SettingsNode = node.GetNode("PartCommanderGameSettings"); windowDefaultX = Mathf.Clamp(SettingsNode.GetValueOrDefault("windowDefaultX", windowDefaultX), 0, Screen.width - 50); windowDefaultY = Mathf.Clamp(SettingsNode.GetValueOrDefault("windowDefaultY", windowDefaultY), 0, Screen.height - 50); windowDefaultWidth = Mathf.Clamp(SettingsNode.GetValueOrDefault("windowDefaultWidth", windowDefaultWidth), 50, Screen.width); windowDefaultHeight = Mathf.Clamp(SettingsNode.GetValueOrDefault("windowDefaultHeight", windowDefaultHeight), 50, Screen.height); windowDefaultRect = new Rect(windowDefaultX, windowDefaultY, windowDefaultWidth, windowDefaultHeight); visibleWindow = SettingsNode.GetValueOrDefault("visibleWindow", visibleWindow); if (SettingsNode.HasNode("Vessels")) { foreach (ConfigNode vesselNode in SettingsNode.GetNode("Vessels").nodes) { Guid vesselId = new Guid(vesselNode.name); uint partId = vesselNode.GetValueOrDefault("currentPartId", 0u); foreach (Vessel v in FlightGlobals.Vessels) { if (v.id == vesselId) { vesselWindows[vesselId] = new PCWindow(vesselNode.GetValueOrDefault("windowX", windowDefaultX), vesselNode.GetValueOrDefault("windowY", windowDefaultY), vesselNode.GetValueOrDefault("windowWidth", windowDefaultWidth), vesselNode.GetValueOrDefault("windowHeight", windowDefaultHeight), false); vesselWindows[vesselId].symLock = vesselNode.GetValueOrDefault("symLock", true); vesselWindows[vesselId].showPartSelector = false; vesselWindows[vesselId].showResources = vesselNode.GetValueOrDefault("showResources", true); vesselWindows[vesselId].showTemp = vesselNode.GetValueOrDefault("showTemp", false); vesselWindows[vesselId].showAero = vesselNode.GetValueOrDefault("showAero", false); vesselWindows[vesselId].currentPartId = partId; if (vesselNode.HasNode("PartWindows")) { foreach (ConfigNode pwNode in vesselNode.GetNode("PartWindows").nodes) { int windowId = int.Parse(pwNode.name); PCWindow pow = new PCWindow(pwNode.GetValueOrDefault("windowX", windowDefaultX), pwNode.GetValueOrDefault("windowY", windowDefaultY), pwNode.GetValueOrDefault("windowWidth", windowDefaultWidth), pwNode.GetValueOrDefault("windowHeight", windowDefaultHeight), true); pow.windowId = windowId; pow.currentPartId = pwNode.GetValueOrDefault("currentPartId", 0u); pow.symLock = pwNode.GetValueOrDefault("symLock", true); pow.showResources = pwNode.GetValueOrDefault("showResources", true); pow.showTemp = pwNode.GetValueOrDefault("showTemp", false); pow.showAero = pwNode.GetValueOrDefault("showAero", false); vesselWindows[vesselId].partWindows.Add(windowId, pow); } } break; } } } } if (PartCommander.Instance.launcherButton != null) { if (visibleWindow) { PartCommander.Instance.launcherButton.SetTrue(); } else { PartCommander.Instance.launcherButton.SetFalse(); } } else { if (visibleWindow) { PartCommander.Instance.showWindow(); } else { PartCommander.Instance.hideWindow(); } } } else { windowDefaultRect = new Rect(windowDefaultX, windowDefaultY, windowDefaultWidth, windowDefaultHeight); } }