mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 19:22:56 +08:00
Define explicit method to add background
Also cleans up some redundant/misplaced comments.
This commit is contained in:
parent
8865d53992
commit
ba89bfee0c
@ -1,6 +1,7 @@
|
|||||||
// 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;
|
||||||
@ -50,12 +51,13 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
private readonly bool isStoryboard;
|
private readonly bool isStoryboard;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// As an optimisation, we add the two blur portions to be applied rather than actually applying two separate blurs.
|
||||||
|
/// </summary>
|
||||||
private Vector2 blurTarget => EnableUserDim.Value
|
private Vector2 blurTarget => EnableUserDim.Value
|
||||||
? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25)
|
? new Vector2(BlurAmount.Value + (float)userBlurLevel.Value * 25)
|
||||||
: new Vector2(BlurAmount.Value);
|
: new Vector2(BlurAmount.Value);
|
||||||
|
|
||||||
private Background background;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="UserDimContainer"/>.
|
/// Creates a new <see cref="UserDimContainer"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -71,14 +73,22 @@ namespace osu.Game.Graphics.Containers
|
|||||||
AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both });
|
AddInternal(DimContainer = new Container { RelativeSizeAxes = Axes.Both });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Add(Drawable drawable)
|
private Background background;
|
||||||
|
|
||||||
|
public Background Background
|
||||||
{
|
{
|
||||||
// Make sure we're already at the correct blur target when a background is added to the container.
|
get => background;
|
||||||
if (drawable is Background b)
|
set
|
||||||
{
|
{
|
||||||
background = b;
|
background = value;
|
||||||
background.BlurTo(blurTarget, 0, Easing.OutQuint);
|
background.BlurTo(blurTarget, 0, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Add(Drawable drawable)
|
||||||
|
{
|
||||||
|
if (drawable is Background)
|
||||||
|
throw new InvalidOperationException($"Use {nameof(Background)} to set a background.");
|
||||||
|
|
||||||
base.Add(drawable);
|
base.Add(drawable);
|
||||||
}
|
}
|
||||||
@ -115,10 +125,7 @@ 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
|
||||||
DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
DimContainer.FadeTo(showStoryboard.Value && StoryboardReplacesBackground.Value ? 0 : 1, background_fade_duration, Easing.OutQuint);
|
||||||
|
|
||||||
// This only works if the background is a direct child of DimContainer.
|
Background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint);
|
||||||
// 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 via the direct children of DimContainer.
|
|
||||||
background?.BlurTo(blurTarget, background_fade_duration, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)userDimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint);
|
DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)userDimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint);
|
||||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
}
|
}
|
||||||
|
|
||||||
b.Depth = newDepth;
|
b.Depth = newDepth;
|
||||||
fadeContainer.Add(Background = b);
|
fadeContainer.Background = Background = b;
|
||||||
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private ScheduledDelegate pushDebounce;
|
private ScheduledDelegate pushDebounce;
|
||||||
protected VisualSettings VisualSettings;
|
protected VisualSettings VisualSettings;
|
||||||
|
|
||||||
// required for IsHovered usage in readyForPush
|
// Hhere because IsHovered will not update unless we do so.
|
||||||
public override bool HandlePositionalInput => true;
|
public override bool HandlePositionalInput => true;
|
||||||
|
|
||||||
private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null;
|
private bool readyForPush => player.LoadState == LoadState.Ready && IsHovered && GetContainingInputManager()?.DraggedDrawable == null;
|
||||||
|
Loading…
Reference in New Issue
Block a user