mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:03:13 +08:00
Add ability to perform a download request with options
This commit is contained in:
parent
8ff26a8fbc
commit
802f48712d
@ -78,7 +78,7 @@ namespace osu.Game.Beatmaps
|
||||
beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
|
||||
}
|
||||
|
||||
protected override DownloadBeatmapSetRequest CreateDownloadRequest(BeatmapSetInfo set) => new DownloadBeatmapSetRequest(set, false);
|
||||
protected override DownloadBeatmapSetRequest CreateDownloadRequest(BeatmapSetInfo set, object[] options) => new DownloadBeatmapSetRequest(set, (options?.FirstOrDefault() as bool?) ?? false);
|
||||
|
||||
protected override void Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive)
|
||||
{
|
||||
|
@ -43,7 +43,15 @@ namespace osu.Game.Database
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
protected abstract TDownloadRequestModel CreateDownloadRequest(TModel model);
|
||||
/// <summary>
|
||||
/// Creates the download request for this <see cref="TModel"/>.
|
||||
/// The <paramref name="options"/> parameters will be provided when the download was initiated with extra options meant
|
||||
/// to be used in the creation of the request.
|
||||
/// </summary>
|
||||
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param>
|
||||
/// <param name="options">Extra parameters for request creation, null if none were passed.</param>
|
||||
/// <returns>The request object.</returns>
|
||||
protected abstract TDownloadRequestModel CreateDownloadRequest(TModel model, object[] options);
|
||||
|
||||
/// <summary>
|
||||
/// Downloads a <see cref="TModel"/>.
|
||||
@ -55,7 +63,24 @@ namespace osu.Game.Database
|
||||
{
|
||||
if (!canDownload(model)) return false;
|
||||
|
||||
var request = CreateDownloadRequest(model);
|
||||
var request = CreateDownloadRequest(model, null);
|
||||
|
||||
performDownloadWithRequest(request);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Downloads a <see cref="TModel"/> with optional parameters for the download request.
|
||||
/// </summary>
|
||||
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param>
|
||||
/// <param name="extra">Optional parameters to be used for creating the download request.</param>
|
||||
/// <returns>Whether downloading can happen.</returns>
|
||||
public bool Download(TModel model, params object[] extra)
|
||||
{
|
||||
if (!canDownload(model)) return false;
|
||||
|
||||
var request = CreateDownloadRequest(model, extra);
|
||||
|
||||
performDownloadWithRequest(request);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user