osukey/osu.Game/Online/API/ArchiveDownloadRequest.cs
Salman Ahmed adb2605d5d Enforce double type in the download progress path
Wasn't sure where to exactly put this, or whether to split it, but it's very small change to worry about, so I guess it's fine being here
2021-01-17 00:12:14 +03:00

31 lines
814 B
C#

// 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
{
public abstract class ArchiveDownloadRequest<TModel> : APIDownloadRequest
where TModel : class
{
public readonly TModel Model;
public double Progress { get; private set; }
public event Action<double> DownloadProgressed;
protected ArchiveDownloadRequest(TModel model)
{
Model = model;
Progressed += (current, total) => SetProgress((double)current / total);
}
protected void SetProgress(double progress)
{
Progress = progress;
DownloadProgressed?.Invoke(progress);
}
}
}