ChoiceMenuOption
Classpublic sealed class ChoiceMenuOption : MenuOptionBase, IMenuOption, IDisposableRepresents a menu option that cycles through a list of choices.
View sourceConstructors
Creates an instance of ChoiceMenuOption with a list of choices.
public ChoiceMenuOption(IEnumerable<string> choices, string? defaultChoice = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- choicesIEnumerable<string>The list of available choices.
- defaultChoicestring?optionalThe default choice to select. If null or not found, defaults to first choice.
- updateIntervalMsintoptionalThe interval in milliseconds between text updates. Defaults to 120ms.
- pauseIntervalMsintoptionalThe pause duration in milliseconds before starting the next text update cycle. Defaults to 1000ms.
When using this constructor, the Text property must be manually set to specify the initial text.
Creates an instance of ChoiceMenuOption with a list of choices.
public ChoiceMenuOption(string text, IEnumerable<string> choices, string? defaultChoice = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- textstringThe text content to display.
- choicesIEnumerable<string>The list of available choices.
- defaultChoicestring?optionalThe default choice to select. If null or not found, defaults to first choice.
- updateIntervalMsintoptionalThe interval in milliseconds between text updates. Defaults to 120ms.
- pauseIntervalMsintoptionalThe pause duration in milliseconds before starting the next text update cycle. Defaults to 1000ms.
Properties
Gets the read-only list of available choices.
public IReadOnlyList<string> Choices { get; }Methods
Gets the display text for this option as it should appear to the specified player.
public override string GetDisplayText(IPlayer player, int displayLine = 0)When a menu option occupies multiple lines, MenuAPI may only need to display a specific line of that option. When LineCount=1 : The displayLine parameter is not needed; return the HTML-formatted string directly. When LineCount>=2 : Check the displayLine parameter: displayLine=0 : Return all content displayLine=1 : Return only the first line content displayLine=2 : Return only the second line content And so on... Note: MenuAPI ensures that the displayLine parameter will not exceed the option's LineCount .
Gets the currently selected choice for the specified player.
public string GetSelectedChoice(IPlayer player)- playerIPlayerThe player whose selected choice to retrieve.
Sets the selected choice for the specified player.
public void SetSelectedChoice(IPlayer player, string choice)Occurs when the selected choice changes for a player.
public event EventHandler<MenuOptionValueChangedEventArgs<string>>? ValueChanged