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

Remove BlurrableBackgroundScreen, rework tests

This commit is contained in:
David Zhao 2019-03-14 16:09:17 +09:00
parent 8714902349
commit 8cdfb1fd61
10 changed files with 40 additions and 49 deletions

View File

@ -109,7 +109,7 @@ namespace osu.Game.Tests.Visual
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied()); AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos)); AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
waitForDim(); waitForDim();
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled()); AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && playerLoader.IsBlurCorrect());
} }
/// <summary> /// <summary>
@ -203,10 +203,11 @@ namespace osu.Game.Tests.Visual
public void TransitionTest() public void TransitionTest()
{ {
performFullSetup(); performFullSetup();
AddStep("Transition to Results", () => player.Push(new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } }))); var results = new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } });
AddStep("Transition to Results", () => player.Push(results));
waitForDim(); waitForDim();
AddAssert("Screen is undimmed, original background retained", () => AddAssert("Screen is undimmed, original background retained", () =>
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && songSelect.IsUserBlurDisabled()); songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
} }
/// <summary> /// <summary>
@ -218,7 +219,7 @@ namespace osu.Game.Tests.Visual
performFullSetup(); performFullSetup();
AddStep("Exit to song select", () => player.Exit()); AddStep("Exit to song select", () => player.Exit());
waitForDim(); waitForDim();
AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsUserBlurDisabled()); AddAssert("Screen is undimmed and user blur removed", () => songSelect.IsBackgroundUndimmed() && songSelect.IsBlurCorrect());
} }
private void waitForDim() => AddWaitStep(5, "Wait for dim"); private void waitForDim() => AddWaitStep(5, "Wait for dim");
@ -300,6 +301,8 @@ namespace osu.Game.Tests.Visual
public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1; public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1;
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
/// <summary> /// <summary>
/// Make sure every time a screen gets pushed, the background doesn't get replaced /// Make sure every time a screen gets pushed, the background doesn't get replaced
/// </summary> /// </summary>
@ -315,6 +318,8 @@ namespace osu.Game.Tests.Visual
} }
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
} }
private class TestPlayer : Player private class TestPlayer : Player
@ -383,6 +388,8 @@ namespace osu.Game.Tests.Visual
public void TriggerOnHover() => OnHover(new HoverEvent(new InputState())); public void TriggerOnHover() => OnHover(new HoverEvent(new InputState()));
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value); protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
} }
@ -394,7 +401,7 @@ namespace osu.Game.Tests.Visual
public float CurrentAlpha => fadeContainer.CurrentAlpha; public float CurrentAlpha => fadeContainer.CurrentAlpha;
public Vector2 CurrentBlur => fadeContainer.CurrentBlur; public Vector2 CurrentBlur => Background.BlurSigma;
private TestVisualSettingsContainer fadeContainer; private TestVisualSettingsContainer fadeContainer;
@ -409,8 +416,6 @@ namespace osu.Game.Tests.Visual
public Color4 CurrentColour => LocalContainer.Colour; public Color4 CurrentColour => LocalContainer.Colour;
public float CurrentAlpha => LocalContainer.Alpha; public float CurrentAlpha => LocalContainer.Alpha;
public Vector2 CurrentBlur => LocalContainer.BlurSigma;
public TestVisualSettingsContainer(bool isStoryboard = false) public TestVisualSettingsContainer(bool isStoryboard = false)
: base(isStoryboard) : base(isStoryboard)
{ {

View File

@ -24,8 +24,6 @@ namespace osu.Game.Graphics.Containers
{ {
private const float background_fade_duration = 800; private const float background_fade_duration = 800;
public Action ContentLoadComplete = () => { };
private Bindable<double> dimLevel { get; set; } private Bindable<double> dimLevel { get; set; }
private Bindable<double> blurLevel { get; set; } private Bindable<double> blurLevel { get; set; }
@ -50,6 +48,10 @@ namespace osu.Game.Graphics.Containers
public Bindable<float> AddedBlur = new Bindable<float>(); public Bindable<float> AddedBlur = new Bindable<float>();
public Vector2 BlurTarget => EnableVisualSettings.Value
? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25)
: new Vector2(AddedBlur.Value);
/// <summary> /// <summary>
/// Creates a new <see cref="VisualSettingsContainer"/>. /// Creates a new <see cref="VisualSettingsContainer"/>.
/// </summary> /// </summary>
@ -71,7 +73,11 @@ namespace osu.Game.Graphics.Containers
dimLevel = config.GetBindable<double>(OsuSetting.DimLevel); dimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
blurLevel = config.GetBindable<double>(OsuSetting.BlurLevel); blurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard); showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
EnableVisualSettings.ValueChanged += _ => UpdateVisuals(); EnableVisualSettings.ValueChanged += _ =>
{
Logger.Log("Oh fuck");
UpdateVisuals();
};
dimLevel.ValueChanged += _ => UpdateVisuals(); dimLevel.ValueChanged += _ => UpdateVisuals();
blurLevel.ValueChanged += _ => UpdateVisuals(); blurLevel.ValueChanged += _ => UpdateVisuals();
showStoryboard.ValueChanged += _ => UpdateVisuals(); showStoryboard.ValueChanged += _ => UpdateVisuals();
@ -101,9 +107,7 @@ namespace osu.Game.Graphics.Containers
// Only blur if this container contains a background // Only blur if this container contains a background
// We can't blur the container like we did with the dim because buffered containers add considerable draw overhead. // We can't blur the container like we did with the dim because buffered containers add considerable draw overhead.
// As a result, this blurs the background directly. // As a result, this blurs the background directly.
((Background)c)?.BlurTo(EnableVisualSettings.Value ((Background)c)?.BlurTo(BlurTarget, background_fade_duration, Easing.OutQuint);
? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25)
: new Vector2(AddedBlur.Value), background_fade_duration, Easing.OutQuint);
Logger.Log("Enable visual settings: " + EnableVisualSettings.Value + " Added blur is: " + AddedBlur.Value); Logger.Log("Enable visual settings: " + EnableVisualSettings.Value + " Added blur is: " + AddedBlur.Value);
} }

View File

@ -5,12 +5,15 @@ using System;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Graphics.Backgrounds;
using osuTK; using osuTK;
namespace osu.Game.Screens namespace osu.Game.Screens
{ {
public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen> public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen>
{ {
protected Background Background;
protected BackgroundScreen() protected BackgroundScreen()
{ {
Anchor = Anchor.Centre; Anchor = Anchor.Centre;

View File

@ -11,7 +11,7 @@ using osu.Game.Graphics.Containers;
namespace osu.Game.Screens.Backgrounds namespace osu.Game.Screens.Backgrounds
{ {
public class BackgroundScreenBeatmap : BlurrableBackgroundScreen public class BackgroundScreenBeatmap : BackgroundScreen
{ {
private WorkingBeatmap beatmap; private WorkingBeatmap beatmap;
@ -54,7 +54,7 @@ namespace osu.Game.Screens.Backgrounds
b.Depth = newDepth; b.Depth = newDepth;
fadeContainer.Add(Background = b); fadeContainer.Add(Background = b);
fadeContainer.UpdateVisuals(); fadeContainer.UpdateVisuals();
Background.BlurSigma = BlurTarget; Background.BlurSigma = fadeContainer.BlurTarget;
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
})); }));
}); });

View File

@ -12,7 +12,7 @@ namespace osu.Game.Screens.Backgrounds
public BackgroundScreenCustom(string textureName) public BackgroundScreenCustom(string textureName)
{ {
this.textureName = textureName; this.textureName = textureName;
AddInternal(new Background(textureName)); AddInternal(Background = new Background(textureName));
} }
public override bool Equals(BackgroundScreen other) public override bool Equals(BackgroundScreen other)

View File

@ -13,7 +13,7 @@ using osu.Game.Users;
namespace osu.Game.Screens.Backgrounds namespace osu.Game.Screens.Backgrounds
{ {
public class BackgroundScreenDefault : BlurrableBackgroundScreen public class BackgroundScreenDefault : BackgroundScreen
{ {
private int currentDisplay; private int currentDisplay;
private const int background_count = 5; private const int background_count = 5;

View File

@ -1,23 +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 osu.Framework.Graphics;
using osu.Framework.Graphics.Transforms;
using osu.Game.Graphics.Backgrounds;
using osuTK;
namespace osu.Game.Screens
{
public abstract class BlurrableBackgroundScreen : BackgroundScreen
{
protected Background Background;
protected Vector2 BlurTarget;
public TransformSequence<Background> BlurTo(Vector2 sigma, double duration, Easing easing = Easing.None)
{
BlurTarget = sigma;
return Background?.BlurTo(BlurTarget, duration, easing);
}
}
}

View File

@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play
{ {
public class PlayerLoader : ScreenWithBeatmapBackground public class PlayerLoader : ScreenWithBeatmapBackground
{ {
private const float background_blur = 15; protected const float BACKGROUND_BLUR = 15;
private readonly Func<Player> createPlayer; private readonly Func<Player> createPlayer;
@ -119,7 +119,8 @@ namespace osu.Game.Screens.Play
private void contentIn() private void contentIn()
{ {
Background.AddedBlur.Value = background_blur; Background.AddedBlur.Value = BACKGROUND_BLUR;
Background.EnableVisualSettings.Value = false;
content.ScaleTo(1, 650, Easing.OutQuint); content.ScaleTo(1, 650, Easing.OutQuint);
content.FadeInFromZero(400); content.FadeInFromZero(400);
@ -128,6 +129,7 @@ namespace osu.Game.Screens.Play
private void contentOut() private void contentOut()
{ {
Background.AddedBlur.Value = 0; Background.AddedBlur.Value = 0;
Background.EnableVisualSettings.Value = true;
content.ScaleTo(0.7f, 300, Easing.InQuint); content.ScaleTo(0.7f, 300, Easing.InQuint);
content.FadeOut(250); content.FadeOut(250);
@ -166,7 +168,7 @@ namespace osu.Game.Screens.Play
{ {
if (this.IsCurrentScreen()) if (this.IsCurrentScreen())
{ {
Background.AddedBlur.Value = background_blur; Background.AddedBlur.Value = BACKGROUND_BLUR;
Background.EnableVisualSettings.Value = false; Background.EnableVisualSettings.Value = false;
} }
@ -251,7 +253,7 @@ namespace osu.Game.Screens.Play
this.FadeOut(150); this.FadeOut(150);
cancelLoad(); cancelLoad();
Background.EnableVisualSettings.Value = true; Background.EnableVisualSettings.Value = false;
return base.OnExiting(next); return base.OnExiting(next);
} }

View File

@ -24,7 +24,7 @@ namespace osu.Game.Screens.Ranking
{ {
public abstract class Results : OsuScreen public abstract class Results : OsuScreen
{ {
private const float background_blur = 20; protected const float BACKGROUND_BLUR = 20;
private Container circleOuterBackground; private Container circleOuterBackground;
private Container circleOuter; private Container circleOuter;
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Ranking
public override void OnEntering(IScreen last) public override void OnEntering(IScreen last)
{ {
base.OnEntering(last); base.OnEntering(last);
((BackgroundScreenBeatmap)Background).AddedBlur.Value = background_blur; ((BackgroundScreenBeatmap)Background).AddedBlur.Value = BACKGROUND_BLUR;
Background.ScaleTo(1.1f, transition_time, Easing.OutQuint); Background.ScaleTo(1.1f, transition_time, Easing.OutQuint);
allCircles.ForEach(c => allCircles.ForEach(c =>

View File

@ -38,7 +38,7 @@ namespace osu.Game.Screens.Select
public abstract class SongSelect : OsuScreen public abstract class SongSelect : OsuScreen
{ {
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245); private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
private const float background_blur = 20; protected const float BACKGROUND_BLUR = 20;
private const float left_area_padding = 20; private const float left_area_padding = 20;
public readonly FilterControl FilterControl; public readonly FilterControl FilterControl;
@ -556,7 +556,7 @@ namespace osu.Game.Screens.Select
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap) if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
{ {
backgroundModeBeatmap.Beatmap = beatmap; backgroundModeBeatmap.Beatmap = beatmap;
backgroundModeBeatmap.AddedBlur.Value = background_blur; backgroundModeBeatmap.AddedBlur.Value = BACKGROUND_BLUR;
backgroundModeBeatmap.FadeColour(Color4.White, 250); backgroundModeBeatmap.FadeColour(Color4.White, 250);
Logger.Log("blur updated!"); Logger.Log("blur updated!");
} }