mirror of
https://github.com/ppy/osu
synced 2025-03-21 02:17:48 +00:00
Hide red tint based on "Show health display even when you can't fail" setting
This commit is contained in:
parent
f381cf3ae8
commit
97a212a7f6
@ -31,6 +31,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double LowHealthThreshold = 0.20f;
|
public double LowHealthThreshold = 0.20f;
|
||||||
|
|
||||||
|
public readonly Bindable<bool> HUDEnabled = new Bindable<bool>();
|
||||||
private readonly Bindable<bool> enabled = new Bindable<bool>();
|
private readonly Bindable<bool> enabled = new Bindable<bool>();
|
||||||
private readonly Container boxes;
|
private readonly Container boxes;
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
boxes.Colour = color.Red;
|
boxes.Colour = color.Red;
|
||||||
|
|
||||||
configEnabled = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
configEnabled = config.GetBindable<bool>(OsuSetting.FadePlayfieldWhenHealthLow);
|
||||||
enabled.BindValueChanged(e => this.FadeTo(e.NewValue ? 1 : 0, fade_time, Easing.OutQuint), true);
|
enabled.BindValueChanged(e => TryToFade(fade_time, Easing.OutQuint, e.NewValue ? true : false), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -105,6 +106,28 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
enabled.Value = false;
|
enabled.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tries to fade based on "Fade playfield when health is low" setting
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fadeDuration">Duration of the fade</param>
|
||||||
|
/// <param name="easing">Type of easing</param>
|
||||||
|
/// <param name="fadeIn">True when you want to fade in, false when you want to fade out</param>
|
||||||
|
public void TryToFade(float fadeDuration, Easing easing, bool fadeIn)
|
||||||
|
{
|
||||||
|
if (HUDEnabled.Value)
|
||||||
|
{
|
||||||
|
if (fadeIn)
|
||||||
|
{
|
||||||
|
if (enabled.Value)
|
||||||
|
this.FadeIn(fadeDuration, easing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.FadeOut(fadeDuration, easing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.FadeOut(fadeDuration, easing);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
double target = Math.Clamp(max_alpha * (1 - Current.Value / LowHealthThreshold), 0, max_alpha);
|
double target = Math.Clamp(max_alpha * (1 - Current.Value / LowHealthThreshold), 0, max_alpha);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.Diagnostics.Runtime.Interop;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
@ -153,6 +154,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
// start all elements hidden
|
// start all elements hidden
|
||||||
hideTargets.ForEach(d => d.Hide());
|
hideTargets.ForEach(d => d.Hide());
|
||||||
|
|
||||||
|
FailingLayer.HUDEnabled.BindTo(ShowHealthbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Hide() => throw new InvalidOperationException($"{nameof(HUDOverlay)} should not be hidden as it will remove the ability of a user to quit. Use {nameof(ShowHud)} instead.");
|
public override void Hide() => throw new InvalidOperationException($"{nameof(HUDOverlay)} should not be hidden as it will remove the ability of a user to quit. Use {nameof(ShowHud)} instead.");
|
||||||
@ -168,11 +171,13 @@ namespace osu.Game.Screens.Play
|
|||||||
if (healthBar.NewValue)
|
if (healthBar.NewValue)
|
||||||
{
|
{
|
||||||
HealthDisplay.FadeIn(fade_duration, fade_easing);
|
HealthDisplay.FadeIn(fade_duration, fade_easing);
|
||||||
|
FailingLayer.TryToFade(fade_duration, fade_easing, true);
|
||||||
topScoreContainer.MoveToY(30, fade_duration, fade_easing);
|
topScoreContainer.MoveToY(30, fade_duration, fade_easing);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HealthDisplay.FadeOut(fade_duration, fade_easing);
|
HealthDisplay.FadeOut(fade_duration, fade_easing);
|
||||||
|
FailingLayer.TryToFade(fade_duration, fade_easing, false);
|
||||||
topScoreContainer.MoveToY(0, fade_duration, fade_easing);
|
topScoreContainer.MoveToY(0, fade_duration, fade_easing);
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user