mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +08:00
Merge branch 'master' into user-lookup-by-username-cleanup
This commit is contained in:
commit
bc17446055
@ -168,19 +168,19 @@ namespace osu.Game.Tests.Online
|
|||||||
return new TestBeatmapModelManager(this, storage, contextFactory, rulesets, api, host);
|
return new TestBeatmapModelManager(this, storage, contextFactory, rulesets, api, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override BeatmapModelDownloader CreateBeatmapModelDownloader(IBeatmapModelManager manager, IAPIProvider api, GameHost host)
|
protected override BeatmapModelDownloader CreateBeatmapModelDownloader(IModelImporter<BeatmapSetInfo> manager, IAPIProvider api, GameHost host)
|
||||||
{
|
{
|
||||||
return new TestBeatmapModelDownloader(manager, api, host);
|
return new TestBeatmapModelDownloader(manager, api, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class TestBeatmapModelDownloader : BeatmapModelDownloader
|
internal class TestBeatmapModelDownloader : BeatmapModelDownloader
|
||||||
{
|
{
|
||||||
public TestBeatmapModelDownloader(IBeatmapModelManager modelManager, IAPIProvider apiProvider, GameHost gameHost)
|
public TestBeatmapModelDownloader(IModelImporter<BeatmapSetInfo> importer, IAPIProvider apiProvider, GameHost gameHost)
|
||||||
: base(modelManager, apiProvider, gameHost)
|
: base(importer, apiProvider, gameHost)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, bool minimiseDownloadSize)
|
protected override ArchiveDownloadRequest<IBeatmapSetInfo> CreateDownloadRequest(IBeatmapSetInfo set, bool minimiseDownloadSize)
|
||||||
=> new TestDownloadRequest(set);
|
=> new TestDownloadRequest(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,12 +202,12 @@ namespace osu.Game.Tests.Online
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestDownloadRequest : ArchiveDownloadRequest<BeatmapSetInfo>
|
private class TestDownloadRequest : ArchiveDownloadRequest<IBeatmapSetInfo>
|
||||||
{
|
{
|
||||||
public new void SetProgress(float progress) => base.SetProgress(progress);
|
public new void SetProgress(float progress) => base.SetProgress(progress);
|
||||||
public new void TriggerSuccess(string filename) => base.TriggerSuccess(filename);
|
public new void TriggerSuccess(string filename) => base.TriggerSuccess(filename);
|
||||||
|
|
||||||
public TestDownloadRequest(BeatmapSetInfo model)
|
public TestDownloadRequest(IBeatmapSetInfo model)
|
||||||
: base(model)
|
: base(model)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// Handles general operations related to global beatmap management.
|
/// Handles general operations related to global beatmap management.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ExcludeFromDynamicCompile]
|
[ExcludeFromDynamicCompile]
|
||||||
public class BeatmapManager : IModelDownloader<BeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, IWorkingBeatmapCache, IDisposable
|
public class BeatmapManager : IModelDownloader<IBeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, IModelImporter<BeatmapSetInfo>, IWorkingBeatmapCache, IDisposable
|
||||||
{
|
{
|
||||||
private readonly BeatmapModelManager beatmapModelManager;
|
private readonly BeatmapModelManager beatmapModelManager;
|
||||||
private readonly BeatmapModelDownloader beatmapModelDownloader;
|
private readonly BeatmapModelDownloader beatmapModelDownloader;
|
||||||
@ -54,7 +54,7 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual BeatmapModelDownloader CreateBeatmapModelDownloader(IBeatmapModelManager modelManager, IAPIProvider api, GameHost host)
|
protected virtual BeatmapModelDownloader CreateBeatmapModelDownloader(IModelImporter<BeatmapSetInfo> modelManager, IAPIProvider api, GameHost host)
|
||||||
{
|
{
|
||||||
return new BeatmapModelDownloader(modelManager, api, host);
|
return new BeatmapModelDownloader(modelManager, api, host);
|
||||||
}
|
}
|
||||||
@ -246,34 +246,16 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
#region Implementation of IModelDownloader<BeatmapSetInfo>
|
#region Implementation of IModelDownloader<BeatmapSetInfo>
|
||||||
|
|
||||||
public IBindable<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>> DownloadBegan => beatmapModelDownloader.DownloadBegan;
|
public IBindable<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>> DownloadBegan => beatmapModelDownloader.DownloadBegan;
|
||||||
|
|
||||||
public IBindable<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>> DownloadFailed => beatmapModelDownloader.DownloadFailed;
|
public IBindable<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>> DownloadFailed => beatmapModelDownloader.DownloadFailed;
|
||||||
|
|
||||||
// Temporary method until this class supports IBeatmapSetInfo or otherwise.
|
|
||||||
public bool Download(IBeatmapSetInfo model, bool minimiseDownloadSize = false)
|
public bool Download(IBeatmapSetInfo model, bool minimiseDownloadSize = false)
|
||||||
{
|
|
||||||
return beatmapModelDownloader.Download(new BeatmapSetInfo
|
|
||||||
{
|
|
||||||
OnlineBeatmapSetID = model.OnlineID,
|
|
||||||
Metadata = new BeatmapMetadata
|
|
||||||
{
|
|
||||||
Title = model.Metadata?.Title ?? string.Empty,
|
|
||||||
Artist = model.Metadata?.Artist ?? string.Empty,
|
|
||||||
TitleUnicode = model.Metadata?.TitleUnicode ?? string.Empty,
|
|
||||||
ArtistUnicode = model.Metadata?.ArtistUnicode ?? string.Empty,
|
|
||||||
AuthorString = model.Metadata?.Author.Username ?? string.Empty,
|
|
||||||
AuthorID = model.Metadata?.Author.OnlineID ?? 1,
|
|
||||||
}
|
|
||||||
}, minimiseDownloadSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Download(BeatmapSetInfo model, bool minimiseDownloadSize = false)
|
|
||||||
{
|
{
|
||||||
return beatmapModelDownloader.Download(model, minimiseDownloadSize);
|
return beatmapModelDownloader.Download(model, minimiseDownloadSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArchiveDownloadRequest<BeatmapSetInfo> GetExistingDownload(BeatmapSetInfo model)
|
public ArchiveDownloadRequest<IBeatmapSetInfo> GetExistingDownload(IBeatmapSetInfo model)
|
||||||
{
|
{
|
||||||
return beatmapModelDownloader.GetExistingDownload(model);
|
return beatmapModelDownloader.GetExistingDownload(model);
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,16 @@ using osu.Game.Online.API.Requests;
|
|||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
public class BeatmapModelDownloader : ModelDownloader<BeatmapSetInfo>
|
public class BeatmapModelDownloader : ModelDownloader<BeatmapSetInfo, IBeatmapSetInfo>
|
||||||
{
|
{
|
||||||
protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, bool minimiseDownloadSize) =>
|
protected override ArchiveDownloadRequest<IBeatmapSetInfo> CreateDownloadRequest(IBeatmapSetInfo set, bool minimiseDownloadSize) =>
|
||||||
new DownloadBeatmapSetRequest(set, minimiseDownloadSize);
|
new DownloadBeatmapSetRequest(set, minimiseDownloadSize);
|
||||||
|
|
||||||
public override ArchiveDownloadRequest<BeatmapSetInfo> GetExistingDownload(BeatmapSetInfo model)
|
public override ArchiveDownloadRequest<IBeatmapSetInfo> GetExistingDownload(IBeatmapSetInfo model)
|
||||||
=> CurrentDownloads.Find(r => r.Model.OnlineID == model.OnlineID);
|
=> CurrentDownloads.Find(r => r.Model.OnlineID == model.OnlineID);
|
||||||
|
|
||||||
public BeatmapModelDownloader(IBeatmapModelManager beatmapModelManager, IAPIProvider api, GameHost host = null)
|
public BeatmapModelDownloader(IModelImporter<BeatmapSetInfo> beatmapImporter, IAPIProvider api, GameHost host = null)
|
||||||
: base(beatmapModelManager, api, host)
|
: base(beatmapImporter, api, host)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ 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>
|
||||||
public abstract class ArchiveModelManager<TModel, TFileModel> : IModelManager<TModel>, IModelFileManager<TModel, TFileModel>
|
public abstract class ArchiveModelManager<TModel, TFileModel> : IModelImporter<TModel>, IModelManager<TModel>, IModelFileManager<TModel, TFileModel>
|
||||||
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
||||||
where TFileModel : class, INamedFileInfo, IHasPrimaryKey, new()
|
where TFileModel : class, INamedFileInfo, IHasPrimaryKey, new()
|
||||||
{
|
{
|
||||||
|
@ -10,35 +10,35 @@ namespace osu.Game.Database
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a <see cref="IModelManager{TModel}"/> that can download new models from an external source.
|
/// Represents a <see cref="IModelManager{TModel}"/> that can download new models from an external source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TModel">The model type.</typeparam>
|
/// <typeparam name="T">The item's interface type.</typeparam>
|
||||||
public interface IModelDownloader<TModel> : IPostNotifications
|
public interface IModelDownloader<T> : IPostNotifications
|
||||||
where TModel : class
|
where T : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when a <typeparamref name="TModel"/> download begins.
|
/// Fired when a <typeparamref name="T"/> download begins.
|
||||||
/// This is NOT run on the update thread and should be scheduled.
|
/// This is NOT run on the update thread and should be scheduled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IBindable<WeakReference<ArchiveDownloadRequest<TModel>>> DownloadBegan { get; }
|
IBindable<WeakReference<ArchiveDownloadRequest<T>>> DownloadBegan { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when a <typeparamref name="TModel"/> download is interrupted, either due to user cancellation or failure.
|
/// Fired when a <typeparamref name="T"/> download is interrupted, either due to user cancellation or failure.
|
||||||
/// This is NOT run on the update thread and should be scheduled.
|
/// This is NOT run on the update thread and should be scheduled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IBindable<WeakReference<ArchiveDownloadRequest<TModel>>> DownloadFailed { get; }
|
IBindable<WeakReference<ArchiveDownloadRequest<T>>> DownloadFailed { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Begin a download for the requested <typeparamref name="TModel"/>.
|
/// Begin a download for the requested <typeparamref name="T"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">The <stypeparamref name="TModel"/> to be downloaded.</param>
|
/// <param name="item">The <stypeparamref name="T"/> to be downloaded.</param>
|
||||||
/// <param name="minimiseDownloadSize">Whether this download should be optimised for slow connections. Generally means extras are not included in the download bundle..</param>
|
/// <param name="minimiseDownloadSize">Whether this download should be optimised for slow connections. Generally means extras are not included in the download bundle..</param>
|
||||||
/// <returns>Whether the download was started.</returns>
|
/// <returns>Whether the download was started.</returns>
|
||||||
bool Download(TModel model, bool minimiseDownloadSize);
|
bool Download(T item, bool minimiseDownloadSize);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an existing <typeparamref name="TModel"/> download request if it exists.
|
/// Gets an existing <typeparamref name="T"/> download request if it exists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">The <typeparamref name="TModel"/> whose request is wanted.</param>
|
/// <param name="item">The <typeparamref name="T"/> whose request is wanted.</param>
|
||||||
/// <returns>The <see cref="ArchiveDownloadRequest{TModel}"/> object if it exists, otherwise null.</returns>
|
/// <returns>The <see cref="ArchiveDownloadRequest{T}"/> object if it exists, otherwise null.</returns>
|
||||||
ArchiveDownloadRequest<TModel> GetExistingDownload(TModel model);
|
ArchiveDownloadRequest<T> GetExistingDownload(T item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Database
|
|||||||
/// Represents a model manager that publishes events when <typeparamref name="TModel"/>s are added or removed.
|
/// Represents a model manager that publishes events when <typeparamref name="TModel"/>s are added or removed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TModel">The model type.</typeparam>
|
/// <typeparam name="TModel">The model type.</typeparam>
|
||||||
public interface IModelManager<TModel> : IModelImporter<TModel>
|
public interface IModelManager<TModel>
|
||||||
where TModel : class
|
where TModel : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -14,39 +14,40 @@ using osu.Game.Overlays.Notifications;
|
|||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
{
|
{
|
||||||
public abstract class ModelDownloader<TModel> : IModelDownloader<TModel>
|
public abstract class ModelDownloader<TModel, T> : IModelDownloader<T>
|
||||||
where TModel : class, IHasPrimaryKey, ISoftDelete, IEquatable<TModel>
|
where TModel : class, IHasPrimaryKey, ISoftDelete, IEquatable<TModel>, T
|
||||||
|
where T : class
|
||||||
{
|
{
|
||||||
public Action<Notification> PostNotification { protected get; set; }
|
public Action<Notification> PostNotification { protected get; set; }
|
||||||
|
|
||||||
public IBindable<WeakReference<ArchiveDownloadRequest<TModel>>> DownloadBegan => downloadBegan;
|
public IBindable<WeakReference<ArchiveDownloadRequest<T>>> DownloadBegan => downloadBegan;
|
||||||
|
|
||||||
private readonly Bindable<WeakReference<ArchiveDownloadRequest<TModel>>> downloadBegan = new Bindable<WeakReference<ArchiveDownloadRequest<TModel>>>();
|
private readonly Bindable<WeakReference<ArchiveDownloadRequest<T>>> downloadBegan = new Bindable<WeakReference<ArchiveDownloadRequest<T>>>();
|
||||||
|
|
||||||
public IBindable<WeakReference<ArchiveDownloadRequest<TModel>>> DownloadFailed => downloadFailed;
|
public IBindable<WeakReference<ArchiveDownloadRequest<T>>> DownloadFailed => downloadFailed;
|
||||||
|
|
||||||
private readonly Bindable<WeakReference<ArchiveDownloadRequest<TModel>>> downloadFailed = new Bindable<WeakReference<ArchiveDownloadRequest<TModel>>>();
|
private readonly Bindable<WeakReference<ArchiveDownloadRequest<T>>> downloadFailed = new Bindable<WeakReference<ArchiveDownloadRequest<T>>>();
|
||||||
|
|
||||||
private readonly IModelManager<TModel> modelManager;
|
private readonly IModelImporter<TModel> importer;
|
||||||
private readonly IAPIProvider api;
|
private readonly IAPIProvider api;
|
||||||
|
|
||||||
protected readonly List<ArchiveDownloadRequest<TModel>> CurrentDownloads = new List<ArchiveDownloadRequest<TModel>>();
|
protected readonly List<ArchiveDownloadRequest<T>> CurrentDownloads = new List<ArchiveDownloadRequest<T>>();
|
||||||
|
|
||||||
protected ModelDownloader(IModelManager<TModel> modelManager, IAPIProvider api, IIpcHost importHost = null)
|
protected ModelDownloader(IModelImporter<TModel> importer, IAPIProvider api, IIpcHost importHost = null)
|
||||||
{
|
{
|
||||||
this.modelManager = modelManager;
|
this.importer = importer;
|
||||||
this.api = api;
|
this.api = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the download request for this <typeparamref name="TModel"/>.
|
/// Creates the download request for this <typeparamref name="T"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">The <typeparamref name="TModel"/> to be downloaded.</param>
|
/// <param name="model">The <typeparamref name="T"/> to be downloaded.</param>
|
||||||
/// <param name="minimiseDownloadSize">Whether this download should be optimised for slow connections. Generally means extras are not included in the download bundle.</param>
|
/// <param name="minimiseDownloadSize">Whether this download should be optimised for slow connections. Generally means extras are not included in the download bundle.</param>
|
||||||
/// <returns>The request object.</returns>
|
/// <returns>The request object.</returns>
|
||||||
protected abstract ArchiveDownloadRequest<TModel> CreateDownloadRequest(TModel model, bool minimiseDownloadSize);
|
protected abstract ArchiveDownloadRequest<T> CreateDownloadRequest(T model, bool minimiseDownloadSize);
|
||||||
|
|
||||||
public bool Download(TModel model, bool minimiseDownloadSize = false)
|
public bool Download(T model, bool minimiseDownloadSize = false)
|
||||||
{
|
{
|
||||||
if (!canDownload(model)) return false;
|
if (!canDownload(model)) return false;
|
||||||
|
|
||||||
@ -68,11 +69,11 @@ namespace osu.Game.Database
|
|||||||
Task.Factory.StartNew(async () =>
|
Task.Factory.StartNew(async () =>
|
||||||
{
|
{
|
||||||
// This gets scheduled back to the update thread, but we want the import to run in the background.
|
// This gets scheduled back to the update thread, but we want the import to run in the background.
|
||||||
var imported = await modelManager.Import(notification, new ImportTask(filename)).ConfigureAwait(false);
|
var imported = await importer.Import(notification, new ImportTask(filename)).ConfigureAwait(false);
|
||||||
|
|
||||||
// for now a failed import will be marked as a failed download for simplicity.
|
// for now a failed import will be marked as a failed download for simplicity.
|
||||||
if (!imported.Any())
|
if (!imported.Any())
|
||||||
downloadFailed.Value = new WeakReference<ArchiveDownloadRequest<TModel>>(request);
|
downloadFailed.Value = new WeakReference<ArchiveDownloadRequest<T>>(request);
|
||||||
|
|
||||||
CurrentDownloads.Remove(request);
|
CurrentDownloads.Remove(request);
|
||||||
}, TaskCreationOptions.LongRunning);
|
}, TaskCreationOptions.LongRunning);
|
||||||
@ -91,25 +92,25 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
api.PerformAsync(request);
|
api.PerformAsync(request);
|
||||||
|
|
||||||
downloadBegan.Value = new WeakReference<ArchiveDownloadRequest<TModel>>(request);
|
downloadBegan.Value = new WeakReference<ArchiveDownloadRequest<T>>(request);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
void triggerFailure(Exception error)
|
void triggerFailure(Exception error)
|
||||||
{
|
{
|
||||||
CurrentDownloads.Remove(request);
|
CurrentDownloads.Remove(request);
|
||||||
|
|
||||||
downloadFailed.Value = new WeakReference<ArchiveDownloadRequest<TModel>>(request);
|
downloadFailed.Value = new WeakReference<ArchiveDownloadRequest<T>>(request);
|
||||||
|
|
||||||
notification.State = ProgressNotificationState.Cancelled;
|
notification.State = ProgressNotificationState.Cancelled;
|
||||||
|
|
||||||
if (!(error is OperationCanceledException))
|
if (!(error is OperationCanceledException))
|
||||||
Logger.Error(error, $"{modelManager.HumanisedModelName.Titleize()} download failed!");
|
Logger.Error(error, $"{importer.HumanisedModelName.Titleize()} download failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract ArchiveDownloadRequest<TModel> GetExistingDownload(TModel model);
|
public abstract ArchiveDownloadRequest<T> GetExistingDownload(T model);
|
||||||
|
|
||||||
private bool canDownload(TModel model) => GetExistingDownload(model) == null && api != null;
|
private bool canDownload(T model) => GetExistingDownload(model) == null && api != null;
|
||||||
|
|
||||||
private class DownloadNotification : ProgressNotification
|
private class DownloadNotification : ProgressNotification
|
||||||
{
|
{
|
||||||
|
@ -6,11 +6,11 @@ using osu.Game.Beatmaps;
|
|||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
public class DownloadBeatmapSetRequest : ArchiveDownloadRequest<BeatmapSetInfo>
|
public class DownloadBeatmapSetRequest : ArchiveDownloadRequest<IBeatmapSetInfo>
|
||||||
{
|
{
|
||||||
private readonly bool noVideo;
|
private readonly bool noVideo;
|
||||||
|
|
||||||
public DownloadBeatmapSetRequest(BeatmapSetInfo set, bool noVideo)
|
public DownloadBeatmapSetRequest(IBeatmapSetInfo set, bool noVideo)
|
||||||
: base(set)
|
: base(set)
|
||||||
{
|
{
|
||||||
this.noVideo = noVideo;
|
this.noVideo = noVideo;
|
||||||
@ -25,6 +25,6 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
protected override string FileExtension => ".osz";
|
protected override string FileExtension => ".osz";
|
||||||
|
|
||||||
protected override string Target => $@"beatmapsets/{Model.OnlineBeatmapSetID}/download{(noVideo ? "?noVideo=1" : "")}";
|
protected override string Target => $@"beatmapsets/{Model.OnlineID}/download{(noVideo ? "?noVideo=1" : "")}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,15 @@ using osu.Game.Scoring;
|
|||||||
|
|
||||||
namespace osu.Game.Online.API.Requests
|
namespace osu.Game.Online.API.Requests
|
||||||
{
|
{
|
||||||
public class DownloadReplayRequest : ArchiveDownloadRequest<ScoreInfo>
|
public class DownloadReplayRequest : ArchiveDownloadRequest<IScoreInfo>
|
||||||
{
|
{
|
||||||
public DownloadReplayRequest(ScoreInfo score)
|
public DownloadReplayRequest(IScoreInfo score)
|
||||||
: base(score)
|
: base(score)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string FileExtension => ".osr";
|
protected override string FileExtension => ".osr";
|
||||||
|
|
||||||
protected override string Target => $@"scores/{Model.Ruleset.ShortName}/{Model.OnlineScoreID}/download";
|
protected override string Target => $@"scores/{Model.Ruleset.ShortName}/{Model.OnlineID}/download";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Online
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
protected BeatmapManager? Manager { get; private set; }
|
protected BeatmapManager? Manager { get; private set; }
|
||||||
|
|
||||||
private ArchiveDownloadRequest<BeatmapSetInfo>? attachedRequest;
|
private ArchiveDownloadRequest<IBeatmapSetInfo>? attachedRequest;
|
||||||
|
|
||||||
public BeatmapDownloadTracker(IBeatmapSetInfo trackedItem)
|
public BeatmapDownloadTracker(IBeatmapSetInfo trackedItem)
|
||||||
: base(trackedItem)
|
: base(trackedItem)
|
||||||
@ -25,8 +25,8 @@ namespace osu.Game.Online
|
|||||||
|
|
||||||
private IBindable<WeakReference<BeatmapSetInfo>>? managerUpdated;
|
private IBindable<WeakReference<BeatmapSetInfo>>? managerUpdated;
|
||||||
private IBindable<WeakReference<BeatmapSetInfo>>? managerRemoved;
|
private IBindable<WeakReference<BeatmapSetInfo>>? managerRemoved;
|
||||||
private IBindable<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>>? managerDownloadBegan;
|
private IBindable<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>>? managerDownloadBegan;
|
||||||
private IBindable<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>>? managerDownloadFailed;
|
private IBindable<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>>? managerDownloadFailed;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load()
|
private void load()
|
||||||
@ -52,7 +52,7 @@ namespace osu.Game.Online
|
|||||||
managerRemoved.BindValueChanged(itemRemoved);
|
managerRemoved.BindValueChanged(itemRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadBegan(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>> weakRequest)
|
private void downloadBegan(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>> weakRequest)
|
||||||
{
|
{
|
||||||
if (weakRequest.NewValue.TryGetTarget(out var request))
|
if (weakRequest.NewValue.TryGetTarget(out var request))
|
||||||
{
|
{
|
||||||
@ -64,7 +64,7 @@ namespace osu.Game.Online
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFailed(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<BeatmapSetInfo>>> weakRequest)
|
private void downloadFailed(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<IBeatmapSetInfo>>> weakRequest)
|
||||||
{
|
{
|
||||||
if (weakRequest.NewValue.TryGetTarget(out var request))
|
if (weakRequest.NewValue.TryGetTarget(out var request))
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ namespace osu.Game.Online
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attachDownload(ArchiveDownloadRequest<BeatmapSetInfo>? request)
|
private void attachDownload(ArchiveDownloadRequest<IBeatmapSetInfo>? request)
|
||||||
{
|
{
|
||||||
if (attachedRequest != null)
|
if (attachedRequest != null)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Online
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
protected ScoreManager? Manager { get; private set; }
|
protected ScoreManager? Manager { get; private set; }
|
||||||
|
|
||||||
private ArchiveDownloadRequest<ScoreInfo>? attachedRequest;
|
private ArchiveDownloadRequest<IScoreInfo>? attachedRequest;
|
||||||
|
|
||||||
public ScoreDownloadTracker(ScoreInfo trackedItem)
|
public ScoreDownloadTracker(ScoreInfo trackedItem)
|
||||||
: base(trackedItem)
|
: base(trackedItem)
|
||||||
@ -25,8 +25,8 @@ namespace osu.Game.Online
|
|||||||
|
|
||||||
private IBindable<WeakReference<ScoreInfo>>? managerUpdated;
|
private IBindable<WeakReference<ScoreInfo>>? managerUpdated;
|
||||||
private IBindable<WeakReference<ScoreInfo>>? managerRemoved;
|
private IBindable<WeakReference<ScoreInfo>>? managerRemoved;
|
||||||
private IBindable<WeakReference<ArchiveDownloadRequest<ScoreInfo>>>? managerDownloadBegan;
|
private IBindable<WeakReference<ArchiveDownloadRequest<IScoreInfo>>>? managerDownloadBegan;
|
||||||
private IBindable<WeakReference<ArchiveDownloadRequest<ScoreInfo>>>? managerDownloadFailed;
|
private IBindable<WeakReference<ArchiveDownloadRequest<IScoreInfo>>>? managerDownloadFailed;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load()
|
private void load()
|
||||||
@ -56,7 +56,7 @@ namespace osu.Game.Online
|
|||||||
managerRemoved.BindValueChanged(itemRemoved);
|
managerRemoved.BindValueChanged(itemRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadBegan(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<ScoreInfo>>> weakRequest)
|
private void downloadBegan(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<IScoreInfo>>> weakRequest)
|
||||||
{
|
{
|
||||||
if (weakRequest.NewValue.TryGetTarget(out var request))
|
if (weakRequest.NewValue.TryGetTarget(out var request))
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ namespace osu.Game.Online
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFailed(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<ScoreInfo>>> weakRequest)
|
private void downloadFailed(ValueChangedEvent<WeakReference<ArchiveDownloadRequest<IScoreInfo>>> weakRequest)
|
||||||
{
|
{
|
||||||
if (weakRequest.NewValue.TryGetTarget(out var request))
|
if (weakRequest.NewValue.TryGetTarget(out var request))
|
||||||
{
|
{
|
||||||
@ -80,7 +80,7 @@ namespace osu.Game.Online
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attachDownload(ArchiveDownloadRequest<ScoreInfo>? request)
|
private void attachDownload(ArchiveDownloadRequest<IScoreInfo>? request)
|
||||||
{
|
{
|
||||||
if (attachedRequest != null)
|
if (attachedRequest != null)
|
||||||
{
|
{
|
||||||
@ -144,7 +144,7 @@ namespace osu.Game.Online
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool checkEquality(ScoreInfo x, ScoreInfo y) => x.OnlineScoreID == y.OnlineScoreID;
|
private bool checkEquality(IScoreInfo x, IScoreInfo y) => x.OnlineID == y.OnlineID;
|
||||||
|
|
||||||
#region Disposal
|
#region Disposal
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -66,8 +67,16 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
if (value?.Scores.Any() != true)
|
if (value?.Scores.Any() != true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
var apiBeatmap = Beatmap.Value;
|
||||||
|
|
||||||
|
Debug.Assert(apiBeatmap != null);
|
||||||
|
|
||||||
// TODO: temporary. should be removed once `OrderByTotalScore` can accept `IScoreInfo`.
|
// TODO: temporary. should be removed once `OrderByTotalScore` can accept `IScoreInfo`.
|
||||||
var beatmapInfo = new BeatmapInfo { MaxCombo = Beatmap.Value.MaxCombo };
|
var beatmapInfo = new BeatmapInfo
|
||||||
|
{
|
||||||
|
MaxCombo = apiBeatmap.MaxCombo,
|
||||||
|
Status = apiBeatmap.Status
|
||||||
|
};
|
||||||
|
|
||||||
scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, beatmapInfo)).ToArray(), loadCancellationSource.Token)
|
scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.CreateScoreInfo(rulesets, beatmapInfo)).ToArray(), loadCancellationSource.Token)
|
||||||
.ContinueWith(ordered => Schedule(() =>
|
.ContinueWith(ordered => Schedule(() =>
|
||||||
@ -77,7 +86,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
|
|
||||||
var topScore = ordered.Result.First();
|
var topScore = ordered.Result.First();
|
||||||
|
|
||||||
scoreTable.DisplayScores(ordered.Result, topScore.BeatmapInfo?.Status.GrantsPerformancePoints() == true);
|
scoreTable.DisplayScores(ordered.Result, apiBeatmap.Status.GrantsPerformancePoints());
|
||||||
scoreTable.Show();
|
scoreTable.Show();
|
||||||
|
|
||||||
var userScore = value.UserScore;
|
var userScore = value.UserScore;
|
||||||
|
@ -25,7 +25,7 @@ using osu.Game.Rulesets.Scoring;
|
|||||||
|
|
||||||
namespace osu.Game.Scoring
|
namespace osu.Game.Scoring
|
||||||
{
|
{
|
||||||
public class ScoreManager : IModelManager<ScoreInfo>, IModelFileManager<ScoreInfo, ScoreFileInfo>, IModelDownloader<ScoreInfo>
|
public class ScoreManager : IModelManager<ScoreInfo>, IModelImporter<ScoreInfo>, IModelFileManager<ScoreInfo, ScoreFileInfo>, IModelDownloader<IScoreInfo>
|
||||||
{
|
{
|
||||||
private readonly Scheduler scheduler;
|
private readonly Scheduler scheduler;
|
||||||
private readonly Func<BeatmapDifficultyCache> difficulties;
|
private readonly Func<BeatmapDifficultyCache> difficulties;
|
||||||
@ -350,16 +350,14 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
#region Implementation of IModelDownloader<ScoreInfo>
|
#region Implementation of IModelDownloader<ScoreInfo>
|
||||||
|
|
||||||
public IBindable<WeakReference<ArchiveDownloadRequest<ScoreInfo>>> DownloadBegan => scoreModelDownloader.DownloadBegan;
|
public IBindable<WeakReference<ArchiveDownloadRequest<IScoreInfo>>> DownloadBegan => scoreModelDownloader.DownloadBegan;
|
||||||
|
|
||||||
public IBindable<WeakReference<ArchiveDownloadRequest<ScoreInfo>>> DownloadFailed => scoreModelDownloader.DownloadFailed;
|
public IBindable<WeakReference<ArchiveDownloadRequest<IScoreInfo>>> DownloadFailed => scoreModelDownloader.DownloadFailed;
|
||||||
|
|
||||||
public bool Download(ScoreInfo model, bool minimiseDownloadSize)
|
public bool Download(IScoreInfo model, bool minimiseDownloadSize) =>
|
||||||
{
|
scoreModelDownloader.Download(model, minimiseDownloadSize);
|
||||||
return scoreModelDownloader.Download(model, minimiseDownloadSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArchiveDownloadRequest<ScoreInfo> GetExistingDownload(ScoreInfo model)
|
public ArchiveDownloadRequest<IScoreInfo> GetExistingDownload(IScoreInfo model)
|
||||||
{
|
{
|
||||||
return scoreModelDownloader.GetExistingDownload(model);
|
return scoreModelDownloader.GetExistingDownload(model);
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,16 @@ using osu.Game.Online.API.Requests;
|
|||||||
|
|
||||||
namespace osu.Game.Scoring
|
namespace osu.Game.Scoring
|
||||||
{
|
{
|
||||||
public class ScoreModelDownloader : ModelDownloader<ScoreInfo>
|
public class ScoreModelDownloader : ModelDownloader<ScoreInfo, IScoreInfo>
|
||||||
{
|
{
|
||||||
public ScoreModelDownloader(ScoreModelManager scoreManager, IAPIProvider api, IIpcHost importHost = null)
|
public ScoreModelDownloader(IModelImporter<ScoreInfo> scoreManager, IAPIProvider api, IIpcHost importHost = null)
|
||||||
: base(scoreManager, api, importHost)
|
: base(scoreManager, api, importHost)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ArchiveDownloadRequest<ScoreInfo> CreateDownloadRequest(ScoreInfo score, bool minimiseDownload) => new DownloadReplayRequest(score);
|
protected override ArchiveDownloadRequest<IScoreInfo> CreateDownloadRequest(IScoreInfo score, bool minimiseDownload) => new DownloadReplayRequest(score);
|
||||||
|
|
||||||
public override ArchiveDownloadRequest<ScoreInfo> GetExistingDownload(ScoreInfo model)
|
public override ArchiveDownloadRequest<IScoreInfo> GetExistingDownload(IScoreInfo model)
|
||||||
=> CurrentDownloads.Find(r => r.Model.OnlineScoreID == model.OnlineScoreID);
|
=> CurrentDownloads.Find(r => r.Model.OnlineID == model.OnlineID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user