mirror of https://github.com/ppy/osu
Merge pull request #26549 from bdach/hit-error-meter-pooling-bad
Fix `ColourHitErrorMeter` not loading pooled drawables ahead of time
This commit is contained in:
commit
456a8e6e82
|
@ -15,7 +15,6 @@
|
|||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
|
@ -42,16 +41,21 @@ public partial class ColourHitErrorMeter : HitErrorMeter
|
|||
[SettingSource(typeof(ColourHitErrorMeterStrings), nameof(ColourHitErrorMeterStrings.JudgementShape), nameof(ColourHitErrorMeterStrings.JudgementShapeDescription))]
|
||||
public Bindable<ShapeStyle> JudgementShape { get; } = new Bindable<ShapeStyle>();
|
||||
|
||||
private readonly DrawablePool<HitErrorShape> judgementShapePool;
|
||||
private readonly JudgementFlow judgementsFlow;
|
||||
|
||||
public ColourHitErrorMeter()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
InternalChild = judgementsFlow = new JudgementFlow
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
JudgementShape = { BindTarget = JudgementShape },
|
||||
JudgementSpacing = { BindTarget = JudgementSpacing },
|
||||
JudgementCount = { BindTarget = JudgementCount }
|
||||
judgementShapePool = new DrawablePool<HitErrorShape>(50),
|
||||
judgementsFlow = new JudgementFlow
|
||||
{
|
||||
JudgementShape = { BindTarget = JudgementShape },
|
||||
JudgementSpacing = { BindTarget = JudgementSpacing },
|
||||
JudgementCount = { BindTarget = JudgementCount }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -60,7 +64,7 @@ protected override void OnNewJudgement(JudgementResult judgement)
|
|||
if (!judgement.Type.IsScorable() || judgement.Type.IsBonus())
|
||||
return;
|
||||
|
||||
judgementsFlow.Push(GetColourForHitResult(judgement.Type));
|
||||
judgementsFlow.Push(judgementShapePool.Get(shape => shape.Colour = GetColourForHitResult(judgement.Type)));
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
|
@ -105,15 +109,10 @@ protected override void LoadComplete()
|
|||
|
||||
private readonly DrawablePool<HitErrorShape> judgementLinePool = new DrawablePool<HitErrorShape>(50);
|
||||
|
||||
public void Push(Color4 colour)
|
||||
public void Push(HitErrorShape shape)
|
||||
{
|
||||
judgementLinePool.Get(shape =>
|
||||
{
|
||||
shape.Colour = colour;
|
||||
Add(shape);
|
||||
|
||||
removeExtraJudgements();
|
||||
});
|
||||
Add(shape);
|
||||
removeExtraJudgements();
|
||||
}
|
||||
|
||||
private void removeExtraJudgements()
|
||||
|
|
Loading…
Reference in New Issue