Fade health bar on value change

This commit is contained in:
Salman Ahmed
2019-07-03 05:11:11 +03:00
committed by KingLuigi4932
parent 8b4ef52c13
commit 3f39541cc2

View File

@ -2,14 +2,17 @@
// 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 osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
public abstract class ModBlockFail : Mod, IApplicableFailOverride, IApplicableToHUD, IReadFromConfig public abstract class ModBlockFail : Mod, IApplicableFailOverride, IApplicableToHUD, IReadFromConfig
{ {
private Bindable<bool> hideHealthBar = new Bindable<bool>(); private Bindable<bool> hideHealthBar;
private HealthDisplay healthDisplay;
/// <summary> /// <summary>
/// We never fail, 'yo. /// We never fail, 'yo.
@ -19,12 +22,13 @@ namespace osu.Game.Rulesets.Mods
public void ReadFromConfig(OsuConfigManager config) public void ReadFromConfig(OsuConfigManager config)
{ {
hideHealthBar = config.GetBindable<bool>(OsuSetting.HideHealthBar); hideHealthBar = config.GetBindable<bool>(OsuSetting.HideHealthBar);
hideHealthBar.ValueChanged += v => healthDisplay?.FadeTo(v.NewValue ? 0 : 1, 250, Easing.OutQuint);
} }
public void ApplyToHUD(HUDOverlay overlay) public void ApplyToHUD(HUDOverlay overlay)
{ {
if (hideHealthBar.Value) healthDisplay = overlay.HealthDisplay;
overlay.HealthDisplay.Hide(); hideHealthBar?.TriggerChange();
} }
} }
} }