SelectorMenuOption`1
Classpublic sealed class SelectorMenuOption<T> : MenuOptionBase, IMenuOption, IDisposableRepresents a selector menu option that allows cycling through a list of choices using left/right keys. Displays as: Label: PrevChoice [CurrentChoice] NextChoice This option claims the Exit and Use keys for previous and next selection respectively.
View sourceConstructors
Creates an instance of SelectorMenuOption%601.
public SelectorMenuOption(IEnumerable<T> choices, int defaultIndex = 0, Func<T, string>? displayFormatter = null, float itemMaxWidth = 10, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- choicesIEnumerable<T>The list of available choices.
- defaultIndexintoptionalThe default selected index. Defaults to 0.
- displayFormatterFunc<T, string>?optionalA function to format each choice for display. Defaults to ToString().
- itemMaxWidthfloatoptionalThe maximum width for each choice item. Defaults to 10.
- updateIntervalMsintoptionalThe interval in milliseconds between text animation updates. Defaults to 120ms.
- pauseIntervalMsintoptionalThe pause duration in milliseconds before starting the next animation cycle. Defaults to 1000ms.
When using this constructor, the Text property must be manually set to specify the label.
Creates an instance of SelectorMenuOption%601.
public SelectorMenuOption(string text, IEnumerable<T> choices, int defaultIndex = 0, Func<T, string>? displayFormatter = null, float itemMaxWidth = 10, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- textstringThe label text to display.
- choicesIEnumerable<T>The list of available choices.
- defaultIndexintoptionalThe default selected index. Defaults to 0.
- displayFormatterFunc<T, string>?optionalA function to format each choice for display. Defaults to ToString().
- itemMaxWidthfloatoptionalThe maximum width for each choice item. Defaults to 10.
- updateIntervalMsintoptionalThe interval in milliseconds between text animation updates. Defaults to 120ms.
- pauseIntervalMsintoptionalThe pause duration in milliseconds before starting the next animation cycle. Defaults to 1000ms.
Properties
Gets the available choices for this selector.
public IReadOnlyList<T> Choices { get; init; }Gets or sets whether the selector should wrap around when reaching the end.
public bool WrapAround { get; set; }Methods
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public override void Dispose()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 T? GetSelectedChoice(IPlayer player)- playerIPlayerThe player whose selection to retrieve.
Gets the currently selected index for the specified player.
public int GetSelectedIndex(IPlayer player)- playerIPlayerThe player whose selection to retrieve.
Sets the selected index for the specified player.
public void SetSelectedIndex(IPlayer player, int index)Occurs when the selected choice changes for a player.
public event EventHandler<MenuOptionValueChangedEventArgs<T>>? SelectionChanged