Indeterminate progress bar

This commit is contained in:
Paul Chote
2011-01-22 09:40:50 +13:00
parent 3609de8ca5
commit d39adf67b2
2 changed files with 15 additions and 4 deletions

View File

@@ -18,6 +18,8 @@ namespace OpenRA.Widgets
public class ProgressBarWidget : Widget
{
public int Percentage = 0;
public bool Indeterminate = false;
int indeterminateTick = 0;
public ProgressBarWidget() : base() {}
protected ProgressBarWidget(ProgressBarWidget widget)
@@ -29,12 +31,20 @@ namespace OpenRA.Widgets
public override void DrawInner()
{
WidgetUtils.DrawPanel("dialog3", RenderBounds);
Rectangle barRect = Indeterminate ?
new Rectangle(RenderBounds.X + 2 + (int)((RenderBounds.Width - 4)*(-Math.Cos(Math.PI*2*indeterminateTick/100) + 1)*3/8), RenderBounds.Y + 2, (RenderBounds.Width - 4) / 4, RenderBounds.Height - 4) :
new Rectangle(RenderBounds.X + 2, RenderBounds.Y + 2, Percentage * (RenderBounds.Width - 4) / 100, RenderBounds.Height - 4);
var barRect = new Rectangle(RenderBounds.X + 2, RenderBounds.Y + 2, Percentage * (RenderBounds.Width - 4) / 100, RenderBounds.Height - 4);
if (barRect.Width > 0)
WidgetUtils.DrawPanel("dialog2", barRect);
}
public override void Tick()
{
if (Indeterminate && indeterminateTick++ >= 100)
indeterminateTick = 0;
}
public override Widget Clone() { return new ProgressBarWidget(this); }
}
}