IMenuSession
Interfacepublic interface IMenuSessionOne player's live view of an open menu.
Every piece of state that varies per player lives here rather than on the menu or its components, which is what allows one component instance to be shared across menus and players.
View sourceProperties
The focused component, or null when the menu has nothing focusable.
IMenuComponent? FocusedComponent { get; }The index of the focused component within the visible focusable body components.
int FocusedIndex { get; }Methods
Routes this player's next chat messages to a handler instead of the chat.
IDisposable CaptureChat(Func<string, bool> onMessage)Only one capture is active per session; starting a second one replaces the first. The capture is dropped automatically when the menu closes or the player disconnects, so a component only needs to dispose the handle when it finishes early.
Gets this player's state for a component, creating it on first use.
TState GetState<TState>(IMenuComponent component) where TState : class, new()- componentIMenuComponentThe component the state belongs to.
Marks this session as needing a redraw on the next tick.
void Invalidate()Call this after changing anything that affects what the player sees. Frames are only sent when a session is invalidated, so forgetting this leaves the display stale.
Moves the selection by a number of entries, wrapping at both ends.
bool MoveFocus(int delta)- deltaintHow far to move. Negative moves towards the top.
Moves the selection to a specific entry.
bool SetFocus(int index)- indexintThe index among visible focusable body components.
Replaces this player's state for a component.
void SetState<TState>(IMenuComponent component, TState state) where TState : class- componentIMenuComponentThe component the state belongs to.
- stateTStateThe state to store.