diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-18 16:03:59 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-18 16:03:59 +0100 |
commit | c4c036eb0199d2a8b4535ff2708f809439baef57 (patch) | |
tree | 4ab2a52ffe94b84463447df59abc10f82f839bf8 /core/src/ch/asynk/rustanddust/game | |
parent | 093d7d83c113599421b90ecfd2b8d37eb71d3925 (diff) | |
download | RustAndDust-c4c036eb0199d2a8b4535ff2708f809439baef57.zip RustAndDust-c4c036eb0199d2a8b4535ff2708f809439baef57.tar.gz |
Hud: plug OptionsPanel in
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/Hud.java | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Hud.java b/core/src/ch/asynk/rustanddust/game/Hud.java index c2e3643..a90507f 100644 --- a/core/src/ch/asynk/rustanddust/game/Hud.java +++ b/core/src/ch/asynk/rustanddust/game/Hud.java @@ -20,6 +20,7 @@ import ch.asynk.rustanddust.game.hud.PlayerInfo; import ch.asynk.rustanddust.game.hud.ActionButtons; import ch.asynk.rustanddust.game.hud.StatisticsPanel; import ch.asynk.rustanddust.game.hud.EngagementPanel; +import ch.asynk.rustanddust.game.hud.OptionsPanel; import ch.asynk.rustanddust.RustAndDust; @@ -41,6 +42,7 @@ public class Hud implements Disposable, Animation private boolean delayOn; private Msg msg; private Bg optionsBtn; + private OptionsPanel optionsPanel; private StatisticsPanel stats; private EngagementPanel engagement; private OkCancel okCancel; @@ -52,6 +54,7 @@ public class Hud implements Disposable, Animation ABORT_TURN, END_TURN, END_DEPLOYMENT, + QUIT_BATTLE, } private OkCancelAction okCancelAction; @@ -68,6 +71,7 @@ public class Hud implements Disposable, Animation msg = new Msg(game.font, game.ninePatch, 20f); okCancel = new OkCancel(game.font, game.ninePatch, game.factory.getHudRegion(game.factory.ACT_DONE), game.factory.getHudRegion(game.factory.ACT_ABORT)); optionsBtn = new Bg(game.factory.getHudRegion(game.factory.ACT_OPTIONS)); + optionsPanel = new OptionsPanel(game); stats = new StatisticsPanel(game); engagement = new EngagementPanel(game); } @@ -80,6 +84,7 @@ public class Hud implements Disposable, Animation msg.dispose(); okCancel.dispose(); optionsBtn.dispose(); + optionsPanel.dispose(); stats.dispose(); engagement.dispose(); } @@ -92,6 +97,7 @@ public class Hud implements Disposable, Animation msg.updatePosition(); okCancel.updatePosition(); optionsBtn.setPosition(ctrl.battle.getHudPosition().verticalMirror().horizontalMirror()); + optionsPanel.updatePosition(); stats.updatePosition(); engagement.updatePosition(); } @@ -134,6 +140,7 @@ public class Hud implements Disposable, Animation msg.draw(batch); okCancel.draw(batch); optionsBtn.draw(batch); + optionsPanel.draw(batch); stats.draw(batch); engagement.draw(batch); } @@ -146,6 +153,7 @@ public class Hud implements Disposable, Animation msg.drawDebug(debugShapes); okCancel.drawDebug(debugShapes); optionsBtn.drawDebug(debugShapes); + optionsPanel.drawDebug(debugShapes); stats.drawDebug(debugShapes); engagement.drawDebug(debugShapes); } @@ -180,6 +188,11 @@ public class Hud implements Disposable, Animation { hit = null; + if (optionsBtn.hit(x, y)) { + hit = optionsBtn; + return true; + } + if (dialogs.size() > 0) { Widget dialog = dialogs.peek(); if (dialog.hit(x, y)) { @@ -197,8 +210,6 @@ public class Hud implements Disposable, Animation hit = actionButtons; else if (playerInfo.touchDown(x, y)) hit = playerInfo; - else if (optionsBtn.hit(x, y)) - hit = optionsBtn; } return (hit != null); @@ -209,6 +220,12 @@ public class Hud implements Disposable, Animation if (hit == null) return false; + if (hit == optionsBtn) { + if (optionsBtn.hit(x, y)) + toggleOptionsPanel(); + return true; + } + if (dialogs.size() > 0) { Widget dialog = dialogs.peek(); if (hit == dialog) { @@ -223,11 +240,6 @@ public class Hud implements Disposable, Animation else if (hit == playerInfo) { playerInfo.touchUp(x, y); } - else if (hit == optionsBtn) { - if (optionsBtn.hit(x, y)) { - System.err.println("Options Not Implemented yet"); - } - } hit = null; } @@ -271,6 +283,13 @@ public class Hud implements Disposable, Animation if (ok) ctrl.endDeployment(); break; + case QUIT_BATTLE: + if (ok) { + closeDialog(); + ctrl.endGame(); + } + break; + } } @@ -301,6 +320,17 @@ public class Hud implements Disposable, Animation dialogs.push(dialog); } + private void toggleOptionsPanel() + { + if (dialogs.size() > 0) { + if (dialogs.peek() == optionsPanel) + closeDialog(); + } else { + optionsPanel.show(); + pushDialog(optionsPanel); + } + } + public void notifyDeploymentDone() { this.okCancelAction = OkCancelAction.END_TURN; @@ -338,6 +368,13 @@ public class Hud implements Disposable, Animation pushDialog(okCancel); } + public void askQuitBattle() + { + this.okCancelAction = OkCancelAction.QUIT_BATTLE; + okCancel.show("Quit this battle ?"); + pushDialog(okCancel); + } + public void engagementSummary(Engagement e) { engagement.show(e, Position.BOTTOM_CENTER, game.config.fxVolume); |