Beispiel #1
0
        private void OnGUIAppLauncherReady()
        {
            if (applauncherButton == null)
            {
                ToolbarInfo tb = GetToolbarInfo();
                var         m  = new System.Collections.Generic.Dictionary <GameScenes, AppScenes>();
                m.Add(GameScenes.FLIGHT, AppScenes.FLIGHT);
                m.Add(GameScenes.EDITOR, AppScenes.SPH | AppScenes.VAB);
                m.Add(GameScenes.SPACECENTER, AppScenes.SPACECENTER);
                // and so on ...
                AppScenes v = AppScenes.NEVER;
                foreach (GameScenes s in tb.visibleInScenes)
                {
                    v |= m[s];
                }

                applauncherButton = KSP.UI.Screens.ApplicationLauncher.Instance.AddModApplication(
                    OnShowByToolbar,
                    OnHideByToolbar,
                    null,
                    null,
                    null,
                    null,
                    v,
                    (Texture)GameDatabase.Instance.GetTexture(tb.launcherTexture, false));
                if (visibleByToolbars)
                {
                    applauncherButton.SetTrue(false);
                }
            }
        }
Beispiel #2
0
        protected void InitializeToolbars()
        {
            if (ToolbarManager.ToolbarAvailable && useToolbar && toolbarButton == null)
            {
                ToolbarInfo tb = GetToolbarInfo();
                toolbarButton             = ToolbarManager.Instance.add(tb.name, tb.name);
                toolbarButton.TexturePath = tb.toolbarTexture;
                toolbarButton.ToolTip     = tb.tooltip;
                toolbarButton.Visibility  = new GameScenesVisibility(tb.visibleInScenes);
                toolbarButton.Enabled     = true;
                toolbarButton.OnClick    += (e) =>
                {
                    visibleByToolbars = !visibleByToolbars;
                    OnGuiVisibilityChange();
                };
            }

            GameEvents.onHideUI.Add(OnHideByKspGui);
            GameEvents.onShowUI.Add(OnShowByKspGui);
            if (useAppLauncher)
            {
                GameEvents.onGUIApplicationLauncherReady.Add(OnGUIAppLauncherReady);
            }
        }