InputMenuOption
Class InputMenuOption
Namespace: SwiftlyS2.Core.Menus.OptionsBase
Assembly: SwiftlyS2.CS2.dll
Represents a menu option that allows text input from players.
public sealed class InputMenuOption : 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
InputMenuOption(int, Func<string, bool>?, string, string?, int, int)
Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.InputMenuOption.
public InputMenuOption(int maxLength = 16, Func<string, bool>? validator = null, string defaultValue = "", string? hintMessage = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- maxLength int — Maximum input length. Defaults to 16.
- validator Func<string, bool>? — Optional function to validate input. Returns true if valid.
- defaultValue string — The default input value. Defaults to empty string.
- hintMessage string? — Optional hint message to display when waiting for input. Defaults to English prompt.
- 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.
InputMenuOption(string, int, Func<string, bool>?, string, string?, int, int)
Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.InputMenuOption.
public InputMenuOption(string text, int maxLength = 16, Func<string, bool>? validator = null, string defaultValue = "", string? hintMessage = null, int updateIntervalMs = 120, int pauseIntervalMs = 1000)- text string — The text content to display.
- maxLength int — Maximum input length. Defaults to 16.
- validator Func<string, bool>? — Optional function to validate input. Returns true if valid.
- defaultValue string — The default input value. Defaults to empty string.
- hintMessage string? — Optional hint message to display when waiting for input. Defaults to English prompt.
- 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
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...
GetValue(IPlayer)
Gets the current input value for the specified player.
public string GetValue(IPlayer player)- player IPlayer — The player whose value to retrieve.
- string — The current input value.
SetValue(IPlayer, string)
Sets the input value for the specified player and triggers validation.
public bool SetValue(IPlayer player, string value)- bool — True if the value is valid and was set, false otherwise.
ValueChanged
Occurs when a player submits a valid input value.
public event EventHandler<MenuOptionValueChangedEventArgs<string>>? ValueChanged