/// <summary> /// Saves the menu state from e if e is a geode menu. /// </summary> /// <param name="e">A menu</param> public void SaveMenuState(StardewValley.Menus.IClickableMenu e) { if (e is GeodeMenu menu) { this.menuStateInfo = menu.SaveState(); } }
/*** ** Event Listeners ****/ /// <summary>Raised after the game window is resized.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnWindowResized(object sender, EventArgs e) { // recreate menu to fit new window size if (Game1.activeClickableMenu is GeodeMenu menu) { this.menuStateInfo = menu.SaveState(); Game1.activeClickableMenu = new GeodeMenu(this, this.config, this.GetNextDropsForGeodes(this.config.NumberOfNextGeodeDropsToShow), this.menuStateInfo, true); } }
/*** * Event Listeners ***/ /// <summary> /// Window resized event listener. Re-creates the menu to make it fit in the new window. /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">Event arguments</param> private void WindowResized(object sender, EventArgs e) { if (Game1.activeClickableMenu is GeodeMenu) { this.menuStateInfo = (Game1.activeClickableMenu as GeodeMenu).SaveState(); GeodeMenu menu = new GeodeMenu(this, this.config, GetNextDropsForGeodes(this.config.NumberOfNextGeodeDropsToShow), this.menuStateInfo, true); Game1.activeClickableMenu = menu; } }
public GeodeMenu(ModEntry mod, ModConfig config, IList <Tuple <int[], bool[]> > items, GeodeMenuStateInfo savedState = null, bool forceReloadState = false) : base(Game1.uiViewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.uiViewport.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, rightNeighborID = 15965, leftNeighborID = 15963, tryDefaultIfNoDownNeighborExists = true, fullyImmutable = true }); this.pages.Add((IClickableMenu) new GeodeTab("omni geode", items[3], this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height)); this.tabs.Add(new ClickableComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 6, this.yPositionOnScreen + IClickableMenu.tabYPositionRelativeToMenuY + Game1.tileSize, Game1.tileSize, Game1.tileSize), "trove", "Artifact Trove") { myID = 15965, downNeighborID = 5, leftNeighborID = 15964, tryDefaultIfNoDownNeighborExists = true, fullyImmutable = true }); this.pages.Add((IClickableMenu) new GeodeTab("artifact trove", items[4], 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); } }