Don't expose dimmable container creation in player

This commit is contained in:
Dean Herbert 2019-07-12 12:04:45 +09:00
parent 46f7bb885b
commit 8b67f88d16
3 changed files with 13 additions and 24 deletions

View File

@ -29,7 +29,6 @@ using osu.Game.Screens.Backgrounds;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.PlayerSettings;
using osu.Game.Screens.Select;
using osu.Game.Storyboards;
using osu.Game.Tests.Resources;
using osu.Game.Users;
using osuTK;
@ -139,14 +138,14 @@ namespace osu.Game.Tests.Visual.Background
player.StoryboardEnabled.Value = true;
});
waitForDim();
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible());
AddAssert("Background is invisible, storyboard is visible", () => songSelect.IsBackgroundInvisible() && player.IsStoryboardVisible);
AddStep("Storyboard Disabled", () =>
{
player.ReplacesBackground.Value = false;
player.StoryboardEnabled.Value = false;
});
waitForDim();
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && player.IsStoryboardInvisible());
AddAssert("Background is visible, storyboard is invisible", () => songSelect.IsBackgroundVisible() && !player.IsStoryboardVisible);
}
/// <summary>
@ -336,9 +335,7 @@ namespace osu.Game.Tests.Visual.Background
{
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
protected override DimmableStoryboard CreateStoryboardContainer(Storyboard storyboard) => new TestDimmableStoryboard { RelativeSizeAxes = Axes.Both };
public new TestDimmableStoryboard DimmableStoryboard => (TestDimmableStoryboard)base.DimmableStoryboard;
public new DimmableStoryboard DimmableStoryboard => base.DimmableStoryboard;
// Whether or not the player should be allowed to load.
public bool BlockLoad;
@ -352,9 +349,7 @@ namespace osu.Game.Tests.Visual.Background
{
}
public bool IsStoryboardVisible() => DimmableStoryboard.CurrentAlpha == 1;
public bool IsStoryboardInvisible() => DimmableStoryboard.CurrentAlpha <= 1;
public bool IsStoryboardVisible => DimmableStoryboard.ContentDisplayed;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, CancellationToken token)
@ -403,16 +398,6 @@ namespace osu.Game.Tests.Visual.Background
}
}
private class TestDimmableStoryboard : DimmableStoryboard
{
public float CurrentAlpha => Content.Alpha;
public TestDimmableStoryboard()
: base(new Storyboard())
{
}
}
private class TestDimmableBackground : BackgroundScreenBeatmap.DimmableBackground
{
public Color4 CurrentColour => Content.Colour;

View File

@ -27,6 +27,11 @@ namespace osu.Game.Graphics.Containers
/// </summary>
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
/// <summary>
/// Whether the content of this container is currently being displayed.
/// </summary>
public bool ContentDisplayed { get; private set; }
protected Bindable<double> UserDimLevel { get; private set; }
protected Bindable<bool> ShowStoryboard { get; private set; }
@ -71,7 +76,9 @@ namespace osu.Game.Graphics.Containers
/// </summary>
protected virtual void UpdateVisuals()
{
dimContent.FadeTo(ShowDimContent ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
ContentDisplayed = ShowDimContent;
dimContent.FadeTo((ContentDisplayed) ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
dimContent.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)UserDimLevel.Value) : Color4.White, BACKGROUND_FADE_DURATION, Easing.OutQuint);
}
}

View File

@ -26,7 +26,6 @@ using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
using osu.Game.Skinning;
using osu.Game.Storyboards;
using osu.Game.Users;
namespace osu.Game.Screens.Play
@ -78,8 +77,6 @@ namespace osu.Game.Screens.Play
protected DimmableStoryboard DimmableStoryboard { get; private set; }
protected virtual DimmableStoryboard CreateStoryboardContainer(Storyboard storyboard) => new DimmableStoryboard(storyboard) { RelativeSizeAxes = Axes.Both };
[Cached]
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
protected new readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
@ -124,7 +121,7 @@ namespace osu.Game.Screens.Play
GameplayClockContainer.Children = new[]
{
DimmableStoryboard = CreateStoryboardContainer(Beatmap.Value.Storyboard),
DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard) { RelativeSizeAxes = Axes.Both },
new ScalingContainer(ScalingMode.Gameplay)
{
Child = new LocalSkinOverrideContainer(working.Skin)