public void Awake() { if (HighLogic.LoadedScene == GameScenes.FLIGHT) { DontDestroyOnLoad(this); Settings.Load(); InvokeRepeating("RunSave", interval, interval); button = ToolbarManager.Instance.add("CrewManifest", "CrewManifest"); button.TexturePath = "CrewManifest/Icons/IconOff_24"; button.ToolTip = "Crew Manifest"; button.Visibility = new GameScenesVisibility(GameScenes.FLIGHT); button.OnClick += (e) => { if (!MapView.MapIsEnabled && !PauseMenu.isOpen && !FlightResultsDialog.isDisplaying && FlightGlobals.fetch != null && FlightGlobals.ActiveVessel != null && ManifestController.GetInstance(FlightGlobals.ActiveVessel).CanDrawButton ) { ManifestController manifestController = ManifestController.GetInstance(FlightGlobals.ActiveVessel); button.TexturePath = manifestController.ShowWindow ? "CrewManifest/Icons/IconOff_24" : "CrewManifest/Icons/IconOn_24"; manifestController.ShowWindow = !manifestController.ShowWindow; } }; } }
public void Update() { if (FlightGlobals.fetch != null && FlightGlobals.ActiveVessel != null) { if (HighLogic.LoadedScene == GameScenes.FLIGHT) { //Instantiate the controller for the active vessel. ManifestController.GetInstance(FlightGlobals.ActiveVessel).CanDrawButton = true; if (crewTransfer != null) { if (Planetarium.GetUniversalTime() - crewTransfer.Initiated >= crewTransferDelay) { if (crewTransfer.Source != null && crewTransfer.Destination != null && crewTransfer.CrewMember != null) { ScreenMessages.PostScreenMessage(string.Format("{0}'s transfer complete.", crewTransfer.CrewMember.name), 2.0f, ScreenMessageStyle.UPPER_CENTER); if (!object.ReferenceEquals(crewTransfer.Source.vessel, crewTransfer.Destination.vessel)) { crewTransfer.Source.vessel.SpawnCrew(); } crewTransfer.Destination.vessel.SpawnCrew(); FireVesselUpdated(); } crewTransfer = null; } } } } }
public void OnGUI() { Resources.SetupGUI(); ManifestController.GetInstance(FlightGlobals.ActiveVessel).drawGui(); if (Settings.ShowDebugger) { Settings.DebuggerPosition = GUILayout.Window(398643, Settings.DebuggerPosition, DrawDebugger, "Manifest Debug Console", GUILayout.MinHeight(20)); } }
public static ManifestController GetInstance(Vessel vessel) { foreach (var kvp in controllers.ToArray()) { var wr = kvp.Key; var v = wr.Target; if (v == null) { controllers.Remove(wr); } else if (v == vessel) { return(controllers[wr]); } } var commander = new ManifestController(); controllers[new WeakReference <Vessel>(vessel)] = commander; return(commander); }
private void onButtonClick() { if (!MapView.MapIsEnabled && !PauseMenu.isOpen && !FlightResultsDialog.isDisplaying && FlightGlobals.fetch != null && FlightGlobals.ActiveVessel != null && ManifestController.GetInstance(FlightGlobals.ActiveVessel).CanDrawButton ) { ManifestController manifestController = ManifestController.GetInstance(FlightGlobals.ActiveVessel); manifestController.ShowWindow = !manifestController.ShowWindow; if (button != null) { button.TexturePath = manifestController.ShowWindow ? "CrewManifest/Icons/IconOff_24" : "CrewManifest/Icons/IconOn_24"; } if (appButton != null) { appButton.SetTexture(manifestController.ShowWindow ? onTexture : offTexture); } } }
public static ManifestController GetInstance(Vessel vessel) { foreach (var kvp in controllers.ToArray()) { var wr = kvp.Key; var v = wr.Target; if (v == null) { controllers.Remove(wr); } else if (v == vessel) { return controllers[wr]; } } var commander = new ManifestController(); controllers[new WeakReference<Vessel>(vessel)] = commander; return commander; }