From 4f491519848cc9afab5babcaa56fd28171ffdc11 Mon Sep 17 00:00:00 2001 From: Huo Yaoyuan Date: Mon, 1 May 2017 21:29:57 +0800 Subject: [PATCH] Make metadata a member of WorkingBeatmap. --- osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/WorkingBeatmap.cs | 7 +++++-- osu.Game/Database/BeatmapDatabase.cs | 4 +++- osu.Game/Database/DatabaseWorkingBeatmap.cs | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs index 5e3f5b5133..b45574b761 100644 --- a/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs +++ b/osu.Desktop.VisualTests/Beatmaps/TestWorkingBeatmap.cs @@ -10,7 +10,7 @@ namespace osu.Desktop.VisualTests.Beatmaps public class TestWorkingBeatmap : WorkingBeatmap { public TestWorkingBeatmap(Beatmap beatmap) - : base(beatmap.BeatmapInfo, beatmap.BeatmapInfo.BeatmapSet) + : base(beatmap.BeatmapInfo) { this.beatmap = beatmap; } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index 589557b088..09a6ea7065 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -18,14 +18,17 @@ namespace osu.Game.Beatmaps public readonly BeatmapSetInfo BeatmapSetInfo; + public readonly BeatmapMetadata Metadata; + public readonly Bindable> Mods = new Bindable>(new Mod[] { }); public readonly bool WithStoryboard; - protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) + protected WorkingBeatmap(BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) { BeatmapInfo = beatmapInfo; - BeatmapSetInfo = beatmapSetInfo; + BeatmapSetInfo = beatmapSetInfo ?? beatmapInfo?.BeatmapSet; + Metadata = metadata ?? beatmapInfo?.Metadata ?? BeatmapSetInfo?.Metadata; WithStoryboard = withStoryboard; Mods.ValueChanged += mods => applyRateAdjustments(); diff --git a/osu.Game/Database/BeatmapDatabase.cs b/osu.Game/Database/BeatmapDatabase.cs index 0e814dea82..6f4559bc52 100644 --- a/osu.Game/Database/BeatmapDatabase.cs +++ b/osu.Game/Database/BeatmapDatabase.cs @@ -274,6 +274,8 @@ namespace osu.Game.Database if (beatmapSetInfo == null) throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database."); + beatmapInfo.BeatmapSet = beatmapSetInfo; + //we need metadata GetChildren(beatmapSetInfo); //we also need a ruleset @@ -282,7 +284,7 @@ namespace osu.Game.Database if (beatmapInfo.Metadata == null) beatmapInfo.Metadata = beatmapSetInfo.Metadata; - WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, beatmapSetInfo, withStoryboard); + WorkingBeatmap working = new DatabaseWorkingBeatmap(this, beatmapInfo, withStoryboard: withStoryboard); previous?.TransferTo(working); diff --git a/osu.Game/Database/DatabaseWorkingBeatmap.cs b/osu.Game/Database/DatabaseWorkingBeatmap.cs index 9fb3bed1e7..d3d5220e7f 100644 --- a/osu.Game/Database/DatabaseWorkingBeatmap.cs +++ b/osu.Game/Database/DatabaseWorkingBeatmap.cs @@ -14,8 +14,8 @@ namespace osu.Game.Database { private readonly BeatmapDatabase database; - public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo, bool withStoryboard = false) - : base(beatmapInfo, beatmapSetInfo, withStoryboard) + public DatabaseWorkingBeatmap(BeatmapDatabase database, BeatmapInfo beatmapInfo, BeatmapSetInfo beatmapSetInfo = null, BeatmapMetadata metadata = null, bool withStoryboard = false) + : base(beatmapInfo, beatmapSetInfo, metadata, withStoryboard) { this.database = database; }