SwiftlyS2

SliderMenuOption

Class SliderMenuOption

Namespace: SwiftlyS2.Core.Menus.OptionsBase

Assembly: SwiftlyS2.CS2.dll

Represents a slider menu option that allows selecting a numeric value within a range.

public sealed class SliderMenuOption : MenuOptionBase, IMenuOption, IDisposable

Inheritance

Implements

Inherited Members

Constructors

SliderMenuOption(float, float, float?, float, int, int, int)

Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.SliderMenuOption.

public SliderMenuOption(float min = 0, float max = 100, float? defaultValue = null, float step = 5, int totalBars = 10, int updateIntervalMs = 120, int pauseIntervalMs = 1000)
Parameters
  • min float — The minimum value. Defaults to 0.
  • max float — The maximum value. Defaults to 100.
  • defaultValue float? — The default starting value. Defaults to the minimum value.
  • step float — The increment/decrement step. Defaults to 5.
  • totalBars int — The number of visual bars to display. Defaults to 10.
  • 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.

SliderMenuOption(string, float, float, float?, float, int, int, int)

Creates an instance of SwiftlyS2.Core.Menus.OptionsBase.SliderMenuOption.

public SliderMenuOption(string text, float min = 0, float max = 100, float? defaultValue = null, float step = 5, int totalBars = 10, int updateIntervalMs = 120, int pauseIntervalMs = 1000)
Parameters
  • text string — The text content to display.
  • min float — The minimum value. Defaults to 0.
  • max float — The maximum value. Defaults to 100.
  • defaultValue float? — The default starting value. Defaults to the minimum value.
  • step float — The increment/decrement step. Defaults to 5.
  • totalBars int — The number of visual bars to display. Defaults to 10.
  • 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

Max

Gets the maximum value of the slider.

public float Max { get; }
Property Value

Min

Gets the minimum value of the slider.

public float Min { get; }
Property Value

Step

Gets the step increment/decrement value.

public float Step { get; }
Property Value

Methods

DecrementValue(IPlayer)

Decrements the slider value by the step amount for the specified player. Wraps to Max if the value goes below Min.

public ValueTask DecrementValue(IPlayer player)
Parameters
  • player IPlayer — The player whose value to decrement.
Returns

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...

GetValue(IPlayer)

Gets the current slider value for the specified player.

public float GetValue(IPlayer player)
Parameters
  • player IPlayer — The player whose value to retrieve.
Returns
  • float — The current slider value.

IncrementValue(IPlayer)

Increments the slider value by the step amount for the specified player. Wraps to Min if the value goes above Max.

public ValueTask IncrementValue(IPlayer player)
Parameters
  • player IPlayer — The player whose value to increment.
Returns

SetValue(IPlayer, float)

Sets the slider value for the specified player.

public void SetValue(IPlayer player, float value)
Parameters
  • player IPlayer — The player whose value to set.
  • value float — The value to set. Will be clamped between Min and Max.

ValueChanged

Occurs when the slider value changes for a player.

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

On this page