ProgressBarMenuOption
Classpublic sealed class ProgressBarMenuOption : MenuOptionBase, IMenuOption, IDisposableRepresents a progress bar menu option that displays progress visually.
View sourceConstructors
Creates an instance of ProgressBarMenuOption.
public ProgressBarMenuOption(Func<float> progressProvider, bool multiLine = false, bool showPercentage = true, string filledChar = "█", string emptyChar = "░", int updateIntervalMs = 120, int pauseIntervalMs = 1000)- progressProviderFunc<float>Function that returns progress value (0.0 to 1.0).
- multiLinebooloptionalIf true, uses 2 lines; if false, uses 1 line. Defaults to false.
- showPercentagebooloptionalWhether to show percentage text. Defaults to true.
- filledCharstringoptionalCharacter for filled portion. Defaults to "█".
- emptyCharstringoptionalCharacter for empty portion. Defaults to "░".
- updateIntervalMsintoptionalThe interval in milliseconds between text updates. Defaults to 120ms.
- pauseIntervalMsintoptionalThe pause duration in milliseconds before starting the next text update cycle. Defaults to 1000ms.
When using this constructor, the Text property must be manually set to specify the initial text.
Creates an instance of ProgressBarMenuOption.
public ProgressBarMenuOption(string text, Func<float> progressProvider, bool multiLine = false, bool showPercentage = true, string filledChar = "█", string emptyChar = "░", int updateIntervalMs = 120, int pauseIntervalMs = 1000)- textstringThe text content to display.
- progressProviderFunc<float>Function that returns progress value (0.0 to 1.0).
- multiLinebooloptionalIf true, uses 2 lines; if false, uses 1 line. Defaults to false.
- showPercentagebooloptionalWhether to show percentage text. Defaults to true.
- filledCharstringoptionalCharacter for filled portion. Defaults to "█".
- emptyCharstringoptionalCharacter for empty portion. Defaults to "░".
- updateIntervalMsintoptionalThe interval in milliseconds between text updates. Defaults to 120ms.
- pauseIntervalMsintoptionalThe pause duration in milliseconds before starting the next text update cycle. Defaults to 1000ms.
Properties
Gets the width of the progress bar in characters.
public int BarWidth { get; }Gets the number of lines this option requests to occupy in the menu.
public override int LineCount { get; }Gets whether to display the percentage value.
public bool ShowPercentage { get; }Methods
Gets the display text for this option as it should appear to the specified player.
public override string GetDisplayText(IPlayer player, int displayLine = 0)When a menu option occupies multiple lines, MenuAPI may only need to display a specific line of that option. When LineCount=1 : The displayLine parameter is not needed; return the HTML-formatted string directly. When LineCount>=2 : Check the displayLine parameter: displayLine=0 : Return all content displayLine=1 : Return only the first line content displayLine=2 : Return only the second line content And so on... Note: MenuAPI ensures that the displayLine parameter will not exceed the option's LineCount .
Gets the current progress value for the specified player.
public float GetProgress(IPlayer player)- playerIPlayerThe player whose progress to retrieve.
Sets or updates the progress provider function for a specific player.
public void SetProgressProvider(IPlayer player, Func<float> progressProvider)