SelectorMenuOption
Class SelectorMenuOption
Namespace: SwiftlyS2.Core.Menus.OptionsBase
Assembly: SwiftlyS2.CS2.dll
Represents 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.
public sealed class SelectorMenuOption<T> : MenuOptionBase, IMenuOption, IDisposable- T — The type of the choices.
Inheritance
Implements
Inherited Members
- MenuOptionBase.Dispose()
- MenuOptionBase.PauseTextAnimation()
- MenuOptionBase.ResumeTextAnimation()
- MenuOptionBase.Menu
- MenuOptionBase.LineCount
- MenuOptionBase.BindingText
- MenuOptionBase.Text
- MenuOptionBase.Comment
- MenuOptionBase.MaxWidth
- MenuOptionBase.Visible
- MenuOptionBase.Enabled
- MenuOptionBase.CloseAfterClick
- MenuOptionBase.Tag
- MenuOptionBase.TextSize
- MenuOptionBase.TextStyle
- MenuOptionBase.PlaySound
- MenuOptionBase.VisibilityChanged
- MenuOptionBase.EnabledChanged
- MenuOptionBase.TextChanged
- MenuOptionBase.Validating
- MenuOptionBase.Click
- MenuOptionBase.BeforeFormat
- MenuOptionBase.AfterFormat
- MenuOptionBase.IsClickTaskCompleted(IPlayer)
- MenuOptionBase.GetVisible(IPlayer)
- MenuOptionBase.SetVisible(IPlayer, bool)
- MenuOptionBase.GetEnabled(IPlayer)
- MenuOptionBase.SetEnabled(IPlayer, bool)
- MenuOptionBase.GetDisplayText(IPlayer, int)
- MenuOptionBase.OnValidatingAsync(IPlayer)
- MenuOptionBase.OnClickAsync(IPlayer)
- object.Equals(object?)
- object.Equals(object?, object?)
- object.GetHashCode()
- object.GetType()
- object.ReferenceEquals(object?, object?)
- object.ToString()
Constructors
SelectorMenuOption(IEnumerable<T>, int, Func<T, string>?, float, int, int)
Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.SelectorMenuOption%601.
public SelectorMenuOption(IEnumerable<T> choices, int defaultIndex = 0, Func<T, string>? displayFormatter = null, float itemMaxWidth = 10, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- choices IEnumerable<T> — The list of available choices.
- defaultIndex int — The default selected index. Defaults to 0.
- displayFormatter Func<T, string>? — A function to format each choice for display. Defaults to ToString().
- itemMaxWidth float — The maximum width for each choice item. Defaults to 10.
- updateIntervalMs int — The interval in milliseconds between text animation updates. Defaults to 120ms.
- pauseIntervalMs int — The pause duration in milliseconds before starting the next animation cycle. Defaults to 1000ms.
When using this constructor, the SwiftlyS2.Core.Menus.OptionsBase.MenuOptionBase.Text property must be manually set to specify the label.
SelectorMenuOption(string, IEnumerable<T>, int, Func<T, string>?, float, int, int)
Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.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)- text string — The label text to display.
- choices IEnumerable<T> — The list of available choices.
- defaultIndex int — The default selected index. Defaults to 0.
- displayFormatter Func<T, string>? — A function to format each choice for display. Defaults to ToString().
- itemMaxWidth float — The maximum width for each choice item. Defaults to 10.
- updateIntervalMs int — The interval in milliseconds between text animation updates. Defaults to 120ms.
- pauseIntervalMs int — The pause duration in milliseconds before starting the next animation cycle. Defaults to 1000ms.
Properties
Choices
Gets the available choices for this selector.
public IReadOnlyList<T> Choices { get; init; }WrapAround
Gets or sets whether the selector should wrap around when reaching the end.
public bool WrapAround { get; set; }Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public override void Dispose()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)- player IPlayer — The player requesting the display text.
- displayLine int — The display line index of the option.
- string — The formatted display text for the option.
- When
LineCount=1: ThedisplayLineparameter is not needed; return the HTML-formatted string directly.displayLine=0: Return all contentdisplayLine=1: Return only the first line contentdisplayLine=2: Return only the second line content- And so on...
GetSelectedChoice(IPlayer)
Gets the currently selected choice for the specified player.
public T? GetSelectedChoice(IPlayer player)- player IPlayer — The player whose selection to retrieve.
- T? — The selected choice, or default if no choices available.
GetSelectedIndex(IPlayer)
Gets the currently selected index for the specified player.
public int GetSelectedIndex(IPlayer player)- player IPlayer — The player whose selection to retrieve.
- int — The selected index.
PauseTextAnimation()
Pauses the dynamic text animation.
public override void PauseTextAnimation()ResumeTextAnimation()
Resumes the dynamic text animation.
public override void ResumeTextAnimation()SetSelectedIndex(IPlayer, int)
Sets the selected index for the specified player.
public void SetSelectedIndex(IPlayer player, int index)- player IPlayer — The player whose selection to set.
- index int — The index to select. Will be clamped to valid range.
SelectionChanged
Occurs when the selected choice changes for a player.
public event EventHandler<MenuOptionValueChangedEventArgs<T>>? SelectionChanged