1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 12:33:01 +08:00

Attach progress immediately

This commit is contained in:
Dean Herbert 2019-01-31 19:08:45 +09:00
parent c54a515b3e
commit b69a19f810
3 changed files with 19 additions and 7 deletions

View File

@ -17,7 +17,7 @@ namespace osu.Game.Online.API
return request;
}
private void request_Progress(long current, long total) => API.Schedule(() => Progress?.Invoke(current, total));
private void request_Progress(long current, long total) => API.Schedule(() => Progressed?.Invoke(current, total));
protected APIDownloadRequest()
{
@ -29,7 +29,7 @@ namespace osu.Game.Online.API
Success?.Invoke(filename);
}
public event APIProgressHandler Progress;
public event APIProgressHandler Progressed;
public new event APISuccessHandler<string> Success;
}

View File

@ -10,6 +10,8 @@ namespace osu.Game.Online.API.Requests
{
public readonly BeatmapSetInfo BeatmapSet;
public float Progress;
public event Action<float> DownloadProgressed;
private readonly bool noVideo;
@ -19,7 +21,7 @@ namespace osu.Game.Online.API.Requests
this.noVideo = noVideo;
BeatmapSet = set;
Progress += (current, total) => DownloadProgressed?.Invoke((float) current / total);
Progressed += (current, total) => DownloadProgressed?.Invoke(Progress = (float)current / total);
}
protected override string Target => $@"beatmapsets/{BeatmapSet.OnlineBeatmapSetID}/download{(noVideo ? "?noVideo=1" : "")}";

View File

@ -79,10 +79,20 @@ namespace osu.Game.Overlays.Direct
if (attachedRequest != null)
{
State.Value = DownloadState.Downloading;
attachedRequest.Failure += onRequestFailure;
attachedRequest.DownloadProgressed += onRequestProgress;
attachedRequest.Success += onRequestSuccess;
if (attachedRequest.Progress == 1)
{
State.Value = DownloadState.Downloaded;
Progress.Value = 1;
}
else
{
State.Value = DownloadState.Downloading;
Progress.Value = attachedRequest.Progress;
attachedRequest.Failure += onRequestFailure;
attachedRequest.DownloadProgressed += onRequestProgress;
attachedRequest.Success += onRequestSuccess;
}
}
else
{