swiftlys2/docs/api/ai/
API Reference Menus

IMenuBuilderAPI

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

Provides a fluent builder interface for creating and configuring menus. All methods support chaining for convenient menu construction.

View source

Properties

Design

Gets the design interface for this menu.

IMenuDesignAPI Design { get; }
Property Value

Methods

AddExtraButton(KeyBind, string, Action<IPlayer, IMenuAPI>)

Adds an extra button to the menu that executes a custom action when pressed.

IMenuBuilderAPI AddExtraButton(KeyBind keyBind, string label, Action<IPlayer, IMenuAPI> action)
Parameters
  • keyBindKeyBindThe key binding for this button.
  • labelstringThe label to display for this button in the menu footer.
  • actionAction<IPlayer, IMenuAPI>The action to execute when the button is pressed.
Returns
This builder for method chaining.

Extra buttons are displayed in the menu footer and allow custom actions beyond standard menu navigation. The keybind should not conflict with existing menu navigation keys.

AddOption(IMenuOption)

Adds a menu option to the menu.

IMenuBuilderAPI AddOption(IMenuOption option)
Parameters
Returns
This builder for method chaining.

BindToParent(IMenuAPI)

Binds this menu to a parent menu, creating a hierarchical navigation structure.

IMenuBuilderAPI BindToParent(IMenuAPI parent)
Parameters
Returns
This builder for method chaining.

Build()

Builds the menu and returns the final menu instance.

IMenuAPI Build()
Returns
The built menu instance.

DisableExit()

Disables the exit button for this menu.

IMenuBuilderAPI DisableExit()
Returns
This builder for method chaining.

DisableSound()

Disables sound effects for menu interactions.

IMenuBuilderAPI DisableSound()
Returns
This builder for method chaining.

EnableExit()

Enables the exit button for this menu.

IMenuBuilderAPI EnableExit()
Returns
This builder for method chaining.

EnableSound()

Enables sound effects for menu interactions.

IMenuBuilderAPI EnableSound()
Returns
This builder for method chaining.

SetAutoCloseDelay(float)

Sets the automatic close delay for the menu.

IMenuBuilderAPI SetAutoCloseDelay(float seconds = 0)
Parameters
  • secondsfloatoptionalTime in seconds before the menu automatically closes. Set to 0 to disable auto-close. Default is 0.
Returns
This builder for method chaining.

SetExitButton(KeyBind)

Overrides the default key binding for closing the menu.

IMenuBuilderAPI SetExitButton(KeyBind keyBind)
Parameters
  • keyBindKeyBindThe key binding to use.
Returns
This builder for method chaining.

This overrides the default exit button behavior. Supports multiple key bindings using the bitwise OR operator. Example: KeyBind.Esc | KeyBind.A allows either Esc or A to close the menu.

SetMoveBackwardButton(KeyBind)

Overrides the default key binding for moving backward through menu options.

IMenuBuilderAPI SetMoveBackwardButton(KeyBind keyBind)
Parameters
  • keyBindKeyBindThe key binding to use.
Returns
This builder for method chaining.

This overrides the default move backward button behavior. Supports multiple key bindings using the bitwise OR operator. Example: KeyBind.S | KeyBind.Mouse2 allows either S or Mouse2 to move backward.

SetMoveForwardButton(KeyBind)

Overrides the default key binding for moving forward through menu options.

IMenuBuilderAPI SetMoveForwardButton(KeyBind keyBind)
Parameters
  • keyBindKeyBindThe key binding to use.
Returns
This builder for method chaining.

This overrides the default move forward button behavior. Supports multiple key bindings using the bitwise OR operator. Example: KeyBind.W | KeyBind.Mouse1 allows either W or Mouse1 to move forward.

SetPlayerFrozen(bool)

Controls whether player movement is frozen while the menu is open.

IMenuBuilderAPI SetPlayerFrozen(bool frozen = false)
Parameters
  • frozenbooloptionalTrue to freeze player movement, false to allow movement. Default is false.
Returns
This builder for method chaining.

SetSelectButton(KeyBind)

Overrides the default key binding for selecting menu options.

IMenuBuilderAPI SetSelectButton(KeyBind keyBind)
Parameters
  • keyBindKeyBindThe key binding to use.
Returns
This builder for method chaining.

This overrides the default select button behavior. Supports multiple key bindings using the bitwise OR operator. Example: KeyBind.Mouse1 | KeyBind.E allows either Mouse1 or E to select options.