/// <summary>Switches the current page handler to the one for the new tab.</summary> /// <param name="newTab">The index of the new tab.</param> /// <returns>True if it successfully changed tabs or is already on that tab.</returns> private bool ChangeTabs(int newTab) { if (this.PreviousTab == newTab) { return(true); } CloseCurrentHandler(); if (this.PageHandlers.ContainsKey(newTab)) { this.PreviousTab = newTab; this.CurrentPageHandler = this.PageHandlers[newTab]; var pages = Helper.Reflection.GetField <List <IClickableMenu> >(this.NativeMenu, "pages").GetValue(); this.CurrentPageHandler.Open(this.NativeMenu, pages[newTab], this.Inventory); return(true); } return(false); }
/// <summary>Closes the current handler and sets the previous tab to invalid.</summary> private void CloseCurrentHandler() { this.CurrentPageHandler?.Close(); this.CurrentPageHandler = null; this.PreviousTab = InvalidTab; }