2019-07-09 15:23:59 +08:00
|
|
|
// 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;
|
2019-07-12 10:50:06 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2019-07-09 15:23:59 +08:00
|
|
|
using osu.Game.Storyboards;
|
|
|
|
using osu.Game.Storyboards.Drawables;
|
|
|
|
|
2019-07-12 10:50:06 +08:00
|
|
|
namespace osu.Game.Screens.Play
|
2019-07-09 15:23:59 +08:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A container that handles <see cref="Storyboard"/> loading, as well as applies user-specified visual settings to it.
|
|
|
|
/// </summary>
|
2019-07-12 10:50:06 +08:00
|
|
|
public class DimmableStoryboard : UserDimContainer
|
2019-07-09 15:23:59 +08:00
|
|
|
{
|
|
|
|
private readonly Storyboard storyboard;
|
|
|
|
private DrawableStoryboard drawableStoryboard;
|
|
|
|
|
2019-07-12 10:50:06 +08:00
|
|
|
public DimmableStoryboard(Storyboard storyboard)
|
2019-07-09 15:23:59 +08:00
|
|
|
{
|
|
|
|
this.storyboard = storyboard;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
initializeStoryboard(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
2019-07-10 11:24:05 +08:00
|
|
|
ShowStoryboard.BindValueChanged(_ => initializeStoryboard(true), true);
|
2019-07-09 15:23:59 +08:00
|
|
|
base.LoadComplete();
|
|
|
|
}
|
|
|
|
|
2019-11-24 15:42:39 +08:00
|
|
|
protected override bool ShowDimContent => IgnoreUserSettings.Value || (ShowStoryboard.Value && DimLevel < 1);
|
2019-07-09 15:23:59 +08:00
|
|
|
|
|
|
|
private void initializeStoryboard(bool async)
|
|
|
|
{
|
|
|
|
if (drawableStoryboard != null)
|
|
|
|
return;
|
|
|
|
|
2019-11-24 15:37:06 +08:00
|
|
|
if (!ShowStoryboard.Value && !IgnoreUserSettings.Value)
|
2019-07-09 15:23:59 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
drawableStoryboard = storyboard.CreateDrawable();
|
|
|
|
drawableStoryboard.Masking = true;
|
|
|
|
|
|
|
|
if (async)
|
|
|
|
LoadComponentAsync(drawableStoryboard, Add);
|
|
|
|
else
|
|
|
|
Add(drawableStoryboard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|