diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-23 12:33:21 +0100 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-23 12:33:21 +0100 | 
| commit | 424755c868b5519d1f73ada82666071a9fa54f8f (patch) | |
| tree | a316be78ea2ac09d5e9b899ae49faddea28a6b52 /core/src/ch/asynk | |
| parent | 93487b179865a8e01fddc6f5a23e64689603b9d7 (diff) | |
| download | RustAndDust-424755c868b5519d1f73ada82666071a9fa54f8f.zip RustAndDust-424755c868b5519d1f73ada82666071a9fa54f8f.tar.gz | |
HUd: regroup dialogs into a Widget[]
Diffstat (limited to 'core/src/ch/asynk')
| -rw-r--r-- | core/src/ch/asynk/tankontank/game/Hud.java | 27 | 
1 files changed, 13 insertions, 14 deletions
| diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java index abaa112..4738c06 100644 --- a/core/src/ch/asynk/tankontank/game/Hud.java +++ b/core/src/ch/asynk/tankontank/game/Hud.java @@ -15,6 +15,7 @@ import ch.asynk.tankontank.game.hud.ActionButtons;  import ch.asynk.tankontank.game.hud.OkCancel;  import ch.asynk.tankontank.game.hud.Statistics;  import ch.asynk.tankontank.game.hud.Engagement; +import ch.asynk.tankontank.game.hud.Widget;  import ch.asynk.tankontank.TankOnTank; @@ -37,6 +38,7 @@ public class Hud implements Disposable      private Engagement engagement;      private OkCancel okCancel;      private DialogAction dialogAction; +    private Widget[] dialogs;      enum DialogAction      { @@ -64,6 +66,7 @@ public class Hud implements Disposable          okCancel = new OkCancel(font, atlas.findRegion("disabled"), atlas, 10f);          stats = new Statistics(font, atlas.findRegion("disabled"), atlas, 10f);          engagement = new Engagement(font, atlas.findRegion("disabled"), atlas, 10f); +        dialogs = new Widget[] { okCancel, stats, engagement};      }      @Override @@ -131,22 +134,18 @@ public class Hud implements Disposable      {          hit = null; -        if (okCancel.visible) { -            if (okCancel.hit(x, y)) -                hit = okCancel; -        } -        else if (stats.visible) { -            if (stats.hit(x, y)) -                hit = stats; +        for (Widget w : dialogs) { +            if (w.visible && w.hit(x, y)) { +                hit = w; +                break; +            }          } -        else if (engagement.visible) { -            if (engagement.hit(x, y)) -                hit = engagement; +        if (hit == null) { +            if (actionButtons.touchDown(x, y)) +                hit = actionButtons; +            else if (playerInfo.touchDown(x, y)) +                hit = playerInfo;          } -        else if (actionButtons.touchDown(x, y)) -            hit = actionButtons; -        else if (playerInfo.touchDown(x, y)) -            hit = playerInfo;          return (hit != null);      } | 
