Progress bars.
This commit is contained in:
@@ -181,6 +181,7 @@
|
|||||||
<Compile Include="Widgets\ScrollPanelWidget.cs" />
|
<Compile Include="Widgets\ScrollPanelWidget.cs" />
|
||||||
<Compile Include="Graphics\ShroudRenderer.cs" />
|
<Compile Include="Graphics\ShroudRenderer.cs" />
|
||||||
<Compile Include="Network\Handshake.cs" />
|
<Compile Include="Network\Handshake.cs" />
|
||||||
|
<Compile Include="Widgets\ProgressBarWidget.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
40
OpenRA.Game/Widgets/ProgressBarWidget.cs
Normal file
40
OpenRA.Game/Widgets/ProgressBarWidget.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation. For more information,
|
||||||
|
* see LICENSE.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using OpenRA.Graphics;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace OpenRA.Widgets
|
||||||
|
{
|
||||||
|
public class ProgressBarWidget : Widget
|
||||||
|
{
|
||||||
|
public int Percentage = 0;
|
||||||
|
|
||||||
|
public ProgressBarWidget() : base() {}
|
||||||
|
protected ProgressBarWidget(ProgressBarWidget widget)
|
||||||
|
: base(widget)
|
||||||
|
{
|
||||||
|
Percentage = widget.Percentage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawInner()
|
||||||
|
{
|
||||||
|
WidgetUtils.DrawPanel("dialog3", RenderBounds);
|
||||||
|
|
||||||
|
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 Widget Clone() { return new ProgressBarWidget(this); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,8 +81,13 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
var status = window.GetWidget<LabelWidget>("STATUS");
|
var status = window.GetWidget<LabelWidget>("STATUS");
|
||||||
status.GetText = () => "Initializing...";
|
status.GetText = () => "Initializing...";
|
||||||
|
|
||||||
|
var progress = window.GetWidget<ProgressBarWidget>("PROGRESS");
|
||||||
|
|
||||||
var dl = DownloadUrl(Info.PackageURL, Info.PackagePath,
|
var dl = DownloadUrl(Info.PackageURL, Info.PackagePath,
|
||||||
(_,i) => status.GetText = () => "{0}% {1}/{2} bytes".F(i.ProgressPercentage, i.BytesReceived, i.TotalBytesToReceive),
|
(_,i) => {
|
||||||
|
status.GetText = () => "Downloading {1}/{2} kB ({0}%)".F(i.ProgressPercentage, i.BytesReceived/1024, i.TotalBytesToReceive/1024);
|
||||||
|
progress.Percentage = i.ProgressPercentage;
|
||||||
|
},
|
||||||
(_,i) => status.GetText = () => "Download Complete");
|
(_,i) => status.GetText = () => "Download Complete");
|
||||||
|
|
||||||
window.GetWidget("CANCEL").OnMouseUp = mi => { CancelDownload(dl); ShowInstallMethodDialog(); return true; };
|
window.GetWidget("CANCEL").OnMouseUp = mi => { CancelDownload(dl); ShowInstallMethodDialog(); return true; };
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ Background@INIT_DOWNLOAD:
|
|||||||
Text:Downloading C&C Content
|
Text:Downloading C&C Content
|
||||||
Align:Center
|
Align:Center
|
||||||
Bold:True
|
Bold:True
|
||||||
TextField@PROGRESS:
|
ProgressBar@PROGRESS:
|
||||||
|
Id:PROGRESS
|
||||||
X:50
|
X:50
|
||||||
Y:65
|
Y:65
|
||||||
Width:PARENT_RIGHT - 100
|
Width:PARENT_RIGHT - 100
|
||||||
|
|||||||
Reference in New Issue
Block a user