osu/osu.Game/Online/API/ArchiveDownloadRequest.cs

31 lines
814 B
C#
Raw Normal View History

2019-06-11 14:19:10 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
namespace osu.Game.Online.API
{
2019-06-12 04:30:23 +00:00
public abstract class ArchiveDownloadRequest<TModel> : APIDownloadRequest
where TModel : class
{
2019-06-12 16:26:36 +00:00
public readonly TModel Model;
public double Progress { get; private set; }
public event Action<double> DownloadProgressed;
2019-06-12 04:30:23 +00:00
protected ArchiveDownloadRequest(TModel model)
{
2019-06-12 16:26:36 +00:00
Model = model;
Progressed += (current, total) => SetProgress((double)current / total);
}
protected void SetProgress(double progress)
{
Progress = progress;
DownloadProgressed?.Invoke(progress);
}
}
}