diff --git a/core/assets/common/screen/createuser/form/gfx/mugshot00.jpg b/core/assets/common/screen/createuser/form/gfx/mugshot00.jpg new file mode 100644 index 0000000000000000000000000000000000000000..75da7bcf703c1e58f178a7de987cf643a78903fe Binary files /dev/null and b/core/assets/common/screen/createuser/form/gfx/mugshot00.jpg differ diff --git a/core/assets/common/screen/createuser/form/gfx/stamp.png b/core/assets/cs/screen/createuser/form/gfx/stamp.png similarity index 100% rename from core/assets/common/screen/createuser/form/gfx/stamp.png rename to core/assets/cs/screen/createuser/form/gfx/stamp.png diff --git a/core/assets/common/screen/createuser/form/gfx/stampplaceholder.png b/core/assets/cs/screen/createuser/form/gfx/stampplaceholder.png similarity index 100% rename from core/assets/common/screen/createuser/form/gfx/stampplaceholder.png rename to core/assets/cs/screen/createuser/form/gfx/stampplaceholder.png diff --git a/core/src/cz/nic/tablexia/TablexiaSettings.java b/core/src/cz/nic/tablexia/TablexiaSettings.java index 7ca2e4a01f48442a75d3d39d9fe785b6f5504f36..e8323f3e5e2f19ed29e38adf623d0624b101882a 100644 --- a/core/src/cz/nic/tablexia/TablexiaSettings.java +++ b/core/src/cz/nic/tablexia/TablexiaSettings.java @@ -13,7 +13,7 @@ import cz.nic.tablexia.game.GameDefinition; import cz.nic.tablexia.game.difficulty.GameDifficulty; import cz.nic.tablexia.loader.application.ApplicationTextManager; import cz.nic.tablexia.screen.AbstractTablexiaScreen; -import cz.nic.tablexia.screen.createuser.PanoramaScreen; +import cz.nic.tablexia.screen.createuser.FormScreen; import cz.nic.tablexia.util.Log; import cz.nic.tablexia.util.Utility; @@ -24,7 +24,7 @@ public class TablexiaSettings { private static final int MIN_SCREEN_HEIGHT = (int) (DEFAULT_SCREEN_WIDTH * MAXIMUM_RATIO); private static final boolean DEBUG_SHOW_BOUNDING_BOXES = true; - public static final Class<? extends AbstractTablexiaScreen<?>> INITIAL_SCREEN = PanoramaScreen.class; + public static final Class<? extends AbstractTablexiaScreen<?>> INITIAL_SCREEN = FormScreen.class; public static final String LOCALE_KEY = "locale"; public static final String CURRENT_SCREEN_KEY = "current_screen"; diff --git a/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java b/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java index 21f1204cf6ad53f4e99d7a9b2f6e965b5264b026..53cc6663f3d7ae8b3d22edceabd7a37f87421136 100644 --- a/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java +++ b/core/src/cz/nic/tablexia/screen/createuser/FormScreen.java @@ -1,33 +1,57 @@ package cz.nic.tablexia.screen.createuser; +import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Group; import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.ui.Stack; +import cz.nic.tablexia.TablexiaSettings; import cz.nic.tablexia.screen.AbstractAutoloadTablexiaScreen; import cz.nic.tablexia.util.ScaleUtil; +import cz.nic.tablexia.util.listener.DragActorListener; public class FormScreen extends AbstractAutoloadTablexiaScreen<Void> { public static final String BASET_ASSET_PATH = "screen/createuser/form"; + private Actor stamp, pen; + public FormScreen() { super(BASET_ASSET_PATH); } @Override protected void screenLoaded() { + getStage().setDebugAll(true); Group group = new Group(); Image background = new Image(getTexture("table")); ScaleUtil.setFullScreen(background, getStage()); group.addActor(background); - Image book = ScaleUtil.createImageSizePosition(getTexture("background"), getStage().getWidth() * 0.98f, getStage().getHeight() * 0.98f, getStage().getWidth() * 0.02f, 0); - group.addActor(book); - - group.addActor(ScaleUtil.createImageWidthPosition(getTexture("badge"), getStage().getWidth() * 0.3f, getStage().getWidth() * 0.12f, getStage().getHeight() * 0.3f)); - group.addActor(ScaleUtil.createImageWidthPosition(getTexture("mugshotframe"), getStage().getWidth() * 0.2f, getStage().getWidth() * 0.62f, getStage().getHeight() * 0.5f)); + group.addActor(ScaleUtil.createImageWidthPosition(getTexture("inkpad"), getStage().getWidth() * 0.3f, getStage().getWidth() * -0.1f, getStage().getWidth() * 0.3f)); + group.addActor(ScaleUtil.createImageSizePosition(getTexture("background"), getStage().getWidth() * 0.75f, TablexiaSettings.getMinScreenHeight() * 0.98f, getStage().getWidth() * 0.13f, 0)); + group.addActor(ScaleUtil.createImageWidthPosition(getTexture("badge"), getStage().getWidth() * 0.3f, getStage().getWidth() * 0.18f, getStage().getWidth() * 0.15f)); + + group.addActor(ScaleUtil.createImageWidthPosition(getTexture("mugshot00"), getStage().getWidth() * 0.13f, getStage().getWidth() * 0.6f, getStage().getWidth() * 0.33f)); // size for all mugshots + group.addActor(ScaleUtil.createImageWidthPosition(getTexture("mugshotframe"), getStage().getWidth() * 0.17f, getStage().getWidth() * 0.58f, getStage().getWidth() * 0.31f)); + group.addActor(ScaleUtil.createImageWidthPosition(getTexture("textfield_covername"), getStage().getWidth() * 0.2f, getStage().getWidth() * 0.57f, getStage().getWidth() * 0.25f)); + group.addActor(ScaleUtil.createImageWidthPosition(getTexture("stampplaceholder"), getStage().getWidth() * 0.1f, getStage().getWidth() * 0.73f, getStage().getWidth() * 0.04f)); + group.addActor(ScaleUtil.createImageWidthPosition(getTexture("texfield_signature"), getStage().getWidth() * 0.15f, getStage().getWidth() * 0.55f, getStage().getWidth() * 0.07f)); + group.addActor(pen = ScaleUtil.createImageWidthPosition(getTexture("pencil_dropped"), getStage().getWidth() * 0.2f, getStage().getWidth() * 0.85f, getStage().getWidth() * -0.13f)); + group.addActor(stamp = ScaleUtil.createImageWidthPosition(getTexture("stamp_left_dropped"), getStage().getWidth() * 0.2f, getStage().getWidth() * -0.01f, getStage().getWidth() * -0.05f)); + pen.addListener(new DragActorListener(pen, true)); + stamp.addListener(new DragActorListener(stamp, true)); +// TODO pens and stamps variant getStage().addActor(group); + + } + class StampStack extends Stack { + public StampStack(float width) { +// TODO + + } + } } diff --git a/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java b/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java index f9580ecf5646c6b4bc7e093dce6c8ac46e705426..99088ad893ce79976e08f2d7cef21818dc750591 100644 --- a/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java +++ b/core/src/cz/nic/tablexia/screen/createuser/PanoramaScreen.java @@ -245,7 +245,7 @@ public class PanoramaScreen extends AbstractAutoloadTablexiaScreen<Void> { final Image[] details = new Image[5]; for (int i = 0; i < 5; i++) { - details[i] = ScaleUtil.fitInto(getTexture("newspaper/detail0" + (i + 1)), getStage().getWidth() * 0.8f, getStage().getHeight() * 0.8f); + details[i] = ScaleUtil.createImageFitInto(getTexture("newspaper/detail0" + (i + 1)), getStage().getWidth() * 0.8f, getStage().getHeight() * 0.8f); details[i].setPosition(getStage().getWidth() / 2 - details[i].getWidth() / 2, getStage().getHeight() / 2 - details[i].getHeight() / 2); help.addActor(details[i]); if (i == 4) { diff --git a/core/src/cz/nic/tablexia/util/ScaleUtil.java b/core/src/cz/nic/tablexia/util/ScaleUtil.java index 0351d3f1cdb4357f9abe44afc44851a0ad83d97c..bdf97b348461354d4a769052d8755d537f28af14 100644 --- a/core/src/cz/nic/tablexia/util/ScaleUtil.java +++ b/core/src/cz/nic/tablexia/util/ScaleUtil.java @@ -28,7 +28,7 @@ public class ScaleUtil { return image; } - public static Image fitInto(Texture texture, float width, float height) { + public static Image createImageFitInto(Texture texture, float width, float height) { Image image = new Image(texture); if (getWidth(texture.getWidth(), texture.getHeight(), height) > width) { image.setSize(width, getHeight(texture.getWidth(), texture.getHeight(), width)); @@ -65,7 +65,12 @@ public class ScaleUtil { } public static void setFullScreen(Actor actor, Stage stage) { - actor.setPosition(0, 0); + setPosition(actor, 0, 0); actor.setSize(stage.getWidth(), stage.getHeight()); } + + public static Actor setPosition(Actor actor, float x, float y) { + actor.setPosition(0, 0); + return actor; + } } diff --git a/core/src/cz/nic/tablexia/util/listener/DragActorListener.java b/core/src/cz/nic/tablexia/util/listener/DragActorListener.java new file mode 100644 index 0000000000000000000000000000000000000000..24c9b763ba49e07de74c83c7ee166cf4cd466658 --- /dev/null +++ b/core/src/cz/nic/tablexia/util/listener/DragActorListener.java @@ -0,0 +1,59 @@ +package cz.nic.tablexia.util.listener; + +import com.badlogic.gdx.math.Interpolation; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.InputListener; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; + +/** + * Created by lhoracek on 4/10/15. + */ +public class DragActorListener extends InputListener { + private float grabX, grabY, startX, startY; + private final Actor actor; + private boolean bounceBack; + + public DragActorListener(Actor actor) { + this.actor = actor; + } + + public DragActorListener(Actor actor, boolean bounceBack) { + this.actor = actor; + this.bounceBack = bounceBack; + } + + // TODO add callback method + private void moveBack() { + actor.addAction(Actions.moveTo(startX, startY, 0.4f, Interpolation.elasticOut)); + } + + @Override + public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { + super.touchDown(event, x, y, pointer, button); + grabX = x; + grabY = y; + startX = actor.getX(); + startY = actor.getY(); + event.stop(); + return true; + } + + @Override + public void touchDragged(InputEvent event, float x, float y, int pointer) { + super.touchDragged(event, x, y, pointer); + float bx = actor.getX() + (x - grabX); + float by = actor.getY() + (y - grabY); + actor.setPosition(bx, by); + event.stop(); + } + + @Override + public void touchUp(InputEvent event, float x, float y, int pointer, int button) { + super.touchUp(event, x, y, pointer, button); + if(bounceBack){ + moveBack(); + } + event.stop(); + } +}