ProgressBarComponent
Classpublic class ProgressBarComponent : TextComponent, IMenuComponentA non-interactive bar showing a value that something else owns.
The value is pulled from ProgressProvider rather than stored, and the component asks for a redraw on its own whenever the value has moved, so a bar tracking live state stays current without the plugin invalidating anything.
View sourceConstructors
Creates a progress bar.
public ProgressBarComponent(string text = "", Func<IMenuSession, float>? progressProvider = null, bool multiLine = false, string? id = null)Properties
How many segments the bar is drawn with. Never below one.
public int BarWidth { get; set; }The bracket drawn after the bar.
public string ClosingBracket { get; set; }The colour of the closing bracket, or null to keep Style.
public string? ClosingBracketColor { get; set; }The character drawn for an empty segment.
public string EmptyChar { get; set; }The colour of the empty segments.
public string? EmptyColor { get; set; }The character drawn for a filled segment.
public string FilledChar { get; set; }The colour of the filled segments, or null to keep Style.
public string? FilledColor { get; set; }Whether the selection can land on this component.
public override bool IsFocusable { get; }A label can hold the selection like any other body entry, so a menu scrolls past it rather than skipping over it, but it never overrides MenuActionContext) so activating it is always a no-op.
How many lines this component draws.
public override int LineCount { get; }Used to decide how much of the body fits on one page, without rendering components that will not be shown. It must match what IMenuComponentRenderContext) produces: a MenuBlankNode costs its Lines, a MenuStackNode costs the sum of its children, and everything else costs one. A component that returns a stack has to override this, otherwise it is budgeted as a single line and the page overflows.
Whether the bar is drawn on its own line below the label.
public bool MultiLine { get; set; }The bracket drawn before the bar.
public string OpeningBracket { get; set; }The colour of the opening bracket, or null to keep Style.
public string? OpeningBracketColor { get; set; }Produces the progress for a player, from zero to one. Null reads as zero.
public Func<IMenuSession, float>? ProgressProvider { get; set; }Whether a percentage is shown next to the bar.
public bool ShowPercentage { get; set; }Methods
Reads the progress for a player, clamped between zero and one.
public float GetProgress(IMenuSession session)- sessionIMenuSessionThe session to read for.
Whether this component needs a new frame even though nothing invalidated the session.
public override bool NeedsRedraw(IMenuSession session, DateTime now)- sessionIMenuSessionThe session asking.
- nowDateTimeThe current time.
Asked once per tick for every visible component of an otherwise clean session, so keep the check cheap. Animated text and live values are what this exists for.
Produces this component's renderer-agnostic output.
public override MenuNode Render(IMenuComponentRenderContext context)- contextIMenuComponentRenderContextThe player and focus state to draw for.