mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 19:13:20 +08: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.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Logging;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
using osu.Game.Screens.Backgrounds;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -19,6 +24,8 @@ 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; }
|
||||||
@ -35,13 +42,13 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
protected BufferedContainer LocalContainer { get; }
|
protected Container LocalContainer { get; }
|
||||||
|
|
||||||
protected override Container<Drawable> Content => LocalContainer;
|
protected override Container<Drawable> Content => LocalContainer;
|
||||||
|
|
||||||
private readonly bool isStoryboard;
|
private readonly bool isStoryboard;
|
||||||
|
|
||||||
private Vector2 returnBlur;
|
public Bindable<float> AddedBlur = new Bindable<float>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="VisualSettingsContainer"/>.
|
/// Creates a new <see cref="VisualSettingsContainer"/>.
|
||||||
@ -55,7 +62,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
public VisualSettingsContainer(bool isStoryboard = false)
|
public VisualSettingsContainer(bool isStoryboard = false)
|
||||||
{
|
{
|
||||||
this.isStoryboard = isStoryboard;
|
this.isStoryboard = isStoryboard;
|
||||||
AddInternal(LocalContainer = new BufferedContainer { RelativeSizeAxes = Axes.Both });
|
AddInternal(LocalContainer = new Container { RelativeSizeAxes = Axes.Both });
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -64,20 +71,21 @@ 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 += _ => UpdateVisuals();
|
||||||
dimLevel.ValueChanged += _ => updateVisuals();
|
dimLevel.ValueChanged += _ => UpdateVisuals();
|
||||||
blurLevel.ValueChanged += _ => updateVisuals();
|
blurLevel.ValueChanged += _ => UpdateVisuals();
|
||||||
showStoryboard.ValueChanged += _ => updateVisuals();
|
showStoryboard.ValueChanged += _ => UpdateVisuals();
|
||||||
StoryboardReplacesBackground.ValueChanged += _ => updateVisuals();
|
StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals();
|
||||||
|
AddedBlur.ValueChanged += _ => UpdateVisuals();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
updateVisuals();
|
UpdateVisuals();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVisuals()
|
public void UpdateVisuals()
|
||||||
{
|
{
|
||||||
if (isStoryboard)
|
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
|
// 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);
|
LocalContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
||||||
|
|
||||||
// Only blur if this container contains a background
|
foreach (Drawable c in LocalContainer)
|
||||||
LocalContainer.BlurTo(EnableVisualSettings.Value ? new Vector2((float)blurLevel.Value * 25) : new Vector2(0), background_fade_duration, Easing.OutQuint);
|
{
|
||||||
|
// 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);
|
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.Beatmaps;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Backgrounds
|
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<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
|
public readonly Bindable<float> AddedBlur = new Bindable<float>();
|
||||||
|
|
||||||
private readonly VisualSettingsContainer fadeContainer;
|
private readonly VisualSettingsContainer fadeContainer;
|
||||||
|
|
||||||
protected virtual VisualSettingsContainer CreateFadeContainer() => new VisualSettingsContainer { RelativeSizeAxes = Axes.Both };
|
protected virtual VisualSettingsContainer CreateFadeContainer() => new VisualSettingsContainer { RelativeSizeAxes = Axes.Both };
|
||||||
@ -52,6 +53,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
|
|
||||||
b.Depth = newDepth;
|
b.Depth = newDepth;
|
||||||
fadeContainer.Add(Background = b);
|
fadeContainer.Add(Background = b);
|
||||||
|
fadeContainer.UpdateVisuals();
|
||||||
Background.BlurSigma = BlurTarget;
|
Background.BlurSigma = BlurTarget;
|
||||||
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
||||||
}));
|
}));
|
||||||
@ -64,6 +66,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
Beatmap = beatmap;
|
Beatmap = beatmap;
|
||||||
InternalChild = fadeContainer = CreateFadeContainer();
|
InternalChild = fadeContainer = CreateFadeContainer();
|
||||||
fadeContainer.EnableVisualSettings.BindTo(EnableVisualSettings);
|
fadeContainer.EnableVisualSettings.BindTo(EnableVisualSettings);
|
||||||
|
fadeContainer.AddedBlur.BindTo(AddedBlur);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(BackgroundScreen other)
|
public override bool Equals(BackgroundScreen other)
|
||||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
public class PlayerLoader : ScreenWithBeatmapBackground
|
public class PlayerLoader : ScreenWithBeatmapBackground
|
||||||
{
|
{
|
||||||
protected static readonly Vector2 BACKGROUND_BLUR = new Vector2(15);
|
private const float background_blur = 15;
|
||||||
|
|
||||||
private readonly Func<Player> createPlayer;
|
private readonly Func<Player> createPlayer;
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private void contentIn()
|
private void contentIn()
|
||||||
{
|
{
|
||||||
Background?.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint);
|
Background.AddedBlur.Value = background_blur;
|
||||||
|
|
||||||
content.ScaleTo(1, 650, Easing.OutQuint);
|
content.ScaleTo(1, 650, Easing.OutQuint);
|
||||||
content.FadeInFromZero(400);
|
content.FadeInFromZero(400);
|
||||||
@ -127,7 +127,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private void contentOut()
|
private void contentOut()
|
||||||
{
|
{
|
||||||
Background?.BlurTo(new Vector2(0), 800, Easing.OutQuint);
|
Background.AddedBlur.Value = 0;
|
||||||
|
|
||||||
content.ScaleTo(0.7f, 300, Easing.InQuint);
|
content.ScaleTo(0.7f, 300, Easing.InQuint);
|
||||||
content.FadeOut(250);
|
content.FadeOut(250);
|
||||||
@ -166,7 +166,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (this.IsCurrentScreen())
|
if (this.IsCurrentScreen())
|
||||||
{
|
{
|
||||||
Background.BlurTo(BACKGROUND_BLUR, 800, Easing.OutQuint);
|
Background.AddedBlur.Value = background_blur;
|
||||||
Background.EnableVisualSettings.Value = false;
|
Background.EnableVisualSettings.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
if (this.IsCurrentScreen() && Background != null)
|
if (this.IsCurrentScreen() && Background != null)
|
||||||
{
|
{
|
||||||
Background.BlurTo(new Vector2(0), 800, Easing.OutQuint);
|
Background.AddedBlur.Value = 0;
|
||||||
Background.EnableVisualSettings.Value = true;
|
Background.EnableVisualSettings.Value = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,6 +239,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public override void OnSuspending(IScreen next)
|
public override void OnSuspending(IScreen next)
|
||||||
{
|
{
|
||||||
|
Background.EnableVisualSettings.Value = true;
|
||||||
|
|
||||||
base.OnSuspending(next);
|
base.OnSuspending(next);
|
||||||
cancelLoad();
|
cancelLoad();
|
||||||
}
|
}
|
||||||
@ -249,7 +251,7 @@ namespace osu.Game.Screens.Play
|
|||||||
this.FadeOut(150);
|
this.FadeOut(150);
|
||||||
cancelLoad();
|
cancelLoad();
|
||||||
|
|
||||||
Background.EnableVisualSettings.Value = false;
|
Background.EnableVisualSettings.Value = true;
|
||||||
|
|
||||||
return base.OnExiting(next);
|
return base.OnExiting(next);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
{
|
{
|
||||||
public abstract class Results : OsuScreen
|
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 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);
|
||||||
(Background as BackgroundScreenBeatmap)?.BlurTo(BACKGROUND_BLUR, 2500, Easing.OutQuint);
|
((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 =>
|
||||||
|
@ -37,8 +37,8 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
public abstract class SongSelect : OsuScreen
|
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 static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
||||||
|
private 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,8 +556,9 @@ namespace osu.Game.Screens.Select
|
|||||||
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
|
if (Background is BackgroundScreenBeatmap backgroundModeBeatmap)
|
||||||
{
|
{
|
||||||
backgroundModeBeatmap.Beatmap = beatmap;
|
backgroundModeBeatmap.Beatmap = beatmap;
|
||||||
backgroundModeBeatmap.BlurTo(BACKGROUND_BLUR, 750, Easing.OutQuint);
|
backgroundModeBeatmap.AddedBlur.Value = background_blur;
|
||||||
backgroundModeBeatmap.FadeColour(Color4.White, 250);
|
backgroundModeBeatmap.FadeColour(Color4.White, 250);
|
||||||
|
Logger.Log("blur updated!");
|
||||||
}
|
}
|
||||||
|
|
||||||
beatmapInfoWedge.Beatmap = beatmap;
|
beatmapInfoWedge.Beatmap = beatmap;
|
||||||
|
Loading…
Reference in New Issue
Block a user