1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 08:07:24 +08:00

Get rid of some properties and todos.

This commit is contained in:
naoey 2017-09-09 12:44:27 +05:30
parent d12a5e927a
commit 0c2bad1de4
2 changed files with 33 additions and 40 deletions

View File

@ -68,7 +68,7 @@ namespace osu.Game.Beatmaps
private readonly APIAccess api;
private readonly List<DownloadBeatmapSetRequest> currentDownloads;
private readonly List<DownloadBeatmapSetRequest> currentDownloads = new List<DownloadBeatmapSetRequest>();
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
private BeatmapIPCChannel ipc;
@ -99,8 +99,6 @@ namespace osu.Game.Beatmaps
if (importHost != null)
ipc = new BeatmapIPCChannel(importHost, this);
currentDownloads = new List<DownloadBeatmapSetRequest>();
}
/// <summary>
@ -194,7 +192,7 @@ namespace osu.Game.Beatmaps
/// <returns>A new <see cref="DownloadBeatmapSetRequest"/>, or an existing one if a download is already in progress.</returns>
public DownloadBeatmapSetRequest Download(BeatmapSetInfo beatmapSetInfo)
{
var existing = currentDownloads.Find(d => d.BeatmapSet.OnlineBeatmapSetID == beatmapSetInfo.OnlineBeatmapSetID);
var existing = GetExistingDownload(beatmapSetInfo);
if (existing != null) return existing;
@ -243,7 +241,6 @@ namespace osu.Game.Beatmaps
PostNotification?.Invoke(downloadNotification);
// don't run in the main api queue as this is a long-running task.
// TODO: ensure the Success/Failure callbacks are being scheduled to the main thread for thread safety.
Task.Run(() => request.Perform(api));
return request;

View File

@ -38,38 +38,6 @@ namespace osu.Game.Overlays.Direct
private BeatmapManager beatmaps;
private NotificationOverlay notifications;
private DownloadBeatmapSetRequest downloadRequest;
protected DownloadBeatmapSetRequest DownloadRequest
{
get { return downloadRequest; }
set
{
if (value == null || downloadRequest == value) return;
downloadRequest = value;
progressBar.FadeIn(400, Easing.OutQuint);
progressBar.ResizeHeightTo(4, 400, Easing.OutQuint);
progressBar.Current.Value = 0;
downloadRequest.Failure += e =>
{
progressBar.Current.Value = 0;
progressBar.FadeOut(500);
Logger.Error(e, "Failed to get beatmap download information");
};
downloadRequest.DownloadProgressed += progress => progressBar.Current.Value = progress;
downloadRequest.Success += data =>
{
progressBar.Current.Value = 1;
progressBar.FadeOut(500);
};
}
}
protected override Container<Drawable> Content => content;
protected DirectPanel(BeatmapSetInfo setInfo)
@ -128,7 +96,10 @@ namespace osu.Game.Overlays.Direct
}
});
DownloadRequest = beatmaps.GetExistingDownload(SetInfo);
var downloadRequest = beatmaps.GetExistingDownload(SetInfo);
if (downloadRequest != null)
attachDownload(downloadRequest);
}
protected override bool OnHover(InputState state)
@ -159,9 +130,9 @@ namespace osu.Game.Overlays.Direct
return;
}
// we already have an active download running.
if (beatmaps.GetExistingDownload(SetInfo) != null)
{
// we already have an active download running.
content.MoveToX(-5, 50, Easing.OutSine).Then()
.MoveToX(5, 100, Easing.InOutSine).Then()
.MoveToX(-5, 100, Easing.InOutSine).Then()
@ -170,7 +141,32 @@ namespace osu.Game.Overlays.Direct
return;
}
DownloadRequest = beatmaps.Download(SetInfo);
var request = beatmaps.Download(SetInfo);
attachDownload(request);
}
private void attachDownload(DownloadBeatmapSetRequest request)
{
progressBar.FadeIn(400, Easing.OutQuint);
progressBar.ResizeHeightTo(4, 400, Easing.OutQuint);
progressBar.Current.Value = 0;
request.Failure += e =>
{
progressBar.Current.Value = 0;
progressBar.FadeOut(500);
Logger.Error(e, "Failed to get beatmap download information");
};
request.DownloadProgressed += progress => progressBar.Current.Value = progress;
request.Success += data =>
{
progressBar.Current.Value = 1;
progressBar.FadeOut(500);
};
}
protected override void LoadComplete()