swiftlys2/docs/api/ai/
API Reference Menus

IMenuManagerAPI

Interface
Namespace: SwiftlyS2.Shared.Menus · Assembly: SwiftlyS2.CS2.dll
public interface IMenuManagerAPI

Central manager for creating and controlling all player menus.

View source

Properties

Configuration

Global configuration settings for all menus.

MenuManagerConfiguration Configuration { get; }

Core

The SwiftlyS2 core instance.

ISwiftlyCore Core { get; }
Property Value

Methods

CloseActiveMenu(IPlayer)

Closes the active menu for a player. If the player has no menu open, this has no effect.

void CloseActiveMenu(IPlayer player)
Parameters
  • playerIPlayerThe player whose active menu will be closed.

CloseAllMenus()

Closes every open menu for every player.

void CloseAllMenus()

CloseMenu(IMenuAPI)

Closes the specified menu for all players who have it open.

void CloseMenu(IMenuAPI menu)
Parameters

CloseMenuForPlayer(IPlayer, IMenuAPI)

Closes the specified menu for a player. If the menu is not open for that player, this has no effect.

void CloseMenuForPlayer(IPlayer player, IMenuAPI menu)
Parameters
  • playerIPlayerThe player whose menu will be closed.
  • menuIMenuAPIThe menu to close.

CreateBuilder()

Creates a new menu builder.

IMenuBuilderAPI CreateBuilder()
Returns
A new menu builder instance.

CreateMenu(MenuConfiguration, MenuKeybindOverrides, IMenuAPI?, MenuOptionScrollStyle, MenuOptionTextStyle)

Creates a new menu with an optional title.

IMenuAPI CreateMenu(MenuConfiguration configuration, MenuKeybindOverrides keybindOverrides, IMenuAPI? parent = null, MenuOptionScrollStyle optionScrollStyle = MenuOptionScrollStyle.CenterFixed, MenuOptionTextStyle optionTextStyle = MenuOptionTextStyle.TruncateEnd)
Parameters
Returns
A new menu instance ready to be configured.

GetCurrentMenu(IPlayer)

Gets the menu currently open for the specified player.

IMenuAPI? GetCurrentMenu(IPlayer player)
Parameters
Returns
The player's active menu, or null if they have no menu open.

OpenMenu(IMenuAPI)

Opens the specified menu for all players.

void OpenMenu(IMenuAPI menu)
Parameters

OpenMenu(IMenuAPI, Action<IPlayer, IMenuAPI>)

Opens the specified menu for all players.

void OpenMenu(IMenuAPI menu, Action<IPlayer, IMenuAPI> onClosed)
Parameters

OpenMenuForPlayer(IPlayer, IMenuAPI)

Opens the specified menu for a player. Any currently open menu will be closed first.

void OpenMenuForPlayer(IPlayer player, IMenuAPI menu)
Parameters
  • playerIPlayerThe player who will see the menu.
  • menuIMenuAPIThe menu to display.

OpenMenuForPlayer(IPlayer, IMenuAPI, Action<IPlayer, IMenuAPI>)

Opens the specified menu for a player. Any currently open menu will be closed first.

void OpenMenuForPlayer(IPlayer player, IMenuAPI menu, Action<IPlayer, IMenuAPI> onClosed)
Parameters

MenuClosed

Fired when a menu is closed for a player.

event EventHandler<MenuManagerEventArgs>? MenuClosed

MenuOpened

Fired when a menu is opened for a player.

event EventHandler<MenuManagerEventArgs>? MenuOpened