mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:02:57 +08:00
Merge pull request #25076 from peppy/fix-argon-health-bar-perf
Ensure health displays don't pile up transforms when off-screen
This commit is contained in:
commit
d701e88a08
@ -16,7 +16,6 @@ using osu.Framework.Threading;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Skinning;
|
||||
@ -75,7 +74,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
return;
|
||||
|
||||
glowBarValue = value;
|
||||
updatePathVertices();
|
||||
Scheduler.AddOnce(updatePathVertices);
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +89,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
return;
|
||||
|
||||
healthBarValue = value;
|
||||
updatePathVertices();
|
||||
Scheduler.AddOnce(updatePathVertices);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,17 +139,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Current.BindValueChanged(v =>
|
||||
{
|
||||
if (v.NewValue >= GlowBarValue)
|
||||
finishMissDisplay();
|
||||
|
||||
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);
|
||||
}, true);
|
||||
Current.BindValueChanged(_ => Scheduler.AddOnce(updateCurrent), true);
|
||||
|
||||
BarLength.BindValueChanged(l => Width = l.NewValue, true);
|
||||
BarHeight.BindValueChanged(_ => updatePath());
|
||||
@ -165,6 +154,17 @@ namespace osu.Game.Screens.Play.HUD
|
||||
return base.OnInvalidate(invalidation, source);
|
||||
}
|
||||
|
||||
private void updateCurrent()
|
||||
{
|
||||
if (Current.Value >= GlowBarValue) finishMissDisplay();
|
||||
|
||||
double time = Current.Value > GlowBarValue ? 500 : 250;
|
||||
|
||||
// TODO: this should probably use interpolation in update.
|
||||
this.TransformTo(nameof(HealthBarValue), Current.Value, time, Easing.OutQuint);
|
||||
if (resetMissBarDelegate == null) this.TransformTo(nameof(GlowBarValue), Current.Value, time, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -173,9 +173,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
glowBar.Alpha = (float)Interpolation.DampContinuously(glowBar.Alpha, GlowBarValue > 0 ? 1 : 0, 40, Time.Elapsed);
|
||||
}
|
||||
|
||||
protected override void Flash(JudgementResult result)
|
||||
protected override void Flash()
|
||||
{
|
||||
base.Flash(result);
|
||||
base.Flash();
|
||||
|
||||
mainBar.TransformTo(nameof(BarPath.GlowColour), main_bar_glow_colour.Opacity(0.8f))
|
||||
.TransformTo(nameof(BarPath.GlowColour), main_bar_glow_colour, 300, Easing.OutQuint);
|
||||
@ -191,9 +191,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Miss(JudgementResult result)
|
||||
protected override void Miss()
|
||||
{
|
||||
base.Miss(result);
|
||||
base.Miss();
|
||||
|
||||
if (resetMissBarDelegate != null)
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -112,6 +111,13 @@ namespace osu.Game.Screens.Play.HUD
|
||||
};
|
||||
}
|
||||
|
||||
protected override 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);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
@ -119,15 +125,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();
|
||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
@ -39,17 +38,17 @@ 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)
|
||||
protected virtual void Flash()
|
||||
{
|
||||
}
|
||||
|
||||
/// <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)
|
||||
protected virtual void Miss()
|
||||
{
|
||||
}
|
||||
|
||||
@ -92,7 +91,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);
|
||||
|
||||
if (newValue >= 1)
|
||||
finishInitialAnimation();
|
||||
@ -101,6 +100,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private void finishInitialAnimation()
|
||||
{
|
||||
if (initialIncrease == null)
|
||||
return;
|
||||
|
||||
initialIncrease?.Cancel();
|
||||
initialIncrease = null;
|
||||
|
||||
@ -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);
|
||||
else if (judgement.Judgement.HealthIncreaseFor(judgement) < 0)
|
||||
Miss(judgement);
|
||||
Scheduler.AddOnce(Miss);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Utils;
|
||||
using osuTK;
|
||||
@ -80,7 +79,7 @@ namespace osu.Game.Skinning
|
||||
marker.Position = fill.Position + new Vector2(fill.DrawWidth, isNewStyle ? fill.DrawHeight / 2 : 0);
|
||||
}
|
||||
|
||||
protected override void Flash(JudgementResult result) => marker.Flash(result);
|
||||
protected override void Flash() => marker.Flash();
|
||||
|
||||
private static Texture getTexture(ISkin skin, string name) => skin?.GetTexture($"scorebar-{name}");
|
||||
|
||||
@ -238,7 +237,7 @@ namespace osu.Game.Skinning
|
||||
});
|
||||
}
|
||||
|
||||
public override void Flash(JudgementResult result)
|
||||
public override void Flash()
|
||||
{
|
||||
bulgeMain();
|
||||
|
||||
@ -257,7 +256,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
public Bindable<double> Current { get; } = new Bindable<double>();
|
||||
|
||||
public virtual void Flash(JudgementResult result)
|
||||
public virtual void Flash()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user