예제 #1
0
 internal static void DestroyToolbarButton()
 {
     Util.DebugLog("");
     DestroyBlizzyToolbarButton();
     DestroyStockToolbarButton();
     IconStyle = IconStyleType.NORMAL;
 }
예제 #2
0
 private static void DestroyStockToolbarButton()
 {
     if (stock_toolbar_button != null)
     {
         ApplicationLauncher.Instance.RemoveModApplication(stock_toolbar_button);
         stock_toolbar_button = null;
     }
     normal_icon_texture = null;
     active_icon_texture = null;
     auto_icon_texture   = null;
     current_iconstyle   = IconStyleType.NORMAL;
 }
예제 #3
0
        /// <summary> Changes the toolbar button icon </summary>
        internal static void ChangeIcon(IconStyleType iconstyle)
        {
            // no icons for blizzy yet so only change the current icon style
            if (ToolbarManager.ToolbarAvailable && Settings.UseBlizzyToolbar)
            {
                switch (iconstyle)
                {
                case IconStyleType.ACTIVE:
                    IconStyle = IconStyleType.ACTIVE;
                    break;

                case IconStyleType.AUTO:
                    IconStyle = IconStyleType.AUTO;
                    break;

                default:
                    IconStyle = IconStyleType.NORMAL;
                    break;
                }
            }

            else
            {
                switch (iconstyle)
                {
                case IconStyleType.ACTIVE:
                    if (stock_toolbar_button != null && StockTexturesAllocated)
                    {
                        stock_toolbar_button.SetTexture(active_icon_texture);
                    }
                    IconStyle = IconStyleType.ACTIVE;
                    break;

                case IconStyleType.AUTO:
                    if (stock_toolbar_button != null && StockTexturesAllocated)
                    {
                        stock_toolbar_button.SetTexture(auto_icon_texture);
                    }
                    IconStyle = IconStyleType.AUTO;
                    break;

                default:
                    if (stock_toolbar_button != null && StockTexturesAllocated)
                    {
                        stock_toolbar_button.SetTexture(normal_icon_texture);
                    }
                    IconStyle = IconStyleType.NORMAL;
                    break;
                }
            }
        }
예제 #4
0
        /// <summary> Creates the toolbar button for either a KSP stock toolbar or Blizzy toolbar if available. </summary>
        internal static void Start()
        {
            Util.DebugLog(constructed ? "Resetting" : "Constructing");

            if (Settings.DisplayTrajectories)
            {
                IconStyle = IconStyleType.ACTIVE;
            }
            else
            {
                IconStyle = IconStyleType.NORMAL;
            }

            if (ToolbarManager.ToolbarAvailable && Settings.UseBlizzyToolbar)
            {
                // setup a toolbar button for the blizzy toolbar
                Util.Log("Using Blizzy toolbar");
                blizzy_toolbar_button             = ToolbarManager.Instance.add(Localizer.Format("#autoLOC_Trajectories_Title"), "TrajectoriesGUI");
                blizzy_toolbar_button.Visibility  = BlizzyToolbarButtonVisibility.fetch;
                blizzy_toolbar_button.TexturePath = "Trajectories/Textures/icon-blizzy";
                blizzy_toolbar_button.ToolTip     = Localizer.Format("#autoLOC_Trajectories_AppButtonTooltip");
                blizzy_toolbar_button.OnClick    += OnBlizzyToggle;
            }
            else if (!constructed)
            {
                // setup a toolbar button for the stock toolbar
                Util.Log("Using KSP stock toolbar");
                string TrajTexturePath = KSPUtil.ApplicationRootPath + "GameData/Trajectories/Textures/";
                normal_icon_texture ??= new Texture2D(36, 36);
                active_icon_texture ??= new Texture2D(36, 36);
                auto_icon_texture ??= new Texture2D(36, 36);
                if (StockTexturesAllocated)
                {
                    normal_icon_texture.LoadImage(File.ReadAllBytes(TrajTexturePath + "icon.png"));
                    active_icon_texture.LoadImage(File.ReadAllBytes(TrajTexturePath + "iconActive.png"));
                    auto_icon_texture.LoadImage(File.ReadAllBytes(TrajTexturePath + "iconAuto.png"));
                }

                GameEvents.onGUIApplicationLauncherReady.Add(delegate { CreateStockToolbarButton(); });
                GameEvents.onGUIApplicationLauncherUnreadifying.Add(delegate { DestroyStockToolbarButton(); });
            }
            else
            {
                Util.Log("Using KSP stock toolbar");
            }

            constructed = true;
        }
예제 #5
0
        /// <summary> Changes the toolbar button icon </summary>
        public static void ChangeIcon(IconStyleType iconstyle)
        {
            // no icons for blizzy yet so only change the current icon style
            if (ToolbarManager.ToolbarAvailable && Settings.fetch.UseBlizzyToolbar)
            {
                switch (iconstyle)
                {
                case IconStyleType.ACTIVE:
                    current_iconstyle = IconStyleType.ACTIVE;
                    break;

                case IconStyleType.AUTO:
                    current_iconstyle = IconStyleType.AUTO;
                    break;

                default:
                    current_iconstyle = IconStyleType.NORMAL;
                    break;
                }
            }

            else
            {
                switch (iconstyle)
                {
                case IconStyleType.ACTIVE:
                    stock_toolbar_button.SetTexture(active_icon_texture);
                    current_iconstyle = IconStyleType.ACTIVE;
                    break;

                case IconStyleType.AUTO:
                    stock_toolbar_button.SetTexture(auto_icon_texture);
                    current_iconstyle = IconStyleType.AUTO;
                    break;

                default:
                    stock_toolbar_button.SetTexture(normal_icon_texture);
                    current_iconstyle = IconStyleType.NORMAL;
                    break;
                }
            }
        }
예제 #6
0
        /// <summary> Creates the toolbar button for either a KSP stock toolbar or Blizzy toolbar if available. </summary>
        public static void Create()
        {
            if (ToolbarManager.ToolbarAvailable && Settings.fetch.UseBlizzyToolbar)
            {
                // setup a toolbar button for the blizzy toolbar
                Debug.Log("Using Blizzy toolbar for Trajectories");
                blizzy_toolbar_button             = ToolbarManager.Instance.add(Localizer.Format("#autoLOC_Trajectories_Title"), "TrajectoriesGUI");
                blizzy_toolbar_button.Visibility  = BlizzyToolbarButtonVisibility.Instance;
                blizzy_toolbar_button.TexturePath = "Trajectories/Textures/icon-blizzy";
                blizzy_toolbar_button.ToolTip     = Localizer.Format("#autoLOC_Trajectories_AppButtonTooltip");
                blizzy_toolbar_button.OnClick    += OnBlizzyToggle;
            }
            else
            {
                // setup a toolbar button for the stock toolbar
                Debug.Log("Using Stock toolbar for Trajectories");
                normal_icon_texture = GameDatabase.Instance.GetTexture("Trajectories/Textures/icon", false);
                active_icon_texture = GameDatabase.Instance.GetTexture("Trajectories/Textures/iconActive", false);
                auto_icon_texture   = GameDatabase.Instance.GetTexture("Trajectories/Textures/iconAuto", false);

                if (Settings.fetch.DisplayTrajectories)
                {
                    current_iconstyle = IconStyleType.ACTIVE;
                }
                else
                {
                    current_iconstyle = IconStyleType.NORMAL;
                }

                GameEvents.onGUIApplicationLauncherReady.Add(delegate
                {
                    CreateStockToolbarButton();
                });
                GameEvents.onGUIApplicationLauncherUnreadifying.Add(delegate
                {
                    DestroyStockToolbarButton();
                });
            }
        }