public void RunWhenReady() { SafeHouse.Logger.SuperVerbose("KOSToolBarWindow: Instance number " + myInstanceNum + " is trying to ready the hooks"); // KSP claims the hook ApplicationLauncherReady.Add will not run until // the application is ready, even though this is emphatically false. It actually // fires the event a few times before the one that "sticks" and works: if (!ApplicationLauncher.Ready) { return; } if (someInstanceHasHooks) { return; } thisInstanceHasHooks = true; someInstanceHasHooks = true; SafeHouse.Logger.SuperVerbose("KOSToolBarWindow: Instance number " + myInstanceNum + " will now actually make its hooks"); ApplicationLauncher launcher = ApplicationLauncher.Instance; launcherButton = launcher.AddModApplication( CallbackOnTrue, CallbackOnFalse, CallbackOnHover, CallbackOnHoverOut, CallbackOnEnable, CallbackOnDisable, APP_SCENES, launcherButtonTexture); launcher.AddOnShowCallback(CallbackOnShow); launcher.AddOnHideCallback(CallbackOnHide); launcher.EnableMutuallyExclusive(launcherButton); SetupBackingConfigInts(); }
public void AddButton() { if (!ApplicationLauncher.Ready) { return; } var useBlizzyOnly = false; if (ToolbarManager.ToolbarAvailable) { useBlizzyOnly = SafeHouse.Config.UseBlizzyToolbarOnly; } if (firstTime) { FirstTimeSetup(); firstTime = false; } if (!useBlizzyOnly && launcherButton == null) { ApplicationLauncher launcher = ApplicationLauncher.Instance; launcherButton = launcher.AddModApplication( CallbackOnTrue, CallbackOnFalse, CallbackOnHover, CallbackOnHoverOut, CallbackOnEnable, CallbackOnDisable, APP_SCENES, launcherButtonTexture); launcher.AddOnShowCallback(CallbackOnShow); launcher.AddOnHideCallback(CallbackOnHide); launcher.EnableMutuallyExclusive(launcherButton); } if (blizzyButton == null) { AddBlizzyButton(); } SetupBackingConfigInts(); SafeHouse.Logger.SuperVerbose("[kOSToolBarWindow] Launcher Icon init successful"); }
public void Start() { switch (HighLogic.LoadedScene) { case GameScenes.SPACECENTER: case GameScenes.TRACKSTATION: case GameScenes.FLIGHT: case GameScenes.EDITOR: break; default: return; } PluginLogger.Instance.Info("Starting!!!!!! " + HighLogic.LoadedScene); launcherButtonTexture = GameDatabase.Instance.GetTexture("KontrolSystem/GFX/dds_launcher_button", false); ApplicationLauncher launcher = ApplicationLauncher.Instance; if (launcher == null) { PluginLogger.Instance.Error("Launcher not ready on start"); return; } var useBlizzyOnly = ToolbarManager.ToolbarAvailable && KontrolSystemParameters.Instance != null && KontrolSystemParameters.Instance.useBlizzyToolbarOnly; if (!useBlizzyOnly && launcherButton == null) { launcherButton = launcher.AddModApplication( CallbackOnTrue, CallbackOnFalse, CallbackOnHover, CallbackOnHoverOut, CallbackOnEnable, CallbackOnDisable, ApplicationLauncher.AppScenes.ALWAYS, launcherButtonTexture); launcher.AddOnShowCallback(CallbackOnShow); launcher.AddOnHideCallback(CallbackOnHide); launcher.EnableMutuallyExclusive(launcherButton); } if (blizzyButton == null && ToolbarManager.ToolbarAvailable) { blizzyButton = ToolbarManager.Instance.Add("KontrolSystem", "ksButton"); blizzyButton.TexturePath = "KontrolSystem/GFX/dds_launcher_button-blizzy"; blizzyButton.ToolTip = "KontrolSystem"; blizzyButton.OnClick += CallbackOnClickBlizzy; } commonStyles ??= new CommonStyles(Instantiate(HighLogic.Skin)); toolbarWindow ??= new ToolbarWindow(GetInstanceID(), commonStyles, consoleWindow, moduleManagerWindow); Mainframe.Instance.Reboot(KontrolSystemConfig.Instance); PluginLogger.Instance.Info("Start success"); }