public void Start() { French = HighLogic.CurrentGame.Parameters.CustomParams <ResearchBodies_SettingsParms>().french; isTSTInstalled = Database.instance.isTSTInstalled; isPCBMInstalled = Utilities.IsPCBMInstalled; if (isPCBMInstalled) //If Progressive CB Maps assembly is present, initialise PCBM wrapper. { PCBMWrapper.InitPCBMWrapper(); if (!PCBMWrapper.APIPCBMReady) { isPCBMInstalled = false; //If the initialise of wrapper failed set bool to false, we won't be interfacing to PCBM today. } } enable = ResearchBodies.Enabled; //Create Instructor instructor_Werner = new ResearchBodiesInstructor("Instructor_Wernher"); instructor_Linus = new ResearchBodiesInstructor("Strategy_ScienceGuy"); instructor_Werner.Instructor.enabled = false; instructor_Linus.Instructor.enabled = false; //Register for Contract On offerred so we can remove ones that are for bodies not yet tracked. if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { GameEvents.Contract.onOffered.Add(CheckContracts); } if (Utilities.IsKopInstalled) { Database.instance.ReApplyRanges(); } //If RB is enabled set initial Discovery Levels of CBs and call ProgressiveCBMaps to set their graphics levels. if (enable) { SetBodyDiscoveryLevels(); GameEvents.onVesselSOIChanged.Add(onVesselSOIChanged); Utilities.setScaledScreen(); windowRect = new Rect(1, 1, Utilities.scaledScreenWidth - 2, Utilities.scaledScreenHeight - 2); GameEvents.onScreenResolutionModified.Add(onScreenResolutionModified); GameEvents.OnMapEntered.Add(onMapEntered); if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) { onMapEntered(); } } else { Database.instance.ResetBodyVisibilities(); SetBodyDiscoveryLevels(); } }
public void OnGUI() { if (!enable || !showGUI) { if (instructor_Werner != null && instructor_Werner.Instructor != null) { Destroy(instructor_Werner.Instructor.gameObject); } if (instructor_Werner != null) { instructor_Werner.Destroy(); instructor_Werner = null; } if (instructor_Linus != null && instructor_Linus.Instructor != null) { Destroy(instructor_Linus.Instructor.gameObject); } if (instructor_Linus != null) { instructor_Linus.Destroy(); instructor_Linus = null; } return; } //Create Instructor if (instructor_Werner == null || instructor_Werner != null && instructor_Werner.Instructor == null) { instructor_Werner = new ResearchBodiesInstructor("Instructor_Wernher"); } if (instructor_Werner != null && instructor_Werner.Instructor != null) { instructor_Werner.Instructor.enabled = true; } if (instructor_Linus == null || instructor_Linus != null && instructor_Linus.Instructor == null) { instructor_Linus = new ResearchBodiesInstructor("Strategy_ScienceGuy"); } if (instructor_Linus != null && instructor_Linus.Instructor != null) { instructor_Linus.Instructor.enabled = true; } try { if (!Textures.StylesSet) { Textures.SetupStyles(); } } catch (Exception ex) { RSTLogWriter.Log("Unable to set GUI Styles to draw the GUI"); RSTLogWriter.Log("Exception: {0}", ex); } GUI.skin = Textures.ObsSkin; #if DEBUGFACILITY if (showObsdebugUI) { observRect = GUILayout.Window(_RBwindowId + 1, observRect, DrawObservDebug, "Research Bodies"); } #endif if (PSystemSetup.Instance.GetSpaceCenterFacility("TrackingStation").GetFacilityDamage() > 0) { ScreenMessages.PostScreenMessage(Localizer.Format("#autoLOC_RBodies_00018"), 3.0f, ScreenMessageStyle.UPPER_CENTER); return; } try { windowRect.ClampInsideScreen(); windowRect = GUILayout.Window(_RBwindowId, windowRect, DrawWindow, "Research Bodies"); Utilities.DrawToolTip(); } catch (Exception ex) { RSTLogWriter.Log("Unable to draw GUI"); RSTLogWriter.Log("Exception: {0}", ex); } }