Add a game setting to disable the layer

This commit is contained in:
Lucas A 2020-03-30 12:59:39 +02:00
parent 00c1ff993a
commit 3cae0cedee
3 changed files with 15 additions and 1 deletions

View File

@ -87,6 +87,7 @@ protected override void InitialiseDefaults()
Set(OsuSetting.ShowInterface, true);
Set(OsuSetting.ShowProgressGraph, true);
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
Set(OsuSetting.FadePlayfieldWhenHealthLow, true);
Set(OsuSetting.KeyOverlay, false);
Set(OsuSetting.ScoreMeter, ScoreMeterType.HitErrorBoth);
@ -181,6 +182,7 @@ public enum OsuSetting
ShowInterface,
ShowProgressGraph,
ShowHealthDisplayWhenCantFail,
FadePlayfieldWhenHealthLow,
MouseDisableButtons,
MouseDisableWheel,
AudioOffset,

View File

@ -53,6 +53,12 @@ private void load(OsuConfigManager config)
Keywords = new[] { "hp", "bar" }
},
new SettingsCheckbox
{
LabelText = "Fade playfield to red when health is low",
Bindable = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow),
Keywords = new[] { "hp", "low", "playfield", "red" }
},
new SettingsCheckbox
{
LabelText = "Always show key overlay",
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)

View File

@ -3,9 +3,11 @@
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Configuration;
using osu.Game.Graphics;
namespace osu.Game.Screens.Play.HUD
@ -21,6 +23,8 @@ public class FailingLayer : HealthDisplay
private readonly Box box;
private Bindable<bool> enabled;
/// <summary>
/// The threshold under which the current player life should be considered low and the layer should start fading in.
/// </summary>
@ -37,9 +41,11 @@ public FailingLayer()
}
[BackgroundDependencyLoader]
private void load(OsuColour color)
private void load(OsuColour color, OsuConfigManager config)
{
box.Colour = color.Red;
enabled = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
enabled.BindValueChanged(e => this.FadeTo(e.NewValue ? 1 : 0, fade_time, Easing.OutQuint), true);
}
protected override void Update()