mirror of
https://github.com/ppy/osu
synced 2024-12-25 16:22:23 +00:00
Attach progress immediately
This commit is contained in:
parent
c54a515b3e
commit
b69a19f810
@ -17,7 +17,7 @@ namespace osu.Game.Online.API
|
|||||||
return request;
|
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()
|
protected APIDownloadRequest()
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ namespace osu.Game.Online.API
|
|||||||
Success?.Invoke(filename);
|
Success?.Invoke(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public event APIProgressHandler Progress;
|
public event APIProgressHandler Progressed;
|
||||||
|
|
||||||
public new event APISuccessHandler<string> Success;
|
public new event APISuccessHandler<string> Success;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
public readonly BeatmapSetInfo BeatmapSet;
|
public readonly BeatmapSetInfo BeatmapSet;
|
||||||
|
|
||||||
|
public float Progress;
|
||||||
|
|
||||||
public event Action<float> DownloadProgressed;
|
public event Action<float> DownloadProgressed;
|
||||||
|
|
||||||
private readonly bool noVideo;
|
private readonly bool noVideo;
|
||||||
@ -19,7 +21,7 @@ namespace osu.Game.Online.API.Requests
|
|||||||
this.noVideo = noVideo;
|
this.noVideo = noVideo;
|
||||||
BeatmapSet = set;
|
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" : "")}";
|
protected override string Target => $@"beatmapsets/{BeatmapSet.OnlineBeatmapSetID}/download{(noVideo ? "?noVideo=1" : "")}";
|
||||||
|
@ -79,10 +79,20 @@ namespace osu.Game.Overlays.Direct
|
|||||||
|
|
||||||
if (attachedRequest != null)
|
if (attachedRequest != null)
|
||||||
{
|
{
|
||||||
State.Value = DownloadState.Downloading;
|
if (attachedRequest.Progress == 1)
|
||||||
attachedRequest.Failure += onRequestFailure;
|
{
|
||||||
attachedRequest.DownloadProgressed += onRequestProgress;
|
State.Value = DownloadState.Downloaded;
|
||||||
attachedRequest.Success += onRequestSuccess;
|
Progress.Value = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
State.Value = DownloadState.Downloading;
|
||||||
|
Progress.Value = attachedRequest.Progress;
|
||||||
|
|
||||||
|
attachedRequest.Failure += onRequestFailure;
|
||||||
|
attachedRequest.DownloadProgressed += onRequestProgress;
|
||||||
|
attachedRequest.Success += onRequestSuccess;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user