bugfixes
@ -3,27 +3,26 @@ package eu.jonahbauer.wizard.client.libgdx.actions;
|
|||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Action;
|
import com.badlogic.gdx.scenes.scene2d.Action;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||||
import com.badlogic.gdx.utils.Pool;
|
|
||||||
import com.badlogic.gdx.utils.Pools;
|
import com.badlogic.gdx.utils.Pools;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
public class ChangeParentAction extends Action {
|
public class ChangeParentAction extends Action {
|
||||||
private Vector2 pos;
|
private final Vector2 pos = Pools.obtain(Vector2.class);
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private Group parent;
|
private Group parent;
|
||||||
private boolean finished;
|
private boolean finished;
|
||||||
|
|
||||||
public boolean act(float delta) {
|
public boolean act(float delta) {
|
||||||
if (pos == null) pos = new Vector2();
|
|
||||||
if (!finished) {
|
if (!finished) {
|
||||||
finished = true;
|
finished = true;
|
||||||
pos.set(target.getX(), target.getY());
|
pos.set(target.getX(), target.getY());
|
||||||
target.parentToLocalCoordinates(pos);
|
if (target.hasParent()) {
|
||||||
target.localToStageCoordinates(pos);
|
target.getParent().localToStageCoordinates(pos);
|
||||||
|
}
|
||||||
parent.stageToLocalCoordinates(pos);
|
parent.stageToLocalCoordinates(pos);
|
||||||
target.setPosition(pos.x, pos.y);
|
|
||||||
parent.addActor(target);
|
parent.addActor(target);
|
||||||
|
target.setPosition(pos.x, pos.y);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -23,14 +23,16 @@ public class ScoreOverlay extends Overlay {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Actor createContent() {
|
protected Actor createContent() {
|
||||||
return padOfTruth;
|
var group = new Group();
|
||||||
|
group.addActor(padOfTruth);
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void show(Group parent) {
|
protected void show(Group parent) {
|
||||||
|
var root = getRoot().fill();
|
||||||
super.show(parent);
|
super.show(parent);
|
||||||
|
|
||||||
var root = getRoot();
|
|
||||||
root.addAction(sequence(
|
root.addAction(sequence(
|
||||||
run(() -> padOfTruth.setEnabled(false)),
|
run(() -> padOfTruth.setEnabled(false)),
|
||||||
parallel(
|
parallel(
|
||||||
|
@ -91,6 +91,7 @@ public class TrumpOverlay extends Overlay {
|
|||||||
private final @NotNull CardActor trumpSuitActor;
|
private final @NotNull CardActor trumpSuitActor;
|
||||||
|
|
||||||
private boolean animateCard = true;
|
private boolean animateCard = true;
|
||||||
|
private boolean animateSuit = true;
|
||||||
|
|
||||||
public TrumpOverlay(@NotNull GameScreen gameScreen, @Nullable String player, @Nullable Card card, @Nullable Card.Suit suit) {
|
public TrumpOverlay(@NotNull GameScreen gameScreen, @Nullable String player, @Nullable Card card, @Nullable Card.Suit suit) {
|
||||||
super(gameScreen, Long.MAX_VALUE);
|
super(gameScreen, Long.MAX_VALUE);
|
||||||
@ -133,7 +134,7 @@ public class TrumpOverlay extends Overlay {
|
|||||||
var cardGroup = new HorizontalGroup().space(20);
|
var cardGroup = new HorizontalGroup().space(20);
|
||||||
root.addActor(cardGroup);
|
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
|
// if card actor is already correct then dont change it
|
||||||
animateCard = false;
|
animateCard = false;
|
||||||
} else {
|
} else {
|
||||||
@ -141,7 +142,8 @@ public class TrumpOverlay extends Overlay {
|
|||||||
trumpCardActor.setCard(card != null ? card : Card.HIDDEN);
|
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.setRotation(0);
|
||||||
trumpSuitActor.setOrigin(0, 0);
|
trumpSuitActor.setOrigin(0, 0);
|
||||||
cardGroup.addActor(trumpSuitActor);
|
cardGroup.addActor(trumpSuitActor);
|
||||||
@ -157,36 +159,60 @@ public class TrumpOverlay extends Overlay {
|
|||||||
public void show(Group parent) {
|
public void show(Group parent) {
|
||||||
super.show(parent);
|
super.show(parent);
|
||||||
|
|
||||||
ParallelAction cardAnimation = parallel();
|
boolean cardVisible = trumpCardActor.hasParent();
|
||||||
if (animateCard) {
|
|
||||||
cardAnimation.addAction(sequence(
|
|
||||||
targeting(trumpCardActor, removeActorSilently()),
|
|
||||||
targeting(trumpSuitActor, changeParent(screen.getContentRoot())),
|
|
||||||
targeting(trumpCardActor, moveTo(10, 10, AnimationTimings.OVERLAY_SHARED_ELEMENT))
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (suit != null && suit != DEFAULT_SUITES.get(card)) {
|
var cardAnimation = sequence();
|
||||||
cardAnimation.addAction(sequence(
|
|
||||||
targeting(trumpSuitActor, removeActorSilently()),
|
// remove from parent
|
||||||
targeting(trumpSuitActor, changeParent(screen.getContentRoot())),
|
var parallel = parallel();
|
||||||
run(trumpCardActor::toFront),
|
if (animateSuit) {
|
||||||
parallel(
|
parallel.addAction(targeting(trumpSuitActor, removeActorSilently()));
|
||||||
targeting(trumpSuitActor, rotateTo(-90, AnimationTimings.OVERLAY_SHARED_ELEMENT)),
|
|
||||||
targeting(trumpSuitActor,
|
|
||||||
moveTo(10, 10 + (trumpSuitActor.getHeight() + trumpSuitActor.getWidth()) / 2, AnimationTimings.OVERLAY_SHARED_ELEMENT)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
if (animateCard) {
|
||||||
|
parallel.addAction(targeting(trumpCardActor, removeActorSilently()));
|
||||||
|
}
|
||||||
|
cardAnimation.addAction(parallel);
|
||||||
|
|
||||||
|
// 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();
|
var root = getRoot();
|
||||||
root.addAction(sequence(
|
root.addAction(sequence(
|
||||||
delay(AnimationTimings.OVERLAY_HOLD),
|
delay(AnimationTimings.OVERLAY_HOLD),
|
||||||
parallel(
|
cardAnimation,
|
||||||
cardAnimation,
|
run(this::close)
|
||||||
run(this::close)
|
|
||||||
)
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ public class ConnectScreen extends MenuScreen {
|
|||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
buttonBack = new TextButton(messages.get("menu.connect.back"), skin);
|
buttonBack = new TextButton(messages.get("menu.connect.back"), skin);
|
||||||
buttonBack.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y);
|
|
||||||
buttonBack.addListener(listener);
|
buttonBack.addListener(listener);
|
||||||
|
getButtonGroup().addActor(buttonBack);
|
||||||
|
|
||||||
buttonConnect = new TextButton(messages.get("menu.connect.connect"), skin);
|
buttonConnect = new TextButton(messages.get("menu.connect.connect"), skin);
|
||||||
buttonConnect.setPosition(WizardGame.WIDTH * 0.725f - buttonConnect.getWidth(), BUTTON_BAR_Y);
|
|
||||||
buttonConnect.addListener(listener);
|
buttonConnect.addListener(listener);
|
||||||
|
getButtonGroup().addActor(buttonConnect);
|
||||||
|
|
||||||
var label = new Label(messages.get("menu.connect.address.label"), skin);
|
var label = new Label(messages.get("menu.connect.address.label"), skin);
|
||||||
label.setSize(0.4f * WizardGame.WIDTH, 64);
|
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.setPosition(0.5f * (WizardGame.WIDTH - uriField.getWidth()), 0.45f * (WizardGame.HEIGHT - uriField.getHeight()));
|
||||||
uriField.addListener(new ResetErrorListener(skin));
|
uriField.addListener(new ResetErrorListener(skin));
|
||||||
|
|
||||||
stage.addActor(buttonBack);
|
|
||||||
stage.addActor(buttonConnect);
|
|
||||||
stage.addActor(uriField);
|
stage.addActor(uriField);
|
||||||
stage.addActor(label);
|
stage.addActor(label);
|
||||||
stage.addCaptureListener(new KeyboardFocusManager(uriField, buttonBack, buttonConnect));
|
stage.addCaptureListener(new KeyboardFocusManager(uriField, buttonBack, buttonConnect));
|
||||||
|
@ -48,12 +48,12 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
buttonBack = new TextButton(messages.get("menu.create_game.back"), skin);
|
buttonBack = new TextButton(messages.get("menu.create_game.back"), skin);
|
||||||
buttonBack.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y);
|
|
||||||
buttonBack.addListener(listener);
|
buttonBack.addListener(listener);
|
||||||
|
getButtonGroup().addActor(buttonBack);
|
||||||
|
|
||||||
buttonContinue = new TextButton(messages.get("menu.create_game.create"), skin);
|
buttonContinue = new TextButton(messages.get("menu.create_game.create"), skin);
|
||||||
buttonContinue.setPosition(WizardGame.WIDTH * 0.725f - buttonContinue.getWidth(), BUTTON_BAR_Y);
|
|
||||||
buttonContinue.addListener(listener);
|
buttonContinue.addListener(listener);
|
||||||
|
getButtonGroup().addActor(buttonContinue);
|
||||||
|
|
||||||
var errorListener = new ResetErrorListener(skin);
|
var errorListener = new ResetErrorListener(skin);
|
||||||
|
|
||||||
@ -108,23 +108,21 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
}
|
}
|
||||||
configurations.setItems(values);
|
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.columnDefaults(0).growX().width(0.4f * WizardGame.WIDTH - 20);
|
||||||
contentTable.setSize(0.4f * WizardGame.WIDTH - 20, 400);
|
contentTable.setSize(0.4f * WizardGame.WIDTH - 20, 400);
|
||||||
contentTable.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.3f);
|
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(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(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(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();
|
contentTable.add(configurations).row();
|
||||||
|
|
||||||
stage.addActor(buttonContinue);
|
|
||||||
stage.addActor(contentTable);
|
stage.addActor(contentTable);
|
||||||
stage.addActor(buttonBack);
|
|
||||||
stage.addCaptureListener(new KeyboardFocusManager(playerName, sessionName, timeOut, configurations, buttonBack, buttonContinue));
|
stage.addCaptureListener(new KeyboardFocusManager(playerName, sessionName, timeOut, configurations, buttonBack, buttonContinue));
|
||||||
|
|
||||||
buttonBack.setName("button_back");
|
buttonBack.setName("button_back");
|
||||||
|
@ -3,7 +3,6 @@ package eu.jonahbauer.wizard.client.libgdx.screens;
|
|||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.scenes.scene2d.*;
|
import com.badlogic.gdx.scenes.scene2d.*;
|
||||||
import com.badlogic.gdx.scenes.scene2d.actions.MoveToAction;
|
import com.badlogic.gdx.scenes.scene2d.actions.MoveToAction;
|
||||||
@ -168,11 +167,11 @@ public class GameScreen extends WizardScreen {
|
|||||||
private Group createBackground() {
|
private Group createBackground() {
|
||||||
var group = new Group();
|
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);
|
background.setBounds(0, 0, WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||||
group.addActor(background);
|
group.addActor(background);
|
||||||
|
|
||||||
var border = skin.get(UiskinAtlas.BORDER_SHADOW, TextureRegion.class);
|
var border = skin.getRegion(UiskinAtlas.BORDER_SHADOW);
|
||||||
borders = new Image[] {
|
borders = new Image[] {
|
||||||
new Image(new TextureRegionDrawable(border), Scaling.stretch),
|
new Image(new TextureRegionDrawable(border), Scaling.stretch),
|
||||||
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[0]);
|
||||||
group.addActor(borders[1]);
|
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.setColor(0.5f, 0.5f, 0.5f, 0.5f);
|
||||||
title.setSize(810, 192);
|
title.setSize(810, 192);
|
||||||
title.setPosition(
|
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}.
|
* 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<UUID, Integer> scores) {
|
public void addScores(@Range(from = 0, to = 19) int round, @NotNull Map<UUID, Integer> scores) {
|
||||||
padOfTruth.checkPosition(orderedPlayers.size(), round);
|
padOfTruth.checkPosition(orderedPlayers.size() - 1, round);
|
||||||
execute(() -> {
|
execute(() -> {
|
||||||
for (int i = 0; i < orderedPlayers.size(); i++) {
|
for (int i = 0; i < orderedPlayers.size(); i++) {
|
||||||
UUID player = orderedPlayers.get(i);
|
UUID player = orderedPlayers.get(i);
|
||||||
|
@ -11,7 +11,6 @@ import eu.jonahbauer.wizard.common.messages.data.SessionData;
|
|||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class LobbyScreen extends MenuScreen {
|
public class LobbyScreen extends MenuScreen {
|
||||||
@ -55,12 +54,17 @@ public class LobbyScreen extends MenuScreen {
|
|||||||
|
|
||||||
buttonBack = new TextButton(messages.get("menu.lobby.back"), skin);
|
buttonBack = new TextButton(messages.get("menu.lobby.back"), skin);
|
||||||
buttonBack.addListener(listener);
|
buttonBack.addListener(listener);
|
||||||
|
getButtonGroup().addActor(buttonBack);
|
||||||
buttonJoin = new TextButton(messages.get("menu.lobby.join"), skin);
|
|
||||||
buttonJoin.addListener(listener);
|
|
||||||
|
|
||||||
buttonCreate = new TextButton(messages.get("menu.lobby.create"), skin);
|
buttonCreate = new TextButton(messages.get("menu.lobby.create"), skin);
|
||||||
buttonCreate.addListener(listener);
|
buttonCreate.addListener(listener);
|
||||||
|
getButtonGroup().addActor(buttonCreate);
|
||||||
|
|
||||||
|
buttonJoin = new TextButton(messages.get("menu.lobby.join"), skin);
|
||||||
|
buttonJoin.addListener(listener);
|
||||||
|
getButtonGroup().addActor(buttonJoin);
|
||||||
|
|
||||||
|
getButtonGroup().setWidth(0.55f * WizardGame.WIDTH);
|
||||||
|
|
||||||
sessions = new List<>(skin) {
|
sessions = new List<>(skin) {
|
||||||
@Override
|
@Override
|
||||||
@ -87,17 +91,8 @@ public class LobbyScreen extends MenuScreen {
|
|||||||
content.addActor(new Container<>(sessionListContainer).width(0.2f * WizardGame.WIDTH).height(400));
|
content.addActor(new Container<>(sessionListContainer).width(0.2f * WizardGame.WIDTH).height(400));
|
||||||
content.addActor(createInfoTable());
|
content.addActor(createInfoTable());
|
||||||
content.layout();
|
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(content);
|
||||||
stage.addActor(buttons);
|
|
||||||
stage.addCaptureListener(new KeyboardFocusManager(sessions, playerName, buttonBack, buttonCreate, buttonJoin));
|
stage.addCaptureListener(new KeyboardFocusManager(sessions, playerName, buttonBack, buttonCreate, buttonJoin));
|
||||||
|
|
||||||
buttonBack.setName("button_back");
|
buttonBack.setName("button_back");
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx.screens;
|
package eu.jonahbauer.wizard.client.libgdx.screens;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
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.Actor;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
@ -40,10 +39,10 @@ public class MainMenuScreen extends MenuScreen {
|
|||||||
int width = 160, height = 224;
|
int width = 160, height = 224;
|
||||||
int left = 384, right = 384, top = 384, bottom = 192;
|
int left = 384, right = 384, top = 384, bottom = 192;
|
||||||
var symbols = new Image[]{
|
var symbols = new Image[]{
|
||||||
new Image(skin.get(UiskinAtlas.SYMBOL_0, TextureRegion.class)),
|
new Image(skin.getRegion(UiskinAtlas.SYMBOL_0)),
|
||||||
new Image(skin.get(UiskinAtlas.SYMBOL_1, TextureRegion.class)),
|
new Image(skin.getRegion(UiskinAtlas.SYMBOL_1)),
|
||||||
new Image(skin.get(UiskinAtlas.SYMBOL_2, TextureRegion.class)),
|
new Image(skin.getRegion(UiskinAtlas.SYMBOL_2)),
|
||||||
new Image(skin.get(UiskinAtlas.SYMBOL_3, TextureRegion.class))
|
new Image(skin.getRegion(UiskinAtlas.SYMBOL_3))
|
||||||
};
|
};
|
||||||
symbols[0].setPosition(left, bottom);
|
symbols[0].setPosition(left, bottom);
|
||||||
symbols[1].setPosition(left, WizardGame.HEIGHT - top - height);
|
symbols[1].setPosition(left, WizardGame.HEIGHT - top - height);
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx.screens;
|
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.ui.Image;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.Layout;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas;
|
import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public abstract class MenuScreen extends WizardScreen {
|
public abstract class MenuScreen extends WizardScreen {
|
||||||
protected final float BUTTON_BAR_Y = WizardGame.HEIGHT * 0.15f;
|
|
||||||
|
|
||||||
private Image[] corners;
|
private Image[] corners;
|
||||||
|
@Getter(value = AccessLevel.PROTECTED, lazy = true)
|
||||||
|
private final HorizontalGroup buttonGroup = createButtonGroup();
|
||||||
|
|
||||||
public MenuScreen(WizardGame game) {
|
public MenuScreen(WizardGame game) {
|
||||||
super(game);
|
super(game);
|
||||||
@ -19,20 +23,48 @@ public abstract class MenuScreen extends WizardScreen {
|
|||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
corners = new Image[4];
|
corners = new Image[4];
|
||||||
corners[0] = new Image(skin.get(UiskinAtlas.CORNER_TOP_LEFT, TextureRegion.class));
|
corners[0] = new Image(skin.getRegion(UiskinAtlas.CORNER_TOP_LEFT));
|
||||||
corners[1] = new Image(skin.get(UiskinAtlas.CORNER_BOTTOM_LEFT, TextureRegion.class));
|
corners[1] = new Image(skin.getRegion(UiskinAtlas.CORNER_BOTTOM_LEFT));
|
||||||
corners[2] = new Image(skin.get(UiskinAtlas.CORNER_BOTTOM_RIGHT, TextureRegion.class));
|
corners[2] = new Image(skin.getRegion(UiskinAtlas.CORNER_BOTTOM_RIGHT));
|
||||||
corners[3] = new Image(skin.get(UiskinAtlas.CORNER_TOP_RIGHT, TextureRegion.class));
|
corners[3] = new Image(skin.getRegion(UiskinAtlas.CORNER_TOP_RIGHT));
|
||||||
for (var corner : corners) {
|
for (var corner : corners) {
|
||||||
stage.addActor(corner);
|
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.setSize(810, 192);
|
||||||
title.setPosition(555, WizardGame.HEIGHT - 192 - 96);
|
title.setPosition(555, WizardGame.HEIGHT - 192 - 96);
|
||||||
stage.addActor(title);
|
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
|
@Override
|
||||||
public void resize(int width, int height) {
|
public void resize(int width, int height) {
|
||||||
super.resize(width, height);
|
super.resize(width, height);
|
||||||
|
@ -51,16 +51,18 @@ public class WaitingScreen extends MenuScreen {
|
|||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
buttonLeave = new TextButton(messages.get("menu.waiting.leave"), skin);
|
buttonLeave = new TextButton(messages.get("menu.waiting.leave"), skin);
|
||||||
buttonLeave.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y);
|
|
||||||
buttonLeave.addListener(listener);
|
buttonLeave.addListener(listener);
|
||||||
|
getButtonGroup().addActor(buttonLeave);
|
||||||
|
|
||||||
buttonReady = new TextButton(messages.get("menu.waiting.ready"), skin);
|
buttonReady = new TextButton(messages.get("menu.waiting.ready"), skin);
|
||||||
buttonReady.setPosition(WizardGame.WIDTH * 0.725f - buttonReady.getWidth(), BUTTON_BAR_Y);
|
|
||||||
buttonReady.addListener(listener);
|
buttonReady.addListener(listener);
|
||||||
|
getButtonGroup().addActor(buttonReady);
|
||||||
|
|
||||||
|
getButtonGroup().setWidth(0.55f * WizardGame.WIDTH);
|
||||||
|
|
||||||
players = new List<>(skin) {
|
players = new List<>(skin) {
|
||||||
private final TextureRegion ready = skin.get(UiskinAtlas.READY, TextureRegion.class);
|
private final TextureRegion ready = skin.getRegion(UiskinAtlas.READY);
|
||||||
private final TextureRegion notReady = skin.get(UiskinAtlas.NOT_READY, TextureRegion.class);
|
private final TextureRegion notReady = skin.getRegion(UiskinAtlas.NOT_READY);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(PlayerData player) {
|
public String toString(PlayerData player) {
|
||||||
@ -91,8 +93,6 @@ public class WaitingScreen extends MenuScreen {
|
|||||||
content.addActor(createInfoTable());
|
content.addActor(createInfoTable());
|
||||||
content.layout();
|
content.layout();
|
||||||
|
|
||||||
stage.addActor(buttonLeave);
|
|
||||||
stage.addActor(buttonReady);
|
|
||||||
stage.addActor(content);
|
stage.addActor(content);
|
||||||
stage.addCaptureListener(new KeyboardFocusManager(buttonLeave, buttonReady));
|
stage.addCaptureListener(new KeyboardFocusManager(buttonLeave, buttonReady));
|
||||||
|
|
||||||
@ -117,17 +117,17 @@ public class WaitingScreen extends MenuScreen {
|
|||||||
labelSessionConfiguration.setEllipsis(true);
|
labelSessionConfiguration.setEllipsis(true);
|
||||||
labelPlayerName.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.columnDefaults(0).growX().width(infoTableWidth);
|
||||||
infoTable.setSize(infoTableWidth, 400);
|
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(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(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(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();
|
infoTable.add(labelPlayerName).row();
|
||||||
|
|
||||||
return infoTable;
|
return infoTable;
|
||||||
|
@ -6,7 +6,6 @@ import com.badlogic.gdx.audio.Sound;
|
|||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
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.Stage;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
@ -69,7 +68,7 @@ public abstract class WizardScreen implements Screen {
|
|||||||
public void show() {
|
public void show() {
|
||||||
load();
|
load();
|
||||||
|
|
||||||
background = new Image(skin.get(UiskinAtlas.BACKGROUND, TextureRegion.class));
|
background = new Image(skin.getRegion(UiskinAtlas.BACKGROUND));
|
||||||
background.setScaling(Scaling.fill);
|
background.setScaling(Scaling.fill);
|
||||||
background.setPosition(0,0);
|
background.setPosition(0,0);
|
||||||
stage.addActor(background);
|
stage.addActor(background);
|
||||||
@ -92,7 +91,8 @@ public abstract class WizardScreen implements Screen {
|
|||||||
offsetX = (worldWidth - WizardGame.WIDTH) / 2;
|
offsetX = (worldWidth - WizardGame.WIDTH) / 2;
|
||||||
offsetY = (worldHeight - WizardGame.HEIGHT) / 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);
|
background.setBounds(-offsetX, -offsetY, worldWidth, worldHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 87 KiB |
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 99 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 78 KiB |