1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:42:56 +08:00

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
No known key found for this signature in database
GPG Key ID: 670DA9BE3DF7EE60
4 changed files with 17 additions and 22 deletions

View File

@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// Handles the storage and retrieval of Beatmaps/WorkingBeatmaps.
/// </summary>
public partial class BeatmapManager : ArchiveDownloadModelManager<BeatmapSetInfo, BeatmapSetFileInfo, DownloadBeatmapSetRequest>
public partial class BeatmapManager : ArchiveDownloadModelManager<BeatmapSetInfo, BeatmapSetFileInfo>
{
/// <summary>
/// Fired when a single difficulty has been hidden.
@ -58,8 +58,6 @@ namespace osu.Game.Beatmaps
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,
WorkingBeatmap defaultBeatmap = null)
: base(storage, contextFactory, api, new BeatmapStore(contextFactory), host)
@ -76,7 +74,7 @@ namespace osu.Game.Beatmaps
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)
{

View File

@ -18,25 +18,23 @@ namespace osu.Game.Database
/// </summary>
/// <typeparam name="TModel">The model 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, TDownloadRequestModel> : ArchiveModelManager<TModel, TFileModel>
public abstract class ArchiveDownloadModelManager<TModel, TFileModel> : ArchiveModelManager<TModel, TFileModel>
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
where TFileModel : INamedFileInfo, new()
where TDownloadRequestModel : ArchiveDownloadModelRequest<TModel>
{
/// <summary>
/// Fired when a <see cref="TModel"/> download begins.
/// </summary>
public event Action<TDownloadRequestModel> DownloadBegan;
public event Action<ArchiveDownloadModelRequest<TModel>> DownloadBegan;
/// <summary>
/// Fired when a <see cref="TModel"/> download is interrupted, either due to user cancellation or failure.
/// </summary>
public event Action<TDownloadRequestModel> DownloadFailed;
public event Action<ArchiveDownloadModelRequest<TModel>> DownloadFailed;
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;
@ -55,7 +53,7 @@ namespace osu.Game.Database
/// <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);
protected abstract ArchiveDownloadModelRequest<TModel> CreateDownloadRequest(TModel model, object[] options);
/// <summary>
/// Downloads a <see cref="TModel"/>.
@ -102,12 +100,12 @@ namespace osu.Game.Database
/// Gets an existing <see cref="TModel"/> download request if it exists.
/// </summary>
/// <param name="model">The <see cref="TModel"/> whose request is wanted.</param>
/// <returns>The <see cref="TDownloadRequestModel"/> object if it exists, otherwise null.</returns>
public TDownloadRequestModel GetExistingDownload(TModel model) => currentDownloads.Find(r => r.Info.Equals(model));
/// <returns>The <see cref="ArchiveDownloadModelRequest{TModel}"/> object if it exists, otherwise null.</returns>
public ArchiveDownloadModelRequest<TModel> GetExistingDownload(TModel model) => currentDownloads.Find(r => r.Info.Equals(model));
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
{

View File

@ -7,17 +7,16 @@ namespace osu.Game.Online.API.Requests
{
public class DownloadBeatmapSetRequest : ArchiveDownloadModelRequest<BeatmapSetInfo>
{
public readonly BeatmapSetInfo BeatmapSet;
private readonly bool noVideo;
private readonly BeatmapSetInfo set;
public DownloadBeatmapSetRequest(BeatmapSetInfo set, bool noVideo)
: base(set)
{
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.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API;
namespace osu.Game.Overlays.Direct
{
@ -49,7 +49,7 @@ namespace osu.Game.Overlays.Direct
beatmaps.DownloadBegan += download =>
{
if (download.BeatmapSet.OnlineBeatmapSetID == BeatmapSet.Value?.OnlineBeatmapSetID)
if (download.Info.OnlineBeatmapSetID == BeatmapSet.Value?.OnlineBeatmapSetID)
attachDownload(download);
};
@ -76,9 +76,9 @@ namespace osu.Game.Overlays.Direct
#endregion
private DownloadBeatmapSetRequest attachedRequest;
private ArchiveDownloadModelRequest<BeatmapSetInfo> attachedRequest;
private void attachDownload(DownloadBeatmapSetRequest request)
private void attachDownload(ArchiveDownloadModelRequest<BeatmapSetInfo> request)
{
if (attachedRequest != null)
{