private void OnMenuChanged(object sender, MenuChangedEventArgs e) { // menu closed if (e.NewMenu == null) { ignoreMenuChanged = false; if (e.OldMenu is LetterViewerMenu && switchBackToCollectionsMenu) { ignoreMenuChanged = true; Game1.activeClickableMenu = savedGameMenu; } switchBackToCollectionsMenu = false; return; } // menu changed or opened if (e.NewMenu is GameMenu gameMenu && !ignoreMenuChanged) { List <IClickableMenu> pages = ModEntry.CommonServices.ReflectionHelper.GetField <List <IClickableMenu> >(gameMenu, "pages").GetValue(); if (collectionsPageTabIndex == -1) { collectionsPageTabIndex = pages.Replace(tab => tab is CollectionsPage, new CollectionsPageEx(gameMenu.xPositionOnScreen, gameMenu.yPositionOnScreen, gameMenu.width - 64 - 16, gameMenu.height)); } else { pages[collectionsPageTabIndex] = new CollectionsPageEx(gameMenu.xPositionOnScreen, gameMenu.yPositionOnScreen, gameMenu.width - 64 - 16, gameMenu.height); } }
private void MenuEvents_MenuChanged(object sender, EventArgsClickableMenuChanged e) { if (e.NewMenu is GameMenu gameMenu && !ignoreMenuChanged) { List <IClickableMenu> pages = ModEntry.CommonServices.ReflectionHelper.GetField <List <IClickableMenu> >(gameMenu, "pages").GetValue(); if (collectionsPageTabIndex == -1) { collectionsPageTabIndex = pages.Replace(tab => tab is CollectionsPage, new CollectionsPageEx(gameMenu.xPositionOnScreen, gameMenu.yPositionOnScreen, gameMenu.width - 64 - 16, gameMenu.height)); } else { pages[collectionsPageTabIndex] = new CollectionsPageEx(gameMenu.xPositionOnScreen, gameMenu.yPositionOnScreen, gameMenu.width - 64 - 16, gameMenu.height); } }