Changes

94 bytes removed ,  04:47, 24 May 2018
no edit summary
Line 203: Line 203:  
You can use ''Reflection'' to get the current active ''GameMenu''. The ''GameMenu'' contains the Inventory, Skills, Social, Map, Crafting, Collections, and Options pages in this respective order, accessed by the tab index with ''inventoryTab'' at 0.
 
You can use ''Reflection'' to get the current active ''GameMenu''. The ''GameMenu'' contains the Inventory, Skills, Social, Map, Crafting, Collections, and Options pages in this respective order, accessed by the tab index with ''inventoryTab'' at 0.
   −
Here is an example for getting the MapPage:
   
<source lang="c#">
 
<source lang="c#">
GameMenu menu = (GameMenu)Game1.activeClickableMenu;
+
if (Game1.activeClickableMenu is GameMenu menu) {
List<IClickableMenu> menuPages = (List<IClickableMenu>)typeof(GameMenu).GetField("pages", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(menu);
+
  IList<IClickableMenu> pages = this.Helper.Reflection.GetField<List<IClickableMenu>>(menu, "pages").GetValue();
MapPage mapPage = (MapPage)menuPages[menu.currentTab];
+
  IClickableMenu page = pages[menu.currentTab];
 
</source>
 
</source>
 +
 
===Set the Active Menu===
 
===Set the Active Menu===
 
Game1.activeClickableMenu = <Menu>
 
Game1.activeClickableMenu = <Menu>
17

edits