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