diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/ChangeParentAction.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/ChangeParentAction.java index 919a2ba..d84ffca 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/ChangeParentAction.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/ChangeParentAction.java @@ -3,27 +3,26 @@ package eu.jonahbauer.wizard.client.libgdx.actions; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.Action; import com.badlogic.gdx.scenes.scene2d.Group; -import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.utils.Pools; import lombok.Setter; public class ChangeParentAction extends Action { - private Vector2 pos; + private final Vector2 pos = Pools.obtain(Vector2.class); @Setter private Group parent; private boolean finished; public boolean act(float delta) { - if (pos == null) pos = new Vector2(); if (!finished) { finished = true; pos.set(target.getX(), target.getY()); - target.parentToLocalCoordinates(pos); - target.localToStageCoordinates(pos); + if (target.hasParent()) { + target.getParent().localToStageCoordinates(pos); + } parent.stageToLocalCoordinates(pos); - target.setPosition(pos.x, pos.y); parent.addActor(target); + target.setPosition(pos.x, pos.y); } return true; } diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/overlay/ScoreOverlay.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/overlay/ScoreOverlay.java index d0fce66..80d4057 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/overlay/ScoreOverlay.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/overlay/ScoreOverlay.java @@ -23,14 +23,16 @@ public class ScoreOverlay extends Overlay { @Override protected Actor createContent() { - return padOfTruth; + var group = new Group(); + group.addActor(padOfTruth); + return group; } @Override protected void show(Group parent) { + var root = getRoot().fill(); super.show(parent); - var root = getRoot(); root.addAction(sequence( run(() -> padOfTruth.setEnabled(false)), parallel( diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/overlay/TrumpOverlay.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/overlay/TrumpOverlay.java index 79cc311..ed29fd9 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/overlay/TrumpOverlay.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/actions/overlay/TrumpOverlay.java @@ -91,6 +91,7 @@ public class TrumpOverlay extends Overlay { private final @NotNull CardActor trumpSuitActor; private boolean animateCard = true; + private boolean animateSuit = true; public TrumpOverlay(@NotNull GameScreen gameScreen, @Nullable String player, @Nullable Card card, @Nullable Card.Suit suit) { super(gameScreen, Long.MAX_VALUE); @@ -133,7 +134,7 @@ public class TrumpOverlay extends Overlay { var cardGroup = new HorizontalGroup().space(20); root.addActor(cardGroup); - if (trumpCardActor.getParent() != null && trumpCardActor.getCard() == card && suit != null) { + if (trumpCardActor.hasParent() && trumpCardActor.getCard() == card && suit != null) { // if card actor is already correct then dont change it animateCard = false; } else { @@ -141,7 +142,8 @@ public class TrumpOverlay extends Overlay { trumpCardActor.setCard(card != null ? card : Card.HIDDEN); } - if (suit != null && suit != DEFAULT_SUITES.get(card)) { + animateSuit = suit != null && suit != DEFAULT_SUITES.get(card); + if (animateSuit) { trumpSuitActor.setRotation(0); trumpSuitActor.setOrigin(0, 0); cardGroup.addActor(trumpSuitActor); @@ -157,36 +159,60 @@ public class TrumpOverlay extends Overlay { public void show(Group parent) { super.show(parent); - ParallelAction cardAnimation = parallel(); + boolean cardVisible = trumpCardActor.hasParent(); + + var cardAnimation = sequence(); + + // remove from parent + var parallel = parallel(); + if (animateSuit) { + parallel.addAction(targeting(trumpSuitActor, removeActorSilently())); + } if (animateCard) { - cardAnimation.addAction(sequence( - targeting(trumpCardActor, removeActorSilently()), - targeting(trumpSuitActor, changeParent(screen.getContentRoot())), - targeting(trumpCardActor, moveTo(10, 10, AnimationTimings.OVERLAY_SHARED_ELEMENT)) - )); + parallel.addAction(targeting(trumpCardActor, removeActorSilently())); } + cardAnimation.addAction(parallel); - if (suit != null && suit != DEFAULT_SUITES.get(card)) { - cardAnimation.addAction(sequence( - targeting(trumpSuitActor, removeActorSilently()), - targeting(trumpSuitActor, changeParent(screen.getContentRoot())), - run(trumpCardActor::toFront), - parallel( - targeting(trumpSuitActor, rotateTo(-90, AnimationTimings.OVERLAY_SHARED_ELEMENT)), - targeting(trumpSuitActor, - moveTo(10, 10 + (trumpSuitActor.getHeight() + trumpSuitActor.getWidth()) / 2, AnimationTimings.OVERLAY_SHARED_ELEMENT) - ) + // change parent in correct order + parallel = parallel(); + if (animateSuit) { + parallel.addAction(targeting(trumpSuitActor, changeParent(screen.getOverlayRoot()))); + } + if (cardVisible) { + parallel.addAction(targeting(trumpCardActor, changeParent(screen.getOverlayRoot()))); + } + cardAnimation.addAction(parallel); + + // animate + parallel = parallel(); + if (animateSuit) { + parallel.addAction(targeting(trumpSuitActor, rotateTo(-90, AnimationTimings.OVERLAY_SHARED_ELEMENT))); + parallel.addAction( + targeting(trumpSuitActor, + moveTo(10, 10 + (trumpSuitActor.getHeight() + trumpSuitActor.getWidth()) / 2, AnimationTimings.OVERLAY_SHARED_ELEMENT) ) - )); + ); + } + if (animateCard) { + parallel.addAction(targeting(trumpCardActor, moveTo(10, 10, AnimationTimings.OVERLAY_SHARED_ELEMENT))); + } + cardAnimation.addAction(parallel); + + // change parent in correct order + parallel = parallel(); + if (animateSuit) { + parallel.addAction(targeting(trumpSuitActor, changeParent(screen.getContentRoot()))); + } + if (cardVisible) { + parallel.addAction(targeting(trumpCardActor, changeParent(screen.getContentRoot()))); } + cardAnimation.addAction(parallel); var root = getRoot(); root.addAction(sequence( delay(AnimationTimings.OVERLAY_HOLD), - parallel( - cardAnimation, - run(this::close) - ) + cardAnimation, + run(this::close) )); } diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/ConnectScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/ConnectScreen.java index f808c70..b85afbe 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/ConnectScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/ConnectScreen.java @@ -50,12 +50,12 @@ public class ConnectScreen extends MenuScreen { super.show(); buttonBack = new TextButton(messages.get("menu.connect.back"), skin); - buttonBack.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y); buttonBack.addListener(listener); + getButtonGroup().addActor(buttonBack); buttonConnect = new TextButton(messages.get("menu.connect.connect"), skin); - buttonConnect.setPosition(WizardGame.WIDTH * 0.725f - buttonConnect.getWidth(), BUTTON_BAR_Y); buttonConnect.addListener(listener); + getButtonGroup().addActor(buttonConnect); var label = new Label(messages.get("menu.connect.address.label"), skin); label.setSize(0.4f * WizardGame.WIDTH, 64); @@ -69,8 +69,6 @@ public class ConnectScreen extends MenuScreen { uriField.setPosition(0.5f * (WizardGame.WIDTH - uriField.getWidth()), 0.45f * (WizardGame.HEIGHT - uriField.getHeight())); uriField.addListener(new ResetErrorListener(skin)); - stage.addActor(buttonBack); - stage.addActor(buttonConnect); stage.addActor(uriField); stage.addActor(label); stage.addCaptureListener(new KeyboardFocusManager(uriField, buttonBack, buttonConnect)); diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/CreateGameScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/CreateGameScreen.java index 477e7d8..e5f70c0 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/CreateGameScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/CreateGameScreen.java @@ -48,12 +48,12 @@ public class CreateGameScreen extends MenuScreen { super.show(); buttonBack = new TextButton(messages.get("menu.create_game.back"), skin); - buttonBack.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y); buttonBack.addListener(listener); + getButtonGroup().addActor(buttonBack); buttonContinue = new TextButton(messages.get("menu.create_game.create"), skin); - buttonContinue.setPosition(WizardGame.WIDTH * 0.725f - buttonContinue.getWidth(), BUTTON_BAR_Y); buttonContinue.addListener(listener); + getButtonGroup().addActor(buttonContinue); var errorListener = new ResetErrorListener(skin); @@ -108,23 +108,21 @@ public class CreateGameScreen extends MenuScreen { } configurations.setItems(values); - var contentTable = new Table().center().left(); + var contentTable = new Table(skin).center().left(); contentTable.columnDefaults(0).growX().width(0.4f * WizardGame.WIDTH - 20); contentTable.setSize(0.4f * WizardGame.WIDTH - 20, 400); contentTable.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.3f); - contentTable.add(new Label(messages.get("menu.create_game.player_name.label"), skin)).row(); + contentTable.add(messages.get("menu.create_game.player_name.label")).row(); contentTable.add(playerName).row(); - contentTable.add(new Label(messages.get("menu.create_game.session_name.label"), skin)).row(); + contentTable.add(messages.get("menu.create_game.session_name.label")).row(); contentTable.add(sessionName).row(); - contentTable.add(new Label(messages.get("menu.create_game.session_timeout.label"), skin)).row(); + contentTable.add(messages.get("menu.create_game.session_timeout.label")).row(); contentTable.add(timeOut).row(); - contentTable.add(new Label(messages.get("menu.create_game.session_configuration.label"), skin)).row(); + contentTable.add(messages.get("menu.create_game.session_configuration.label")).row(); contentTable.add(configurations).row(); - stage.addActor(buttonContinue); stage.addActor(contentTable); - stage.addActor(buttonBack); stage.addCaptureListener(new KeyboardFocusManager(playerName, sessionName, timeOut, configurations, buttonBack, buttonContinue)); buttonBack.setName("button_back"); diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/GameScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/GameScreen.java index 8297ab6..b2f67c1 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/GameScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/GameScreen.java @@ -3,7 +3,6 @@ package eu.jonahbauer.wizard.client.libgdx.screens; import com.badlogic.gdx.Input; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.TextureAtlas; -import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.scenes.scene2d.*; import com.badlogic.gdx.scenes.scene2d.actions.MoveToAction; @@ -168,11 +167,11 @@ public class GameScreen extends WizardScreen { private Group createBackground() { var group = new Group(); - var background = new Image(skin.get(UiskinAtlas.BACKGROUND, TextureRegion.class)); + var background = new Image(skin.getRegion(UiskinAtlas.BACKGROUND)); background.setBounds(0, 0, WizardGame.WIDTH, WizardGame.HEIGHT); group.addActor(background); - var border = skin.get(UiskinAtlas.BORDER_SHADOW, TextureRegion.class); + var border = skin.getRegion(UiskinAtlas.BORDER_SHADOW); borders = new Image[] { new Image(new TextureRegionDrawable(border), Scaling.stretch), new Image(new TextureRegionDrawable(border), Scaling.stretch) @@ -180,7 +179,7 @@ public class GameScreen extends WizardScreen { group.addActor(borders[0]); group.addActor(borders[1]); - var title = new Image(skin.get(UiskinAtlas.TITLE, TextureRegion.class)); + var title = new Image(skin.getRegion(UiskinAtlas.TITLE)); title.setColor(0.5f, 0.5f, 0.5f, 0.5f); title.setSize(810, 192); title.setPosition( @@ -491,7 +490,7 @@ public class GameScreen extends WizardScreen { * Adds the scores for a round to the corresponding row of the {@linkplain #padOfTruth pad of truth}. */ public void addScores(@Range(from = 0, to = 19) int round, @NotNull Map scores) { - padOfTruth.checkPosition(orderedPlayers.size(), round); + padOfTruth.checkPosition(orderedPlayers.size() - 1, round); execute(() -> { for (int i = 0; i < orderedPlayers.size(); i++) { UUID player = orderedPlayers.get(i); diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/LobbyScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/LobbyScreen.java index 163b9e4..be6eb70 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/LobbyScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/LobbyScreen.java @@ -11,7 +11,6 @@ import eu.jonahbauer.wizard.common.messages.data.SessionData; import lombok.extern.log4j.Log4j2; import java.util.UUID; -import java.util.stream.StreamSupport; @Log4j2 public class LobbyScreen extends MenuScreen { @@ -55,12 +54,17 @@ public class LobbyScreen extends MenuScreen { buttonBack = new TextButton(messages.get("menu.lobby.back"), skin); buttonBack.addListener(listener); + getButtonGroup().addActor(buttonBack); + + buttonCreate = new TextButton(messages.get("menu.lobby.create"), skin); + buttonCreate.addListener(listener); + getButtonGroup().addActor(buttonCreate); buttonJoin = new TextButton(messages.get("menu.lobby.join"), skin); buttonJoin.addListener(listener); + getButtonGroup().addActor(buttonJoin); - buttonCreate = new TextButton(messages.get("menu.lobby.create"), skin); - buttonCreate.addListener(listener); + getButtonGroup().setWidth(0.55f * WizardGame.WIDTH); sessions = new List<>(skin) { @Override @@ -87,17 +91,8 @@ public class LobbyScreen extends MenuScreen { content.addActor(new Container<>(sessionListContainer).width(0.2f * WizardGame.WIDTH).height(400)); content.addActor(createInfoTable()); content.layout(); - - var buttons = new HorizontalGroup(); - buttons.setPosition(WizardGame.WIDTH * 0.2f, BUTTON_BAR_Y); - buttons.setSize(WizardGame.WIDTH * 0.60f, 125); - buttons.addActor(buttonBack); - buttons.addActor(buttonCreate); - buttons.addActor(buttonJoin); - buttons.space(Math.max(0, (float) (buttons.getWidth() - StreamSupport.stream(buttons.getChildren().spliterator(), false).mapToDouble(Actor::getWidth).sum()) / (buttons.getChildren().size - 1))); stage.addActor(content); - stage.addActor(buttons); stage.addCaptureListener(new KeyboardFocusManager(sessions, playerName, buttonBack, buttonCreate, buttonJoin)); buttonBack.setName("button_back"); diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MainMenuScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MainMenuScreen.java index 4ee8f6d..01ad8bd 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MainMenuScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MainMenuScreen.java @@ -1,7 +1,6 @@ package eu.jonahbauer.wizard.client.libgdx.screens; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; @@ -40,10 +39,10 @@ public class MainMenuScreen extends MenuScreen { int width = 160, height = 224; int left = 384, right = 384, top = 384, bottom = 192; var symbols = new Image[]{ - new Image(skin.get(UiskinAtlas.SYMBOL_0, TextureRegion.class)), - new Image(skin.get(UiskinAtlas.SYMBOL_1, TextureRegion.class)), - new Image(skin.get(UiskinAtlas.SYMBOL_2, TextureRegion.class)), - new Image(skin.get(UiskinAtlas.SYMBOL_3, TextureRegion.class)) + new Image(skin.getRegion(UiskinAtlas.SYMBOL_0)), + new Image(skin.getRegion(UiskinAtlas.SYMBOL_1)), + new Image(skin.getRegion(UiskinAtlas.SYMBOL_2)), + new Image(skin.getRegion(UiskinAtlas.SYMBOL_3)) }; symbols[0].setPosition(left, bottom); symbols[1].setPosition(left, WizardGame.HEIGHT - top - height); diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MenuScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MenuScreen.java index 7c4bbab..d8f5037 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MenuScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/MenuScreen.java @@ -1,14 +1,18 @@ package eu.jonahbauer.wizard.client.libgdx.screens; -import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.scenes.scene2d.Actor; +import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup; import com.badlogic.gdx.scenes.scene2d.ui.Image; +import com.badlogic.gdx.scenes.scene2d.utils.Layout; import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas; import eu.jonahbauer.wizard.client.libgdx.WizardGame; +import lombok.AccessLevel; +import lombok.Getter; public abstract class MenuScreen extends WizardScreen { - protected final float BUTTON_BAR_Y = WizardGame.HEIGHT * 0.15f; - private Image[] corners; + @Getter(value = AccessLevel.PROTECTED, lazy = true) + private final HorizontalGroup buttonGroup = createButtonGroup(); public MenuScreen(WizardGame game) { super(game); @@ -19,20 +23,48 @@ public abstract class MenuScreen extends WizardScreen { super.show(); corners = new Image[4]; - corners[0] = new Image(skin.get(UiskinAtlas.CORNER_TOP_LEFT, TextureRegion.class)); - corners[1] = new Image(skin.get(UiskinAtlas.CORNER_BOTTOM_LEFT, TextureRegion.class)); - corners[2] = new Image(skin.get(UiskinAtlas.CORNER_BOTTOM_RIGHT, TextureRegion.class)); - corners[3] = new Image(skin.get(UiskinAtlas.CORNER_TOP_RIGHT, TextureRegion.class)); + corners[0] = new Image(skin.getRegion(UiskinAtlas.CORNER_TOP_LEFT)); + corners[1] = new Image(skin.getRegion(UiskinAtlas.CORNER_BOTTOM_LEFT)); + corners[2] = new Image(skin.getRegion(UiskinAtlas.CORNER_BOTTOM_RIGHT)); + corners[3] = new Image(skin.getRegion(UiskinAtlas.CORNER_TOP_RIGHT)); for (var corner : corners) { stage.addActor(corner); } - var title = new Image(skin.get(UiskinAtlas.TITLE, TextureRegion.class)); + var title = new Image(skin.getRegion(UiskinAtlas.TITLE)); title.setSize(810, 192); title.setPosition(555, WizardGame.HEIGHT - 192 - 96); stage.addActor(title); } + private HorizontalGroup createButtonGroup() { + var group = new HorizontalGroup() { + @Override + public void layout() { + float contentWidth = 0; + for (Actor child : getChildren()) { + if (child instanceof Layout layout) { + contentWidth += layout.getPrefWidth(); + } else { + contentWidth += child.getWidth(); + } + } + + space(Math.max(0, (getWidth() - contentWidth) / (getChildren().size - 1))); + super.layout(); + } + + @Override + protected void sizeChanged() { + setPosition((WizardGame.WIDTH - getWidth()) / 2f, WizardGame.HEIGHT * 0.15f); + } + }; + group.setSize(WizardGame.WIDTH * 0.45f, 125); + group.center(); + stage.addActor(group); + return group; + } + @Override public void resize(int width, int height) { super.resize(width, height); diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WaitingScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WaitingScreen.java index bb74b85..9d77c24 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WaitingScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WaitingScreen.java @@ -51,16 +51,18 @@ public class WaitingScreen extends MenuScreen { super.show(); buttonLeave = new TextButton(messages.get("menu.waiting.leave"), skin); - buttonLeave.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y); buttonLeave.addListener(listener); + getButtonGroup().addActor(buttonLeave); buttonReady = new TextButton(messages.get("menu.waiting.ready"), skin); - buttonReady.setPosition(WizardGame.WIDTH * 0.725f - buttonReady.getWidth(), BUTTON_BAR_Y); buttonReady.addListener(listener); + getButtonGroup().addActor(buttonReady); + + getButtonGroup().setWidth(0.55f * WizardGame.WIDTH); players = new List<>(skin) { - private final TextureRegion ready = skin.get(UiskinAtlas.READY, TextureRegion.class); - private final TextureRegion notReady = skin.get(UiskinAtlas.NOT_READY, TextureRegion.class); + private final TextureRegion ready = skin.getRegion(UiskinAtlas.READY); + private final TextureRegion notReady = skin.getRegion(UiskinAtlas.NOT_READY); @Override public String toString(PlayerData player) { @@ -91,8 +93,6 @@ public class WaitingScreen extends MenuScreen { content.addActor(createInfoTable()); content.layout(); - stage.addActor(buttonLeave); - stage.addActor(buttonReady); stage.addActor(content); stage.addCaptureListener(new KeyboardFocusManager(buttonLeave, buttonReady)); @@ -117,17 +117,17 @@ public class WaitingScreen extends MenuScreen { labelSessionConfiguration.setEllipsis(true); labelPlayerName.setEllipsis(true); - var infoTable = new Table().center().left(); + var infoTable = new Table(skin).center().left(); infoTable.columnDefaults(0).growX().width(infoTableWidth); infoTable.setSize(infoTableWidth, 400); - infoTable.add(new Label(messages.get("menu.waiting.session_name.label"), skin)).row(); + infoTable.add(messages.get("menu.waiting.session_name.label")).row(); infoTable.add(labelSessionName).row(); - infoTable.add(new Label(messages.get("menu.waiting.session_uuid.label"), skin)).row(); + infoTable.add(messages.get("menu.waiting.session_uuid.label")).row(); infoTable.add(labelSessionUUID).row(); - infoTable.add(new Label(messages.get("menu.waiting.session_configuration.label"), skin)).row(); + infoTable.add(messages.get("menu.waiting.session_configuration.label")).row(); infoTable.add(labelSessionConfiguration).row(); - infoTable.add(new Label(messages.get("menu.waiting.player_name.label"), skin)).row(); + infoTable.add(messages.get("menu.waiting.player_name.label")).row(); infoTable.add(labelPlayerName).row(); return infoTable; diff --git a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WizardScreen.java b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WizardScreen.java index 11c1210..fec5c26 100644 --- a/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WizardScreen.java +++ b/wizard-client/wizard-client-libgdx/core/src/main/java/eu/jonahbauer/wizard/client/libgdx/screens/WizardScreen.java @@ -6,7 +6,6 @@ import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Skin; @@ -69,7 +68,7 @@ public abstract class WizardScreen implements Screen { public void show() { load(); - background = new Image(skin.get(UiskinAtlas.BACKGROUND, TextureRegion.class)); + background = new Image(skin.getRegion(UiskinAtlas.BACKGROUND)); background.setScaling(Scaling.fill); background.setPosition(0,0); stage.addActor(background); @@ -92,7 +91,8 @@ public abstract class WizardScreen implements Screen { offsetX = (worldWidth - WizardGame.WIDTH) / 2; offsetY = (worldHeight - WizardGame.HEIGHT) / 2; - stage.getRoot().setPosition(offsetX, offsetY); + stage.getCamera().position.x -= offsetX; + stage.getCamera().position.y -= offsetY; background.setBounds(-offsetX, -offsetY, worldWidth, worldHeight); } diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_0.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_0.png index 657e030..f940c73 100644 Binary files a/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_0.png and b/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_0.png differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_1.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_1.png index 3b2f8c4..cdda722 100644 Binary files a/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_1.png and b/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_1.png differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_2.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_2.png index d7a53ed..49fe238 100644 Binary files a/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_2.png and b/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_2.png differ diff --git a/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_3.png b/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_3.png index 8cbfa5b..1720722 100644 Binary files a/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_3.png and b/wizard-client/wizard-client-libgdx/core/src/main/textures/uiskin/symbol_3.png differ