From a8110d8675c0fdec2a486e8020747e4a5d4273b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 18 May 2016 22:48:22 +0200 Subject: LabelStack: uses IterableQueue --- core/src/ch/asynk/rustanddust/ui/LabelStack.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/ui/LabelStack.java b/core/src/ch/asynk/rustanddust/ui/LabelStack.java index b534f45..9ab0768 100644 --- a/core/src/ch/asynk/rustanddust/ui/LabelStack.java +++ b/core/src/ch/asynk/rustanddust/ui/LabelStack.java @@ -1,9 +1,8 @@ package ch.asynk.rustanddust.ui; -import java.util.ArrayDeque; - import com.badlogic.gdx.graphics.g2d.BitmapFont; +import ch.asynk.rustanddust.engine.util.IterableQueue; import ch.asynk.rustanddust.engine.gfx.Animation; public class LabelStack extends Label implements Animation @@ -23,19 +22,19 @@ public class LabelStack extends Label implements Animation private float duration; private float elapsed; - private ArrayDeque stack; + private IterableQueue queue; public LabelStack(BitmapFont font, float padding) { super(font, padding); this.visible = false; - this.stack = new ArrayDeque(); + this.queue = new IterableQueue(3); } public void pushWrite(String text, float duration, Position position) { if (visible) - stack.push(new MsgInfo(text, duration, position)); + queue.enqueue(new MsgInfo(text, duration, position)); else write(text, duration, position); } @@ -61,8 +60,8 @@ public class LabelStack extends Label implements Animation elapsed += delta; if (elapsed >= duration) { visible = false; - if (stack.size() > 0) { - MsgInfo info = stack.pop(); + if (queue.size() > 0) { + MsgInfo info = queue.dequeue(); write(info.text, info.duration, info.position); return true; } -- cgit v1.1-2-g2b99