mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:42:54 +08:00
Remove BlurrableBackgroundScreen, rework tests
This commit is contained in:
parent
8714902349
commit
8cdfb1fd61
@ -109,7 +109,7 @@ namespace osu.Game.Tests.Visual
|
||||
AddAssert("Screen is dimmed and blur applied", () => songSelect.IsBackgroundDimmed() && songSelect.IsUserBlurApplied());
|
||||
AddStep("Stop background preview", () => InputManager.MoveMouseTo(playerLoader.ScreenPos));
|
||||
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>
|
||||
@ -203,10 +203,11 @@ namespace osu.Game.Tests.Visual
|
||||
public void TransitionTest()
|
||||
{
|
||||
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();
|
||||
AddAssert("Screen is undimmed, original background retained", () =>
|
||||
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && songSelect.IsUserBlurDisabled());
|
||||
AddAssert("Screen is undimmed, original background retained", () =>
|
||||
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -218,7 +219,7 @@ namespace osu.Game.Tests.Visual
|
||||
performFullSetup();
|
||||
AddStep("Exit to song select", () => player.Exit());
|
||||
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");
|
||||
@ -300,6 +301,8 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
public bool IsBackgroundVisible() => ((FadeAccessibleBackground)Background).CurrentAlpha == 1;
|
||||
|
||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||
|
||||
/// <summary>
|
||||
/// Make sure every time a screen gets pushed, the background doesn't get replaced
|
||||
/// </summary>
|
||||
@ -315,6 +318,8 @@ namespace osu.Game.Tests.Visual
|
||||
}
|
||||
|
||||
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
|
||||
|
||||
public bool IsBlurCorrect() => ((FadeAccessibleBackground)Background).CurrentBlur == new Vector2(BACKGROUND_BLUR);
|
||||
}
|
||||
|
||||
private class TestPlayer : Player
|
||||
@ -383,6 +388,8 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -394,7 +401,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
public float CurrentAlpha => fadeContainer.CurrentAlpha;
|
||||
|
||||
public Vector2 CurrentBlur => fadeContainer.CurrentBlur;
|
||||
public Vector2 CurrentBlur => Background.BlurSigma;
|
||||
|
||||
private TestVisualSettingsContainer fadeContainer;
|
||||
|
||||
@ -409,8 +416,6 @@ namespace osu.Game.Tests.Visual
|
||||
public Color4 CurrentColour => LocalContainer.Colour;
|
||||
public float CurrentAlpha => LocalContainer.Alpha;
|
||||
|
||||
public Vector2 CurrentBlur => LocalContainer.BlurSigma;
|
||||
|
||||
public TestVisualSettingsContainer(bool isStoryboard = false)
|
||||
: base(isStoryboard)
|
||||
{
|
||||
|
@ -24,8 +24,6 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
private const float background_fade_duration = 800;
|
||||
|
||||
public Action ContentLoadComplete = () => { };
|
||||
|
||||
private Bindable<double> dimLevel { 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 Vector2 BlurTarget => EnableVisualSettings.Value
|
||||
? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25)
|
||||
: new Vector2(AddedBlur.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="VisualSettingsContainer"/>.
|
||||
/// </summary>
|
||||
@ -71,7 +73,11 @@ namespace osu.Game.Graphics.Containers
|
||||
dimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||
blurLevel = config.GetBindable<double>(OsuSetting.BlurLevel);
|
||||
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
EnableVisualSettings.ValueChanged += _ => UpdateVisuals();
|
||||
EnableVisualSettings.ValueChanged += _ =>
|
||||
{
|
||||
Logger.Log("Oh fuck");
|
||||
UpdateVisuals();
|
||||
};
|
||||
dimLevel.ValueChanged += _ => UpdateVisuals();
|
||||
blurLevel.ValueChanged += _ => UpdateVisuals();
|
||||
showStoryboard.ValueChanged += _ => UpdateVisuals();
|
||||
@ -101,9 +107,7 @@ namespace osu.Game.Graphics.Containers
|
||||
// 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.
|
||||
// As a result, this blurs the background directly.
|
||||
((Background)c)?.BlurTo(EnableVisualSettings.Value
|
||||
? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25)
|
||||
: new Vector2(AddedBlur.Value), background_fade_duration, Easing.OutQuint);
|
||||
((Background)c)?.BlurTo(BlurTarget, background_fade_duration, Easing.OutQuint);
|
||||
|
||||
Logger.Log("Enable visual settings: " + EnableVisualSettings.Value + " Added blur is: " + AddedBlur.Value);
|
||||
}
|
||||
|
@ -5,12 +5,15 @@ using System;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens
|
||||
{
|
||||
public abstract class BackgroundScreen : Screen, IEquatable<BackgroundScreen>
|
||||
{
|
||||
protected Background Background;
|
||||
|
||||
protected BackgroundScreen()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Screens.Backgrounds
|
||||
{
|
||||
public class BackgroundScreenBeatmap : BlurrableBackgroundScreen
|
||||
public class BackgroundScreenBeatmap : BackgroundScreen
|
||||
{
|
||||
private WorkingBeatmap beatmap;
|
||||
|
||||
@ -54,7 +54,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
b.Depth = newDepth;
|
||||
fadeContainer.Add(Background = b);
|
||||
fadeContainer.UpdateVisuals();
|
||||
Background.BlurSigma = BlurTarget;
|
||||
Background.BlurSigma = fadeContainer.BlurTarget;
|
||||
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
||||
}));
|
||||
});
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
public BackgroundScreenCustom(string textureName)
|
||||
{
|
||||
this.textureName = textureName;
|
||||
AddInternal(new Background(textureName));
|
||||
AddInternal(Background = new Background(textureName));
|
||||
}
|
||||
|
||||
public override bool Equals(BackgroundScreen other)
|
||||
|
@ -13,7 +13,7 @@ using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Screens.Backgrounds
|
||||
{
|
||||
public class BackgroundScreenDefault : BlurrableBackgroundScreen
|
||||
public class BackgroundScreenDefault : BackgroundScreen
|
||||
{
|
||||
private int currentDisplay;
|
||||
private const int background_count = 5;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class PlayerLoader : ScreenWithBeatmapBackground
|
||||
{
|
||||
private const float background_blur = 15;
|
||||
protected const float BACKGROUND_BLUR = 15;
|
||||
|
||||
private readonly Func<Player> createPlayer;
|
||||
|
||||
@ -119,7 +119,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private void contentIn()
|
||||
{
|
||||
Background.AddedBlur.Value = background_blur;
|
||||
Background.AddedBlur.Value = BACKGROUND_BLUR;
|
||||
Background.EnableVisualSettings.Value = false;
|
||||
|
||||
content.ScaleTo(1, 650, Easing.OutQuint);
|
||||
content.FadeInFromZero(400);
|
||||
@ -128,6 +129,7 @@ namespace osu.Game.Screens.Play
|
||||
private void contentOut()
|
||||
{
|
||||
Background.AddedBlur.Value = 0;
|
||||
Background.EnableVisualSettings.Value = true;
|
||||
|
||||
content.ScaleTo(0.7f, 300, Easing.InQuint);
|
||||
content.FadeOut(250);
|
||||
@ -166,7 +168,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (this.IsCurrentScreen())
|
||||
{
|
||||
Background.AddedBlur.Value = background_blur;
|
||||
Background.AddedBlur.Value = BACKGROUND_BLUR;
|
||||
Background.EnableVisualSettings.Value = false;
|
||||
}
|
||||
|
||||
@ -251,7 +253,7 @@ namespace osu.Game.Screens.Play
|
||||
this.FadeOut(150);
|
||||
cancelLoad();
|
||||
|
||||
Background.EnableVisualSettings.Value = true;
|
||||
Background.EnableVisualSettings.Value = false;
|
||||
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
public abstract class Results : OsuScreen
|
||||
{
|
||||
private const float background_blur = 20;
|
||||
protected const float BACKGROUND_BLUR = 20;
|
||||
|
||||
private Container circleOuterBackground;
|
||||
private Container circleOuter;
|
||||
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Ranking
|
||||
public override void OnEntering(IScreen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
((BackgroundScreenBeatmap)Background).AddedBlur.Value = background_blur;
|
||||
((BackgroundScreenBeatmap)Background).AddedBlur.Value = BACKGROUND_BLUR;
|
||||
Background.ScaleTo(1.1f, transition_time, Easing.OutQuint);
|
||||
|
||||
allCircles.ForEach(c =>
|
||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Screens.Select
|
||||
public abstract class SongSelect : OsuScreen
|
||||
{
|
||||
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;
|
||||
|
||||
public readonly FilterControl FilterControl;
|
||||
@ -556,7 +556,7 @@ namespace osu.Game.Screens.Select
|
||||
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
|
||||
{
|
||||
backgroundModeBeatmap.Beatmap = beatmap;
|
||||
backgroundModeBeatmap.AddedBlur.Value = background_blur;
|
||||
backgroundModeBeatmap.AddedBlur.Value = BACKGROUND_BLUR;
|
||||
backgroundModeBeatmap.FadeColour(Color4.White, 250);
|
||||
Logger.Log("blur updated!");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user