public void GoAway() { if (isOpen) { Close(); } clickedOn = false; try { if (launcherButton != null && ApplicationLauncher.Instance != null) { ApplicationLauncher launcher = ApplicationLauncher.Instance; launcher.DisableMutuallyExclusive(launcherButton); launcher.RemoveOnRepositionCallback(CallbackOnShow); launcher.RemoveOnHideCallback(CallbackOnHide); launcher.RemoveOnShowCallback(CallbackOnShow); launcher.RemoveModApplication(launcherButton); launcherButton = null; } } catch (Exception e) { SafeHouse.Logger.SuperVerbose("[kOSToolBarWindow] Failed unregistering AppLauncher handlers," + e.Message); } if (blizzyButton != null) { blizzyButton.Destroy(); } }
/** Set up for the toolbar-button */ private void setupButton() { if (ApplicationLauncher.Ready) { ApplicationLauncher instance = ApplicationLauncher.Instance; if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX) { if (etButton == null) { debugPrint("Setting up button"); etButton = instance.AddModApplication(toggleActive, toggleActive, null, null, null, null, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW, getButtonTexture()); } else { debugPrint("Button already set up"); etButton.onTrue = toggleActive; etButton.onFalse = toggleActive; } } else { debugPrint("Removing button"); if (etButton != null) { instance.RemoveModApplication(etButton); } Destroy(this); } } }
/** Set up for the toolbar-button */ private void setupButton() { #if false if (ApplicationLauncher.Ready) { ApplicationLauncher instance = ApplicationLauncher.Instance; if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER || HighLogic.CurrentGame.Mode == Game.Modes.SCIENCE_SANDBOX) { if (etButton == null) { debugPrint("Setting up button"); etButton = instance.AddModApplication(toggleActive, toggleActive, null, null, null, null, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW, getButtonTexture()); } else { debugPrint("Button already set up"); etButton.onTrue = toggleActive; etButton.onFalse = toggleActive; } } else { debugPrint("Removing button"); if (etButton != null) { instance.RemoveModApplication(etButton); } Destroy(this); } } #endif if (toolbarControl == null) { toolbarControl = gameObject.AddComponent <ToolbarControl>(); toolbarControl.AddToAllToolbars(toggleActive, toggleActive, ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW, MODID, "experimentTrackerButton", getButtonTexture + "-38", getButtonTexture + "-24", MODNAME ); } }
public void OnDestroy() { try { ApplicationLauncher launcher = ApplicationLauncher.Instance; if (launcherButton != null && launcher != null) { launcher.DisableMutuallyExclusive(launcherButton); launcher.RemoveOnRepositionCallback(CallbackOnShow); launcher.RemoveOnHideCallback(CallbackOnHide); launcher.RemoveOnShowCallback(CallbackOnShow); launcher.RemoveModApplication(launcherButton); launcherButton = null; } } catch (Exception e) { PluginLogger.Instance.Error("Failed unregistering AppLauncher handlers," + e.Message); } PluginLogger.Instance.Info("Destroy"); _instance = null; }
public void GoAway() { SafeHouse.Logger.SuperVerbose("KOSToolBarWindow: PROOF: Instance " + myInstanceNum + " is in GoAway()."); if (thisInstanceHasHooks) { SafeHouse.Logger.SuperVerbose("KOSToolBarWindow: PROOF: Instance " + myInstanceNum + " has hooks and is entering the guts of GoAway()."); if (isOpen) { Close(); } clickedOn = false; thisInstanceHasHooks = false; someInstanceHasHooks = false; // if this is the instance that had hooks and it's going away, let another instance have a go. ApplicationLauncher launcher = ApplicationLauncher.Instance; launcher.DisableMutuallyExclusive(launcherButton); launcher.RemoveOnRepositionCallback(CallbackOnShow); launcher.RemoveOnHideCallback(CallbackOnHide); launcher.RemoveOnShowCallback(CallbackOnShow); launcher.RemoveModApplication(launcherButton); } }