SwiftlyS2

ChoiceMenuOption

Class ChoiceMenuOption

Namespace: SwiftlyS2.Core.Menus.OptionsBase

Assembly: SwiftlyS2.CS2.dll

Represents a menu option that cycles through a list of choices.

public sealed class ChoiceMenuOption : MenuOptionBase, IMenuOption, IDisposable

Inheritance

Implements

Inherited Members

Constructors

ChoiceMenuOption(IEnumerable<string>, string?, int, int)

Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.ChoiceMenuOption with a list of choices.

public ChoiceMenuOption(IEnumerable<string> choices, string? defaultChoice = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)
Parameters
  • choices IEnumerable<string> — The list of available choices.
  • defaultChoice string? — The default choice to select. If null or not found, defaults to first choice.
  • updateIntervalMs int — The interval in milliseconds between text updates. Defaults to 120ms.
  • pauseIntervalMs int — The pause duration in milliseconds before starting the next text update cycle. Defaults to 1000ms.
Remarks

When using this constructor, the SwiftlyS2.Core.Menus.OptionsBase.MenuOptionBase.Text property must be manually set to specify the initial text.

ChoiceMenuOption(string, IEnumerable<string>, string?, int, int)

Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.ChoiceMenuOption with a list of choices.

public ChoiceMenuOption(string text, IEnumerable<string> choices, string? defaultChoice = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)
Parameters
  • text string — The text content to display.
  • choices IEnumerable<string> — The list of available choices.
  • defaultChoice string? — The default choice to select. If null or not found, defaults to first choice.
  • updateIntervalMs int — The interval in milliseconds between text updates. Defaults to 120ms.
  • pauseIntervalMs int — The pause duration in milliseconds before starting the next text update cycle. Defaults to 1000ms.

Properties

Choices

Gets the read-only list of available choices.

public IReadOnlyList<string> Choices { get; }
Property Value

Methods

GetDisplayText(IPlayer, int)

Gets the display text for this option as it should appear to the specified player.

public override string GetDisplayText(IPlayer player, int displayLine = 0)
Parameters
  • player IPlayer — The player requesting the display text.
  • displayLine int — The display line index of the option.
Returns
  • string — The formatted display text for the option.
Remarks
  • When LineCount=1: The displayLine parameter is not needed; return the HTML-formatted string directly.
    • displayLine=0: Return all content
    • displayLine=1: Return only the first line content
    • displayLine=2: Return only the second line content
    • And so on...

GetSelectedChoice(IPlayer)

Gets the currently selected choice for the specified player.

public string GetSelectedChoice(IPlayer player)
Parameters
  • player IPlayer — The player whose selected choice to retrieve.
Returns
  • string — The currently selected choice string.

SetSelectedChoice(IPlayer, string)

Sets the selected choice for the specified player.

public void SetSelectedChoice(IPlayer player, string choice)
Parameters
  • player IPlayer — The player whose choice to set.
  • choice string — The choice to select. Must exist in the SwiftlyS2.Core.Menus.OptionsBase.ChoiceMenuOption.Choices list.

ValueChanged

Occurs when the selected choice changes for a player.

public event EventHandler<MenuOptionValueChangedEventArgs<string>>? ValueChanged
Event Type

On this page