1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:12:57 +08:00

Move blurring logic into Update instead

This commit is contained in:
David Zhao 2019-03-20 16:50:47 +09:00
parent 1086688e0a
commit e9034c8a30

View File

@ -2,13 +2,11 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Screens;
using osu.Framework.Threading;
@ -41,6 +39,8 @@ namespace osu.Game.Screens.Play
public override bool DisallowExternalBeatmapRulesetChanges => true;
public override bool HandlePositionalInput => true;
private Task loadTask;
public PlayerLoader(Func<Player> createPlayer)
@ -158,35 +158,6 @@ namespace osu.Game.Screens.Play
private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null;
protected override bool OnHover(HoverEvent e)
{
// Acts as an "on hover lost" trigger for the visual settings panel.
// Returns background dim and blur to the values specified by PlayerLoader.
if (this.IsCurrentScreen())
{
Background.BlurAmount.Value = BACKGROUND_BLUR;
Background.EnableUserDim.Value = false;
}
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
// Acts as an "on hover" trigger for the visual settings panel.
// Preview user-defined background dim and blur when hovered on the visual settings panel.
if (GetContainingInputManager()?.HoveredDrawables.Contains(VisualSettings) == true)
{
if (this.IsCurrentScreen() && Background != null)
{
Background.BlurAmount.Value = 0;
Background.EnableUserDim.Value = true;
}
}
base.OnHoverLost(e);
}
private void pushWhenLoaded()
{
if (!this.IsCurrentScreen()) return;
@ -267,6 +238,29 @@ namespace osu.Game.Screens.Play
}
}
protected override void Update()
{
base.Update();
if (!this.IsCurrentScreen())
return;
if (Background.BlurAmount.Value != 0 && VisualSettings.IsHovered)
{
// Acts as an "on hover" trigger for the visual settings panel.
// Preview user-defined background dim and blur when hovered on the visual settings panel.
Background.EnableUserDim.Value = true;
Background.BlurAmount.Value = 0;
}
else if (Background.BlurAmount.Value != BACKGROUND_BLUR && !VisualSettings.IsHovered)
{
// Acts as an "on hover lost" trigger for the visual settings panel.
// Returns background dim and blur to the values specified by PlayerLoader.
Background.EnableUserDim.Value = false;
Background.BlurAmount.Value = BACKGROUND_BLUR;
}
}
private class BeatmapMetadataDisplay : Container
{
private class MetadataLine : Container