From f8ffea3395563f3964c260e0a7176b9c42d12cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 1 Apr 2016 01:00:58 +0200 Subject: Ctrl: code reorder --- core/src/ch/asynk/rustanddust/game/Ctrl.java | 96 ++++++++++++++-------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java index 4d73c17..eba5e39 100644 --- a/core/src/ch/asynk/rustanddust/game/Ctrl.java +++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java @@ -165,6 +165,54 @@ public abstract class Ctrl implements Disposable freeEvents.clear(); } + // JSON + + protected boolean isLoading() + { + return (stateType == StateType.LOADING); + } + + protected void load(Marshal.Mode mode, String payload) + { + JsonValue root = new JsonReader().parse(payload); + battle.load(mode, root); + } + + protected String unload(Marshal.Mode mode) + { + Json json = new Json(OutputType.json); + writer.getBuffer().setLength(0); + json.setWriter(writer); + battle.unload(mode, json); + writer.flush(); + return writer.toString(); + } + + // INPUTS + + public boolean drag(float x, float y, int dx, int dy) + { + if (!blockHud && hud.drag(x, y, dx, dy)) + return true; + return false; + } + + public void touchDown(float hudX, float hudY, float mapX, float mapY) + { + boolean inAnimation = (this.stateType == StateType.ANIMATION); + + if (!blockHud && hud.hit(hudX, hudY, inAnimation)) + return; + + touchedHex = (blockMap ? null : map.getHexAt(mapX, mapY)); + } + + public void touchUp(float hudX, float hudY, float mapX, float mapY) + { + if (!blockMap && (touchedHex != null) && (touchedHex == map.getHexAt(mapX, mapY))) + state.touch(touchedHex); + } + // EVENTS private Event getEvent() @@ -236,54 +284,6 @@ public abstract class Ctrl implements Disposable freeEvents.push(evt); } - // JSON - - protected boolean isLoading() - { - return (stateType == StateType.LOADING); - } - - protected void load(Marshal.Mode mode, String payload) - { - JsonValue root = new JsonReader().parse(payload); - battle.load(mode, root); - } - - protected String unload(Marshal.Mode mode) - { - Json json = new Json(OutputType.json); - writer.getBuffer().setLength(0); - json.setWriter(writer); - battle.unload(mode, json); - writer.flush(); - return writer.toString(); - } - - // INPUTS - - public boolean drag(float x, float y, int dx, int dy) - { - if (!blockHud && hud.drag(x, y, dx, dy)) - return true; - return false; - } - - public void touchDown(float hudX, float hudY, float mapX, float mapY) - { - boolean inAnimation = (this.stateType == StateType.ANIMATION); - - if (!blockHud && hud.hit(hudX, hudY, inAnimation)) - return; - - touchedHex = (blockMap ? null : map.getHexAt(mapX, mapY)); - } - - public void touchUp(float hudX, float hudY, float mapX, float mapY) - { - if (!blockMap && (touchedHex != null) && (touchedHex == map.getHexAt(mapX, mapY))) - state.touch(touchedHex); - } - // State callbacks public void setAfterAnimationState(StateType after) -- cgit v1.1-2-g2b99