diff options
Diffstat (limited to 'core/src/ch/asynk')
6 files changed, 25 insertions, 57 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/ActionButtons.java b/core/src/ch/asynk/tankontank/game/hud/ActionButtons.java index b3a9afe..90e9873 100644 --- a/core/src/ch/asynk/tankontank/game/hud/ActionButtons.java +++ b/core/src/ch/asynk/tankontank/game/hud/ActionButtons.java @@ -14,13 +14,11 @@ public class ActionButtons extends Bg public enum Buttons { NONE(-1, 0), - MOVE(0, 1), - ROTATE( 1, 2), - PROMOTE(2, 4), - ENGAGE(3, 8), - DONE(4, 16), - ABORT(5, 32), - LAST(6, 0); + PROMOTE(0, 1), + ORDER(1, 2), + DONE(2, 4), + ABORT(3, 8), + LAST(4, 0); Buttons(int i, int b) { @@ -34,7 +32,7 @@ public class ActionButtons extends Bg public float padding; private int idx; - private Button buttons []; + private Bg buttons []; private StateType states []; private Position position; @@ -47,19 +45,17 @@ public class ActionButtons extends Bg this.position = Position.BOTTOM_RIGHT; this.idx = Buttons.NONE.i; - this.buttons = new Button[Buttons.LAST.i]; - this.buttons[Buttons.MOVE.i] = new Button(atlas, "btn-move"); - this.buttons[Buttons.ROTATE.i] = new Button(atlas, "btn-rotate"); - this.buttons[Buttons.PROMOTE.i] = new Button(atlas, "btn-promote"); - this.buttons[Buttons.ENGAGE.i] = new Button(atlas, "btn-engage"); - this.buttons[Buttons.DONE.i] = new Button(atlas, "btn-check"); - this.buttons[Buttons.ABORT.i] = new Button(atlas, "btn-cancel"); + + this.buttons = new Bg[Buttons.LAST.i]; + this.buttons[Buttons.DONE.i] = new Bg(atlas.findRegion("ok")); + this.buttons[Buttons.ABORT.i] = new Bg(atlas.findRegion("cancel")); + this.buttons[Buttons.ORDER.i] = new Bg(atlas.findRegion("order")); + this.buttons[Buttons.PROMOTE.i] = new Bg(atlas.findRegion("promote")); this.states = new StateType[Buttons.LAST.i]; - this.states[Buttons.MOVE.i] = StateType.MOVE; - this.states[Buttons.ROTATE.i] = StateType.ROTATE; + // FIXME + // this.states[Buttons.ORDER.i] = StateType.ORDER; this.states[Buttons.PROMOTE.i] = StateType.PROMOTE; - this.states[Buttons.ENGAGE.i] = StateType.ENGAGE; this.states[Buttons.DONE.i] = StateType.DONE; this.states[Buttons.ABORT.i] = StateType.ABORT; } @@ -77,29 +73,14 @@ public class ActionButtons extends Bg this.position = position; } - public void setUp(Buttons b) - { - buttons[b.i].setUp(); - } - - public void setDown(Buttons b) - { - buttons[b.i].setDown(); - } - - public void setOn(Buttons b) - { - buttons[b.i].setOn(); - } - public void hide() { for (int i = 0; i < Buttons.LAST.i; i++) - buttons[i].hide(); + buttons[i].visible = false; this.visible = false; } - private float setButton(Button btn, float x, float y) + private float setButton(Bg btn, float x, float y) { btn.visible = true; btn.setPosition(x, y); @@ -134,7 +115,7 @@ public class ActionButtons extends Bg if ((bits & b) == b) y = setButton(buttons[i], x, y); else - buttons[i].hide(); + buttons[i].visible = false; b *= 2; } @@ -155,9 +136,6 @@ public class ActionButtons extends Bg } } - if (idx != Buttons.NONE.i) - buttons[idx].setDown(); - return (idx != Buttons.NONE.i); } @@ -171,8 +149,7 @@ public class ActionButtons extends Bg if (super.hit(x,y) && buttons[idx].hit(x, y)) { ctrl.setState(states[idx]); ret = true; - } else - buttons[idx].setUp(); + } idx = Buttons.NONE.i; diff --git a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java index 3a6f2a5..aad241c 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateDeployment.java +++ b/core/src/ch/asynk/tankontank/game/states/StateDeployment.java @@ -117,8 +117,7 @@ public class StateDeployment extends StateCommon map.selectHex(selectedHex); map.showDirections(selectedHex); ctrl.hud.playerInfo.unitDock.hide(); - ctrl.hud.actionButtons.show(Buttons.ROTATE.b | Buttons.ABORT.b); - ctrl.hud.actionButtons.setOn(Buttons.ROTATE); + ctrl.hud.actionButtons.show(Buttons.ABORT.b); } private void doRotation(Orientation o) diff --git a/core/src/ch/asynk/tankontank/game/states/StateEngage.java b/core/src/ch/asynk/tankontank/game/states/StateEngage.java index 85e6c30..55adac4 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateEngage.java +++ b/core/src/ch/asynk/tankontank/game/states/StateEngage.java @@ -11,8 +11,7 @@ public class StateEngage extends StateCommon public void enter(StateType prevState) { map.possibleTargets.clear(); - ctrl.hud.actionButtons.show(Buttons.ENGAGE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); - ctrl.hud.actionButtons.setOn(Buttons.ENGAGE); + ctrl.hud.actionButtons.show(ctrl.cfg.canCancel ? Buttons.ABORT.b : 0); // activeUnit is the target if (prevState == StateType.SELECT) { @@ -89,7 +88,7 @@ public class StateEngage extends StateCommon activeUnit.showTarget(); map.collectAttackAssists(selectedUnit, activeUnit, ctrl.player.units); map.showAttackAssists(); - ctrl.hud.actionButtons.show(Buttons.ENGAGE.b | Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); + ctrl.hud.actionButtons.show(Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); } else if (unit == activeUnit) { ctrl.setState(StateType.DONE); diff --git a/core/src/ch/asynk/tankontank/game/states/StateMove.java b/core/src/ch/asynk/tankontank/game/states/StateMove.java index 0e83782..f7103a8 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateMove.java +++ b/core/src/ch/asynk/tankontank/game/states/StateMove.java @@ -10,8 +10,7 @@ public class StateMove extends StateCommon public void enter(StateType prevState) { boolean moreThanOne = ((map.moveableUnits.size() + map.activatedUnits.size()) > 1); - ctrl.hud.actionButtons.show(Buttons.ROTATE.b | Buttons.MOVE.b | ((moreThanOne) ? Buttons.DONE.b : 0) | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); - ctrl.hud.actionButtons.setOn(Buttons.MOVE); + ctrl.hud.actionButtons.show((moreThanOne ? Buttons.DONE.b : 0) | (ctrl.cfg.canCancel ? Buttons.ABORT.b : 0)); if (prevState == StateType.ESCAPE) { if (map.possiblePaths.size() == 1) diff --git a/core/src/ch/asynk/tankontank/game/states/StateRotate.java b/core/src/ch/asynk/tankontank/game/states/StateRotate.java index 88505dc..aa427ab 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateRotate.java +++ b/core/src/ch/asynk/tankontank/game/states/StateRotate.java @@ -14,8 +14,7 @@ public class StateRotate extends StateCommon @Override public void enter(StateType prevState) { - ctrl.hud.actionButtons.show(Buttons.ROTATE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); - ctrl.hud.actionButtons.setOn(Buttons.ROTATE); + ctrl.hud.actionButtons.show(ctrl.cfg.canCancel ? Buttons.ABORT.b : 0); if (activeUnit == null) activeUnit = selectedUnit; @@ -95,7 +94,7 @@ public class StateRotate extends StateCommon if (ctrl.cfg.mustValidate) { map.hideDirections(to); map.showOrientation(to, o); - ctrl.hud.actionButtons.show(Buttons.ROTATE.b | Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); + ctrl.hud.actionButtons.show(Buttons.DONE.b | ((ctrl.cfg.canCancel) ? Buttons.ABORT.b : 0)); } else { doRotation(o); ctrl.setState(StateType.ANIMATION); diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java index 46b73c0..86139b7 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java +++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java @@ -83,12 +83,7 @@ public class StateSelect extends StateCommon if (moves > 0) map.collectMoveableUnits(selectedUnit); showPossibilities(selectedUnit); - ctrl.hud.actionButtons.show( - ((ctrl.player.canPromote(selectedUnit)) ? Buttons.PROMOTE.b : 0 ) | - ((selectedUnit.canMove()) ? Buttons.ROTATE.b : 0 ) | - ((moves > 0) ? Buttons.MOVE.b : 0 ) | - ((targets > 0) ? Buttons.ENGAGE.b : 0) - ); + ctrl.hud.actionButtons.show((ctrl.player.canPromote(selectedUnit)) ? Buttons.PROMOTE.b : 0 ); } else { ctrl.hud.actionButtons.hide(); map.clearAll(); |