mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:32:55 +08:00
Attach progress immediately
This commit is contained in:
parent
c54a515b3e
commit
b69a19f810
@ -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;
|
||||
}
|
||||
|
@ -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" : "")}";
|
||||
|
@ -78,12 +78,22 @@ namespace osu.Game.Overlays.Direct
|
||||
attachedRequest = request;
|
||||
|
||||
if (attachedRequest != null)
|
||||
{
|
||||
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
|
||||
{
|
||||
State.Value = DownloadState.NotDownloaded;
|
||||
|
Loading…
Reference in New Issue
Block a user