public RadioConfig() { UHF = new RadioPresetList(); VHF = new RadioPresetList(); TACAN = new TACANConfig(); ILS = new ILSConfig(); }
/// <summary> /// Launchsite Editor /// </summary> /// <param name="id"></param> void drawLaunchSiteEditorWindow(int id) { BoxNoBorder = new GUIStyle(GUI.skin.box); BoxNoBorder.normal.background = null; BoxNoBorder.normal.textColor = Color.white; DeadButton = new GUIStyle(GUI.skin.button); DeadButton.normal.background = null; DeadButton.hover.background = null; DeadButton.active.background = null; DeadButton.focused.background = null; DeadButton.normal.textColor = Color.yellow; DeadButton.hover.textColor = Color.white; DeadButton.active.textColor = Color.yellow; DeadButton.focused.textColor = Color.yellow; DeadButton.fontSize = 14; DeadButton.fontStyle = FontStyle.Normal; DeadButtonRed = new GUIStyle(GUI.skin.button); DeadButtonRed.normal.background = null; DeadButtonRed.hover.background = null; DeadButtonRed.active.background = null; DeadButtonRed.focused.background = null; DeadButtonRed.normal.textColor = Color.red; DeadButtonRed.hover.textColor = Color.yellow; DeadButtonRed.active.textColor = Color.red; DeadButtonRed.focused.textColor = Color.red; DeadButtonRed.fontSize = 12; DeadButtonRed.fontStyle = FontStyle.Bold; GUILayout.BeginHorizontal(); { GUI.enabled = false; GUILayout.Button("-KK-", DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUILayout.Button("Launchsite Editor", DeadButton, GUILayout.Height(21)); GUILayout.FlexibleSpace(); GUI.enabled = true; if (GUILayout.Button("X", DeadButtonRed, GUILayout.Height(21))) { this.Close(); } } GUILayout.EndHorizontal(); GUILayout.Space(1); GUILayout.Box(UIMain.tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUILayout.Box(selectedObject.model.title); GUILayout.BeginHorizontal(); GUILayout.Label("Site Name: ", GUILayout.Width(120)); siteName = GUILayout.TextField(siteName, GUILayout.Height(19)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Transform: ", GUILayout.Width(120)); GUILayout.Box("" + siteTrans); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Length: ", GUILayout.Width(120)); stLength = GUILayout.TextField(stLength, GUILayout.Height(19)); GUILayout.Label(" m"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Width: ", GUILayout.Width(120)); stWidth = GUILayout.TextField(stWidth, GUILayout.Height(19)); GUILayout.Label(" m"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Site Category: ", GUILayout.Width(115)); GUILayout.Label(siteCategory, GUILayout.Width(85)); GUILayout.FlexibleSpace(); GUI.enabled = !(siteCategory == "RocketPad"); if (GUILayout.Button("RP", GUILayout.Width(25), GUILayout.Height(23))) { siteCategory = "RocketPad"; } GUI.enabled = !(siteCategory == "Runway"); if (GUILayout.Button("RW", GUILayout.Width(25), GUILayout.Height(23))) { siteCategory = "Runway"; } GUI.enabled = !(siteCategory == "Helipad"); if (GUILayout.Button("HP", GUILayout.Width(25), GUILayout.Height(23))) { siteCategory = "Helipad"; } GUI.enabled = !(siteCategory == "Waterlaunch"); if (GUILayout.Button("WA", GUILayout.Width(25), GUILayout.Height(23))) { siteCategory = "Waterlaunch"; } GUI.enabled = !(siteCategory == "Other"); if (GUILayout.Button("OT", GUILayout.Width(25), GUILayout.Height(23))) { siteCategory = "Other"; } GUILayout.EndHorizontal(); GUI.enabled = true; GUILayout.BeginHorizontal(); GUILayout.Label("Site Type: ", GUILayout.Width(120)); if (siteType == SiteType.VAB) { GUILayout.Label("VAB", GUILayout.Width(40)); } if (siteType == SiteType.SPH) { GUILayout.Label("SPH", GUILayout.Width(40)); } if (siteType == SiteType.Any) { GUILayout.Label("Any", GUILayout.Width(40)); } GUILayout.FlexibleSpace(); GUI.enabled = !(siteType == (SiteType)0); if (GUILayout.Button("VAB", GUILayout.Height(23))) { siteType = SiteType.VAB; } GUI.enabled = !(siteType == (SiteType)1); if (GUILayout.Button("SPH", GUILayout.Height(23))) { siteType = SiteType.SPH; } GUI.enabled = !(siteType == (SiteType)2); if (GUILayout.Button("Any", GUILayout.Height(23))) { siteType = SiteType.Any; } GUILayout.EndHorizontal(); GUI.enabled = true; GUILayout.BeginHorizontal(); GUILayout.Label("Author: ", GUILayout.Width(120)); siteAuthor = GUILayout.TextField(siteAuthor, GUILayout.Height(19)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Open Cost: ", GUILayout.Width(120)); stOpenCost = GUILayout.TextField(stOpenCost, GUILayout.Height(19)); GUILayout.Label(" \\F"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Close Value: ", GUILayout.Width(120)); stCloseValue = GUILayout.TextField(stCloseValue, GUILayout.Height(19)); GUILayout.Label(" \\F"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Recovery Factor: ", GUILayout.Width(120)); stRecoveryFactor = GUILayout.TextField(stRecoveryFactor, GUILayout.Height(19)); GUILayout.Label(" %"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Effective Range: ", GUILayout.Width(120)); stRecoveryRange = GUILayout.TextField(stRecoveryRange, GUILayout.Height(19)); GUILayout.Label(" m"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Launch Refund: ", GUILayout.Width(120)); stLaunchRefund = GUILayout.TextField(stLaunchRefund, GUILayout.Height(19)); GUILayout.Label(" %"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Site is hidden: ", GUILayout.Width(115)); GUILayout.Label(siteHidden, GUILayout.Width(85)); GUILayout.FlexibleSpace(); GUI.enabled = !(siteHidden == "false"); if (GUILayout.Button("No", GUILayout.Width(40), GUILayout.Height(23))) { siteHidden = "false"; } GUI.enabled = !(siteHidden == "true"); if (GUILayout.Button("Yes", GUILayout.Width(40), GUILayout.Height(23))) { siteHidden = "true"; } GUI.enabled = true; GUILayout.EndHorizontal(); //if (ILSConfig.DetectNavUtils ()) { // NavUtilities config generator GUILayout.BeginHorizontal(); GUILayout.Label("ILS/HSI on (NavUtilities)", GUILayout.Width(115)); GUILayout.Label(ILSActive, GUILayout.Width(85)); GUILayout.FlexibleSpace(); GUI.enabled = !(ILSActive == "false"); if (GUILayout.Button("No", GUILayout.Width(40), GUILayout.Height(23))) { ILSActive = "false"; } GUI.enabled = !(ILSActive == "true"); if (GUILayout.Button("Yes", GUILayout.Width(40), GUILayout.Height(23))) { ILSActive = "true"; } GUILayout.EndHorizontal(); //} GUI.enabled = true; GUILayout.Label("Description: "); descScroll = GUILayout.BeginScrollView(descScroll); siteDesc = GUILayout.TextArea(siteDesc, GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); GUI.enabled = true; GUILayout.BeginHorizontal(); GUI.enabled = siteName.Length > 0; if (GUILayout.Button("Save", GUILayout.Width(115), GUILayout.Height(23))) { bool addToDB = false; if (!selectedObject.hasLauchSites) { Log.Normal("Creating LaunchSite"); LaunchSite lsite = new LaunchSite(); selectedObject.launchSite = lsite; Log.Normal("created; lsite = " + lsite + "; launch site = " + selectedObject.launchSite); selectedObject.hasLauchSites = true; lsite.parentInstance = selectedObject; selectedObject.launchSite.body = selectedObject.CelestialBody; addToDB = true; } string oldName = selectedObject.launchSite.LaunchSiteName; string oldCategory = selectedObject.launchSite.Category; bool oldState = selectedObject.launchSite.ILSIsActive; selectedObject.launchSite.LaunchSiteName = siteName; selectedObject.launchSite.LaunchSiteLength = float.Parse(stLength); selectedObject.launchSite.LaunchSiteWidth = float.Parse(stWidth); selectedObject.launchSite.LaunchSiteType = siteType; selectedObject.launchSite.LaunchPadTransform = siteTrans; selectedObject.launchSite.LaunchSiteDescription = siteDesc; selectedObject.launchSite.OpenCost = float.Parse(stOpenCost); selectedObject.launchSite.CloseValue = float.Parse(stCloseValue); selectedObject.launchSite.RecoveryFactor = float.Parse(stRecoveryFactor); selectedObject.launchSite.RecoveryRange = float.Parse(stRecoveryRange); selectedObject.launchSite.LaunchRefund = float.Parse(stLaunchRefund); selectedObject.launchSite.OpenCloseState = "Open"; selectedObject.launchSite.Category = siteCategory; selectedObject.launchSite.LaunchSiteIsHidden = bool.Parse(siteHidden); selectedObject.launchSite.ILSIsActive = bool.Parse(ILSActive); selectedObject.launchSite.LaunchSiteAuthor = siteAuthor; selectedObject.launchSite.refLat = (float)selectedObject.RefLatitude; selectedObject.launchSite.refLon = (float)selectedObject.RefLongitude; selectedObject.launchSite.refAlt = selectedObject.RadiusOffset; if (ILSConfig.DetectNavUtils()) { Log.Normal("NavUtils detected"); Log.Debug("object: " + selectedObject); Log.Debug("launchsite: " + selectedObject.launchSite); Log.Debug("body: " + selectedObject.launchSite.body); bool regenerateILSConfig = false; Log.Debug("old name: " + oldName); Log.Debug("new name: " + selectedObject.launchSite.LaunchSiteName); if (oldName != null && !oldName.Equals(siteName)) { ILSConfig.RenameSite(selectedObject.launchSite.LaunchSiteName, siteName); regenerateILSConfig = true; } Log.Debug("old category: " + oldCategory); if (oldCategory != null && !oldCategory.Equals(siteCategory)) { ILSConfig.HandleCategoryChange(selectedObject.launchSite.Category, siteCategory, selectedObject); regenerateILSConfig = true; } bool state = bool.Parse(ILSActive); Log.Normal("new state: " + state + "; old state: " + oldState); if (oldState != state || regenerateILSConfig) { if (state) { ILSConfig.GenerateFullILSConfig(selectedObject); } else { ILSConfig.DropILSConfig(selectedObject.launchSite.name, true); } } } if (addToDB) { KerbalKonstructs.instance.SaveInstanceByCfg(selectedObject.configPath); LaunchSiteManager.RegisterLaunchSite(selectedObject.launchSite); } KerbalKonstructs.instance.SaveInstanceByCfg(selectedObject.configPath); this.Close(); } GUI.enabled = true; GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", GUILayout.Width(115), GUILayout.Height(23))) { this.Close(); } GUILayout.EndHorizontal(); GUILayout.Label("NOTE: If a newly created launchsite object does not display when launched from, a restart of KSP will be required for the site to be correctly rendered."); GUILayout.Space(1); GUILayout.Box(UIMain.tHorizontalSep, BoxNoBorder, GUILayout.Height(4)); GUILayout.Space(2); GUI.DragWindow(new Rect(0, 0, 10000, 10000)); }
internal void SaveSettings() { bool addToDB = false; if (!selectedObject.hasLauchSites) { Log.Normal("Creating LaunchSite"); KKLaunchSite lsite = new KKLaunchSite(); selectedObject.launchSite = lsite; Log.Normal("created; lsite = " + lsite + "; launch site = " + selectedObject.launchSite); selectedObject.hasLauchSites = true; lsite.staticInstance = selectedObject; selectedObject.launchSite.body = selectedObject.CelestialBody; addToDB = true; } string oldName = selectedObject.launchSite.LaunchSiteName; LaunchSiteCategory oldCategory = category; bool oldState = selectedObject.launchSite.ILSIsActive; selectedObject.launchSite.LaunchSiteName = siteName; selectedObject.launchSite.LaunchSiteLength = float.Parse(stLength); selectedObject.launchSite.LaunchSiteWidth = float.Parse(stWidth); selectedObject.launchSite.LaunchSiteType = siteType; selectedObject.launchSite.LaunchPadTransform = siteTrans; selectedObject.launchSite.LaunchSiteDescription = siteDesc; selectedObject.launchSite.OpenCost = float.Parse(stOpenCost); selectedObject.launchSite.CloseValue = float.Parse(stCloseValue); selectedObject.launchSite.LaunchSiteIsHidden = bool.Parse(siteHidden); selectedObject.launchSite.ILSIsActive = bool.Parse(ILSActive); selectedObject.launchSite.LaunchSiteAuthor = siteAuthor; selectedObject.launchSite.refLat = (float)selectedObject.RefLatitude; selectedObject.launchSite.refLon = (float)selectedObject.RefLongitude; selectedObject.launchSite.refAlt = selectedObject.RadiusOffset; selectedObject.launchSite.sitecategory = category; selectedObject.launchSite.InitialCameraRotation = float.Parse(initialCameraRotation); if (ILSConfig.DetectNavUtils()) { Log.Normal("NavUtils detected"); Log.Debug("object: " + selectedObject); Log.Debug("launchsite: " + selectedObject.launchSite); Log.Debug("body: " + selectedObject.launchSite.body); bool regenerateILSConfig = false; Log.Debug("old name: " + oldName); Log.Debug("new name: " + selectedObject.launchSite.LaunchSiteName); if (oldName != null && !oldName.Equals(siteName)) { ILSConfig.RenameSite(selectedObject.launchSite.LaunchSiteName, siteName); regenerateILSConfig = true; } Log.Debug("old category: " + oldCategory); if ((oldCategory != category)) { ILSConfig.HandleCategoryChange(selectedObject); regenerateILSConfig = true; } bool state = bool.Parse(ILSActive); Log.Normal("new state: " + state + "; old state: " + oldState); if (oldState != state || regenerateILSConfig) { if (state) { ILSConfig.GenerateFullILSConfig(selectedObject); } else { ILSConfig.DropILSConfig(selectedObject.launchSite.LaunchSiteName, true); } } } if (addToDB) { selectedObject.launchSite.ParseLSConfig(selectedObject, null); selectedObject.SaveConfig(); EditorGUI.instance.enableColliders = true; selectedObject.ToggleAllColliders(true); LaunchSiteManager.RegisterLaunchSite(selectedObject.launchSite); } selectedObject.SaveConfig(); }