From ea89006b40d024886deb280ec51268eb5507b904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 27 Nov 2014 15:36:39 +0100 Subject: Hud: simplify touchUp() code --- core/src/ch/asynk/tankontank/game/Hud.java | 35 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index 9220925..da3c31c 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -163,26 +163,25 @@ public class Hud implements Disposable if (hit == null) return false; - if (hit == actionButtons) { - actionButtons.touchUp(x, y); - } - else if (hit == playerInfo) { - playerInfo.touchUp(x, y); - } - else if (hit == okCancel) { - if (okCancel.hit(x, y)) - closeDialog(); - } - else if (hit == stats) { - if (stats.hit(x, y)) - closeDialog(); - } - else if (hit == engagement) { - if (engagement.hit(x, y)) - closeDialog(); + for (Widget w : dialogs) { + if (hit == w) { + if (w.hit(x, y)) + closeDialog(); + hit = null; + break; + } } - hit = null; + if (hit != null) { + if (hit == actionButtons) { + actionButtons.touchUp(x, y); + } + else if (hit == playerInfo) { + playerInfo.touchUp(x, y); + } + + hit = null; + } return true; } -- cgit v1.1-2-g2b99