From a0e25d18cd5f809bfade52754a652d318d47a805 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 15 Nov 2021 18:24:00 +0900 Subject: [PATCH] Expose more of `WorkingBeatmap` via interface --- osu.Game/Beatmaps/IWorkingBeatmap.cs | 65 +++++++++++++++++++++++++--- osu.Game/Beatmaps/WorkingBeatmap.cs | 21 ++++----- 2 files changed, 66 insertions(+), 20 deletions(-) diff --git a/osu.Game/Beatmaps/IWorkingBeatmap.cs b/osu.Game/Beatmaps/IWorkingBeatmap.cs index a916b37b85..22a922db59 100644 --- a/osu.Game/Beatmaps/IWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/IWorkingBeatmap.cs @@ -17,33 +17,69 @@ namespace osu.Game.Beatmaps { public interface IWorkingBeatmap { + IBeatmapInfo BeatmapInfo { get; } + + IBeatmapSetInfo BeatmapSetInfo => BeatmapInfo.BeatmapSet; + + IBeatmapMetadataInfo Metadata => BeatmapInfo.Metadata; + /// - /// Retrieves the which this represents. + /// Whether the Beatmap has finished loading. + /// + public bool BeatmapLoaded { get; } + + /// + /// Whether the Background has finished loading. + /// + public bool BackgroundLoaded { get; } + + /// + /// Whether the Waveform has finished loading. + /// + public bool WaveformLoaded { get; } + + /// + /// Whether the Storyboard has finished loading. + /// + public bool StoryboardLoaded { get; } + + /// + /// Whether the Skin has finished loading. + /// + public bool SkinLoaded { get; } + + /// + /// Whether the Track has finished loading. + /// + public bool TrackLoaded { get; } + + /// + /// Retrieves the which this represents. /// IBeatmap Beatmap { get; } /// - /// Retrieves the background for this . + /// Retrieves the background for this . /// Texture Background { get; } /// - /// Retrieves the for the of this . + /// Retrieves the for the of this . /// Waveform Waveform { get; } /// - /// Retrieves the which this provides. + /// Retrieves the which this provides. /// Storyboard Storyboard { get; } /// - /// Retrieves the which this provides. + /// Retrieves the which this provides. /// ISkin Skin { get; } /// - /// Retrieves the which this has loaded. + /// Retrieves the which this has loaded. /// Track Track { get; } @@ -67,7 +103,7 @@ public interface IWorkingBeatmap /// /// /// In a standard game context, the loading of the track is managed solely by MusicController, which will - /// automatically load the track of the current global IBindable WorkingBeatmap. + /// automatically load the track of the current global IBindable IWorkingBeatmap. /// As such, this method should only be called in very special scenarios, such as external tests or apps which are /// outside of the game context. /// @@ -79,5 +115,20 @@ public interface IWorkingBeatmap /// /// The storage path to the file. Stream GetStream(string storagePath); + + /// + /// Beings loading the contents of this asynchronously. + /// + public void BeginAsyncLoad(); + + /// + /// Cancels the asynchronous loading of the contents of this . + /// + public void CancelAsyncLoad(); + + /// + /// Reads the correct track restart point from beatmap metadata and sets looping to enabled. + /// + void PrepareTrackForPreviewLooping(); } } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index d2c0f7de0f..51eea94d3a 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -28,8 +28,10 @@ public abstract class WorkingBeatmap : IWorkingBeatmap { public readonly BeatmapInfo BeatmapInfo; + // ReSharper disable once FieldHidesInterfacePropertyWithDefaultImplementation public readonly BeatmapSetInfo BeatmapSetInfo; + // ReSharper disable once FieldHidesInterfacePropertyWithDefaultImplementation public readonly BeatmapMetadata Metadata; protected AudioManager AudioManager { get; } @@ -89,6 +91,9 @@ public virtual IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList - /// Beings loading the contents of this asynchronously. - /// - public void BeginAsyncLoad() - { - loadBeatmapAsync(); - } + public void BeginAsyncLoad() => loadBeatmapAsync(); - /// - /// Cancels the asynchronous loading of the contents of this . - /// public void CancelAsyncLoad() { lock (beatmapFetchLock) @@ -234,6 +230,8 @@ private Task loadBeatmapAsync() public virtual bool BeatmapLoaded => beatmapLoadTask?.IsCompleted ?? false; + IBeatmapInfo IWorkingBeatmap.BeatmapInfo => BeatmapInfo; + public IBeatmap Beatmap { get @@ -273,9 +271,6 @@ public IBeatmap Beatmap [NotNull] public Track LoadTrack() => loadedTrack = GetBeatmapTrack() ?? GetVirtualTrack(1000); - /// - /// Reads the correct track restart point from beatmap metadata and sets looping to enabled. - /// public void PrepareTrackForPreviewLooping() { Track.Looping = true;