From 7c70b2a13d74a5021073fc963bc6252bfc2986ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 18 Dec 2015 15:55:36 +0100 Subject: Hud: dialogs is a Stack --- core/src/ch/asynk/rustanddust/game/Hud.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/Hud.java b/core/src/ch/asynk/rustanddust/game/Hud.java index 7a1e2ad..c2e3643 100644 --- a/core/src/ch/asynk/rustanddust/game/Hud.java +++ b/core/src/ch/asynk/rustanddust/game/Hud.java @@ -1,6 +1,6 @@ package ch.asynk.rustanddust.game; -import java.util.LinkedList; +import java.util.Stack; import com.badlogic.gdx.Gdx; @@ -44,7 +44,7 @@ public class Hud implements Disposable, Animation private StatisticsPanel stats; private EngagementPanel engagement; private OkCancel okCancel; - private LinkedList dialogs = new LinkedList(); + private Stack dialogs = new Stack(); public enum OkCancelAction { @@ -181,7 +181,7 @@ public class Hud implements Disposable, Animation hit = null; if (dialogs.size() > 0) { - Widget dialog = dialogs.getFirst(); + Widget dialog = dialogs.peek(); if (dialog.hit(x, y)) { hit = dialog; return true; @@ -210,7 +210,7 @@ public class Hud implements Disposable, Animation return false; if (dialogs.size() > 0) { - Widget dialog = dialogs.getFirst(); + Widget dialog = dialogs.peek(); if (hit == dialog) { if (dialog.hit(x, y)) closeDialog(); @@ -237,7 +237,7 @@ public class Hud implements Disposable, Animation private void closeDialog() { - Widget dialog = dialogs.removeFirst(); + Widget dialog = dialogs.pop(); dialog.visible = false; if (dialog == okCancel) @@ -246,7 +246,7 @@ public class Hud implements Disposable, Animation ctrl.endGame(); if (dialogs.size() > 0) - dialogs.getFirst().visible = true; + dialogs.peek().visible = true; else ctrl.blockMap = false; } @@ -283,7 +283,7 @@ public class Hud implements Disposable, Animation private void delayOver() { delayOn = false; - Widget dialog = dialogs.getFirst(); + Widget dialog = dialogs.peek(); if (dialog == engagement) closeDialog(); } @@ -297,8 +297,8 @@ public class Hud implements Disposable, Animation { ctrl.blockMap = true; if (dialogs.size() != 0) - dialog.visible = false; - dialogs.addLast(dialog); + dialogs.peek().visible = false; + dialogs.push(dialog); } public void notifyDeploymentDone() -- cgit v1.1-2-g2b99