Exemple #1
0
        /// <summary>
        /// Attaches the delegates that handle the button click and draw method of the tab
        /// </summary>
        private void MenuOpened(object sender, EventArgsClickableMenuChanged e)
        {
            // copied from MenuClosed
            GraphicsEvents.OnPostRenderGuiEvent -= RenderTab;
            GraphicsEvents.OnPreRenderGuiEvent  -= HandleJunimo;

            if (Tab != null)
            {
                Tab.RemoveListeners();
                Tab = null;
            }

            if (Page != null)
            {
                if (e.PriorMenu is GameMenu)
                {
                    List <IClickableMenu> oldpages = Helper.Reflection.GetField <List <IClickableMenu> >((e.PriorMenu as GameMenu), "pages").GetValue();
                    oldpages.Remove(Page);
                }

                Page.RemoveListeners(true);
                Page      = null;
                PageIndex = null;
            }

            if (!(e.NewMenu is GameMenu))
            {
                Tab       = null;
                Page      = null;
                PageIndex = null;
                return;
            }

            GameMenu menu = (GameMenu)e.NewMenu;
            List <IClickableMenu> pages = Helper.Reflection.GetField <List <IClickableMenu> >(menu, "pages").GetValue();

            var options = pages.Find(x => { return(x is OptionsPage); });
            int width   = options.width;

            Page      = new MenuPage(OptionPackageList, menu.xPositionOnScreen, menu.yPositionOnScreen, width, menu.height);
            PageIndex = pages.Count;
            pages.Add(Page);

            bool infoSuiteInstalled = Helper.ModRegistry.IsLoaded("Cdaragorn.UiInfoSuite");
            int  tabLocation        = infoSuiteInstalled ? 9 : 11;

            Tab = new MenuTab(Helper, new Rectangle(menu.xPositionOnScreen + Game1.tileSize * tabLocation, menu.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize));

            GraphicsEvents.OnPostRenderGuiEvent -= RenderTab;
            GraphicsEvents.OnPostRenderGuiEvent += RenderTab;
            GraphicsEvents.OnPreRenderGuiEvent  -= HandleJunimo;
            GraphicsEvents.OnPreRenderGuiEvent  += HandleJunimo;
        }
Exemple #2
0
        /// <summary>
        /// Removes the delegates that handle the button click and draw method of the tab
        /// </summary>
        private void MenuClosed(object sender, EventArgsClickableMenuClosed e)
        {
            GraphicsEvents.OnPostRenderGuiEvent -= RenderTab;
            GraphicsEvents.OnPreRenderGuiEvent  -= HandleJunimo;

            if (Tab != null)
            {
                Tab.RemoveListeners();
                Tab = null;
            }

            if (Page != null)
            {
                if (e.PriorMenu is GameMenu)
                {
                    List <IClickableMenu> pages = Helper.Reflection.GetField <List <IClickableMenu> >((e.PriorMenu as GameMenu), "pages").GetValue();
                    pages.Remove(Page);
                }

                Page.RemoveListeners(true);
                Page      = null;
                PageIndex = null;
            }
        }