Fix spawning too many sprites due to not yet populated sizing

This commit is contained in:
Dean Herbert 2020-05-13 19:19:58 +09:00
parent e28e89213f
commit 00efeb7cc6
1 changed files with 4 additions and 7 deletions

View File

@ -17,6 +17,8 @@ namespace osu.Game.Rulesets.Taiko.Skinning
{ {
public class LegacyTaikoScroller : CompositeDrawable public class LegacyTaikoScroller : CompositeDrawable
{ {
public Bindable<JudgementResult> LastResult = new Bindable<JudgementResult>();
public LegacyTaikoScroller() public LegacyTaikoScroller()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -50,21 +52,16 @@ protected override void LoadComplete()
}, true); }, true);
} }
public Bindable<JudgementResult> LastResult = new Bindable<JudgementResult>();
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
bool wideEnough() =>
InternalChildren.Any()
&& InternalChildren.First().ScreenSpaceDrawQuad.Width * InternalChildren.Count >= ScreenSpaceDrawQuad.Width * 2;
// store X before checking wide enough so if we perform layout there is no positional discrepancy. // store X before checking wide enough so if we perform layout there is no positional discrepancy.
float currentX = (InternalChildren?.FirstOrDefault()?.X ?? 0) - (float)Clock.ElapsedFrameTime * 0.1f; float currentX = (InternalChildren?.FirstOrDefault()?.X ?? 0) - (float)Clock.ElapsedFrameTime * 0.1f;
// ensure we have enough sprites // ensure we have enough sprites
while (!wideEnough()) if (!InternalChildren.Any()
|| InternalChildren.First().ScreenSpaceDrawQuad.Width * InternalChildren.Count < ScreenSpaceDrawQuad.Width * 2)
AddInternal(new ScrollerSprite { Passing = passing }); AddInternal(new ScrollerSprite { Passing = passing });
var first = InternalChildren.First(); var first = InternalChildren.First();