/// <summary> /// Called after Awake. used for setting up references between objects and initializing windows. /// </summary> public void Start() { Log.Warning("WindowManager Start"); KerbalKonstructs.instance.WindowManager = this; GUI_Editor = new EditorGUI(); GUI_StaticsEditor = new StaticsEditorGUI(); GUI_NGS = new NavGuidanceSystem(); GUI_Downlink = new DownlinkGUI(); GUI_FlightManager = new BaseBossFlight(); GUI_FacilityManager = new FacilityManager(); GUI_LaunchSiteSelector = new LaunchSiteSelectorGUI(); GUI_MapIconManager = new MapIconManager(); GUI_KSCManager = new KSCManagerNGUI(); GUI_AirRacingApp = new AirRacing(); GUI_BaseManager = new BaseManager(); GUI_Settings = new KKSettingsNGUI(); GUI_ModelInfo = new ModelInfo(); }
public static void TargetSelector(string sTargetTypeSelected, StaticObject selectedFacility = null) { scrollPos = GUILayout.BeginScrollView(scrollPos); { if (sTargetTypeSelected == "Station") { sSelectedTrackingTarget = "None"; foreach (StaticObject obj in KerbalKonstructs.instance.getStaticDB().getAllStatics()) { if ((string)obj.getSetting("FacilityType") == "TrackingStation") { if ((string)obj.getSetting("OpenCloseState") == "Closed") { continue; } GUILayout.BeginHorizontal(); { fAlt = (float)obj.getSetting("RadiusOffset"); cPlanetoid = (CelestialBody)obj.getSetting("CelestialBody"); ObjectPos = cPlanetoid.transform.InverseTransformPoint(obj.gameObject.transform.position); dObjectLat = NavUtils.GetLatitude(ObjectPos); dObjectLon = NavUtils.GetLongitude(ObjectPos); disObjectLat = dObjectLat * 180 / Math.PI; disObjectLon = dObjectLon * 180 / Math.PI; if (disObjectLon < 0) { disObjectLon = disObjectLon + 360; } sButtonText = cPlanetoid.name + " Station\nAltitude: " + fAlt.ToString("#0") + "m\nLat. " + disObjectLat.ToString("#0.000") + " Lon. " + disObjectLon.ToString("#0.000"); GUI.enabled = (obj != selectedStation); //GUILayout.Box(sButtonText, GUILayout.Height(50)); ButtonSmallText = new GUIStyle(GUI.skin.button); ButtonSmallText.fontSize = 12; ButtonSmallText.fontStyle = FontStyle.Normal; if (GUILayout.Button("" + sButtonText, ButtonSmallText, GUILayout.Height(55))) { selectedStation = obj; } GUI.enabled = true; } GUILayout.EndHorizontal(); } } } if (sTargetTypeSelected == "Craft") { selectedStation = null; foreach (Vessel vVessel in FlightGlobals.Vessels) { if (vVessel.vesselType == VesselType.SpaceObject) { continue; } if (vVessel.vesselType == VesselType.Debris) { continue; } if (vVessel.vesselType == VesselType.EVA) { continue; } if (vVessel.vesselType == VesselType.Flag) { continue; } if (vVessel.vesselType == VesselType.Unknown) { continue; } if (vVessel == FlightGlobals.ActiveVessel) { continue; } int iU = vVessel.name.IndexOf("("); if (iU < 2) { iU = vVessel.name.Length + 1; } string sDisplayTarget = vVessel.name.Substring(0, iU - 1); GUI.enabled = (sSelectedTrackingTarget != vVessel.name + "_" + vVessel.id.ToString()); if (GUILayout.Button(sDisplayTarget, GUILayout.Height(20))) { sSelectedTrackingTarget = vVessel.name + "_" + vVessel.id.ToString(); } GUI.enabled = true; } } if (sTargetTypeSelected == "Celestial Body") { foreach (CelestialBody cBody in FlightGlobals.Bodies) { GUI.enabled = (sSelectedTrackingTarget != cBody.name); if (GUILayout.Button(cBody.name, GUILayout.Height(20))) { sSelectedTrackingTarget = cBody.name; } GUI.enabled = true; } } if (sTargetTypeSelected == "Asteroid") { foreach (Vessel vVessel in FlightGlobals.Vessels) { if (vVessel.vesselType != VesselType.SpaceObject && vVessel.vesselType != VesselType.Unknown) { continue; } int iU = vVessel.name.IndexOf("("); if (iU < 2) { iU = vVessel.name.Length + 1; } string sDisplayTarget = vVessel.name.Substring(0, iU - 1); GUI.enabled = (sSelectedTrackingTarget != vVessel.name + "_" + vVessel.id.ToString()); if (GUILayout.Button(sDisplayTarget, GUILayout.Height(20))) { sSelectedTrackingTarget = vVessel.name + "_" + vVessel.id.ToString(); } GUI.enabled = true; } } if (sTargetTypeSelected == "Station's Discretion") { GUILayout.Box("Target is selected by the station."); } if (sTargetTypeSelected == "None") { GUILayout.Box("Select a target type."); } } GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { if (sSelectedTrackingTarget != "None") { bGUIenabled = true; } if (selectedStation != null) { bGUIenabled = true; } GUI.enabled = bGUIenabled; if (GUILayout.Button("Select", GUILayout.Height(25))) { sTarget = sSelectedTrackingTarget; if (selectedFacility != null) { selectedFacility.setSetting("TargetID", sTarget); PersistenceUtils.saveStaticPersistence(selectedFacility); } else { if (selectedStation != null) { DownlinkGUI.soTargetStation = selectedStation; var FacilityKey = selectedStation.getSetting("RadialPosition"); DownlinkGUI.sStationRadial = FacilityKey.ToString(); } else { DownlinkGUI.sTarget = sTarget; } DownlinkGUI.SaveCommsState(); } } GUI.enabled = true; if (GUILayout.Button("Close", GUILayout.Height(25))) { if (selectedFacility != null) { FacilityManager.changeTarget(false); } else { DownlinkGUI.changeTarget(false); } } } GUILayout.EndHorizontal(); }