1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 15:02:54 +08:00

Fix ColourHitErrorMeter not loading pooled drawables ahead of time

This commit is contained in:
Bartłomiej Dach 2024-01-15 21:39:33 +01:00
parent 40f612435d
commit 97e08f5071
No known key found for this signature in database

View File

@ -15,7 +15,6 @@ using osu.Game.Localisation.HUD;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD.HitErrorMeters namespace osu.Game.Screens.Play.HUD.HitErrorMeters
{ {
@ -42,16 +41,21 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
[SettingSource(typeof(ColourHitErrorMeterStrings), nameof(ColourHitErrorMeterStrings.JudgementShape), nameof(ColourHitErrorMeterStrings.JudgementShapeDescription))] [SettingSource(typeof(ColourHitErrorMeterStrings), nameof(ColourHitErrorMeterStrings.JudgementShape), nameof(ColourHitErrorMeterStrings.JudgementShapeDescription))]
public Bindable<ShapeStyle> JudgementShape { get; } = new Bindable<ShapeStyle>(); public Bindable<ShapeStyle> JudgementShape { get; } = new Bindable<ShapeStyle>();
private readonly DrawablePool<HitErrorShape> judgementShapePool;
private readonly JudgementFlow judgementsFlow; private readonly JudgementFlow judgementsFlow;
public ColourHitErrorMeter() public ColourHitErrorMeter()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
InternalChild = judgementsFlow = new JudgementFlow InternalChildren = new Drawable[]
{ {
JudgementShape = { BindTarget = JudgementShape }, judgementShapePool = new DrawablePool<HitErrorShape>(50),
JudgementSpacing = { BindTarget = JudgementSpacing }, judgementsFlow = new JudgementFlow
JudgementCount = { BindTarget = JudgementCount } {
JudgementShape = { BindTarget = JudgementShape },
JudgementSpacing = { BindTarget = JudgementSpacing },
JudgementCount = { BindTarget = JudgementCount }
}
}; };
} }
@ -60,7 +64,7 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
if (!judgement.Type.IsScorable() || judgement.Type.IsBonus()) if (!judgement.Type.IsScorable() || judgement.Type.IsBonus())
return; return;
judgementsFlow.Push(GetColourForHitResult(judgement.Type)); judgementsFlow.Push(judgementShapePool.Get(shape => shape.Colour = GetColourForHitResult(judgement.Type)));
} }
public override void Clear() public override void Clear()
@ -105,15 +109,10 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
private readonly DrawablePool<HitErrorShape> judgementLinePool = new DrawablePool<HitErrorShape>(50); private readonly DrawablePool<HitErrorShape> judgementLinePool = new DrawablePool<HitErrorShape>(50);
public void Push(Color4 colour) public void Push(HitErrorShape shape)
{ {
judgementLinePool.Get(shape => Add(shape);
{ removeExtraJudgements();
shape.Colour = colour;
Add(shape);
removeExtraJudgements();
});
} }
private void removeExtraJudgements() private void removeExtraJudgements()