1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 18:42:56 +08:00
osu-lazer/osu.Game/Online/API/ArchiveDownloadRequest.cs

33 lines
829 B
C#
Raw Normal View History

2019-06-11 22:19:10 +08: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.
2022-06-17 15:37:17 +08:00
#nullable disable
2019-06-11 22:19:10 +08:00
using System;
namespace osu.Game.Online.API
{
2019-06-12 12:30:23 +08:00
public abstract class ArchiveDownloadRequest<TModel> : APIDownloadRequest
where TModel : class
{
2019-06-13 00:26:36 +08:00
public readonly TModel Model;
public float Progress { get; private set; }
public event Action<float> DownloadProgressed;
2019-06-12 12:30:23 +08:00
protected ArchiveDownloadRequest(TModel model)
{
2019-06-13 00:26:36 +08:00
Model = model;
Progressed += (current, total) => SetProgress((float)current / total);
}
protected void SetProgress(float progress)
{
Progress = progress;
DownloadProgressed?.Invoke(progress);
}
}
}