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

Rename request type to be less verbose

This commit is contained in:
Dean Herbert 2019-06-12 13:30:23 +09:00
parent eaeeffaa86
commit c591a6f1fa
6 changed files with 16 additions and 16 deletions

View File

@ -74,7 +74,7 @@ namespace osu.Game.Beatmaps
beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b); beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
} }
protected override ArchiveDownloadModelRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, object[] options) => new DownloadBeatmapSetRequest(set, (options?.FirstOrDefault() as bool?) ?? false); protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, object[] options) => new DownloadBeatmapSetRequest(set, (options?.FirstOrDefault() as bool?) ?? false);
protected override void Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive) protected override void Populate(BeatmapSetInfo beatmapSet, ArchiveReader archive)
{ {

View File

@ -22,13 +22,13 @@ namespace osu.Game.Database
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
where TFileModel : INamedFileInfo, new() where TFileModel : INamedFileInfo, new()
{ {
public event Action<ArchiveDownloadModelRequest<TModel>> DownloadBegan; public event Action<ArchiveDownloadRequest<TModel>> DownloadBegan;
public event Action<ArchiveDownloadModelRequest<TModel>> DownloadFailed; public event Action<ArchiveDownloadRequest<TModel>> DownloadFailed;
private readonly IAPIProvider api; private readonly IAPIProvider api;
private readonly List<ArchiveDownloadModelRequest<TModel>> currentDownloads = new List<ArchiveDownloadModelRequest<TModel>>(); private readonly List<ArchiveDownloadRequest<TModel>> currentDownloads = new List<ArchiveDownloadRequest<TModel>>();
private readonly MutableDatabaseBackedStoreWithFileIncludes<TModel, TFileModel> modelStore; private readonly MutableDatabaseBackedStoreWithFileIncludes<TModel, TFileModel> modelStore;
@ -47,7 +47,7 @@ namespace osu.Game.Database
/// <param name="model">The <see cref="TModel"/> to be downloaded.</param> /// <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> /// <param name="options">Extra parameters for request creation, null if none were passed.</param>
/// <returns>The request object.</returns> /// <returns>The request object.</returns>
protected abstract ArchiveDownloadModelRequest<TModel> CreateDownloadRequest(TModel model, object[] options); protected abstract ArchiveDownloadRequest<TModel> CreateDownloadRequest(TModel model, object[] options);
public bool Download(TModel model) public bool Download(TModel model)
{ {
@ -78,11 +78,11 @@ namespace osu.Game.Database
/// <returns>Whether the <see cref="TModel"/> exists locally.</returns> /// <returns>Whether the <see cref="TModel"/> exists locally.</returns>
public virtual bool IsAvailableLocally(TModel model) => modelStore.ConsumableItems.Any(m => m.Equals(model) && !m.DeletePending); public virtual bool IsAvailableLocally(TModel model) => modelStore.ConsumableItems.Any(m => m.Equals(model) && !m.DeletePending);
public ArchiveDownloadModelRequest<TModel> GetExistingDownload(TModel model) => currentDownloads.Find(r => r.Info.Equals(model)); public ArchiveDownloadRequest<TModel> GetExistingDownload(TModel model) => currentDownloads.Find(r => r.Info.Equals(model));
private bool canDownload(TModel model) => GetExistingDownload(model) == null && api != null; private bool canDownload(TModel model) => GetExistingDownload(model) == null && api != null;
private void performDownloadWithRequest(ArchiveDownloadModelRequest<TModel> request) private void performDownloadWithRequest(ArchiveDownloadRequest<TModel> request)
{ {
DownloadNotification notification = new DownloadNotification DownloadNotification notification = new DownloadNotification
{ {

View File

@ -12,12 +12,12 @@ namespace osu.Game.Database
/// <summary> /// <summary>
/// Fired when a <see cref="TModel"/> download begins. /// Fired when a <see cref="TModel"/> download begins.
/// </summary> /// </summary>
event Action<ArchiveDownloadModelRequest<TModel>> DownloadBegan; event Action<ArchiveDownloadRequest<TModel>> DownloadBegan;
/// <summary> /// <summary>
/// Fired when a <see cref="TModel"/> download is interrupted, either due to user cancellation or failure. /// Fired when a <see cref="TModel"/> download is interrupted, either due to user cancellation or failure.
/// </summary> /// </summary>
event Action<ArchiveDownloadModelRequest<TModel>> DownloadFailed; event Action<ArchiveDownloadRequest<TModel>> DownloadFailed;
bool IsAvailableLocally(TModel model); bool IsAvailableLocally(TModel model);
@ -42,7 +42,7 @@ namespace osu.Game.Database
/// Gets an existing <see cref="TModel"/> download request if it exists. /// Gets an existing <see cref="TModel"/> download request if it exists.
/// </summary> /// </summary>
/// <param name="model">The <see cref="TModel"/> whose request is wanted.</param> /// <param name="model">The <see cref="TModel"/> whose request is wanted.</param>
/// <returns>The <see cref="ArchiveDownloadModelRequest{TModel}"/> object if it exists, otherwise null.</returns> /// <returns>The <see cref="ArchiveDownloadRequest{TModel}"/> object if it exists, otherwise null.</returns>
ArchiveDownloadModelRequest<TModel> GetExistingDownload(TModel model); ArchiveDownloadRequest<TModel> GetExistingDownload(TModel model);
} }
} }

View File

@ -5,7 +5,7 @@ using System;
namespace osu.Game.Online.API namespace osu.Game.Online.API
{ {
public abstract class ArchiveDownloadModelRequest<TModel> : APIDownloadRequest public abstract class ArchiveDownloadRequest<TModel> : APIDownloadRequest
where TModel : class where TModel : class
{ {
public readonly TModel Info; public readonly TModel Info;
@ -14,7 +14,7 @@ namespace osu.Game.Online.API
public event Action<float> DownloadProgressed; public event Action<float> DownloadProgressed;
protected ArchiveDownloadModelRequest(TModel model) protected ArchiveDownloadRequest(TModel model)
{ {
Info = model; Info = model;

View File

@ -5,7 +5,7 @@ using osu.Game.Beatmaps;
namespace osu.Game.Online.API.Requests namespace osu.Game.Online.API.Requests
{ {
public class DownloadBeatmapSetRequest : ArchiveDownloadModelRequest<BeatmapSetInfo> public class DownloadBeatmapSetRequest : ArchiveDownloadRequest<BeatmapSetInfo>
{ {
private readonly bool noVideo; private readonly bool noVideo;
private readonly BeatmapSetInfo set; private readonly BeatmapSetInfo set;

View File

@ -76,9 +76,9 @@ namespace osu.Game.Overlays.Direct
#endregion #endregion
private ArchiveDownloadModelRequest<BeatmapSetInfo> attachedRequest; private ArchiveDownloadRequest<BeatmapSetInfo> attachedRequest;
private void attachDownload(ArchiveDownloadModelRequest<BeatmapSetInfo> request) private void attachDownload(ArchiveDownloadRequest<BeatmapSetInfo> request)
{ {
if (attachedRequest != null) if (attachedRequest != null)
{ {