ToggleMenuOption
Class ToggleMenuOption
Namespace: SwiftlyS2.Core.Menus.OptionsBase
Assembly: SwiftlyS2.CS2.dll
Represents a toggleable menu option that displays an on/off state.
public sealed class ToggleMenuOption : MenuOptionBase, IMenuOption, IDisposableInheritance
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
ToggleMenuOption(bool, string?, string?, int, int)
Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.ToggleMenuOption with dynamic text updating capabilities.
public ToggleMenuOption(bool defaultToggleState = true, string? toggleOnSymbol = null, string? toggleOffSymbol = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- defaultToggleState bool — The default toggle state for new players. Defaults to true.
- toggleOnSymbol string? — The HTML symbol to display when toggle is on. Defaults to green checkmark.
- toggleOffSymbol string? — The HTML symbol to display when toggle is off. Defaults to red X mark.
- 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.
When using this constructor, the SwiftlyS2.Core.Menus.OptionsBase.MenuOptionBase.Text property must be manually set to specify the initial text.
ToggleMenuOption(string, bool, string?, string?, int, int)
Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.ToggleMenuOption with dynamic text updating capabilities.
public ToggleMenuOption(string text, bool defaultToggleState = true, string? toggleOnSymbol = null, string? toggleOffSymbol = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- text string — The text content to display.
- defaultToggleState bool — The default toggle state for new players. Defaults to true.
- toggleOnSymbol string? — The HTML symbol to display when toggle is on. Defaults to green checkmark.
- toggleOffSymbol string? — The HTML symbol to display when toggle is off. Defaults to red X mark.
- 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.
Methods
GetDisplayText(IPlayer, int)
Gets the display text for this option, including the toggle state indicator.
public override string GetDisplayText(IPlayer player, int displayLine = 0)- player IPlayer — The player viewing the option.
- displayLine int — The display line number (not used in this implementation).
- string — The formatted display text with toggle state indicator.
GetToggleState(IPlayer)
Gets the toggle state for the specified player.
public bool GetToggleState(IPlayer player)- player IPlayer — The player whose toggle state to retrieve.
- bool — True if toggled on, false if toggled off. Uses the configured default value for new players.
SetToggleState(IPlayer, bool)
Sets the toggle state for the specified player and triggers the value changed event.
public bool SetToggleState(IPlayer player, bool value)- bool — True if the value was changed, false if it was already the same value.
ValueChanged
Event triggered when the toggle value changes for a player.
public event EventHandler<MenuOptionValueChangedEventArgs<bool>>? ValueChanged