mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:12:56 +08:00
Move classes to local namespaces
Also renames test scene to more appropriate name.
This commit is contained in:
parent
b5ca7faca4
commit
46f7bb885b
@ -38,7 +38,7 @@ using osuTK.Graphics;
|
||||
namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneBackgroundScreenBeatmap : ManualInputManagerTestScene
|
||||
public class TestSceneUserDimContainer : ManualInputManagerTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
@ -243,7 +243,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
player.StoryboardEnabled.Value = false;
|
||||
player.ReplacesBackground.Value = false;
|
||||
player.CurrentDimmableStoryboardContainer.Add(new OsuSpriteText
|
||||
player.DimmableStoryboard.Add(new OsuSpriteText
|
||||
{
|
||||
Size = new Vector2(500, 50),
|
||||
Alpha = 1,
|
||||
@ -336,9 +336,9 @@ namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
|
||||
protected override DimmableStoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new TestDimmableStoryboardContainer { RelativeSizeAxes = Axes.Both };
|
||||
protected override DimmableStoryboard CreateStoryboardContainer(Storyboard storyboard) => new TestDimmableStoryboard { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public TestDimmableStoryboardContainer CurrentDimmableStoryboardContainer => (TestDimmableStoryboardContainer)DimmableStoryboardContainer;
|
||||
public new TestDimmableStoryboard DimmableStoryboard => (TestDimmableStoryboard)base.DimmableStoryboard;
|
||||
|
||||
// Whether or not the player should be allowed to load.
|
||||
public bool BlockLoad;
|
||||
@ -352,9 +352,9 @@ namespace osu.Game.Tests.Visual.Background
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsStoryboardVisible() => CurrentDimmableStoryboardContainer.CurrentAlpha == 1;
|
||||
public bool IsStoryboardVisible() => DimmableStoryboard.CurrentAlpha == 1;
|
||||
|
||||
public bool IsStoryboardInvisible() => CurrentDimmableStoryboardContainer.CurrentAlpha <= 1;
|
||||
public bool IsStoryboardInvisible() => DimmableStoryboard.CurrentAlpha <= 1;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config, CancellationToken token)
|
||||
@ -387,15 +387,15 @@ namespace osu.Game.Tests.Visual.Background
|
||||
|
||||
private class FadeAccessibleBackground : BackgroundScreenBeatmap
|
||||
{
|
||||
protected override DimmableBackgroundContainer CreateFadeContainer() => fadeContainer = new TestDimmableBackgroundContainer { RelativeSizeAxes = Axes.Both };
|
||||
protected override DimmableBackground CreateFadeContainer() => dimmable = new TestDimmableBackground { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public Color4 CurrentColour => fadeContainer.CurrentColour;
|
||||
public Color4 CurrentColour => dimmable.CurrentColour;
|
||||
|
||||
public float CurrentAlpha => fadeContainer.CurrentAlpha;
|
||||
public float CurrentAlpha => dimmable.CurrentAlpha;
|
||||
|
||||
public Vector2 CurrentBlur => Background.BlurSigma;
|
||||
|
||||
private TestDimmableBackgroundContainer fadeContainer;
|
||||
private TestDimmableBackground dimmable;
|
||||
|
||||
public FadeAccessibleBackground(WorkingBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
@ -403,17 +403,17 @@ namespace osu.Game.Tests.Visual.Background
|
||||
}
|
||||
}
|
||||
|
||||
private class TestDimmableStoryboardContainer : DimmableStoryboardContainer
|
||||
private class TestDimmableStoryboard : DimmableStoryboard
|
||||
{
|
||||
public float CurrentAlpha => Content.Alpha;
|
||||
|
||||
public TestDimmableStoryboardContainer()
|
||||
public TestDimmableStoryboard()
|
||||
: base(new Storyboard())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private class TestDimmableBackgroundContainer : DimmableBackgroundContainer
|
||||
private class TestDimmableBackground : BackgroundScreenBeatmap.DimmableBackground
|
||||
{
|
||||
public Color4 CurrentColour => Content.Colour;
|
||||
public float CurrentAlpha => Content.Alpha;
|
@ -1,71 +0,0 @@
|
||||
// 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;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
public class DimmableBackgroundContainer : UserDimContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of blur to be applied to the background in addition to user-specified blur.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in <see cref="PlayerLoader"/>
|
||||
/// </remarks>
|
||||
public readonly Bindable<float> BlurAmount = new Bindable<float>();
|
||||
|
||||
public Background Background
|
||||
{
|
||||
get => background;
|
||||
set
|
||||
{
|
||||
base.Add(background = value);
|
||||
background.BlurTo(blurTarget, 0, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
private Bindable<double> userBlurLevel { get; set; }
|
||||
|
||||
private Background background;
|
||||
|
||||
public override void Add(Drawable drawable)
|
||||
{
|
||||
if (drawable is Background)
|
||||
throw new InvalidOperationException($"Use {nameof(Background)} to set a background.");
|
||||
|
||||
base.Add(drawable);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs.
|
||||
/// </summary>
|
||||
private Vector2 blurTarget => EnableUserDim.Value
|
||||
? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25)
|
||||
: new Vector2(BlurAmount.Value);
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
userBlurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
|
||||
userBlurLevel.ValueChanged += _ => UpdateVisuals();
|
||||
BlurAmount.ValueChanged += _ => UpdateVisuals();
|
||||
}
|
||||
|
||||
protected override bool ShowDimContent => !ShowStoryboard.Value || !StoryboardReplacesBackground.Value; // The background needs to be hidden in the case of it being replaced by the storyboard
|
||||
|
||||
protected override void UpdateVisuals()
|
||||
{
|
||||
base.UpdateVisuals();
|
||||
|
||||
Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,18 @@
|
||||
// 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;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Backgrounds
|
||||
{
|
||||
@ -30,16 +34,17 @@ namespace osu.Game.Screens.Backgrounds
|
||||
/// </summary>
|
||||
public readonly Bindable<float> BlurAmount = new Bindable<float>();
|
||||
|
||||
private readonly DimmableBackgroundContainer fadeContainer;
|
||||
private readonly DimmableBackground dimmable;
|
||||
|
||||
protected virtual DimmableBackgroundContainer CreateFadeContainer() => new DimmableBackgroundContainer { RelativeSizeAxes = Axes.Both };
|
||||
protected virtual DimmableBackground CreateFadeContainer() => new DimmableBackground { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
public BackgroundScreenBeatmap(WorkingBeatmap beatmap = null)
|
||||
{
|
||||
Beatmap = beatmap;
|
||||
InternalChild = fadeContainer = CreateFadeContainer();
|
||||
fadeContainer.EnableUserDim.BindTo(EnableUserDim);
|
||||
fadeContainer.BlurAmount.BindTo(BlurAmount);
|
||||
|
||||
InternalChild = dimmable = CreateFadeContainer();
|
||||
dimmable.EnableUserDim.BindTo(EnableUserDim);
|
||||
dimmable.BlurAmount.BindTo(BlurAmount);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -86,8 +91,8 @@ namespace osu.Game.Screens.Backgrounds
|
||||
}
|
||||
|
||||
b.Depth = newDepth;
|
||||
fadeContainer.Background = Background = b;
|
||||
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
||||
dimmable.Background = Background = b;
|
||||
StoryboardReplacesBackground.BindTo(dimmable.StoryboardReplacesBackground);
|
||||
}
|
||||
|
||||
public override bool Equals(BackgroundScreen other)
|
||||
@ -112,5 +117,62 @@ namespace osu.Game.Screens.Backgrounds
|
||||
Sprite.Texture = Beatmap?.Background ?? textures.Get(@"Backgrounds/bg1");
|
||||
}
|
||||
}
|
||||
|
||||
public class DimmableBackground : UserDimContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of blur to be applied to the background in addition to user-specified blur.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in <see cref="PlayerLoader"/>
|
||||
/// </remarks>
|
||||
public readonly Bindable<float> BlurAmount = new Bindable<float>();
|
||||
|
||||
public Background Background
|
||||
{
|
||||
get => background;
|
||||
set
|
||||
{
|
||||
base.Add(background = value);
|
||||
background.BlurTo(blurTarget, 0, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
private Bindable<double> userBlurLevel { get; set; }
|
||||
|
||||
private Background background;
|
||||
|
||||
public override void Add(Drawable drawable)
|
||||
{
|
||||
if (drawable is Background)
|
||||
throw new InvalidOperationException($"Use {nameof(Background)} to set a background.");
|
||||
|
||||
base.Add(drawable);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs.
|
||||
/// </summary>
|
||||
private Vector2 blurTarget => EnableUserDim.Value
|
||||
? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25)
|
||||
: new Vector2(BlurAmount.Value);
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
userBlurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
|
||||
userBlurLevel.ValueChanged += _ => UpdateVisuals();
|
||||
BlurAmount.ValueChanged += _ => UpdateVisuals();
|
||||
}
|
||||
|
||||
protected override bool ShowDimContent => !ShowStoryboard.Value || !StoryboardReplacesBackground.Value; // The background needs to be hidden in the case of it being replaced by the storyboard
|
||||
|
||||
protected override void UpdateVisuals()
|
||||
{
|
||||
base.UpdateVisuals();
|
||||
|
||||
Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,20 +2,21 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Storyboards.Drawables;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
/// <summary>
|
||||
/// A container that handles <see cref="Storyboard"/> loading, as well as applies user-specified visual settings to it.
|
||||
/// </summary>
|
||||
public class DimmableStoryboardContainer : UserDimContainer
|
||||
public class DimmableStoryboard : UserDimContainer
|
||||
{
|
||||
private readonly Storyboard storyboard;
|
||||
private DrawableStoryboard drawableStoryboard;
|
||||
|
||||
public DimmableStoryboardContainer(Storyboard storyboard)
|
||||
public DimmableStoryboard(Storyboard storyboard)
|
||||
{
|
||||
this.storyboard = storyboard;
|
||||
}
|
@ -76,9 +76,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
protected GameplayClockContainer GameplayClockContainer { get; private set; }
|
||||
|
||||
protected DimmableStoryboardContainer DimmableStoryboardContainer { get; private set; }
|
||||
protected DimmableStoryboard DimmableStoryboard { get; private set; }
|
||||
|
||||
protected virtual DimmableStoryboardContainer CreateStoryboardContainer(Storyboard storyboard) => new DimmableStoryboardContainer(storyboard) { RelativeSizeAxes = Axes.Both };
|
||||
protected virtual DimmableStoryboard CreateStoryboardContainer(Storyboard storyboard) => new DimmableStoryboard(storyboard) { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||
@ -124,7 +124,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
GameplayClockContainer.Children = new[]
|
||||
{
|
||||
DimmableStoryboardContainer = CreateStoryboardContainer(Beatmap.Value.Storyboard),
|
||||
DimmableStoryboard = CreateStoryboardContainer(Beatmap.Value.Storyboard),
|
||||
new ScalingContainer(ScalingMode.Gameplay)
|
||||
{
|
||||
Child = new LocalSkinOverrideContainer(working.Skin)
|
||||
@ -455,7 +455,7 @@ namespace osu.Game.Screens.Play
|
||||
Background.BlurAmount.Value = 0;
|
||||
|
||||
Background.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
DimmableStoryboardContainer.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
DimmableStoryboard.StoryboardReplacesBackground.BindTo(storyboardReplacesBackground);
|
||||
|
||||
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user