Indeterminate progress bar
This commit is contained in:
@@ -18,6 +18,8 @@ namespace OpenRA.Widgets
|
|||||||
public class ProgressBarWidget : Widget
|
public class ProgressBarWidget : Widget
|
||||||
{
|
{
|
||||||
public int Percentage = 0;
|
public int Percentage = 0;
|
||||||
|
public bool Indeterminate = false;
|
||||||
|
int indeterminateTick = 0;
|
||||||
|
|
||||||
public ProgressBarWidget() : base() {}
|
public ProgressBarWidget() : base() {}
|
||||||
protected ProgressBarWidget(ProgressBarWidget widget)
|
protected ProgressBarWidget(ProgressBarWidget widget)
|
||||||
@@ -29,12 +31,20 @@ namespace OpenRA.Widgets
|
|||||||
public override void DrawInner()
|
public override void DrawInner()
|
||||||
{
|
{
|
||||||
WidgetUtils.DrawPanel("dialog3", RenderBounds);
|
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)
|
if (barRect.Width > 0)
|
||||||
WidgetUtils.DrawPanel("dialog2", barRect);
|
WidgetUtils.DrawPanel("dialog2", barRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Tick()
|
||||||
|
{
|
||||||
|
if (Indeterminate && indeterminateTick++ >= 100)
|
||||||
|
indeterminateTick = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public override Widget Clone() { return new ProgressBarWidget(this); }
|
public override Widget Clone() { return new ProgressBarWidget(this); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,12 +90,12 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
window = Widget.OpenWindow("INIT_COPY");
|
window = Widget.OpenWindow("INIT_COPY");
|
||||||
var status = window.GetWidget<LabelWidget>("STATUS");
|
var status = window.GetWidget<LabelWidget>("STATUS");
|
||||||
var progress = window.GetWidget<ProgressBarWidget>("PROGRESS");
|
var progress = window.GetWidget<ProgressBarWidget>("PROGRESS");
|
||||||
|
progress.Indeterminate = true;
|
||||||
|
|
||||||
// TODO: Handle cancelling copy
|
// TODO: Handle cancelling copy
|
||||||
// TODO: Make the progress bar indeterminate
|
window.GetWidget<ButtonWidget>("CANCEL").IsVisible = () => false;
|
||||||
window.GetWidget("CANCEL").OnMouseUp = mi => { ShowInstallMethodDialog(); return true; };
|
window.GetWidget("CANCEL").OnMouseUp = mi => { ShowInstallMethodDialog(); return true; };
|
||||||
window.GetWidget("RETRY").OnMouseUp = mi => PromptForCD();
|
window.GetWidget("RETRY").OnMouseUp = mi => PromptForCD();
|
||||||
window.GetWidget<ButtonWidget>("CANCEL").IsVisible = () => false;
|
|
||||||
|
|
||||||
status.GetText = () => "Copying...";
|
status.GetText = () => "Copying...";
|
||||||
var error = false;
|
var error = false;
|
||||||
@@ -144,6 +144,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
else if (!cancelled)
|
else if (!cancelled)
|
||||||
{
|
{
|
||||||
// Automatically extract
|
// Automatically extract
|
||||||
|
status.GetText = () => "Extracting...";
|
||||||
progress.Indeterminate = true;
|
progress.Indeterminate = true;
|
||||||
var error = false;
|
var error = false;
|
||||||
Action<string> parseOutput = s =>
|
Action<string> parseOutput = s =>
|
||||||
|
|||||||
Reference in New Issue
Block a user