swiftlys2/docs/api/ai/
API Reference › Menu

IMenu

Interface
Namespace: SwiftlyS2.Shared.Menu · Assembly: SwiftlyS2.CS2.dll
public interface IMenu : IDisposable
Implements IDisposable

An arrangement of components, a renderer and a keymap.

A menu arranges and manages components. It implements no interaction behaviour of its own beyond traversal, and no drawing behaviour at all.

View source

Properties

AutoCloseDelay

How long a session may sit idle before it closes itself, or null to never auto-close.

TimeSpan? AutoCloseDelay { get; }
Property Value

Counted from when the session opens, not from the last input. Closing acts exactly like the player pressing the Close key: it returns to Parent when there is one.

Id

The menu id. Doubles as its configuration scope for keybinds.

string Id { get; }
Property Value

InputMethod

How players interact with this menu.

MenuInputMethod InputMethod { get; }
Property Value

ItemsPerPage

How many body entries are visible at once.

int ItemsPerPage { get; }
Property Value

Keymap

The resolved actions and keys for this menu.

IMenuKeymap Keymap { get; }
Property Value

Parent

The menu to return to when this one closes, if any.

IMenu? Parent { get; set; }
Property Value

Normally set once through IMenu). It stays writable so a menu built lazily by a SubmenuComponent can be told where it was opened from.

Renderer

The renderer this menu draws through.

IMenuRenderer Renderer { get; }
Property Value

Sessions

The sessions currently viewing this menu.

IReadOnlyList<IMenuSession> Sessions { get; }

Tag

An arbitrary value carried alongside this menu.

object? Tag { get; set; }
Property Value

Methods

Add(MenuRegion, IMenuComponent)

Appends a component to a region.

void Add(MenuRegion region, IMenuComponent component)
Parameters

Close(IPlayer)

Closes this menu for a player.

void Close(IPlayer player)
Parameters
  • playerIPlayerThe player to close for.

CloseAll()

Closes this menu for everyone viewing it.

void CloseAll()

GetComponents(MenuRegion)

Lists the components in a region, in layout order.

IReadOnlyList<IMenuComponent> GetComponents(MenuRegion region)
Parameters
Returns
The components in that region.

GetSession(IPlayer)

Gets a player's session for this menu.

IMenuSession? GetSession(IPlayer player)
Parameters
  • playerIPlayerThe player to look up.
Returns
The session, or null when this menu is not open for them.

Insert(MenuRegion, int, IMenuComponent)

Inserts a component into a region at a position.

void Insert(MenuRegion region, int index, IMenuComponent component)
Parameters

Open(IPlayer)

Opens this menu for a player, replacing whatever menu they had open.

IMenuSession Open(IPlayer player)
Parameters
  • playerIPlayerThe player to show the menu to.
Returns
The new session.

OpenForAll()

Opens this menu for every connected, non-bot player, replacing whatever each had open.

IReadOnlyList<IMenuSession> OpenForAll()
Returns
The new sessions, one per player it was opened for.

Remove(IMenuComponent)

Removes a component from wherever it sits.

bool Remove(IMenuComponent component)
Parameters
Returns
true when the component was present.

Closed

Raised after a session is closed.

event Action<IMenuSession>? Closed

FocusChanged

Raised after the selection moves within a session.

event Action<IMenuSession>? FocusChanged

Opened

Raised after a session is opened.

event Action<IMenuSession>? Opened