mirror of
https://github.com/ppy/osu
synced 2025-01-02 04:12:13 +00:00
Handle all blurring directly from background
This commit is contained in:
parent
de6d8fc637
commit
8714902349
@ -1,11 +1,16 @@
|
||||
// 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 System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -19,6 +24,8 @@ 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; }
|
||||
@ -35,13 +42,13 @@ namespace osu.Game.Graphics.Containers
|
||||
/// </summary>
|
||||
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||
|
||||
protected BufferedContainer LocalContainer { get; }
|
||||
protected Container LocalContainer { get; }
|
||||
|
||||
protected override Container<Drawable> Content => LocalContainer;
|
||||
|
||||
private readonly bool isStoryboard;
|
||||
|
||||
private Vector2 returnBlur;
|
||||
public Bindable<float> AddedBlur = new Bindable<float>();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="VisualSettingsContainer"/>.
|
||||
@ -55,7 +62,7 @@ namespace osu.Game.Graphics.Containers
|
||||
public VisualSettingsContainer(bool isStoryboard = false)
|
||||
{
|
||||
this.isStoryboard = isStoryboard;
|
||||
AddInternal(LocalContainer = new BufferedContainer { RelativeSizeAxes = Axes.Both });
|
||||
AddInternal(LocalContainer = new Container { RelativeSizeAxes = Axes.Both });
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -64,20 +71,21 @@ 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();
|
||||
dimLevel.ValueChanged += _ => updateVisuals();
|
||||
blurLevel.ValueChanged += _ => updateVisuals();
|
||||
showStoryboard.ValueChanged += _ => updateVisuals();
|
||||
StoryboardReplacesBackground.ValueChanged += _ => updateVisuals();
|
||||
EnableVisualSettings.ValueChanged += _ => UpdateVisuals();
|
||||
dimLevel.ValueChanged += _ => UpdateVisuals();
|
||||
blurLevel.ValueChanged += _ => UpdateVisuals();
|
||||
showStoryboard.ValueChanged += _ => UpdateVisuals();
|
||||
StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals();
|
||||
AddedBlur.ValueChanged += _ => UpdateVisuals();
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateVisuals();
|
||||
UpdateVisuals();
|
||||
}
|
||||
|
||||
private void updateVisuals()
|
||||
public void UpdateVisuals()
|
||||
{
|
||||
if (isStoryboard)
|
||||
{
|
||||
@ -88,8 +96,17 @@ namespace osu.Game.Graphics.Containers
|
||||
// The background needs to be hidden in the case of it being replaced by the storyboard
|
||||
LocalContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
||||
|
||||
// Only blur if this container contains a background
|
||||
LocalContainer.BlurTo(EnableVisualSettings.Value ? new Vector2((float)blurLevel.Value * 25) : new Vector2(0), background_fade_duration, Easing.OutQuint);
|
||||
foreach (Drawable c in LocalContainer)
|
||||
{
|
||||
// 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);
|
||||
|
||||
Logger.Log("Enable visual settings: " + EnableVisualSettings.Value + " Added blur is: " + AddedBlur.Value);
|
||||
}
|
||||
}
|
||||
|
||||
LocalContainer.FadeColour(EnableVisualSettings.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint);
|
||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Backgrounds
|
||||
{
|
||||
@ -23,6 +22,8 @@ namespace osu.Game.Screens.Backgrounds
|
||||
|
||||
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||
|
||||
public readonly Bindable<float> AddedBlur = new Bindable<float>();
|
||||
|
||||
private readonly VisualSettingsContainer fadeContainer;
|
||||
|
||||
protected virtual VisualSettingsContainer CreateFadeContainer() => new VisualSettingsContainer { RelativeSizeAxes = Axes.Both };
|
||||
@ -52,6 +53,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
|
||||
b.Depth = newDepth;
|
||||
fadeContainer.Add(Background = b);
|
||||
fadeContainer.UpdateVisuals();
|
||||
Background.BlurSigma = BlurTarget;
|
||||
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
||||
}));
|
||||
@ -64,6 +66,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
Beatmap = beatmap;
|
||||
InternalChild = fadeContainer = CreateFadeContainer();
|
||||
fadeContainer.EnableVisualSettings.BindTo(EnableVisualSettings);
|
||||
fadeContainer.AddedBlur.BindTo(AddedBlur);
|
||||
}
|
||||
|
||||
public override bool Equals(BackgroundScreen other)
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
public class PlayerLoader : ScreenWithBeatmapBackground
|
||||
{
|
||||
protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(15);
|
||||
private const float background_blur = 15;
|
||||
|
||||
private readonly Func<Player> createPlayer;
|
||||
|
||||
@ -119,7 +119,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private void contentIn()
|
||||
{
|
||||
Background?.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint);
|
||||
Background.AddedBlur.Value = background_blur;
|
||||
|
||||
content.ScaleTo(1, 650, Easing.OutQuint);
|
||||
content.FadeInFromZero(400);
|
||||
@ -127,7 +127,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private void contentOut()
|
||||
{
|
||||
Background?.BlurTo(new Vector2(0), 800, Easing.OutQuint);
|
||||
Background.AddedBlur.Value = 0;
|
||||
|
||||
content.ScaleTo(0.7f, 300, Easing.InQuint);
|
||||
content.FadeOut(250);
|
||||
@ -166,7 +166,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (this.IsCurrentScreen())
|
||||
{
|
||||
Background.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint);
|
||||
Background.AddedBlur.Value = background_blur;
|
||||
Background.EnableVisualSettings.Value = false;
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
if (this.IsCurrentScreen() && Background != null)
|
||||
{
|
||||
Background.BlurTo(new Vector2(0), 800, Easing.OutQuint);
|
||||
Background.AddedBlur.Value = 0;
|
||||
Background.EnableVisualSettings.Value = true;
|
||||
}
|
||||
}
|
||||
@ -239,6 +239,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
{
|
||||
Background.EnableVisualSettings.Value = true;
|
||||
|
||||
base.OnSuspending(next);
|
||||
cancelLoad();
|
||||
}
|
||||
@ -249,7 +251,7 @@ namespace osu.Game.Screens.Play
|
||||
this.FadeOut(150);
|
||||
cancelLoad();
|
||||
|
||||
Background.EnableVisualSettings.Value = false;
|
||||
Background.EnableVisualSettings.Value = true;
|
||||
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
public abstract class Results : OsuScreen
|
||||
{
|
||||
protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(20);
|
||||
private 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);
|
||||
(Background as BackgroundScreenBeatmap)?.BlurTo(BACKGROUND_BLUR, 2500, Easing.OutQuint);
|
||||
((BackgroundScreenBeatmap)Background).AddedBlur.Value = background_blur;
|
||||
Background.ScaleTo(1.1f, transition_time, Easing.OutQuint);
|
||||
|
||||
allCircles.ForEach(c =>
|
||||
|
@ -37,8 +37,8 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
public abstract class SongSelect : OsuScreen
|
||||
{
|
||||
protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(20);
|
||||
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
||||
private const float background_blur = 20;
|
||||
private const float left_area_padding = 20;
|
||||
|
||||
public readonly FilterControl FilterControl;
|
||||
@ -556,8 +556,9 @@ namespace osu.Game.Screens.Select
|
||||
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
|
||||
{
|
||||
backgroundModeBeatmap.Beatmap = beatmap;
|
||||
backgroundModeBeatmap.BlurTo(BACKGROUND_BLUR, 750, Easing.OutQuint);
|
||||
backgroundModeBeatmap.AddedBlur.Value = background_blur;
|
||||
backgroundModeBeatmap.FadeColour(Color4.White, 250);
|
||||
Logger.Log("blur updated!");
|
||||
}
|
||||
|
||||
beatmapInfoWedge.Beatmap = beatmap;
|
||||
|
Loading…
Reference in New Issue
Block a user