From 21b641b302e8952e23cb6245022c976530d7b028 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 16 Feb 2018 12:07:59 +0900 Subject: [PATCH 1/4] Give storyboards a BeatmapInfo to reduce weird method calls Also removes unnecessary background texture (the actual storyboard background spec wasn't implemented correctly anyway). --- .../Beatmaps/BeatmapManager_WorkingBeatmap.cs | 19 ++++++++++---- osu.Game/Beatmaps/WorkingBeatmap.cs | 2 +- .../Drawables/DrawableStoryboard.cs | 18 ------------- osu.Game/Storyboards/Storyboard.cs | 26 ++++++++----------- 4 files changed, 26 insertions(+), 39 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs index 14a4028b44..07d05f470e 100644 --- a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs @@ -75,23 +75,32 @@ namespace osu.Game.Beatmaps protected override Storyboard GetStoryboard() { + Storyboard storyboard; try { using (var beatmap = new StreamReader(store.GetStream(getPathForFile(BeatmapInfo.Path)))) { Decoder decoder = Decoder.GetDecoder(beatmap); - if (BeatmapSetInfo?.StoryboardFile == null) - return decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap); + // todo: support loading from both set-wide storyboard *and* baetmap specific. - using (var storyboard = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile)))) - return decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap, storyboard); + if (BeatmapSetInfo?.StoryboardFile == null) + storyboard = decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap); + else + { + using (var reader = new StreamReader(store.GetStream(getPathForFile(BeatmapSetInfo.StoryboardFile)))) + storyboard = decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap, reader); + } } } catch { - return new Storyboard(); + storyboard = new Storyboard(); } + + storyboard.BeatmapInfo = BeatmapInfo; + + return storyboard; } } } diff --git a/osu.Game/Beatmaps/WorkingBeatmap.cs b/osu.Game/Beatmaps/WorkingBeatmap.cs index c633b94951..8a2a7b01a1 100644 --- a/osu.Game/Beatmaps/WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/WorkingBeatmap.cs @@ -57,7 +57,7 @@ namespace osu.Game.Beatmaps protected abstract Texture GetBackground(); protected abstract Track GetTrack(); protected virtual Waveform GetWaveform() => new Waveform(); - protected virtual Storyboard GetStoryboard() => new Storyboard(); + protected virtual Storyboard GetStoryboard() => new Storyboard { BeatmapInfo = BeatmapInfo }; public bool BeatmapLoaded => beatmap.IsResultAvailable; public Beatmap Beatmap => beatmap.Value.Result; diff --git a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs index 2489369493..aaeaaabd55 100644 --- a/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs +++ b/osu.Game/Storyboards/Drawables/DrawableStoryboard.cs @@ -5,7 +5,6 @@ using OpenTK; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.IO; @@ -15,13 +14,6 @@ namespace osu.Game.Storyboards.Drawables { public Storyboard Storyboard { get; private set; } - private readonly Background background; - public Texture BackgroundTexture - { - get { return background.Texture; } - set { background.Texture = value; } - } - private readonly Container content; protected override Container Content => content; @@ -52,11 +44,6 @@ namespace osu.Game.Storyboards.Drawables Anchor = Anchor.Centre; Origin = Anchor.Centre; - AddInternal(background = new Background - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - }); AddInternal(content = new Container { Size = new Vector2(640, 480), @@ -79,10 +66,5 @@ namespace osu.Game.Storyboards.Drawables foreach (var layer in Children) layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing; } - - private class Background : Sprite - { - protected override Vector2 DrawScale => Texture != null ? new Vector2(Parent.DrawHeight / Texture.DisplayHeight) : base.DrawScale; - } } } diff --git a/osu.Game/Storyboards/Storyboard.cs b/osu.Game/Storyboards/Storyboard.cs index e2587debc9..9d4efadc81 100644 --- a/osu.Game/Storyboards/Storyboard.cs +++ b/osu.Game/Storyboards/Storyboard.cs @@ -14,6 +14,8 @@ namespace osu.Game.Storyboards private readonly Dictionary layers = new Dictionary(); public IEnumerable Layers => layers.Values; + public BeatmapInfo BeatmapInfo = new BeatmapInfo(); + public bool HasDrawable => Layers.Any(l => l.Elements.Any(e => e.IsDrawable)); public Storyboard() @@ -36,28 +38,22 @@ namespace osu.Game.Storyboards /// /// Whether the beatmap's background should be hidden while this storyboard is being displayed. /// - public bool ReplacesBackground(BeatmapInfo beatmapInfo) + public bool ReplacesBackground { - var backgroundPath = beatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant(); - if (backgroundPath == null) - return false; + get + { + var backgroundPath = BeatmapInfo.BeatmapSet?.Metadata?.BackgroundFile?.ToLowerInvariant(); + if (backgroundPath == null) + return false; - return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath); + return GetLayer("Background").Elements.Any(e => e.Path.ToLowerInvariant() == backgroundPath); + } } - public float AspectRatio(BeatmapInfo beatmapInfo) - => beatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f; - public DrawableStoryboard CreateDrawable(WorkingBeatmap working = null) { var drawable = new DrawableStoryboard(this); - if (working != null) - { - var beatmapInfo = working.Beatmap.BeatmapInfo; - drawable.Width = drawable.Height * AspectRatio(beatmapInfo); - if (!ReplacesBackground(beatmapInfo)) - drawable.BackgroundTexture = working.Background; - } + drawable.Width = drawable.Height * (BeatmapInfo.WidescreenStoryboard ? 16 / 9f : 4 / 3f); return drawable; } From e0faf14a3e6ac549608acc2f304abeeb4e381974 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 Feb 2018 12:33:07 +0900 Subject: [PATCH 2/4] Actually consume ReplacesBackground --- osu.Game/Screens/Play/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 5df88b2b23..4954618ef9 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -387,7 +387,7 @@ namespace osu.Game.Screens.Play .FadeTo(storyboardVisible && opacity > 0 ? 1 : 0, duration, Easing.OutQuint); (Background as BackgroundScreenBeatmap)?.BlurTo(new Vector2((float)blurLevel.Value * 25), duration, Easing.OutQuint); - Background?.FadeTo(!storyboardVisible || beatmap.Background == null ? opacity : 0, duration, Easing.OutQuint); + Background?.FadeTo(beatmap.Background != null && (!storyboardVisible || !beatmap.Storyboard.ReplacesBackground) ? opacity : 0, duration, Easing.OutQuint); } private void fadeOut() From a7915e70415a5c49f13ba5c2a4ccbb8781008dd0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 Feb 2018 14:00:48 +0900 Subject: [PATCH 3/4] Fix typo --- osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs index 07d05f470e..a72c1adfcd 100644 --- a/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs +++ b/osu.Game/Beatmaps/BeatmapManager_WorkingBeatmap.cs @@ -82,7 +82,7 @@ namespace osu.Game.Beatmaps { Decoder decoder = Decoder.GetDecoder(beatmap); - // todo: support loading from both set-wide storyboard *and* baetmap specific. + // todo: support loading from both set-wide storyboard *and* beatmap specific. if (BeatmapSetInfo?.StoryboardFile == null) storyboard = decoder.GetStoryboardDecoder().DecodeStoryboard(beatmap); From d70d40e3b8f5d6919b030281df21847c9eceffdb Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 Feb 2018 15:52:14 +0900 Subject: [PATCH 4/4] Add back forgotten score store to valid importers --- osu.Game/OsuGameBase.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index de2a4d0b82..8974275da2 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -118,6 +118,7 @@ namespace osu.Game dependencies.Cache(new OsuColour()); fileImporters.Add(BeatmapManager); + fileImporters.Add(ScoreStore); //this completely overrides the framework default. will need to change once we make a proper FontStore. dependencies.Cache(Fonts = new FontStore { ScaleAdjust = 100 });