unify {RA,Cnc}DownloadPackagesLogic

This commit is contained in:
Chris Forbes
2011-10-19 19:28:33 +13:00
parent 1c69f5bef9
commit 42aa8a57c5
7 changed files with 12 additions and 126 deletions

View File

@@ -19,21 +19,21 @@ using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
{
public class RADownloadPackagesLogic
public class DownloadPackagesLogic
{
Widget panel;
Dictionary<string,string> installData;
ProgressBarWidget progressBar;
LabelWidget statusLabel;
Action continueLoading;
Action afterInstall;
[ObjectCreator.UseCtor]
public RADownloadPackagesLogic([ObjectCreator.Param] Widget widget,
public DownloadPackagesLogic([ObjectCreator.Param] Widget widget,
[ObjectCreator.Param] Dictionary<string,string> installData,
[ObjectCreator.Param] Action continueLoading)
[ObjectCreator.Param] Action afterInstall)
{
this.installData = installData;
this.continueLoading = continueLoading;
this.afterInstall = afterInstall;
panel = widget.GetWidget("INSTALL_DOWNLOAD_PANEL");
progressBar = panel.GetWidget<ProgressBarWidget>("PROGRESS_BAR");
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
// Save the package to a temp file
var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
var dest = new string[] { Platform.SupportDir, "Content", "ra" }.Aggregate(Path.Combine);
var dest = new string[] { Platform.SupportDir, "Content", Game.modData.Manifest.Mods[0] }.Aggregate(Path.Combine);
Action<DownloadProgressChangedEventArgs> onDownloadProgress = i =>
{
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
Game.RunAfterTick(() =>
{
Widget.CloseWindow();
continueLoading();
afterInstall();
});
}
};

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
var panel = widget.GetWidget("INSTALL_PANEL");
var args = new WidgetArgs()
{
{ "continueLoading", () => { Widget.CloseWindow(); continueLoading(); } },
{ "afterInstall", () => { Widget.CloseWindow(); continueLoading(); } },
{ "installData", installData }
};