mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Lighten user-dim container if on break time
This commit is contained in:
parent
b93bbf81aa
commit
bb078c2afc
@ -1,11 +1,13 @@
|
|||||||
// 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.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Containers
|
namespace osu.Game.Graphics.Containers
|
||||||
{
|
{
|
||||||
@ -14,7 +16,9 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class UserDimContainer : Container
|
public abstract class UserDimContainer : Container
|
||||||
{
|
{
|
||||||
protected const float BACKGROUND_FADE_DURATION = 800;
|
private const float break_lighten_amount = 0.3f;
|
||||||
|
|
||||||
|
protected const double BACKGROUND_FADE_DURATION = 800;
|
||||||
|
|
||||||
/// <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.
|
||||||
@ -26,6 +30,12 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
public readonly Bindable<bool> StoryboardReplacesBackground = new Bindable<bool>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether player is in break time.
|
||||||
|
/// Must be bound to <see cref="BreakOverlay.IsBreakTime"/> to allow for dim adjustments in gameplay.
|
||||||
|
/// </summary>
|
||||||
|
internal readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the content of this container is currently being displayed.
|
/// Whether the content of this container is currently being displayed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -33,11 +43,14 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
protected Bindable<double> UserDimLevel { get; private set; }
|
protected Bindable<double> UserDimLevel { get; private set; }
|
||||||
|
|
||||||
|
protected Bindable<bool> LightenDuringBreaks { get; private set; }
|
||||||
|
|
||||||
protected Bindable<bool> ShowStoryboard { get; private set; }
|
protected Bindable<bool> ShowStoryboard { get; private set; }
|
||||||
|
|
||||||
protected Bindable<bool> ShowVideo { get; private set; }
|
protected Bindable<bool> ShowVideo { get; private set; }
|
||||||
|
|
||||||
protected double DimLevel => EnableUserDim.Value ? UserDimLevel.Value : 0;
|
private float breakLightening => LightenDuringBreaks.Value && IsBreakTime.Value ? break_lighten_amount : 0;
|
||||||
|
protected float DimLevel => Math.Max(EnableUserDim.Value ? (float)UserDimLevel.Value - breakLightening : 0, 0);
|
||||||
|
|
||||||
protected override Container<Drawable> Content => dimContent;
|
protected override Container<Drawable> Content => dimContent;
|
||||||
|
|
||||||
@ -55,11 +68,14 @@ namespace osu.Game.Graphics.Containers
|
|||||||
private void load(OsuConfigManager config)
|
private void load(OsuConfigManager config)
|
||||||
{
|
{
|
||||||
UserDimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
UserDimLevel = config.GetBindable<double>(OsuSetting.DimLevel);
|
||||||
|
LightenDuringBreaks = config.GetBindable<bool>(OsuSetting.LightenDuringBreaks);
|
||||||
ShowStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
ShowStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||||
ShowVideo = config.GetBindable<bool>(OsuSetting.ShowVideoBackground);
|
ShowVideo = config.GetBindable<bool>(OsuSetting.ShowVideoBackground);
|
||||||
|
|
||||||
EnableUserDim.ValueChanged += _ => UpdateVisuals();
|
EnableUserDim.ValueChanged += _ => UpdateVisuals();
|
||||||
UserDimLevel.ValueChanged += _ => UpdateVisuals();
|
UserDimLevel.ValueChanged += _ => UpdateVisuals();
|
||||||
|
LightenDuringBreaks.ValueChanged += _ => UpdateVisuals();
|
||||||
|
IsBreakTime.ValueChanged += _ => UpdateVisuals();
|
||||||
ShowStoryboard.ValueChanged += _ => UpdateVisuals();
|
ShowStoryboard.ValueChanged += _ => UpdateVisuals();
|
||||||
ShowVideo.ValueChanged += _ => UpdateVisuals();
|
ShowVideo.ValueChanged += _ => UpdateVisuals();
|
||||||
StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals();
|
StoryboardReplacesBackground.ValueChanged += _ => UpdateVisuals();
|
||||||
@ -84,7 +100,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
ContentDisplayed = ShowDimContent;
|
ContentDisplayed = ShowDimContent;
|
||||||
|
|
||||||
dimContent.FadeTo(ContentDisplayed ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
dimContent.FadeTo(ContentDisplayed ? 1 : 0, BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
dimContent.FadeColour(OsuColour.Gray(1 - (float)DimLevel), BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
dimContent.FadeColour(OsuColour.Gray(1f - DimLevel), BACKGROUND_FADE_DURATION, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,8 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Bindable<float> BlurAmount = new Bindable<float>();
|
public readonly Bindable<float> BlurAmount = new Bindable<float>();
|
||||||
|
|
||||||
|
internal readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
||||||
|
|
||||||
private readonly DimmableBackground dimmable;
|
private readonly DimmableBackground dimmable;
|
||||||
|
|
||||||
protected virtual DimmableBackground CreateFadeContainer() => new DimmableBackground { RelativeSizeAxes = Axes.Both };
|
protected virtual DimmableBackground CreateFadeContainer() => new DimmableBackground { RelativeSizeAxes = Axes.Both };
|
||||||
@ -48,6 +50,7 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
|
|
||||||
InternalChild = dimmable = CreateFadeContainer();
|
InternalChild = dimmable = CreateFadeContainer();
|
||||||
dimmable.EnableUserDim.BindTo(EnableUserDim);
|
dimmable.EnableUserDim.BindTo(EnableUserDim);
|
||||||
|
dimmable.IsBreakTime.BindTo(IsBreakTime);
|
||||||
dimmable.BlurAmount.BindTo(BlurAmount);
|
dimmable.BlurAmount.BindTo(BlurAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user