diff --git a/OpenRA.Game/Download.cs b/OpenRA.Game/Download.cs index 5955d3b588..4cd997ae7d 100644 --- a/OpenRA.Game/Download.cs +++ b/OpenRA.Game/Download.cs @@ -52,6 +52,20 @@ namespace OpenRA wc.DownloadFileAsync(new Uri(url), path); } + public Download(string url, Action onProgress, Action onComplete) + { + wc = new WebClient(); + wc.Proxy = null; + + wc.DownloadProgressChanged += (_, a) => onProgress(a); + wc.DownloadDataCompleted += (_, a) => onComplete(a, cancelled); + + Game.OnQuit += Cancel; + wc.DownloadDataCompleted += (_, a) => { Game.OnQuit -= Cancel; }; + + wc.DownloadDataAsync(new Uri(url)); + } + public void Cancel() { Game.OnQuit -= Cancel;