1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 18:32:55 +08:00

Don't expose DimContainer

This commit is contained in:
Dean Herbert 2019-07-12 11:38:15 +09:00
parent c9599b65eb
commit 0d9f978857
4 changed files with 21 additions and 25 deletions

View File

@ -405,7 +405,7 @@ namespace osu.Game.Tests.Visual.Background
private class TestDimmableStoryboardContainer : DimmableStoryboardContainer
{
public float CurrentAlpha => DimContainer.Alpha;
public float CurrentAlpha => Content.Alpha;
public TestDimmableStoryboardContainer()
: base(new Storyboard())
@ -415,8 +415,8 @@ namespace osu.Game.Tests.Visual.Background
private class TestDimmableBackgroundContainer : DimmableBackgroundContainer
{
public Color4 CurrentColour => DimContainer.Colour;
public float CurrentAlpha => DimContainer.Alpha;
public Color4 CurrentColour => Content.Colour;
public float CurrentAlpha => Content.Alpha;
}
}
}

View File

@ -55,14 +55,16 @@ namespace osu.Game.Graphics.Containers
private void load(OsuConfigManager config)
{
userBlurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
BlurAmount.ValueChanged += _ => UpdateVisuals();
userBlurLevel.ValueChanged += _ => UpdateVisuals();
BlurAmount.ValueChanged += _ => UpdateVisuals();
}
protected override void ApplyFade()
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()
{
// The background needs to be hidden in the case of it being replaced by the storyboard
DimContainer.FadeTo(ShowStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint);
base.UpdateVisuals();
Background?.BlurTo(blurTarget, BACKGROUND_FADE_DURATION, Easing.OutQuint);
}
}

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Storyboards;
using osu.Game.Storyboards.Drawables;
@ -37,10 +36,7 @@ namespace osu.Game.Graphics.Containers
base.LoadComplete();
}
protected override void ApplyFade()
{
DimContainer.FadeTo(!ShowStoryboard.Value || UserDimLevel.Value == 1 ? 0 : 1, BACKGROUND_FADE_DURATION, Easing.OutQuint);
}
protected override bool ShowDimContent => ShowStoryboard.Value && UserDimLevel.Value < 1;
private void initializeStoryboard(bool async)
{

View File

@ -31,16 +31,16 @@ namespace osu.Game.Graphics.Containers
protected Bindable<bool> ShowStoryboard { get; private set; }
protected Container DimContainer { get; }
protected override Container<Drawable> Content => dimContent;
protected override Container<Drawable> Content => DimContainer;
private Container dimContent { get; }
/// <summary>
/// Creates a new <see cref="UserDimContainer"/>.
/// </summary>
protected UserDimContainer()
{
AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both });
AddInternal(dimContent = new Container { RelativeSizeAxes = Axes.Both });
}
[BackgroundDependencyLoader]
@ -62,19 +62,17 @@ namespace osu.Game.Graphics.Containers
}
/// <summary>
/// Apply non-dim related settings to the content, such as hiding and blurring.
/// Whether the content of this container should currently be visible.
/// </summary>
/// <remarks>
/// While both backgrounds and storyboards allow user dim levels to be applied, storyboards can be toggled via <see cref="ShowStoryboard"/>
/// and can cause backgrounds to become hidden via <see cref="StoryboardReplacesBackground"/>. Storyboards are also currently unable to be blurred.
/// </remarks>
protected abstract void ApplyFade();
protected virtual bool ShowDimContent => true;
protected void UpdateVisuals()
/// <summary>
/// Should be invoked when any dependent dim level or user setting is changed and bring the visual state up-to-date.
/// </summary>
protected virtual void UpdateVisuals()
{
ApplyFade();
DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint);
dimContent.FadeTo(ShowDimContent ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
dimContent.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint);
}
}
}