/** 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);
         }
     }
 }
Ejemplo n.º 2
0
        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 static ApplicationLauncherButton AddModApplication(this ApplicationLauncher appLauncher,
                                                           ApplicationLauncher.AppScenes visibleInScenes,
                                                           Texture texture
                                                           )
 {
     return(appLauncher.AddModApplication(
                Dummy, Dummy,
                Dummy, Dummy,
                Dummy, Dummy,
                visibleInScenes,
                texture
                ));
 }
 public static ApplicationLauncherButton AddModApplication(this ApplicationLauncher appLauncher,
                                                           Callback onTrue,
                                                           Callback onFalse,
                                                           ApplicationLauncher.AppScenes visibleInScenes,
                                                           Texture texture
                                                           )
 {
     return(appLauncher.AddModApplication(
                onTrue, onFalse,
                Dummy, Dummy,
                Dummy, Dummy,
                visibleInScenes,
                texture
                ));
 }
Ejemplo n.º 5
0
        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");
        }
        /** 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
                                                );
            }
        }
Ejemplo n.º 7
0
        void _onGUIApplicationLauncherReady()
        {
            if (_button == null)
            {
                ApplicationLauncher appLauncher = ApplicationLauncher.Instance;

                _button = appLauncher.AddModApplication(OnClick,         // true
                                                        OnUnclick,       // false
                                                        OnHover,         // hover
                                                        OnUnhover,       // unhover
                                                        OnEnable,        // enable? what does this mean
                                                        OnDisable,       // disable? what does this mean
                                                        Visibility,
                                                        AppLauncherIcon);

                appLauncher.EnableMutuallyExclusive(_button);
            }

            onGUIApplicationLauncherReady();
        }
Ejemplo n.º 8
0
 public void setupAppButton()
 {
     UDprint("setupAppButton");
     if (setupApp)
     {
         UDprint("app Button already set up");
     }
     else if (ApplicationLauncher.Ready)
     {
         setupApp = true;
         if (appButton == null)
         {
             UDprint("Setting up AppLauncher");
             ApplicationLauncher appinstance = ApplicationLauncher.Instance;
             UDprint("Setting up AppLauncher Button");
             appTexture = loadTexture("Undockinator/undockinator-app");
             appButton  = appinstance.AddModApplication(buttonPressed, buttonPressed, doNothing, doNothing, doNothing, doNothing, ApplicationLauncher.AppScenes.FLIGHT, appTexture);
             if (useBlizzy)
             {
                 appButton.VisibleInScenes = ApplicationLauncher.AppScenes.NEVER;
             }
             else
             {
                 appButton.VisibleInScenes = ApplicationLauncher.AppScenes.FLIGHT;
             }
         }
         else
         {
             appButton.onTrue  = buttonPressed;
             appButton.onFalse = buttonPressed;
         }
     }
     else
     {
         UDprint("ApplicationLauncher.Ready is false");
     }
 }
Ejemplo n.º 9
0
        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");
        }
 public void createAppLauncher()
 {
     toolbarButton = toolbar.AddModApplication(onTrue: ShowGUI, onFalse: HideGUI, onHover: null, onHoverOut: null, onEnable: null, onDisable: Destroy, visibleInScenes: ApplicationLauncher.AppScenes.VAB, texture: buttontexture);
 }