API Progressbar - shmellyorc/Box GitHub Wiki

Progressbar

Namespace: Box.Entities.Graphics

Description

Represents a graphical progress bar control that renders a background and a fill region to indicate a value between configurable minimum and maximum bounds. Supports four fill directions (left-to-right, right-to-left, top-to-bottom, bottom-to-top) and customizable colors.

Constructor

public Progressbar();

Creates a progress bar with default Min = 0f, Max = 1f, Value = 0f, Type = LeftToRight, and white background/blue foreground surfaces configured on first enter.

Properties

Property Description
BoxColor BgColor Background tint color for the empty portion of the bar.
BoxColor FgColor Foreground tint color for the filled portion of the bar.
ProgressBarType Type Direction of fill progression (LeftToRight, RightToLeft, TopToBottom, BottomToTop).
float Min Minimum value of the bar; Value is clamped to >= Min.
float Max Maximum value of the bar; Value is clamped to <= Max.
float Value Current progress value; setting this updates the fill region immediately.

Methods

Method Signature Description Returns
protected override void OnEnter() Called when the entity is first activated; creates one-pixel background and foreground surfaces. void
protected override void Update() Called each frame; clamps Value, computes fill region based on Type, and draws background and fill. void

Examples

// Create a horizontal progress bar at 50%
var bar = new Progressbar
{
    Position = new Vect2(50, 50),
    Size = new Vect2(200, 20),
    Min = 0f,
    Max = 100f,
    Value = 50f,
    Type = ProgressBarType.LeftToRight,
    BgColor = BoxColor.AllShades.Gray,
    FgColor = BoxColor.AllShades.Green
};

mainScreen.AddEntity(bar);