1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 19:53:21 +08:00
osu-lazer/osu.Game/Graphics/Backgrounds/BeatmapBackgroundWithStoryboard.cs
Nathan Alo 996c156106 apply suggestions
- apply 0 alpha to beatmap background if storyboard replaces it
- use an AudioContainer to mute all samples coming from the storyboard
2021-06-04 13:56:10 +08:00

37 lines
1.2 KiB
C#

// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Storyboards.Drawables;
namespace osu.Game.Graphics.Backgrounds
{
public class BeatmapBackgroundWithStoryboard : BeatmapBackground
{
public BeatmapBackgroundWithStoryboard(WorkingBeatmap beatmap, string fallbackTextureName = "Backgrounds/bg1")
: base(beatmap, fallbackTextureName)
{
}
[BackgroundDependencyLoader]
private void load()
{
if (!Beatmap.Storyboard.HasDrawable)
return;
if (Beatmap.Storyboard.ReplacesBackground)
Sprite.Alpha = 0;
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);
}
}
}