SwiftlyS2

IMenuAPI

Interface IMenuAPI

Namespace: SwiftlyS2.Shared.Menus

Assembly: SwiftlyS2.CS2.dll

Represents an interactive menu that can be displayed to players.

public interface IMenuAPI : IDisposable

Implements

Properties

Builder

The builder used to construct and configure this menu.

IMenuBuilderAPI? Builder { get; }
Property Value

Configuration

Configuration settings for this menu.

MenuConfiguration Configuration { get; }
Property Value

DefaultComment

Gets or sets the default comment text to use when a menu option's SwiftlyS2.Shared.Menus.IMenuOption.Comment is not set.

string DefaultComment { get; set; }
Property Value

KeybindOverrides

Keybind overrides for this menu.

MenuKeybindOverrides KeybindOverrides { get; }
Property Value

The menu manager that this menu belongs to.

IMenuManagerAPI MenuManager { get; }
Property Value

OptionScrollStyle

The scroll style for this menu options.

MenuOptionScrollStyle OptionScrollStyle { get; }
Property Value

Options

Read-only collection of all options in this menu.

IReadOnlyList<IMenuOption> Options { get; }
Property Value

Parent

The parent hierarchy information in a hierarchical menu structure.

(IMenuAPI? ParentMenu, IMenuOption? TriggerOption) Parent { get; }
Property Value
Remarks

ParentMenu is the parent menu instance, null for top-level menus. TriggerOption is the menu option that triggered this submenu, null for top-level or directly created menus.

Tag

Gets or sets an object that contains data about this menu.

object? Tag { get; set; }
Property Value

Methods

AddOption(IMenuOption)

Adds a new option to this menu.

void AddOption(IMenuOption option)
Parameters

GetCurrentOption(IPlayer)

Gets the menu option currently highlighted by the specified player.

IMenuOption? GetCurrentOption(IPlayer player)
Parameters
  • player IPlayer — The player whose current selection to retrieve.
Returns
  • IMenuOption? — The currently selected option, or null if nothing is selected.

GetCurrentOptionIndex(IPlayer)

Gets the index of the currently highlighted option for the specified player.

int GetCurrentOptionIndex(IPlayer player)
Parameters
  • player IPlayer — The player whose current selection index to retrieve.
Returns
  • int — The index of the currently selected option, or -1 if nothing is selected.

HideForPlayer(IPlayer)

Hides this menu for the specified player by removing its visual display.

void HideForPlayer(IPlayer player)
Parameters
  • player IPlayer — The player whose menu will be hidden.
Remarks

This method only hides the menu visually. To properly close a menu (which handles state cleanup, triggering events, and reopening parent menus), use SwiftlyS2.Shared.Menus.IMenuManagerAPI.CloseMenuForPlayer(SwiftlyS2.Shared.Players.IPlayer%2cSwiftlyS2.Shared.Menus.IMenuAPI) instead.

MoveToOption(IPlayer, IMenuOption)

Moves the player's selection to the specified option.

bool MoveToOption(IPlayer player, IMenuOption option)
Parameters
  • player IPlayer — The player whose selection to move.
  • option IMenuOption — The option to move the selection to.
Returns
  • bool — True if the move was successful, false if the option was not found.

MoveToOptionIndex(IPlayer, int)

Moves the player's selection to the specified option index.

bool MoveToOptionIndex(IPlayer player, int index)
Parameters
  • player IPlayer — The player whose selection to move.
  • index int — The index of the option to move the selection to.
Returns
  • bool — True if the move was successful, false if the index was out of bounds.

RemoveOption(IMenuOption)

Removes an option from this menu.

bool RemoveOption(IMenuOption option)
Parameters
Returns
  • bool — True if the option was successfully removed, false if the option was not found.

ShowForPlayer(IPlayer)

Shows this menu to the specified player by displaying its content.

void ShowForPlayer(IPlayer player)
Parameters
  • player IPlayer — The player who will see the menu.
Remarks

This method only displays the menu visually. To properly open a menu (which handles state management, closing other menus, and triggering events), use SwiftlyS2.Shared.Menus.IMenuManagerAPI.OpenMenuForPlayer(SwiftlyS2.Shared.Players.IPlayer%2cSwiftlyS2.Shared.Menus.IMenuAPI) instead.

OptionHovering

Fired when the selection pointer is hovering over an option.

event EventHandler<MenuEventArgs>? OptionHovering
Event Type

On this page