Remove unecessary third generic and change usages to match

This commit is contained in:
naoey
2019-06-11 21:11:30 +05:30
parent f4dab4da85
commit 06a558c4b7
4 changed files with 17 additions and 22 deletions

View File

@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps
/// <summary> /// <summary>
/// Handles the storage and retrieval of Beatmaps/WorkingBeatmaps. /// Handles the storage and retrieval of Beatmaps/WorkingBeatmaps.
/// </summary> /// </summary>
public partial class BeatmapManager : ArchiveDownloadModelManager<BeatmapSetInfo, BeatmapSetFileInfo, DownloadBeatmapSetRequest> public partial class BeatmapManager : ArchiveDownloadModelManager<BeatmapSetInfo, BeatmapSetFileInfo>
{ {
/// <summary> /// <summary>
/// Fired when a single difficulty has been hidden. /// Fired when a single difficulty has been hidden.
@ -58,8 +58,6 @@ namespace osu.Game.Beatmaps
private readonly GameHost host; private readonly GameHost host;
private readonly List<DownloadBeatmapSetRequest> currentDownloads = new List<DownloadBeatmapSetRequest>();
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, AudioManager audioManager, GameHost host = null, public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, AudioManager audioManager, GameHost host = null,
WorkingBeatmap defaultBeatmap = null) WorkingBeatmap defaultBeatmap = null)
: base(storage, contextFactory, api, new BeatmapStore(contextFactory), host) : base(storage, contextFactory, api, new BeatmapStore(contextFactory), host)
@ -76,7 +74,7 @@ namespace osu.Game.Beatmaps
beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b); beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
} }
protected override DownloadBeatmapSetRequest CreateDownloadRequest(BeatmapSetInfo set, object[] options) => new DownloadBeatmapSetRequest(set, (options?.FirstOrDefault() as bool?) ?? false); protected override ArchiveDownloadModelRequest<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

@ -18,25 +18,23 @@ namespace osu.Game.Database
/// </summary> /// </summary>
/// <typeparam name="TModel">The model type.</typeparam> /// <typeparam name="TModel">The model type.</typeparam>
/// <typeparam name="TFileModel">The associated file join type.</typeparam> /// <typeparam name="TFileModel">The associated file join type.</typeparam>
/// <typeparam name="TDownloadRequestModel">The associated <see cref="ArchiveDownloadModelRequest{TModel}"/> for this model.</typeparam> public abstract class ArchiveDownloadModelManager<TModel, TFileModel> : ArchiveModelManager<TModel, TFileModel>
public abstract class ArchiveDownloadModelManager<TModel, TFileModel, TDownloadRequestModel> : ArchiveModelManager<TModel, TFileModel>
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
where TFileModel : INamedFileInfo, new() where TFileModel : INamedFileInfo, new()
where TDownloadRequestModel : ArchiveDownloadModelRequest<TModel>
{ {
/// <summary> /// <summary>
/// Fired when a <see cref="TModel"/> download begins. /// Fired when a <see cref="TModel"/> download begins.
/// </summary> /// </summary>
public event Action<TDownloadRequestModel> DownloadBegan; public event Action<ArchiveDownloadModelRequest<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>
public event Action<TDownloadRequestModel> DownloadFailed; public event Action<ArchiveDownloadModelRequest<TModel>> DownloadFailed;
private readonly IAPIProvider api; private readonly IAPIProvider api;
private readonly List<TDownloadRequestModel> currentDownloads = new List<TDownloadRequestModel>(); private readonly List<ArchiveDownloadModelRequest<TModel>> currentDownloads = new List<ArchiveDownloadModelRequest<TModel>>();
private readonly MutableDatabaseBackedStoreWithFileIncludes<TModel, TFileModel> modelStore; private readonly MutableDatabaseBackedStoreWithFileIncludes<TModel, TFileModel> modelStore;
@ -55,7 +53,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 TDownloadRequestModel CreateDownloadRequest(TModel model, object[] options); protected abstract ArchiveDownloadModelRequest<TModel> CreateDownloadRequest(TModel model, object[] options);
/// <summary> /// <summary>
/// Downloads a <see cref="TModel"/>. /// Downloads a <see cref="TModel"/>.
@ -102,12 +100,12 @@ 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="TDownloadRequestModel"/> object if it exists, otherwise null.</returns> /// <returns>The <see cref="ArchiveDownloadModelRequest{TModel}"/> object if it exists, otherwise null.</returns>
public TDownloadRequestModel GetExistingDownload(TModel model) => currentDownloads.Find(r => r.Info.Equals(model)); public ArchiveDownloadModelRequest<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(TDownloadRequestModel request) private void performDownloadWithRequest(ArchiveDownloadModelRequest<TModel> request)
{ {
DownloadNotification notification = new DownloadNotification DownloadNotification notification = new DownloadNotification
{ {

View File

@ -7,17 +7,16 @@ namespace osu.Game.Online.API.Requests
{ {
public class DownloadBeatmapSetRequest : ArchiveDownloadModelRequest<BeatmapSetInfo> public class DownloadBeatmapSetRequest : ArchiveDownloadModelRequest<BeatmapSetInfo>
{ {
public readonly BeatmapSetInfo BeatmapSet;
private readonly bool noVideo; private readonly bool noVideo;
private readonly BeatmapSetInfo set;
public DownloadBeatmapSetRequest(BeatmapSetInfo set, bool noVideo) public DownloadBeatmapSetRequest(BeatmapSetInfo set, bool noVideo)
: base(set) : base(set)
{ {
this.noVideo = noVideo; this.noVideo = noVideo;
BeatmapSet = set; this.set = set;
} }
protected override string Target => $@"beatmapsets/{BeatmapSet.OnlineBeatmapSetID}/download{(noVideo ? "?noVideo=1" : "")}"; protected override string Target => $@"beatmapsets/{set.OnlineBeatmapSetID}/download{(noVideo ? "?noVideo=1" : "")}";
} }
} }

View File

@ -7,7 +7,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests; using osu.Game.Online.API;
namespace osu.Game.Overlays.Direct namespace osu.Game.Overlays.Direct
{ {
@ -49,7 +49,7 @@ namespace osu.Game.Overlays.Direct
beatmaps.DownloadBegan += download => beatmaps.DownloadBegan += download =>
{ {
if (download.BeatmapSet.OnlineBeatmapSetID == BeatmapSet.Value?.OnlineBeatmapSetID) if (download.Info.OnlineBeatmapSetID == BeatmapSet.Value?.OnlineBeatmapSetID)
attachDownload(download); attachDownload(download);
}; };
@ -76,9 +76,9 @@ namespace osu.Game.Overlays.Direct
#endregion #endregion
private DownloadBeatmapSetRequest attachedRequest; private ArchiveDownloadModelRequest<BeatmapSetInfo> attachedRequest;
private void attachDownload(DownloadBeatmapSetRequest request) private void attachDownload(ArchiveDownloadModelRequest<BeatmapSetInfo> request)
{ {
if (attachedRequest != null) if (attachedRequest != null)
{ {