Example #1
0
 /// <summary>
 /// Entry method. Sets up config and event listeners.
 /// </summary>
 /// <param name="helper">Mod helper to read config and load sprites.</param>
 public override void Entry(IModHelper helper)
 {
     this.config = helper.ReadConfig <GeodeInfoMenuConfig>();
     this.config.NumberOfNextGeodeDropsToShow = this.config.NumberOfNextGeodeDropsToShow < 0 ? 0 : this.config.NumberOfNextGeodeDropsToShow;
     this.config.NumberOfNextGeodeDropsToShow = this.config.NumberOfNextGeodeDropsToShow > 999 ? 9 : this.config.NumberOfNextGeodeDropsToShow;
     this.Geodes = new Dictionary <GeodeType, int> {
         { GeodeType.Normal, 535 }, { GeodeType.FrozenGeode, 536 }, { GeodeType.MagmaGeode, 537 }, { GeodeType.OmniGeode, 749 }
     };
     this.dropNameToGeodeDrop             = this.GetAllPossibleDropMappings();
     GeodeMenu.tabIcons                   = helper.Content.Load <Texture2D>("Sprites/tabs.png");
     helper.Events.Input.ButtonPressed   += this.OnButtonPressed;
     helper.Events.Display.MenuChanged   += this.OnMenuChanged;
     helper.Events.Display.WindowResized += this.OnWindowResized;
 }
        public GeodeMenu(GeodeInfoMenuMod mod, GeodeInfoMenuConfig config, IList <Tuple <int[], bool[]> > items, GeodeMenuStateInfo savedState = null, bool forceReloadState = false)
            : base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, true)
        {
            this.config   = config;
            this.modEntry = mod;
            this.wasSearchTextBoxSelectedWhenPageLeft = false;

            this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "search", "Search for Drops")
            {
                myID            = 15960,
                downNeighborID  = 0,
                rightNeighborID = 15961,
                tryDefaultIfNoDownNeighborExists = true,
                fullyImmutable = true
            });
            this.pages.Add((IClickableMenu) new SearchTab(mod, config, this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height));
            this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 2, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "normal", "Geode")
            {
                myID            = 15961,
                downNeighborID  = 1,
                rightNeighborID = 15962,
                leftNeighborID  = 15960,
                tryDefaultIfNoDownNeighborExists = true,
                fullyImmutable = true
            });
            this.pages.Add((IClickableMenu) new GeodeTab("geode", items[0], this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height));
            this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 3, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "frozen", "Frozen Geode")
            {
                myID            = 15962,
                downNeighborID  = 2,
                rightNeighborID = 15963,
                leftNeighborID  = 15961,
                tryDefaultIfNoDownNeighborExists = true,
                fullyImmutable = true
            });
            this.pages.Add((IClickableMenu) new GeodeTab("frozen geode", items[1], this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height));
            this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 4, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "magma", "Magma Geode")
            {
                myID            = 15963,
                downNeighborID  = 3,
                rightNeighborID = 15964,
                leftNeighborID  = 15962,
                tryDefaultIfNoDownNeighborExists = true,
                fullyImmutable = true
            });
            this.pages.Add((IClickableMenu) new GeodeTab("magma geode", items[2], this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height));
            this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 5, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "omni", "Omni Geode")
            {
                myID           = 15964,
                downNeighborID = 4,
                leftNeighborID = 15963,
                tryDefaultIfNoDownNeighborExists = true,
                fullyImmutable = true
            });
            this.pages.Add((IClickableMenu) new GeodeTab("omni geode", items[3], this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height));

            if (Game1.activeClickableMenu == null)
            {
                Game1.playSound("bigSelect");
            }

            GeodeMenu.forcePreventClose = false;

            if (savedState != null)
            {
                (this.pages[0] as SearchTab).SetSearchBoxText(savedState.searchText);
                if (config.IfRememberingMenuStateAlsoRememberScrollBarPositions || forceReloadState)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        (this.pages[i] as IScrollableMenu).SetCurrentIndex(savedState.scrollBarIndicies[i]);
                    }
                }
            }

            if (Game1.options.SnappyMenus)
            {
                this.pages[this.currentTab].populateClickableComponentList();
                this.pages[this.currentTab].allClickableComponents.AddRange((IEnumerable <ClickableComponent>) this.tabs);
                this.snapToDefaultClickableComponent();
            }


            if (savedState != null)
            {
                this.ChangeTab(savedState.currentTab);
            }
        }
 public GeodeMenu(int startingTab, GeodeInfoMenuMod entry, GeodeInfoMenuConfig config, IList <Tuple <int[], bool[]> > items) : this(entry, config, items)
 {
     this.ChangeTab(startingTab);
 }