int page = 1; // Current page in the list of kerbals public void Start() { if (!Core.ModEnabled) { return; } Core.Log("KerbalHealthScenario.Start", Core.LogLevel.Important); Core.Log(Core.Factors.Count + " factors initialized."); Core.KerbalHealthList.RegisterKerbals(); GameEvents.onCrewOnEva.Add(OnKerbalEva); GameEvents.onCrewKilled.Add(OnCrewKilled); GameEvents.OnCrewmemberHired.Add(OnCrewmemberHired); GameEvents.OnCrewmemberSacked.Add(OnCrewmemberSacked); GameEvents.onKerbalAdded.Add(OnKerbalAdded); GameEvents.onKerbalRemoved.Add(OnKerbalRemoved); GameEvents.onKerbalNameChange.Add(OnKerbalNameChange); if (!DFWrapper.InstanceExists) { Core.Log("Initializing DFWrapper...", Core.LogLevel.Important); DFWrapper.InitDFWrapper(); if (DFWrapper.InstanceExists) { Core.Log("DFWrapper initialized.", Core.LogLevel.Important); } else { Core.Log("Could not initialize DFWrapper.", Core.LogLevel.Important); } } if (DFWrapper.InstanceExists) { EventData <Part, ProtoCrewMember> dfEvent; dfEvent = GameEvents.FindEvent <EventData <Part, ProtoCrewMember> >("onKerbalFrozen"); if (dfEvent != null) { dfEvent.Add(OnKerbalFrozen); } else { Core.Log("Could not find onKerbalFrozen event!", Core.LogLevel.Error); } dfEvent = GameEvents.FindEvent <EventData <Part, ProtoCrewMember> >("onKerbalThaw"); if (dfEvent != null) { dfEvent.Add(OnKerbalThaw); } else { Core.Log("Could not find onKerbalThaw event!", Core.LogLevel.Error); } } if (ToolbarManager.ToolbarAvailable && Core.UseBlizzysToolbar) { Core.Log("Registering Blizzy's Toolbar button...", Core.LogLevel.Important); toolbarButton = ToolbarManager.Instance.add("KerbalHealth", "HealthMonitor"); toolbarButton.Text = "Kerbal Health Monitor"; toolbarButton.TexturePath = "KerbalHealth/toolbar"; toolbarButton.ToolTip = "Kerbal Health"; toolbarButton.OnClick += (e) => { if (monitorWindow == null) { DisplayData(); } else { UndisplayData(); } }; } else { Core.Log("Registering AppLauncher button...", Core.LogLevel.Important); Texture2D icon = new Texture2D(38, 38); icon.LoadImage(System.IO.File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "icon.png"))); appLauncherButton = ApplicationLauncher.Instance.AddModApplication(DisplayData, UndisplayData, null, null, null, null, ApplicationLauncher.AppScenes.ALWAYS, icon); } lastUpdated = Planetarium.GetUniversalTime(); nextEventTime = lastUpdated + GetNextEventInterval(); Version v = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; if (version != v) { Core.Log("Current mod version " + v + " is different from v" + version + " used to save the game. Most likely, Kerbal Health has been recently updated.", Core.LogLevel.Important); } else { Core.Log("Kerbal Health v" + version); } if ((version < new Version(1, 1, 0)) && (HighLogic.CurrentGame.Parameters.CustomParams <KerbalHealthFactorsSettings>().CrowdedBaseFactor != -3) && (Planetarium.GetUniversalTime() > 0)) { Core.Log("Crowded Factor is " + HighLogic.CurrentGame.Parameters.CustomParams <KerbalHealthFactorsSettings>().CrowdedBaseFactor + " instead of -3. Sending a warning to the player."); HighLogic.CurrentGame.Parameters.CustomParams <KerbalHealthFactorsSettings>().CrowdedBaseFactor = -3; Core.ShowMessage("Kerbal Health has been updated to v" + v.ToString(3) + ". Crowded factor value has been reset to -3. It is recommended that you load each crewed vessel briefly to update Kerbal Health cache.", true); } version = v; Core.Log("KerbalHealthScenario.Start finished.", Core.LogLevel.Important); }
int page = 1; // Current page in the list of kerbals public void Start() { if (!Core.ModEnabled) { return; } Core.Log("KerbalHealthScenario.Start", Core.LogLevel.Important); Core.Log(Core.Factors.Count + " factors initialized."); if (!Core.Loaded) { Core.LoadConfig(); } Core.KerbalHealthList.RegisterKerbals(); GameEvents.onCrewOnEva.Add(OnKerbalEva); GameEvents.onCrewKilled.Add(OnCrewKilled); GameEvents.OnCrewmemberHired.Add(OnCrewmemberHired); GameEvents.OnCrewmemberSacked.Add(OnCrewmemberSacked); GameEvents.onKerbalAdded.Add(OnKerbalAdded); GameEvents.onKerbalRemoved.Add(OnKerbalRemoved); GameEvents.onKerbalNameChange.Add(OnKerbalNameChange); if (!DFWrapper.InstanceExists) { Core.Log("Initializing DFWrapper...", Core.LogLevel.Important); DFWrapper.InitDFWrapper(); if (DFWrapper.InstanceExists) { Core.Log("DFWrapper initialized.", Core.LogLevel.Important); } else { Core.Log("Could not initialize DFWrapper.", Core.LogLevel.Important); } } if (DFWrapper.InstanceExists) { EventData <Part, ProtoCrewMember> dfEvent; dfEvent = GameEvents.FindEvent <EventData <Part, ProtoCrewMember> >("onKerbalFrozen"); if (dfEvent != null) { dfEvent.Add(OnKerbalFrozen); } else { Core.Log("Could not find onKerbalFrozen event!", Core.LogLevel.Error); } dfEvent = GameEvents.FindEvent <EventData <Part, ProtoCrewMember> >("onKerbalThaw"); if (dfEvent != null) { dfEvent.Add(OnKerbalThaw); } else { Core.Log("Could not find onKerbalThaw event!", Core.LogLevel.Error); } } if (ToolbarManager.ToolbarAvailable && Core.UseBlizzysToolbar) { Core.Log("Registering Blizzy's Toolbar button...", Core.LogLevel.Important); toolbarButton = ToolbarManager.Instance.add("KerbalHealth", "HealthMonitor"); toolbarButton.Text = "Kerbal Health Monitor"; toolbarButton.TexturePath = "KerbalHealth/toolbar"; toolbarButton.ToolTip = "Kerbal Health"; toolbarButton.OnClick += (e) => { if (monitorWindow == null) { DisplayData(); } else { UndisplayData(); } }; } else { Core.Log("Registering AppLauncher button...", Core.LogLevel.Important); Texture2D icon = new Texture2D(38, 38); icon.LoadImage(System.IO.File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "icon.png"))); appLauncherButton = ApplicationLauncher.Instance.AddModApplication(DisplayData, UndisplayData, null, null, null, null, ApplicationLauncher.AppScenes.ALWAYS, icon); } lastUpdated = Planetarium.GetUniversalTime(); nextEventTime = lastUpdated + GetNextEventInterval(); Core.Log("KerbalHealthScenario.Start finished.", Core.LogLevel.Important); }