mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:42:54 +08:00
Fix health processor event leaks
This commit is contained in:
parent
4d82a55594
commit
927cfe4257
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -156,8 +157,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
HealthProcessor.NewJudgement += result => pendingJudgementResult = result;
|
HealthProcessor.NewJudgement += onNewJudgement;
|
||||||
Current.BindValueChanged(_ => Scheduler.AddOnce(updateCurrent), true);
|
Current.BindValueChanged(onCurrentChanged, true);
|
||||||
|
|
||||||
// we're about to set `RelativeSizeAxes` depending on the value of `UseRelativeSize`.
|
// we're about to set `RelativeSizeAxes` depending on the value of `UseRelativeSize`.
|
||||||
// setting `RelativeSizeAxes` internally transforms absolute sizing to relative and back to keep the size the same,
|
// setting `RelativeSizeAxes` internally transforms absolute sizing to relative and back to keep the size the same,
|
||||||
@ -170,7 +171,12 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
BarHeight.BindValueChanged(_ => updatePath(), true);
|
BarHeight.BindValueChanged(_ => updatePath(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCurrent()
|
private void onNewJudgement(JudgementResult result) => pendingJudgementResult = result;
|
||||||
|
|
||||||
|
private void onCurrentChanged(ValueChangedEvent<double> valueChangedEvent)
|
||||||
|
=> Scheduler.AddOnce(updateDisplay);
|
||||||
|
|
||||||
|
private void updateDisplay()
|
||||||
{
|
{
|
||||||
var result = pendingJudgementResult;
|
var result = pendingJudgementResult;
|
||||||
|
|
||||||
@ -333,6 +339,14 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
mainBar.Position = healthBarVertices[0];
|
mainBar.Position = healthBarVertices[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
if (HealthProcessor.IsNotNull())
|
||||||
|
HealthProcessor.NewJudgement -= onNewJudgement;
|
||||||
|
}
|
||||||
|
|
||||||
private partial class BackgroundPath : SmoothPath
|
private partial class BackgroundPath : SmoothPath
|
||||||
{
|
{
|
||||||
protected override Color4 ColourAt(float position)
|
protected override Color4 ColourAt(float position)
|
||||||
|
Loading…
Reference in New Issue
Block a user