1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Ensure health displays don't pile up transforms when off-screen

This commit is contained in:
Dean Herbert 2023-10-10 15:23:50 +09:00
parent 6b38600010
commit 57f588fa86
No known key found for this signature in database
3 changed files with 21 additions and 18 deletions

View File

@ -142,14 +142,17 @@ namespace osu.Game.Screens.Play.HUD
Current.BindValueChanged(v =>
{
if (v.NewValue >= GlowBarValue)
finishMissDisplay();
Scheduler.AddOnce(() =>
{
if (v.NewValue >= GlowBarValue)
finishMissDisplay();
double time = v.NewValue > GlowBarValue ? 500 : 250;
double time = v.NewValue > GlowBarValue ? 500 : 250;
this.TransformTo(nameof(HealthBarValue), v.NewValue, time, Easing.OutQuint);
if (resetMissBarDelegate == null)
this.TransformTo(nameof(GlowBarValue), v.NewValue, time, Easing.OutQuint);
this.TransformTo(nameof(HealthBarValue), v.NewValue, time, Easing.OutQuint);
if (resetMissBarDelegate == null)
this.TransformTo(nameof(GlowBarValue), v.NewValue, time, Easing.OutQuint);
});
}, true);
BarLength.BindValueChanged(l => Width = l.NewValue, true);

View File

@ -112,6 +112,13 @@ namespace osu.Game.Screens.Play.HUD
};
}
protected override void Flash(JudgementResult result)
{
fill.FadeEdgeEffectTo(Math.Min(1, fill.EdgeEffect.Colour.Linear.A + (1f - base_glow_opacity) / glow_max_hits), 50, Easing.OutQuint)
.Delay(glow_fade_delay)
.FadeEdgeEffectTo(base_glow_opacity, glow_fade_time, Easing.OutQuint);
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
@ -119,15 +126,6 @@ namespace osu.Game.Screens.Play.HUD
GlowColour = colours.BlueDarker;
}
protected override void Flash(JudgementResult result) => Scheduler.AddOnce(flash);
private void flash()
{
fill.FadeEdgeEffectTo(Math.Min(1, fill.EdgeEffect.Colour.Linear.A + (1f - base_glow_opacity) / glow_max_hits), 50, Easing.OutQuint)
.Delay(glow_fade_delay)
.FadeEdgeEffectTo(base_glow_opacity, glow_fade_time, Easing.OutQuint);
}
protected override void Update()
{
base.Update();

View File

@ -39,6 +39,7 @@ namespace osu.Game.Screens.Play.HUD
/// <summary>
/// Triggered when a <see cref="Judgement"/> is a successful hit, signaling the health display to perform a flash animation (if designed to do so).
/// Calls to this method are debounced.
/// </summary>
/// <param name="result">The judgement result.</param>
protected virtual void Flash(JudgementResult result)
@ -47,6 +48,7 @@ namespace osu.Game.Screens.Play.HUD
/// <summary>
/// Triggered when a <see cref="Judgement"/> resulted in the player losing health.
/// Calls to this method are debounced.
/// </summary>
/// <param name="result">The judgement result.</param>
protected virtual void Miss(JudgementResult result)
@ -92,7 +94,7 @@ namespace osu.Game.Screens.Play.HUD
{
double newValue = Current.Value + 0.05f;
this.TransformBindableTo(Current, newValue, increase_delay);
Flash(new JudgementResult(new HitObject(), new Judgement()));
Scheduler.AddOnce(Flash, new JudgementResult(new HitObject(), new Judgement()));
if (newValue >= 1)
finishInitialAnimation();
@ -115,9 +117,9 @@ namespace osu.Game.Screens.Play.HUD
private void onNewJudgement(JudgementResult judgement)
{
if (judgement.IsHit && judgement.Type != HitResult.IgnoreHit)
Flash(judgement);
Scheduler.AddOnce(Flash, judgement);
else if (judgement.Judgement.HealthIncreaseFor(judgement) < 0)
Miss(judgement);
Scheduler.AddOnce(Miss, judgement);
}
protected override void Dispose(bool isDisposing)