Timer Bars Overview - alexguirre/RAGENativeUI GitHub Wiki
Table of Contents
Basics
The TimerBarPool
class handles positioning and drawing the timer bars. So first, create a new TimerBarPool
instance and call TimerBarPool.Draw()
each tick, for example, in a new GameFiber
. Then, any created timer bars, should be added to the pool.
static TimerBarPool myTimerBarPool = new TimerBarPool();
// ...
// add timer bars to the pool
myTimerBarPool.Add(myTimerBar);
// start the fiber which will handle drawing the timer bars
GameFiber.StartNew(ProcessTimerBars);
// ...
private static void ProcessTimerBars()
{
while (true)
{
GameFiber.Yield();
myTimerBarPool.Draw();
}
}
TimerBarBase
Base class for all timer bars. Provides the basic functionality of a timer bar, like drawing the background and the label.
TimerBarBase.Label
gets or sets the string
displayed at the left side of the timer bar.
TimerBarBase.Highlight
gets or sets the highlight color. If not null
, the timer bar background is drawn with an overlay of the specified color.
tb.Highlight = HudColor.Red.GetColor();
/images/timerbars/highlight.png
TimerBarBase.Accent
gets or sets the accent color. If not null
, it is displayed as a thin line in the right edge of the timer bar.
tb.Accent = HudColor.Red.GetColor();
TextTimerBar
Timer bar with text located at the right side.
TextTimerBar.Text
gets or sets the string
displayed at the right side of the timer bar.
var tb = new TextTimerBar("LABEL", "TEXT");
BarTimerBar
Timer bar with a progress bar.
BarTimerBar.Percentage
gets or sets how filled the progress bar is, between 0.0f
(empty) and 1.0f
(full).
BarTimerBar.BackgroundColor/ForegroundColor
define the colors of the progress bar.
BarTimerBar.Markers
defines the markers of the progress bar, thin lines at specific percentages.
var tb = new BarTimerBar("LABEL") { Percentage = 0.75f };
tb.Markers.Add(new TimerBarMarker(0.25f));
tb.Markers.Add(new TimerBarMarker(0.5f, HudColor.Green.GetColor()));
/images/timerbars/bar-markers.png
CheckpointsTimerBar
Timer bar with a set of circles that represent the progress of an objective.
CheckpointsTimerBar.Checkpoints
gets or sets the list of TimerBarCheckpoint
s.
TimerBarCheckpoint.State
gets or sets the state of the checkpoint (TimerBarCheckpointState.InProgress
, TimerBarCheckpointState.Completed
or TimerBarCheckpointState.Failed
).
TimerBarCheckpoint.IsCrossedOut
gets or sets whether to show a cross on top of the checkpoint circle.
TimerBarCheckpoint.Color
gets or sets the color of the checkpoint circle when State
is TimerBarCheckpointState.Completed
.
var tb = new CheckpointsTimerBar("LABEL", 5);
tb.Checkpoints[0].State = TimerBarCheckpointState.Completed;
tb.Checkpoints[1].State = TimerBarCheckpointState.Failed;
tb.Checkpoints[2].State = TimerBarCheckpointState.Completed;
tb.Checkpoints[2].IsCrossedOut = true;
tb.Checkpoints[3].IsCrossedOut = true;
foreach (var cp in tb.Checkpoints) cp.Color = HudColor.Green.GetColor();
/images/timerbars/checkpoints.png
IconsTimerBar
Timer bar that contains a list of icons.
IconsTimerBar.Icons
gets or sets the list of TimerBarIcon
s.
var tb = new IconsTimerBar("LABEL");
tb.Icons.Add(TimerBarIcon.Rocket); // a built-in icon
tb.Icons.Add(new TimerBarIcon("commonmenu", "card_suit_diamonds") { Color = HudColor.Red.GetColor() });
tb.Icons.Add(TimerBarIcon.Spike);