IMenuBuilderAPI
Interface IMenuBuilderAPI
Namespace: SwiftlyS2.Shared.Menus
Assembly: SwiftlyS2.CS2.dll
Provides a fluent builder interface for creating and configuring menus. All methods support chaining for convenient menu construction.
public interface IMenuBuilderAPIProperties
Design
Gets the design interface for this menu.
IMenuDesignAPI Design { get; }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)- keyBind KeyBind — The key binding for this button.
- label string — The label to display for this button in the menu footer.
- action Action<IPlayer, IMenuAPI> — The action to execute when the button is pressed.
- IMenuBuilderAPI — 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)- option IMenuOption — The menu option to add.
- IMenuBuilderAPI — This builder for method chaining.
BindToParent(IMenuAPI)
Binds this menu to a parent menu, creating a hierarchical navigation structure.
IMenuBuilderAPI BindToParent(IMenuAPI parent)- parent IMenuAPI — The parent menu.
- IMenuBuilderAPI — This builder for method chaining.
Build()
Builds the menu and returns the final menu instance.
IMenuAPI Build()- IMenuAPI — The built menu instance.
DisableExit()
Disables the exit button for this menu.
IMenuBuilderAPI DisableExit()- IMenuBuilderAPI — This builder for method chaining.
DisableSound()
Disables sound effects for menu interactions.
IMenuBuilderAPI DisableSound()- IMenuBuilderAPI — This builder for method chaining.
EnableExit()
Enables the exit button for this menu.
IMenuBuilderAPI EnableExit()- IMenuBuilderAPI — This builder for method chaining.
EnableSound()
Enables sound effects for menu interactions.
IMenuBuilderAPI EnableSound()- IMenuBuilderAPI — This builder for method chaining.
SetAutoCloseDelay(float)
Sets the automatic close delay for the menu.
IMenuBuilderAPI SetAutoCloseDelay(float seconds = 0)- seconds float — Time in seconds before the menu automatically closes. Set to 0 to disable auto-close. Default is 0.
- IMenuBuilderAPI — This builder for method chaining.
SetExitButton(KeyBind)
Overrides the default key binding for closing the menu.
IMenuBuilderAPI SetExitButton(KeyBind keyBind)- keyBind KeyBind — The key binding to use.
- IMenuBuilderAPI — 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)- keyBind KeyBind — The key binding to use.
- IMenuBuilderAPI — 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)- keyBind KeyBind — The key binding to use.
- IMenuBuilderAPI — 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)- frozen bool — True to freeze player movement, false to allow movement. Default is false.
- IMenuBuilderAPI — This builder for method chaining.
SetSelectButton(KeyBind)
Overrides the default key binding for selecting menu options.
IMenuBuilderAPI SetSelectButton(KeyBind keyBind)- keyBind KeyBind — The key binding to use.
- IMenuBuilderAPI — 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.