apply suggestions

- apply 0 alpha to beatmap background if storyboard replaces it
- use an AudioContainer to mute all samples coming from the storyboard
This commit is contained in:
Nathan Alo 2021-06-04 13:56:10 +08:00
parent d7d0dde5d2
commit 996c156106
1 changed files with 9 additions and 18 deletions

View File

@ -1,13 +1,11 @@
// 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.
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Storyboards;
using osu.Game.Storyboards.Drawables;
namespace osu.Game.Graphics.Backgrounds
@ -22,24 +20,17 @@ public BeatmapBackgroundWithStoryboard(WorkingBeatmap beatmap, string fallbackTe
[BackgroundDependencyLoader]
private void load()
{
var storyboard = new Storyboard { BeatmapInfo = Beatmap.BeatmapInfo };
foreach (var layer in storyboard.Layers)
{
if (layer.Name != "Fail")
layer.Elements = Beatmap.Storyboard.GetLayer(layer.Name).Elements.Where(e => !(e is StoryboardSampleInfo)).ToList();
}
if (!storyboard.HasDrawable)
if (!Beatmap.Storyboard.HasDrawable)
return;
if (storyboard.ReplacesBackground)
{
Sprite.Texture = Texture.WhitePixel;
Sprite.Colour = Colour4.Black;
}
if (Beatmap.Storyboard.ReplacesBackground)
Sprite.Alpha = 0;
LoadComponentAsync(new DrawableStoryboard(storyboard) { Clock = new InterpolatingFramedClock(Beatmap.Track) }, AddInternal);
var audio = new AudioContainer { RelativeSizeAxes = Axes.Both };
audio.Volume.Value = 0;
AddInternal(audio);
LoadComponentAsync(new DrawableStoryboard(Beatmap.Storyboard) { Clock = new InterpolatingFramedClock(Beatmap.Track) }, audio.Add);
}
}
}