IMenuAPI
Interface IMenuAPI
Namespace: SwiftlyS2.Shared.Menus
Assembly: SwiftlyS2.CS2.dll
Represents an interactive menu that can be displayed to players.
public interface IMenuAPI : IDisposableImplements
Properties
Builder
The builder used to construct and configure this menu.
IMenuBuilderAPI? Builder { get; }Configuration
Configuration settings for this menu.
MenuConfiguration Configuration { get; }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; }KeybindOverrides
Keybind overrides for this menu.
MenuKeybindOverrides KeybindOverrides { get; }MenuManager
The menu manager that this menu belongs to.
IMenuManagerAPI MenuManager { get; }OptionScrollStyle
The scroll style for this menu options.
MenuOptionScrollStyle OptionScrollStyle { get; }Options
Read-only collection of all options in this menu.
IReadOnlyList<IMenuOption> Options { get; }Parent
The parent hierarchy information in a hierarchical menu structure.
(IMenuAPI? ParentMenu, IMenuOption? TriggerOption) Parent { get; }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; }Methods
AddOption(IMenuOption)
Adds a new option to this menu.
void AddOption(IMenuOption option)- option IMenuOption — The menu option to add.
GetCurrentOption(IPlayer)
Gets the menu option currently highlighted by the specified player.
IMenuOption? GetCurrentOption(IPlayer player)- player IPlayer — The player whose current selection to retrieve.
- 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)- player IPlayer — The player whose current selection index to retrieve.
- 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)- player IPlayer — The player whose menu will be hidden.
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)- player IPlayer — The player whose selection to move.
- option IMenuOption — The option to move the selection to.
- 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)- player IPlayer — The player whose selection to move.
- index int — The index of the option to move the selection to.
- 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)- option IMenuOption — The menu option to remove.
- 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)- player IPlayer — The player who will see the menu.
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