mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 15:12:57 +08:00
Initial implementation of LowHealthLayer
This commit is contained in:
parent
b9cdb317c5
commit
1aacd1aaa2
@ -88,6 +88,7 @@ namespace osu.Game.Configuration
|
|||||||
Set(OsuSetting.ShowInterface, true);
|
Set(OsuSetting.ShowInterface, true);
|
||||||
Set(OsuSetting.ShowProgressGraph, true);
|
Set(OsuSetting.ShowProgressGraph, true);
|
||||||
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
|
Set(OsuSetting.ShowHealthDisplayWhenCantFail, true);
|
||||||
|
Set(OsuSetting.FadePlayfieldWhenLowHealth, true);
|
||||||
Set(OsuSetting.KeyOverlay, false);
|
Set(OsuSetting.KeyOverlay, false);
|
||||||
Set(OsuSetting.ScoreMeter, ScoreMeterType.HitErrorBoth);
|
Set(OsuSetting.ScoreMeter, ScoreMeterType.HitErrorBoth);
|
||||||
|
|
||||||
@ -183,6 +184,7 @@ namespace osu.Game.Configuration
|
|||||||
ShowInterface,
|
ShowInterface,
|
||||||
ShowProgressGraph,
|
ShowProgressGraph,
|
||||||
ShowHealthDisplayWhenCantFail,
|
ShowHealthDisplayWhenCantFail,
|
||||||
|
FadePlayfieldWhenLowHealth,
|
||||||
MouseDisableButtons,
|
MouseDisableButtons,
|
||||||
MouseDisableWheel,
|
MouseDisableWheel,
|
||||||
AudioOffset,
|
AudioOffset,
|
||||||
|
@ -53,6 +53,12 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
Keywords = new[] { "hp", "bar" }
|
Keywords = new[] { "hp", "bar" }
|
||||||
},
|
},
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
|
{
|
||||||
|
LabelText = "Fade playfield to red when health is low",
|
||||||
|
Bindable = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenLowHealth),
|
||||||
|
Keywords = new[] { "hp", "playfield", "health" }
|
||||||
|
},
|
||||||
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
LabelText = "Always show key overlay",
|
LabelText = "Always show key overlay",
|
||||||
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
||||||
|
47
osu.Game/Screens/Play/HUD/LowHealthLayer.cs
Normal file
47
osu.Game/Screens/Play/HUD/LowHealthLayer.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play.HUD
|
||||||
|
{
|
||||||
|
public class LowHealthLayer : HealthDisplay
|
||||||
|
{
|
||||||
|
private const float max_alpha = 0.4f;
|
||||||
|
|
||||||
|
private const double fade_time = 300;
|
||||||
|
|
||||||
|
private readonly Box box;
|
||||||
|
|
||||||
|
private Bindable<bool> configFadeRedWhenLowHealth;
|
||||||
|
|
||||||
|
public LowHealthLayer()
|
||||||
|
{
|
||||||
|
Child = box = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config, OsuColour color)
|
||||||
|
{
|
||||||
|
configFadeRedWhenLowHealth = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenLowHealth);
|
||||||
|
box.Colour = color.Red;
|
||||||
|
|
||||||
|
configFadeRedWhenLowHealth.BindValueChanged(value =>
|
||||||
|
{
|
||||||
|
if (value.NewValue)
|
||||||
|
this.FadeIn(fade_time, Easing.OutQuint);
|
||||||
|
else
|
||||||
|
this.FadeOut(fade_time, Easing.OutQuint);
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user