1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 18:32:55 +08:00

Make blurtarget private, improve documentation

This commit is contained in:
David Zhao 2019-03-19 20:15:28 +09:00
parent dc26e90a8d
commit a8e2072286
4 changed files with 26 additions and 21 deletions

View File

@ -333,7 +333,7 @@ namespace osu.Game.Tests.Visual
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 1, Alpha = 1,
EnableVisualSettings = { Value = true } EnableUserDim = { Value = true }
}; };
} }

View File

@ -20,31 +20,37 @@ namespace osu.Game.Graphics.Containers
{ {
private const float background_fade_duration = 800; private const float background_fade_duration = 800;
private Bindable<double> dimLevel { get; set; }
private Bindable<double> blurLevel { get; set; }
private Bindable<bool> showStoryboard { get; set; }
/// <summary> /// <summary>
/// Whether or not user-configured dim levels should be applied to the container. /// Whether or not user-configured dim levels should be applied to the container.
/// </summary> /// </summary>
public readonly Bindable<bool> EnableVisualSettings = new Bindable<bool>(); public readonly Bindable<bool> EnableUserDim = new Bindable<bool>();
/// <summary> /// <summary>
/// Whether or not the storyboard loaded should completely hide the background behind it. /// Whether or not the storyboard loaded should completely hide the background behind it.
/// </summary> /// </summary>
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>(); public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
/// <summary>
/// The amount of blur to be applied to the background in addition to user-specified blur.
/// </summary>
/// <remarks>
/// Used in contexts where there can potentially be both user and screen-specified blurring occuring at the same time, such as in <see cref="PlayerLoader"/>
/// </remarks>
public Bindable<float> AddedBlur = new Bindable<float>();
private Bindable<double> dimLevel { get; set; }
private Bindable<double> blurLevel { get; set; }
private Bindable<bool> showStoryboard { get; set; }
protected Container DimContainer { get; } protected Container DimContainer { get; }
protected override Container<Drawable> Content => DimContainer; protected override Container<Drawable> Content => DimContainer;
private readonly bool isStoryboard; private readonly bool isStoryboard;
public Bindable<float> AddedBlur = new Bindable<float>(); private Vector2 blurTarget => EnableUserDim.Value
public Vector2 BlurTarget => EnableVisualSettings.Value
? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25) ? new Vector2(AddedBlur.Value + (float)blurLevel.Value * 25)
: new Vector2(AddedBlur.Value); : new Vector2(AddedBlur.Value);
@ -69,7 +75,7 @@ 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(); EnableUserDim.ValueChanged += _ => UpdateVisuals();
dimLevel.ValueChanged += _ => UpdateVisuals(); dimLevel.ValueChanged += _ => UpdateVisuals();
blurLevel.ValueChanged += _ => UpdateVisuals(); blurLevel.ValueChanged += _ => UpdateVisuals();
showStoryboard.ValueChanged += _ => UpdateVisuals(); showStoryboard.ValueChanged += _ => UpdateVisuals();
@ -83,7 +89,7 @@ namespace osu.Game.Graphics.Containers
UpdateVisuals(); UpdateVisuals();
} }
public void UpdateVisuals() public void UpdateVisuals(bool instant = false)
{ {
if (isStoryboard) if (isStoryboard)
{ {
@ -97,13 +103,13 @@ namespace osu.Game.Graphics.Containers
foreach (Drawable c in DimContainer) foreach (Drawable c in DimContainer)
{ {
// Only blur if this container contains a background // 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. // 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.
// As a result, this blurs the background directly. // We need to support instant blurring here in the case of SongSelect, where blurring shouldn't be from 0 every time the beatmap is changed.
((Background)c)?.BlurTo(BlurTarget, background_fade_duration, Easing.OutQuint); ((Background)c)?.BlurTo(blurTarget, instant ? 0 : background_fade_duration, Easing.OutQuint);
} }
} }
DimContainer.FadeColour(EnableVisualSettings.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint); DimContainer.FadeColour(EnableUserDim.Value ? OsuColour.Gray(1 - (float)dimLevel.Value) : Color4.White, background_fade_duration, Easing.OutQuint);
} }
} }
} }

View File

@ -53,8 +53,7 @@ namespace osu.Game.Screens.Backgrounds
b.Depth = newDepth; b.Depth = newDepth;
fadeContainer.Add(Background = b); fadeContainer.Add(Background = b);
fadeContainer.UpdateVisuals(); fadeContainer.UpdateVisuals(true);
Background.BlurSigma = fadeContainer.BlurTarget;
StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground); StoryboardReplacesBackground.BindTo(fadeContainer.StoryboardReplacesBackground);
})); }));
}); });
@ -65,7 +64,7 @@ namespace osu.Game.Screens.Backgrounds
{ {
Beatmap = beatmap; Beatmap = beatmap;
InternalChild = fadeContainer = CreateFadeContainer(); InternalChild = fadeContainer = CreateFadeContainer();
fadeContainer.EnableVisualSettings.BindTo(EnableVisualSettings); fadeContainer.EnableUserDim.BindTo(EnableVisualSettings);
fadeContainer.AddedBlur.BindTo(AddedBlur); fadeContainer.AddedBlur.BindTo(AddedBlur);
} }

View File

@ -79,7 +79,7 @@ namespace osu.Game.Screens.Play
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Alpha = 1, Alpha = 1,
EnableVisualSettings = { Value = true } EnableUserDim = { Value = true }
}; };
public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true; public bool LoadedBeatmapSuccessfully => RulesetContainer?.Objects.Any() == true;