From 791b70c479b7f0b6582a58e38a33321af8b1828b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 17 Dec 2015 22:20:13 +0100 Subject: Hud: add options button, not implemented yet --- android/assets/data/hud.atlas | 7 +++++++ android/assets/data/hud.png | Bin 93061 -> 99795 bytes assets/hud/options.png | Bin 0 -> 5989 bytes core/src/ch/asynk/rustanddust/game/Hud.java | 15 +++++++++++++++ core/src/ch/asynk/rustanddust/game/State.java | 3 ++- .../ch/asynk/rustanddust/game/battles/Factory.java | 1 + 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 assets/hud/options.png diff --git a/android/assets/data/hud.atlas b/android/assets/data/hud.atlas index 08199ed..590038f 100644 --- a/android/assets/data/hud.atlas +++ b/android/assets/data/hud.atlas @@ -53,6 +53,13 @@ ok orig: 48, 47 offset: 0, 0 index: -1 +options + rotate: false + xy: 138, 58 + size: 48, 47 + orig: 48, 47 + offset: 0, 0 + index: -1 promote rotate: false xy: 84, 28 diff --git a/android/assets/data/hud.png b/android/assets/data/hud.png index 951b061..cf24f0e 100644 Binary files a/android/assets/data/hud.png and b/android/assets/data/hud.png differ diff --git a/assets/hud/options.png b/assets/hud/options.png new file mode 100644 index 0000000..535161d Binary files /dev/null and b/assets/hud/options.png differ diff --git a/core/src/ch/asynk/rustanddust/game/Hud.java b/core/src/ch/asynk/rustanddust/game/Hud.java index 77b9f71..3ced3dd 100644 --- a/core/src/ch/asynk/rustanddust/game/Hud.java +++ b/core/src/ch/asynk/rustanddust/game/Hud.java @@ -14,6 +14,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import ch.asynk.rustanddust.engine.gfx.Animation; import ch.asynk.rustanddust.game.State.StateType; import ch.asynk.rustanddust.ui.Position; +import ch.asynk.rustanddust.ui.Bg; import ch.asynk.rustanddust.ui.Msg; import ch.asynk.rustanddust.ui.OkCancel; import ch.asynk.rustanddust.ui.Widget; @@ -41,6 +42,7 @@ public class Hud implements Disposable, Animation private float delay; private boolean delayOn; private Msg msg; + private Bg optionsBtn; private StatisticsPanel stats; private EngagementPanel engagement; private OkCancel okCancel; @@ -66,6 +68,7 @@ public class Hud implements Disposable, Animation actionButtons = new ActionButtons(game); actionButtons.hide(); msg = new Msg(game.font, game.ninePatch, 20f); + optionsBtn = new Bg(game.factory.getHudRegion(game.factory.ACT_OPTIONS)); okCancel = new OkCancel(game.font, game.ninePatch, game.factory.getHudRegion(game.factory.ACT_DONE), game.factory.getHudRegion(game.factory.ACT_ABORT)); stats = new StatisticsPanel(game); engagement = new EngagementPanel(game); @@ -77,6 +80,7 @@ public class Hud implements Disposable, Animation playerInfo.dispose(); actionButtons.dispose(); msg.dispose(); + optionsBtn.dispose(); okCancel.dispose(); engagement.dispose(); stats.dispose(); @@ -88,6 +92,7 @@ public class Hud implements Disposable, Animation playerInfo.updatePosition(); actionButtons.updatePosition(); msg.updatePosition(); + optionsBtn.setPosition(ctrl.battle.getHudPosition().verticalMirror().horizontalMirror()); stats.updatePosition(); engagement.updatePosition(); okCancel.updatePosition(); @@ -98,6 +103,7 @@ public class Hud implements Disposable, Animation Position position = ctrl.battle.getHudPosition(); playerInfo.update(ctrl.battle.getPlayer(), position); actionButtons.update(position.horizontalMirror()); + optionsBtn.setPosition(position.verticalMirror().horizontalMirror()); } @Override @@ -128,6 +134,7 @@ public class Hud implements Disposable, Animation playerInfo.draw(batch); actionButtons.draw(batch); msg.draw(batch); + optionsBtn.draw(batch); okCancel.draw(batch); engagement.draw(batch); stats.draw(batch); @@ -139,6 +146,7 @@ public class Hud implements Disposable, Animation playerInfo.drawDebug(debugShapes); actionButtons.drawDebug(debugShapes); msg.drawDebug(debugShapes); + optionsBtn.drawDebug(debugShapes); okCancel.drawDebug(debugShapes); engagement.drawDebug(debugShapes); stats.drawDebug(debugShapes); @@ -191,6 +199,8 @@ 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); @@ -215,6 +225,11 @@ 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; } diff --git a/core/src/ch/asynk/rustanddust/game/State.java b/core/src/ch/asynk/rustanddust/game/State.java index 386df8b..cc7ea9c 100644 --- a/core/src/ch/asynk/rustanddust/game/State.java +++ b/core/src/ch/asynk/rustanddust/game/State.java @@ -15,7 +15,8 @@ public interface State WITHDRAW, ABORT, DONE, - TURN_OVER + TURN_OVER, + OPTIONS }; public void enter(StateType prevState); diff --git a/core/src/ch/asynk/rustanddust/game/battles/Factory.java b/core/src/ch/asynk/rustanddust/game/battles/Factory.java index 020231f..a2833d0 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/Factory.java +++ b/core/src/ch/asynk/rustanddust/game/battles/Factory.java @@ -28,6 +28,7 @@ public class Factory implements Board.TileBuilder, Disposable public static final String ACT_DONE = "ok"; public static final String ACT_ABORT = "cancel"; public static final String ACT_PROMOTE = "promote"; + public static final String ACT_OPTIONS = "options"; public static final String DISABLED = "disabled"; public static final String REINFORCEMENT = "reinforcement"; public static final String REINFORCEMENT_SELECTED = "reinforcement-selected"; -- cgit v1.1-2-g2b99