Fix TestCasePlayerLoader not having a background stack

This commit is contained in:
David Zhao 2019-02-25 22:05:49 +09:00
parent 16fa30f71e
commit d750023c52
3 changed files with 16 additions and 8 deletions

View File

@ -6,6 +6,7 @@
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Screens;
using osu.Game.Screens.Play;
namespace osu.Game.Tests.Visual
@ -15,13 +16,20 @@ public class TestCasePlayerLoader : ManualInputManagerTestCase
private PlayerLoader loader;
private ScreenStack stack;
[Cached]
private BackgroundScreenStack backgroundStack;
public TestCasePlayerLoader()
{
InputManager.Add(backgroundStack = new BackgroundScreenStack {RelativeSizeAxes = Axes.Both});
InputManager.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both });
}
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
{
Beatmap.Value = new DummyWorkingBeatmap(game);
InputManager.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both });
AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player
{
AllowPause = false,

View File

@ -354,8 +354,8 @@ public override void OnEntering(IScreen last)
Background.EnableUserDim.Value = true;
storyboardReplacesBackground.BindTo(Background?.StoryboardReplacesBackground);
storyboardReplacesBackground.BindTo(storyboardContainer.StoryboardReplacesBackground);
storyboardReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
storyboardContainer.StoryboardReplacesBackground.BindTo(Background.StoryboardReplacesBackground);
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
Task.Run(() =>

View File

@ -159,7 +159,7 @@ protected override bool OnHover(HoverEvent e)
{
// restore our screen defaults
InitializeBackgroundElements();
if (this.IsCurrentScreen() && (Background?.IsLoaded ?? false))
if (this.IsCurrentScreen())
Background.EnableUserDim.Value = false;
return base.OnHover(e);
}
@ -168,7 +168,8 @@ protected override void OnHoverLost(HoverLostEvent e)
{
if (GetContainingInputManager()?.HoveredDrawables.Contains(VisualSettings) == true)
{
// show user setting preview
// Update background elements is only being called here because blur logic still exists in Player.
// Will need to be removed when resolving https://github.com/ppy/osu/issues/4322
UpdateBackgroundElements();
if (this.IsCurrentScreen())
Background.EnableUserDim.Value = true;
@ -245,8 +246,7 @@ public override bool OnExiting(IScreen next)
this.FadeOut(150);
cancelLoad();
if (Background != null)
Background.EnableUserDim.Value = false;
Background.EnableUserDim.Value = false;
return base.OnExiting(next);
}