migration to asset manager
@ -5,21 +5,11 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.Graphics;
|
import com.badlogic.gdx.Graphics;
|
||||||
import com.badlogic.gdx.Input;
|
import com.badlogic.gdx.Input;
|
||||||
import com.badlogic.gdx.audio.Music;
|
import com.badlogic.gdx.audio.Music;
|
||||||
import com.badlogic.gdx.audio.Sound;
|
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
|
||||||
import com.badlogic.gdx.utils.I18NBundle;
|
import com.badlogic.gdx.utils.I18NBundle;
|
||||||
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
|
||||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
|
||||||
import eu.jonahbauer.wizard.client.libgdx.listeners.AutoFocusListener;
|
|
||||||
import eu.jonahbauer.wizard.client.libgdx.listeners.ButtonKeyListener;
|
|
||||||
import eu.jonahbauer.wizard.client.libgdx.screens.MainMenuScreen;
|
import eu.jonahbauer.wizard.client.libgdx.screens.MainMenuScreen;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.util.WizardAssetManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -30,11 +20,9 @@ public class WizardGame extends Game {
|
|||||||
public static final int HEIGHT = 1080;
|
public static final int HEIGHT = 1080;
|
||||||
|
|
||||||
public SpriteBatch batch;
|
public SpriteBatch batch;
|
||||||
public I18NBundle messages;
|
public WizardAssetManager assets;
|
||||||
public Data data;
|
|
||||||
|
|
||||||
private boolean toggle;
|
|
||||||
|
|
||||||
|
private boolean fullscreenToggle;
|
||||||
private int oldHeight, oldWidth;
|
private int oldHeight, oldWidth;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -43,18 +31,21 @@ public class WizardGame extends Game {
|
|||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
batch = new SpriteBatch();
|
batch = new SpriteBatch();
|
||||||
messages = I18NBundle.createBundle(Gdx.files.internal("i18n/messages"), Locale.getDefault());
|
|
||||||
|
assets = new WizardAssetManager();
|
||||||
|
assets.loadShared();
|
||||||
|
assets.finishLoading();
|
||||||
|
|
||||||
// background music
|
// background music
|
||||||
Music backgroundMusic = Gdx.audio.newMusic(Gdx.files.internal("background.mp3"));
|
Music backgroundMusic = assets.get(WizardAssetManager.MUSIC_BACKGROUND, Music.class);
|
||||||
backgroundMusic.setLooping(true);
|
backgroundMusic.setLooping(true);
|
||||||
backgroundMusic.setVolume(0.07f);
|
backgroundMusic.setVolume(0.07f);
|
||||||
backgroundMusic.play();
|
backgroundMusic.play();
|
||||||
|
|
||||||
// set cursor
|
// set cursor
|
||||||
Pixmap cursor = new Pixmap(Gdx.files.internal("cursor.png"));
|
Pixmap cursor = assets.get(WizardAssetManager.CURSOR, Pixmap.class);
|
||||||
Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor, 0, 0));
|
Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor, 0, 0));
|
||||||
cursor.dispose();
|
assets.unload(WizardAssetManager.CURSOR);
|
||||||
|
|
||||||
this.setScreen(new MainMenuScreen(this));
|
this.setScreen(new MainMenuScreen(this));
|
||||||
}
|
}
|
||||||
@ -68,8 +59,8 @@ public class WizardGame extends Game {
|
|||||||
var alt = (Gdx.input.isKeyPressed(Input.Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.ALT_RIGHT));
|
var alt = (Gdx.input.isKeyPressed(Input.Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Input.Keys.ALT_RIGHT));
|
||||||
var toggle = enter && alt;
|
var toggle = enter && alt;
|
||||||
|
|
||||||
if (toggle && !this.toggle) {
|
if (toggle && !this.fullscreenToggle) {
|
||||||
this.toggle = true;
|
this.fullscreenToggle = true;
|
||||||
var fullscreen = Gdx.graphics.isFullscreen();
|
var fullscreen = Gdx.graphics.isFullscreen();
|
||||||
Graphics.DisplayMode displayMode = Gdx.graphics.getDisplayMode();
|
Graphics.DisplayMode displayMode = Gdx.graphics.getDisplayMode();
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
@ -80,80 +71,19 @@ public class WizardGame extends Game {
|
|||||||
Gdx.graphics.setFullscreenMode(displayMode);
|
Gdx.graphics.setFullscreenMode(displayMode);
|
||||||
}
|
}
|
||||||
} else if (!toggle) {
|
} else if (!toggle) {
|
||||||
this.toggle = false;
|
this.fullscreenToggle = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose () {
|
public void dispose () {
|
||||||
batch.dispose();
|
batch.dispose();
|
||||||
|
assets.dispose();
|
||||||
client.shutdownNow();
|
client.shutdownNow();
|
||||||
var socket = client.getSocket();
|
var socket = client.getSocket();
|
||||||
if (socket != null) {
|
if (socket != null) {
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Data {
|
|
||||||
public final ExtendViewport extendViewport;
|
|
||||||
public final FitViewport fitViewport;
|
|
||||||
|
|
||||||
public final Sound buttonClickSound;
|
|
||||||
|
|
||||||
public final TextureAtlas uiskinAtlas;
|
|
||||||
public final TextureAtlas menuAtlas;
|
|
||||||
|
|
||||||
public final TextureRegion title;
|
|
||||||
public final TextureRegion background;
|
|
||||||
public final TextureRegion[] corners = new TextureRegion[4];
|
|
||||||
public final TextureRegion[] symbols = new TextureRegion[4];
|
|
||||||
|
|
||||||
public final Skin skin;
|
|
||||||
public final Stage stage;
|
|
||||||
|
|
||||||
public Data() {
|
|
||||||
this.extendViewport = new ExtendViewport(WizardGame.WIDTH, WizardGame.HEIGHT);
|
|
||||||
this.fitViewport = new FitViewport(WizardGame.WIDTH, WizardGame.HEIGHT);
|
|
||||||
|
|
||||||
this.buttonClickSound = Gdx.audio.newSound(Gdx.files.internal("button_click_s.mp3"));
|
|
||||||
|
|
||||||
this.uiskinAtlas = new TextureAtlas(Gdx.files.internal(UiskinAtlas.$PATH));
|
|
||||||
this.menuAtlas = new TextureAtlas(Gdx.files.internal(MenuAtlas.$PATH));
|
|
||||||
|
|
||||||
this.title = menuAtlas.findRegion(MenuAtlas.TITLE);
|
|
||||||
this.background = menuAtlas.findRegion(MenuAtlas.BACKGROUND);
|
|
||||||
this.corners[0] = menuAtlas.findRegion(MenuAtlas.ECKE_LO);
|
|
||||||
this.corners[1] = menuAtlas.findRegion(MenuAtlas.ECKE_LU);
|
|
||||||
this.corners[2] = menuAtlas.findRegion(MenuAtlas.ECKE_RU);
|
|
||||||
this.corners[3] = menuAtlas.findRegion(MenuAtlas.ECKE_RO);
|
|
||||||
this.symbols[0] = menuAtlas.findRegion(MenuAtlas.SYMBOL0);
|
|
||||||
this.symbols[1] = menuAtlas.findRegion(MenuAtlas.SYMBOL1);
|
|
||||||
this.symbols[2] = menuAtlas.findRegion(MenuAtlas.SYMBOL2);
|
|
||||||
this.symbols[3] = menuAtlas.findRegion(MenuAtlas.SYMBOL3);
|
|
||||||
|
|
||||||
this.skin = new Skin(Gdx.files.internal("uiskin.json"), uiskinAtlas);
|
|
||||||
this.skin.getAll(BitmapFont.class).forEach(entry ->
|
|
||||||
entry.value.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
|
||||||
);
|
|
||||||
this.stage = new Stage(fitViewport);
|
|
||||||
if (WizardGame.DEBUG) {
|
|
||||||
stage.setDebugAll(true);
|
|
||||||
}
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset() {
|
|
||||||
stage.clear();
|
|
||||||
stage.addListener(new ButtonKeyListener());
|
|
||||||
stage.addListener(new AutoFocusListener());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose() {
|
|
||||||
buttonClickSound.dispose();
|
|
||||||
uiskinAtlas.dispose();
|
|
||||||
menuAtlas.dispose();
|
|
||||||
skin.dispose();
|
|
||||||
stage.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class MakePredictionOverlay extends Overlay implements InteractionOverlay
|
|||||||
public VerticalGroup createContent() {
|
public VerticalGroup createContent() {
|
||||||
var root = new VerticalGroup().columnCenter().space(10);
|
var root = new VerticalGroup().columnCenter().space(10);
|
||||||
|
|
||||||
var prompt = new Label(messages.get("game.overlay.make_prediction.prompt"), data.skin);
|
var prompt = new Label(messages.get("game.overlay.make_prediction.prompt"), skin);
|
||||||
var buttonGroup = new HorizontalGroup().space(20);
|
var buttonGroup = new HorizontalGroup().space(20);
|
||||||
|
|
||||||
var listener = new ChangeListener() {
|
var listener = new ChangeListener() {
|
||||||
@ -47,7 +47,7 @@ public class MakePredictionOverlay extends Overlay implements InteractionOverlay
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (int i = 0; i < values.length; i++) {
|
||||||
buttons[i] = new TextButton(String.valueOf(i), data.skin);
|
buttons[i] = new TextButton(String.valueOf(i), skin);
|
||||||
buttons[i].addListener(listener);
|
buttons[i].addListener(listener);
|
||||||
buttonGroup.addActor(buttons[i]);
|
buttonGroup.addActor(buttons[i]);
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,14 @@ package eu.jonahbauer.wizard.client.libgdx.actions.overlay;
|
|||||||
|
|
||||||
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.Interpolation;
|
import com.badlogic.gdx.math.Interpolation;
|
||||||
import com.badlogic.gdx.scenes.scene2d.*;
|
import com.badlogic.gdx.scenes.scene2d.*;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
import com.badlogic.gdx.utils.I18NBundle;
|
import com.badlogic.gdx.utils.I18NBundle;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.AnimationTimings;
|
import eu.jonahbauer.wizard.client.libgdx.util.AnimationTimings;
|
||||||
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 eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||||
@ -19,7 +21,7 @@ import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*;
|
|||||||
|
|
||||||
public abstract class Overlay extends Action {
|
public abstract class Overlay extends Action {
|
||||||
protected final GameScreen screen;
|
protected final GameScreen screen;
|
||||||
protected final WizardGame.Data data;
|
protected final Skin skin;
|
||||||
protected final I18NBundle messages;
|
protected final I18NBundle messages;
|
||||||
protected final TextureAtlas atlas;
|
protected final TextureAtlas atlas;
|
||||||
private long timeout;
|
private long timeout;
|
||||||
@ -32,7 +34,7 @@ public abstract class Overlay extends Action {
|
|||||||
|
|
||||||
public Overlay(@NotNull GameScreen gameScreen, long timeout) {
|
public Overlay(@NotNull GameScreen gameScreen, long timeout) {
|
||||||
this.screen = gameScreen;
|
this.screen = gameScreen;
|
||||||
this.data = gameScreen.getData();
|
this.skin = gameScreen.getSkin();
|
||||||
this.messages = gameScreen.getMessages();
|
this.messages = gameScreen.getMessages();
|
||||||
this.atlas = gameScreen.getAtlas();
|
this.atlas = gameScreen.getAtlas();
|
||||||
this.timeout = timeout;
|
this.timeout = timeout;
|
||||||
@ -62,7 +64,7 @@ public abstract class Overlay extends Action {
|
|||||||
protected Container<?> getRoot() {
|
protected Container<?> getRoot() {
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
root = new Container<>(createContent());
|
root = new Container<>(createContent());
|
||||||
root.setBackground(new TextureRegionDrawable(data.uiskinAtlas.findRegion(UiskinAtlas.WHITE)).tint(new Color(0, 0, 0, 0.5f)));
|
root.setBackground(new TextureRegionDrawable(skin.get(UiskinAtlas.WHITE, TextureRegion.class)).tint(new Color(0, 0, 0, 0.5f)));
|
||||||
root.setSize(WizardGame.WIDTH, WizardGame.HEIGHT);
|
root.setSize(WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||||
root.setTouchable(Touchable.enabled);
|
root.setTouchable(Touchable.enabled);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class PickTrumpOverlay extends Overlay implements InteractionOverlay {
|
|||||||
public Actor createContent() {
|
public Actor createContent() {
|
||||||
var root = new VerticalGroup().columnCenter().space(10);
|
var root = new VerticalGroup().columnCenter().space(10);
|
||||||
|
|
||||||
var prompt = new Label(messages.get("game.overlay.pick_trump.prompt"), data.skin);
|
var prompt = new Label(messages.get("game.overlay.pick_trump.prompt"), skin);
|
||||||
var cardGroup = new HorizontalGroup().space(20);
|
var cardGroup = new HorizontalGroup().space(20);
|
||||||
|
|
||||||
cards.put(Card.Suit.RED, new CardActor(Card.Suit.RED, atlas));
|
cards.put(Card.Suit.RED, new CardActor(Card.Suit.RED, atlas));
|
||||||
|
@ -37,7 +37,7 @@ public class PlayColoredCardOverlay extends Overlay implements InteractionOverla
|
|||||||
public Actor createContent() {
|
public Actor createContent() {
|
||||||
var root = new VerticalGroup().columnCenter().space(10);
|
var root = new VerticalGroup().columnCenter().space(10);
|
||||||
|
|
||||||
var prompt = new Label(messages.get("game.overlay.play_colored_card.prompt"), data.skin);
|
var prompt = new Label(messages.get("game.overlay.play_colored_card.prompt"), skin);
|
||||||
var cardGroup = new HorizontalGroup().space(20);
|
var cardGroup = new HorizontalGroup().space(20);
|
||||||
|
|
||||||
var card = new CardActor(this.card, atlas);
|
var card = new CardActor(this.card, atlas);
|
||||||
@ -67,7 +67,7 @@ public class PlayColoredCardOverlay extends Overlay implements InteractionOverla
|
|||||||
root.addActor(prompt);
|
root.addActor(prompt);
|
||||||
root.addActor(cardGroup);
|
root.addActor(cardGroup);
|
||||||
|
|
||||||
var cancel = new TextButton(messages.get("game.overlay.play_colored_card.cancel"), data.skin, "simple");
|
var cancel = new TextButton(messages.get("game.overlay.play_colored_card.cancel"), skin, "simple");
|
||||||
cancel.addListener(new ChangeListener() {
|
cancel.addListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
@ -4,7 +4,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.AnimationTimings;
|
import eu.jonahbauer.wizard.client.libgdx.util.AnimationTimings;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ public class StartRoundOverlay extends Overlay {
|
|||||||
public Actor createContent() {
|
public Actor createContent() {
|
||||||
var root = new VerticalGroup().columnCenter().space(10f);
|
var root = new VerticalGroup().columnCenter().space(10f);
|
||||||
|
|
||||||
var label = new Label(messages.format("game.overlay.round.title", round + 1), data.skin, "enchanted");
|
var label = new Label(messages.format("game.overlay.round.title", round + 1), skin, "enchanted");
|
||||||
label.setFontScale(1.5f);
|
label.setFontScale(1.5f);
|
||||||
root.addActor(label);
|
root.addActor(label);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.actions.ParallelAction;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.AnimationTimings;
|
import eu.jonahbauer.wizard.client.libgdx.util.AnimationTimings;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.actions.MyActions;
|
import eu.jonahbauer.wizard.client.libgdx.actions.MyActions;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.actors.CardActor;
|
import eu.jonahbauer.wizard.client.libgdx.actors.CardActor;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||||
@ -126,7 +126,7 @@ public class TrumpOverlay extends Overlay {
|
|||||||
} : "game.overlay.trump.unknown.player", player);
|
} : "game.overlay.trump.unknown.player", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
var label = new Label(text, data.skin);
|
var label = new Label(text, skin);
|
||||||
label.getStyle().font.getData().markupEnabled = true;
|
label.getStyle().font.getData().markupEnabled = true;
|
||||||
label.setFontScale(1.5f);
|
label.setFontScale(1.5f);
|
||||||
root.addActor(label);
|
root.addActor(label);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx.actors;
|
package eu.jonahbauer.wizard.client.libgdx.actors;
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.*;
|
import com.badlogic.gdx.scenes.scene2d.*;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.AnimationTimings;
|
import eu.jonahbauer.wizard.client.libgdx.util.AnimationTimings;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -8,7 +8,7 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
import com.badlogic.gdx.scenes.scene2d.InputListener;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
|
||||||
import com.badlogic.gdx.utils.Pools;
|
import com.badlogic.gdx.utils.Pools;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.AnimationTimings;
|
import eu.jonahbauer.wizard.client.libgdx.util.AnimationTimings;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.util.Pair;
|
import eu.jonahbauer.wizard.client.libgdx.util.Pair;
|
||||||
import eu.jonahbauer.wizard.common.model.Card;
|
import eu.jonahbauer.wizard.common.model.Card;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -12,7 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
import com.badlogic.gdx.scenes.scene2d.ui.Table;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.AnimationTimings;
|
import eu.jonahbauer.wizard.client.libgdx.util.AnimationTimings;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.jetbrains.annotations.Range;
|
import org.jetbrains.annotations.Range;
|
||||||
|
|
||||||
|
@ -10,16 +10,15 @@ import com.badlogic.gdx.scenes.scene2d.utils.UIUtils;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class KeyboardFocusManager extends InputListener {
|
public class KeyboardFocusManager extends InputListener {
|
||||||
private final Stage stage;
|
|
||||||
private final List<Actor> focusOrder;
|
private final List<Actor> focusOrder;
|
||||||
|
|
||||||
public KeyboardFocusManager(Stage stage, List<Actor> focusOrder) {
|
public KeyboardFocusManager(Actor...focusOrder) {
|
||||||
this.stage = stage;
|
this.focusOrder = List.of(focusOrder);
|
||||||
this.focusOrder = focusOrder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyTyped(InputEvent event, char character) {
|
public boolean keyTyped(InputEvent event, char character) {
|
||||||
|
var stage = event.getStage();
|
||||||
if (character == '\t') {
|
if (character == '\t') {
|
||||||
var currentFocus = stage.getKeyboardFocus();
|
var currentFocus = stage.getKeyboardFocus();
|
||||||
var index = currentFocus == null ? -1 : focusOrder.indexOf(currentFocus);
|
var index = currentFocus == null ? -1 : focusOrder.indexOf(currentFocus);
|
||||||
|
@ -14,7 +14,6 @@ import eu.jonahbauer.wizard.client.libgdx.state.Menu;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ConnectScreen extends MenuScreen {
|
public class ConnectScreen extends MenuScreen {
|
||||||
private static String uri;
|
private static String uri;
|
||||||
@ -41,7 +40,7 @@ public class ConnectScreen extends MenuScreen {
|
|||||||
ConnectScreen.uri = uriString;
|
ConnectScreen.uri = uriString;
|
||||||
game.getClient().execute(Menu.class, (s, c) -> s.connect(c, uri));
|
game.getClient().execute(Menu.class, (s, c) -> s.connect(c, uri));
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
uriField.setStyle(game.data.skin.get("error", TextField.TextFieldStyle.class));
|
uriField.setStyle(skin.get("error", TextField.TextFieldStyle.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
sfxClick();
|
sfxClick();
|
||||||
@ -53,35 +52,31 @@ public class ConnectScreen extends MenuScreen {
|
|||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
buttonBack = new TextButton(game.messages.get("menu.connect.back"), game.data.skin);
|
buttonBack = new TextButton(messages.get("menu.connect.back"), skin);
|
||||||
buttonBack.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y);
|
buttonBack.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y);
|
||||||
buttonBack.addListener(listener);
|
buttonBack.addListener(listener);
|
||||||
|
|
||||||
buttonConnect = new TextButton(game.messages.get("menu.connect.connect"), game.data.skin);
|
buttonConnect = new TextButton(messages.get("menu.connect.connect"), skin);
|
||||||
buttonConnect.setPosition(WizardGame.WIDTH * 0.725f - buttonConnect.getWidth(), BUTTON_BAR_Y);
|
buttonConnect.setPosition(WizardGame.WIDTH * 0.725f - buttonConnect.getWidth(), BUTTON_BAR_Y);
|
||||||
buttonConnect.addListener(listener);
|
buttonConnect.addListener(listener);
|
||||||
|
|
||||||
var label = new Label(game.messages.get("menu.connect.address.label"), game.data.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);
|
||||||
label.setAlignment(Align.center);
|
label.setAlignment(Align.center);
|
||||||
label.setPosition(0.5f * (WizardGame.WIDTH - label.getWidth()), 0.55f * (WizardGame.HEIGHT - label.getHeight()));
|
label.setPosition(0.5f * (WizardGame.WIDTH - label.getWidth()), 0.55f * (WizardGame.HEIGHT - label.getHeight()));
|
||||||
|
|
||||||
// TODO sensible default value
|
// TODO sensible default value
|
||||||
uriField = new TextField(uri != null ? uri : "wss://webdev.jonahbauer.eu/wizard/", game.data.skin);
|
uriField = new TextField(uri != null ? uri : "wss://webdev.jonahbauer.eu/wizard/", skin);
|
||||||
uriField.setMessageText(game.messages.get("menu.connect.uri.hint"));
|
uriField.setMessageText(messages.get("menu.connect.uri.hint"));
|
||||||
uriField.setSize(0.4f * WizardGame.WIDTH, 64);
|
uriField.setSize(0.4f * WizardGame.WIDTH, 64);
|
||||||
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(game.data.skin));
|
uriField.addListener(new ResetErrorListener(skin));
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(game.data.stage);
|
stage.addActor(buttonBack);
|
||||||
game.data.stage.addActor(buttonBack);
|
stage.addActor(buttonConnect);
|
||||||
game.data.stage.addActor(buttonConnect);
|
stage.addActor(uriField);
|
||||||
game.data.stage.addActor(uriField);
|
stage.addActor(label);
|
||||||
game.data.stage.addActor(label);
|
stage.addCaptureListener(new KeyboardFocusManager(uriField, buttonBack, buttonConnect));
|
||||||
game.data.stage.addCaptureListener(new KeyboardFocusManager(
|
|
||||||
game.data.stage,
|
|
||||||
List.of(uriField, buttonBack, buttonConnect)
|
|
||||||
));
|
|
||||||
|
|
||||||
buttonBack.setName("button_back");
|
buttonBack.setName("button_back");
|
||||||
buttonConnect.setName("button_connect");
|
buttonConnect.setName("button_connect");
|
||||||
|
@ -48,28 +48,28 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
buttonBack = new TextButton(game.messages.get("menu.create_game.back"), game.data.skin);
|
buttonBack = new TextButton(messages.get("menu.create_game.back"), skin);
|
||||||
buttonBack.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y);
|
buttonBack.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y);
|
||||||
buttonBack.addListener(listener);
|
buttonBack.addListener(listener);
|
||||||
|
|
||||||
buttonContinue = new TextButton(game.messages.get("menu.create_game.create"), game.data.skin);
|
buttonContinue = new TextButton(messages.get("menu.create_game.create"), skin);
|
||||||
buttonContinue.setPosition(WizardGame.WIDTH * 0.725f - buttonContinue.getWidth(), BUTTON_BAR_Y);
|
buttonContinue.setPosition(WizardGame.WIDTH * 0.725f - buttonContinue.getWidth(), BUTTON_BAR_Y);
|
||||||
buttonContinue.addListener(listener);
|
buttonContinue.addListener(listener);
|
||||||
|
|
||||||
var errorListener = new ResetErrorListener(game.data.skin);
|
var errorListener = new ResetErrorListener(skin);
|
||||||
|
|
||||||
sessionName = new TextField("", game.data.skin);
|
sessionName = new TextField("", skin);
|
||||||
sessionName.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.5f);
|
sessionName.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.5f);
|
||||||
sessionName.setSize(0.4f * WizardGame.WIDTH, 64);
|
sessionName.setSize(0.4f * WizardGame.WIDTH, 64);
|
||||||
sessionName.addListener(errorListener);
|
sessionName.addListener(errorListener);
|
||||||
sessionName.setProgrammaticChangeEvents(true);
|
sessionName.setProgrammaticChangeEvents(true);
|
||||||
|
|
||||||
playerName = new TextField(oldPlayerName, game.data.skin);
|
playerName = new TextField(oldPlayerName, skin);
|
||||||
playerName.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.45f);
|
playerName.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.45f);
|
||||||
playerName.setSize(0.4f * WizardGame.WIDTH, 64);
|
playerName.setSize(0.4f * WizardGame.WIDTH, 64);
|
||||||
playerName.addListener(errorListener);
|
playerName.addListener(errorListener);
|
||||||
var playerNameListener = new ChangeListener() {
|
var playerNameListener = new ChangeListener() {
|
||||||
private final String format = game.messages.get("menu.create_game.session_name.default");
|
private final String format = messages.get("menu.create_game.session_name.default");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
@ -90,13 +90,13 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
playerName.addListener(playerNameListener);
|
playerName.addListener(playerNameListener);
|
||||||
playerNameListener.changed(null, null);
|
playerNameListener.changed(null, null);
|
||||||
|
|
||||||
timeOut = new TextField("", game.data.skin);
|
timeOut = new TextField("", skin);
|
||||||
timeOut.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.4f);
|
timeOut.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.4f);
|
||||||
timeOut.setSize(0.4f * WizardGame.WIDTH, 64);
|
timeOut.setSize(0.4f * WizardGame.WIDTH, 64);
|
||||||
timeOut.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
|
timeOut.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
|
||||||
timeOut.addListener(errorListener);
|
timeOut.addListener(errorListener);
|
||||||
|
|
||||||
configurations = new SelectBox<>(game.data.skin);
|
configurations = new SelectBox<>(skin);
|
||||||
configurations.setSize(400, 64);
|
configurations.setSize(400, 64);
|
||||||
configurations.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.3f);
|
configurations.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.3f);
|
||||||
configurations.addListener(errorListener);
|
configurations.addListener(errorListener);
|
||||||
@ -113,23 +113,19 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
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(game.messages.get("menu.create_game.player_name.label"), game.data.skin)).row();
|
contentTable.add(new Label(messages.get("menu.create_game.player_name.label"), skin)).row();
|
||||||
contentTable.add(playerName).row();
|
contentTable.add(playerName).row();
|
||||||
contentTable.add(new Label(game.messages.get("menu.create_game.session_name.label"), game.data.skin)).row();
|
contentTable.add(new Label(messages.get("menu.create_game.session_name.label"), skin)).row();
|
||||||
contentTable.add(sessionName).row();
|
contentTable.add(sessionName).row();
|
||||||
contentTable.add(new Label(game.messages.get("menu.create_game.session_timeout.label"), game.data.skin)).row();
|
contentTable.add(new Label(messages.get("menu.create_game.session_timeout.label"), skin)).row();
|
||||||
contentTable.add(timeOut).row();
|
contentTable.add(timeOut).row();
|
||||||
contentTable.add(new Label(game.messages.get("menu.create_game.session_configuration.label"), game.data.skin)).row();
|
contentTable.add(new Label(messages.get("menu.create_game.session_configuration.label"), skin)).row();
|
||||||
contentTable.add(configurations).row();
|
contentTable.add(configurations).row();
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(game.data.stage);
|
stage.addActor(buttonContinue);
|
||||||
game.data.stage.addActor(buttonContinue);
|
stage.addActor(contentTable);
|
||||||
game.data.stage.addActor(contentTable);
|
stage.addActor(buttonBack);
|
||||||
game.data.stage.addActor(buttonBack);
|
stage.addCaptureListener(new KeyboardFocusManager(playerName, sessionName, timeOut, configurations, buttonBack, buttonContinue));
|
||||||
game.data.stage.addCaptureListener(new KeyboardFocusManager(
|
|
||||||
game.data.stage,
|
|
||||||
java.util.List.of(playerName, sessionName, timeOut, configurations, buttonBack, buttonContinue)
|
|
||||||
));
|
|
||||||
|
|
||||||
buttonBack.setName("button_back");
|
buttonBack.setName("button_back");
|
||||||
buttonContinue.setName("button_continue");
|
buttonContinue.setName("button_continue");
|
||||||
@ -145,14 +141,14 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
String sessionName = this.sessionName.getText();
|
String sessionName = this.sessionName.getText();
|
||||||
if (sessionName.isBlank()) {
|
if (sessionName.isBlank()) {
|
||||||
log.warn("Please choose a session name.");
|
log.warn("Please choose a session name.");
|
||||||
this.sessionName.setStyle(game.data.skin.get("error", TextField.TextFieldStyle.class));
|
this.sessionName.setStyle(skin.get("error", TextField.TextFieldStyle.class));
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerName = this.playerName.getText();
|
String playerName = this.playerName.getText();
|
||||||
if (playerName.isBlank()) {
|
if (playerName.isBlank()) {
|
||||||
log.warn("Please choose a name.");
|
log.warn("Please choose a name.");
|
||||||
this.playerName.setStyle(game.data.skin.get("error", TextField.TextFieldStyle.class));
|
this.playerName.setStyle(skin.get("error", TextField.TextFieldStyle.class));
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +157,7 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
timeout = Long.parseLong(this.timeOut.getText());
|
timeout = Long.parseLong(this.timeOut.getText());
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
log.warn("Please choose a valid timeout.");
|
log.warn("Please choose a valid timeout.");
|
||||||
this.timeOut.setStyle(game.data.skin.get("error", TextField.TextFieldStyle.class));
|
this.timeOut.setStyle(skin.get("error", TextField.TextFieldStyle.class));
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,7 +167,7 @@ public class CreateGameScreen extends MenuScreen {
|
|||||||
config = Configuration.values()[selected];
|
config = Configuration.values()[selected];
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
log.warn("Please select a valid configuration.");
|
log.warn("Please select a valid configuration.");
|
||||||
this.configurations.setStyle(game.data.skin.get("error", SelectBox.SelectBoxStyle.class));
|
this.configurations.setStyle(skin.get("error", SelectBox.SelectBoxStyle.class));
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx.screens;
|
package eu.jonahbauer.wizard.client.libgdx.screens;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
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.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
@ -9,11 +8,11 @@ import com.badlogic.gdx.scenes.scene2d.Touchable;
|
|||||||
import com.badlogic.gdx.scenes.scene2d.actions.MoveToAction;
|
import com.badlogic.gdx.scenes.scene2d.actions.MoveToAction;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
import com.badlogic.gdx.scenes.scene2d.ui.Container;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
import com.badlogic.gdx.scenes.scene2d.ui.Label;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import com.badlogic.gdx.utils.I18NBundle;
|
import com.badlogic.gdx.utils.I18NBundle;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.AnimationTimings;
|
|
||||||
import eu.jonahbauer.wizard.client.libgdx.GameAtlas;
|
import eu.jonahbauer.wizard.client.libgdx.GameAtlas;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.actions.overlay.*;
|
import eu.jonahbauer.wizard.client.libgdx.actions.overlay.*;
|
||||||
@ -22,10 +21,11 @@ import eu.jonahbauer.wizard.client.libgdx.actors.CardStack;
|
|||||||
import eu.jonahbauer.wizard.client.libgdx.actors.CardsGroup;
|
import eu.jonahbauer.wizard.client.libgdx.actors.CardsGroup;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.actors.PadOfTruth;
|
import eu.jonahbauer.wizard.client.libgdx.actors.PadOfTruth;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.state.Game;
|
import eu.jonahbauer.wizard.client.libgdx.state.Game;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.util.AnimationTimings;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.util.WizardAssetManager;
|
||||||
import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage;
|
import eu.jonahbauer.wizard.common.messages.observer.UserInputMessage;
|
||||||
import eu.jonahbauer.wizard.common.model.Card;
|
import eu.jonahbauer.wizard.common.model.Card;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.Nls;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.Range;
|
import org.jetbrains.annotations.Range;
|
||||||
@ -55,7 +55,7 @@ public class GameScreen extends MenuScreen {
|
|||||||
@Getter
|
@Getter
|
||||||
private CardActor trumpSuitActor;
|
private CardActor trumpSuitActor;
|
||||||
|
|
||||||
private VerticalGroup messages;
|
private VerticalGroup messageStack;
|
||||||
private Label persistentMessage;
|
private Label persistentMessage;
|
||||||
|
|
||||||
private Action currentAction;
|
private Action currentAction;
|
||||||
@ -77,8 +77,12 @@ public class GameScreen extends MenuScreen {
|
|||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
atlas = new TextureAtlas(Gdx.files.internal(GameAtlas.$PATH));
|
|
||||||
labelStyleDefault = game.data.skin.get(Label.LabelStyle.class);
|
assets.loadGame();
|
||||||
|
assets.finishLoading();
|
||||||
|
atlas = assets.get(WizardAssetManager.ATLAS_GAME);
|
||||||
|
|
||||||
|
labelStyleDefault = skin.get(Label.LabelStyle.class);
|
||||||
labelStyleActive = new Label.LabelStyle(labelStyleDefault);
|
labelStyleActive = new Label.LabelStyle(labelStyleDefault);
|
||||||
labelStyleActive.fontColor = Color.RED;
|
labelStyleActive.fontColor = Color.RED;
|
||||||
|
|
||||||
@ -91,12 +95,12 @@ public class GameScreen extends MenuScreen {
|
|||||||
container.setSize(1200, CardActor.PREF_HEIGHT);
|
container.setSize(1200, CardActor.PREF_HEIGHT);
|
||||||
container.fillX();
|
container.fillX();
|
||||||
|
|
||||||
messages = new VerticalGroup().columnCenter().bottom();
|
messageStack = new VerticalGroup().columnCenter().bottom();
|
||||||
messages.setPosition(360, 85 + CardActor.PREF_HEIGHT);
|
messageStack.setPosition(360, 85 + CardActor.PREF_HEIGHT);
|
||||||
messages.setSize(1200, 0);
|
messageStack.setSize(1200, 0);
|
||||||
messages.setTouchable(Touchable.disabled);
|
messageStack.setTouchable(Touchable.disabled);
|
||||||
|
|
||||||
padOfTruth = new PadOfTruth(game.data.skin, new TextureRegionDrawable(atlas.findRegion(GameAtlas.PAD_OF_TRUTH)));
|
padOfTruth = new PadOfTruth(skin, new TextureRegionDrawable(atlas.findRegion(GameAtlas.PAD_OF_TRUTH)));
|
||||||
padOfTruth.setPosition(WizardGame.WIDTH - 10 - PadOfTruth.EXTENDED_WIDTH, 10);
|
padOfTruth.setPosition(WizardGame.WIDTH - 10 - PadOfTruth.EXTENDED_WIDTH, 10);
|
||||||
padOfTruth.setOrigin(PadOfTruth.EXTENDED_WIDTH, 0);
|
padOfTruth.setOrigin(PadOfTruth.EXTENDED_WIDTH, 0);
|
||||||
|
|
||||||
@ -105,11 +109,10 @@ public class GameScreen extends MenuScreen {
|
|||||||
|
|
||||||
addLabels();
|
addLabels();
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(game.data.stage);
|
stage.addActor(container);
|
||||||
game.data.stage.addActor(container);
|
stage.addActor(cardStack);
|
||||||
game.data.stage.addActor(cardStack);
|
stage.addActor(padOfTruth);
|
||||||
game.data.stage.addActor(padOfTruth);
|
stage.addActor(messageStack);
|
||||||
game.data.stage.addActor(messages);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void seat() {
|
private void seat() {
|
||||||
@ -139,14 +142,14 @@ public class GameScreen extends MenuScreen {
|
|||||||
padOfTruth.setName(i++, name);
|
padOfTruth.setName(i++, name);
|
||||||
|
|
||||||
if (isSelf(uuid)) continue;
|
if (isSelf(uuid)) continue;
|
||||||
var label = new Label("", game.data.skin);
|
var label = new Label("", skin);
|
||||||
var seat = seats.get(uuid);
|
var seat = seats.get(uuid);
|
||||||
label.setX(seat.getLabelX());
|
label.setX(seat.getLabelX());
|
||||||
label.setY(seat.getLabelY());
|
label.setY(seat.getLabelY());
|
||||||
label.setAlignment(seat.getLabelAlign());
|
label.setAlignment(seat.getLabelAlign());
|
||||||
label.setText(name);
|
label.setText(name);
|
||||||
nameLabels.put(uuid, label);
|
nameLabels.put(uuid, label);
|
||||||
game.data.stage.addActor(label);
|
stage.addActor(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
@ -154,24 +157,24 @@ public class GameScreen extends MenuScreen {
|
|||||||
@Override
|
@Override
|
||||||
protected void renderBackground(float delta) {
|
protected void renderBackground(float delta) {
|
||||||
float scale = Math.max(
|
float scale = Math.max(
|
||||||
game.data.extendViewport.getWorldWidth() / WizardGame.WIDTH,
|
extendViewport.getWorldWidth() / WizardGame.WIDTH,
|
||||||
game.data.extendViewport.getWorldHeight() / WizardGame.HEIGHT
|
extendViewport.getWorldHeight() / WizardGame.HEIGHT
|
||||||
);
|
);
|
||||||
game.batch.draw(game.data.background, 0,0, scale * WizardGame.WIDTH, scale * WizardGame.HEIGHT);
|
game.batch.draw(background, 0,0, scale * WizardGame.WIDTH, scale * WizardGame.HEIGHT);
|
||||||
game.batch.setColor(1, 1, 1, 0.25f);
|
game.batch.setColor(1, 1, 1, 0.25f);
|
||||||
game.batch.draw(
|
game.batch.draw(
|
||||||
game.data.title,
|
title,
|
||||||
(game.data.extendViewport.getWorldWidth() - game.data.title.getRegionWidth() * 0.75f) / 2f,
|
(extendViewport.getWorldWidth() - title.getRegionWidth() * 0.75f) / 2f,
|
||||||
(game.data.extendViewport.getWorldHeight() - game.data.title.getRegionHeight() * 0.75f) / 2f,
|
(extendViewport.getWorldHeight() - title.getRegionHeight() * 0.75f) / 2f,
|
||||||
0.75f * game.data.title.getRegionWidth(),
|
0.75f * title.getRegionWidth(),
|
||||||
0.75f * game.data.title.getRegionHeight()
|
0.75f * title.getRegionHeight()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderForeground(float delta) {
|
protected void renderForeground(float delta) {
|
||||||
if (pendingActions.size() > 0) {
|
if (pendingActions.size() > 0) {
|
||||||
var actions = game.data.stage.getRoot().getActions();
|
var actions = stage.getRoot().getActions();
|
||||||
boolean running = false;
|
boolean running = false;
|
||||||
if (currentAction != null) {
|
if (currentAction != null) {
|
||||||
for (int i = 0; i < actions.size; i++) {
|
for (int i = 0; i < actions.size; i++) {
|
||||||
@ -184,7 +187,7 @@ public class GameScreen extends MenuScreen {
|
|||||||
|
|
||||||
if (!running) {
|
if (!running) {
|
||||||
currentAction = pendingActions.poll();
|
currentAction = pendingActions.poll();
|
||||||
game.data.stage.addAction(currentAction);
|
stage.addAction(currentAction);
|
||||||
}
|
}
|
||||||
} else if (pendingSync.getAndSet(false)) {
|
} else if (pendingSync.getAndSet(false)) {
|
||||||
game.getClient().execute(Game.class, Game::sync);
|
game.getClient().execute(Game.class, Game::sync);
|
||||||
@ -252,7 +255,7 @@ public class GameScreen extends MenuScreen {
|
|||||||
rotation.setUseShortestDirection(true);
|
rotation.setUseShortestDirection(true);
|
||||||
|
|
||||||
action.addAction(sequence(
|
action.addAction(sequence(
|
||||||
targeting(card, changeParent(game.data.stage.getRoot())),
|
targeting(card, changeParent(stage.getRoot())),
|
||||||
parallel(
|
parallel(
|
||||||
targeting(card, rotation),
|
targeting(card, rotation),
|
||||||
targeting(card, moveTo(
|
targeting(card, moveTo(
|
||||||
@ -293,10 +296,10 @@ public class GameScreen extends MenuScreen {
|
|||||||
*/
|
*/
|
||||||
public void addPrediction(@Range(from = 0, to = 19) int round, @NotNull UUID player, int prediction, boolean changed) {
|
public void addPrediction(@Range(from = 0, to = 19) int round, @NotNull UUID player, int prediction, boolean changed) {
|
||||||
if (isSelf(player)) {
|
if (isSelf(player)) {
|
||||||
addMessage(game.messages.format("game.action." + (changed ? "change" : "make") + "_prediction.self", prediction));
|
addMessage("game.action." + (changed ? "change" : "make") + "_prediction.self", prediction);
|
||||||
} else {
|
} else {
|
||||||
var name = players.get(player);
|
var name = players.get(player);
|
||||||
addMessage(game.messages.format("game.action." + (changed ? "change" : "make") + "_prediction.other", name, prediction));
|
addMessage("game.action." + (changed ? "change" : "make") + "_prediction.other", name, prediction);
|
||||||
}
|
}
|
||||||
|
|
||||||
var index = orderedPlayers.indexOf(player);
|
var index = orderedPlayers.indexOf(player);
|
||||||
@ -312,10 +315,10 @@ public class GameScreen extends MenuScreen {
|
|||||||
*/
|
*/
|
||||||
public void playCard(@NotNull UUID player, @NotNull Card card) {
|
public void playCard(@NotNull UUID player, @NotNull Card card) {
|
||||||
if (isSelf(player)) {
|
if (isSelf(player)) {
|
||||||
addMessage(game.messages.get("game.action.play_card.self"));
|
addMessage("game.action.play_card.self");
|
||||||
} else {
|
} else {
|
||||||
var name = players.get(player);
|
var name = players.get(player);
|
||||||
addMessage(game.messages.format("game.action.play_card.other", name));
|
addMessage("game.action.play_card.other", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Seat seat = seats.getOrDefault(player, Seat.FALLBACK);
|
Seat seat = seats.getOrDefault(player, Seat.FALLBACK);
|
||||||
@ -378,9 +381,9 @@ public class GameScreen extends MenuScreen {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
setPersistentMessage(game.messages.format(key + "other", players.get(player)));
|
setPersistentMessage(key + "other", players.get(player));
|
||||||
} else {
|
} else {
|
||||||
setPersistentMessage(game.messages.get(key + "all"));
|
setPersistentMessage(key + "all");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,7 +442,7 @@ public class GameScreen extends MenuScreen {
|
|||||||
var handCard = new CardActor(trumpCardActor.getCard(), atlas);
|
var handCard = new CardActor(trumpCardActor.getCard(), atlas);
|
||||||
handCard.setPosition(10, 10);
|
handCard.setPosition(10, 10);
|
||||||
trumpCardActor.setCard(Card.WEREWOLF);
|
trumpCardActor.setCard(Card.WEREWOLF);
|
||||||
game.data.stage.addActor(handCard);
|
stage.addActor(handCard);
|
||||||
|
|
||||||
sequence.addAction(seat.moveToHand(trumpCardActor, 0));
|
sequence.addAction(seat.moveToHand(trumpCardActor, 0));
|
||||||
sequence.addAction(parallel(
|
sequence.addAction(parallel(
|
||||||
@ -454,6 +457,14 @@ public class GameScreen extends MenuScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//<editor-fold desc="Overlays" defaultstate="collapsed">
|
//<editor-fold desc="Overlays" defaultstate="collapsed">
|
||||||
|
public Skin getSkin() {
|
||||||
|
return skin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public I18NBundle getMessages() {
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
public void showTrumpOverlay(@Nullable UUID player, @Nullable Card trumpCard, @Nullable Card.Suit trumpSuit) {
|
public void showTrumpOverlay(@Nullable UUID player, @Nullable Card trumpCard, @Nullable Card.Suit trumpSuit) {
|
||||||
if (trumpCardActor == null) {
|
if (trumpCardActor == null) {
|
||||||
trumpCardActor = new CardActor(Card.HIDDEN, atlas);
|
trumpCardActor = new CardActor(Card.HIDDEN, atlas);
|
||||||
@ -512,12 +523,21 @@ public class GameScreen extends MenuScreen {
|
|||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold desc="Messages" defaultstate="collapsed">
|
//<editor-fold desc="Messages" defaultstate="collapsed">
|
||||||
public void addMessage(@Nls String text) {
|
public void addMessage(String key) {
|
||||||
addMessage(text, false);
|
addMessage(false, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMessage(@Nls String text, boolean immediate) {
|
public void addMessage(String key, Object...args) {
|
||||||
var label = new Label(text, game.data.skin);
|
addMessage(false, key, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMessage(boolean immediate, String key) {
|
||||||
|
addMessage(immediate, key, (Object[]) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMessage(boolean immediate, String key, Object...args) {
|
||||||
|
var text = args != null ? messages.format(key, args) : messages.get(key);
|
||||||
|
var label = new Label(text, skin);
|
||||||
label.addAction(sequence(
|
label.addAction(sequence(
|
||||||
delay(AnimationTimings.MESSAGE_HOLD),
|
delay(AnimationTimings.MESSAGE_HOLD),
|
||||||
alpha(0, AnimationTimings.MESSAGE_FADE),
|
alpha(0, AnimationTimings.MESSAGE_FADE),
|
||||||
@ -525,10 +545,10 @@ public class GameScreen extends MenuScreen {
|
|||||||
));
|
));
|
||||||
|
|
||||||
Runnable runnable = () -> {
|
Runnable runnable = () -> {
|
||||||
if (persistentMessage != null && persistentMessage.getParent() == messages) {
|
if (persistentMessage != null && persistentMessage.getParent() == messageStack) {
|
||||||
messages.addActorBefore(persistentMessage, label);
|
messageStack.addActorBefore(persistentMessage, label);
|
||||||
} else {
|
} else {
|
||||||
messages.addActor(label);
|
messageStack.addActor(label);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -539,7 +559,12 @@ public class GameScreen extends MenuScreen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPersistentMessage(@Nls String text) {
|
public void setPersistentMessage(String key) {
|
||||||
|
setPersistentMessage(key, (Object[]) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPersistentMessage(String key, Object...args) {
|
||||||
|
var text = key == null ? null : args != null ? messages.format(key, args) : messages.get(key);
|
||||||
execute(() -> {
|
execute(() -> {
|
||||||
if (persistentMessage != null) {
|
if (persistentMessage != null) {
|
||||||
persistentMessage.addAction(sequence(
|
persistentMessage.addAction(sequence(
|
||||||
@ -551,8 +576,8 @@ public class GameScreen extends MenuScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
persistentMessage = new Label(text, game.data.skin);
|
persistentMessage = new Label(text, skin);
|
||||||
messages.addActor(persistentMessage);
|
messageStack.addActor(persistentMessage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -563,7 +588,7 @@ public class GameScreen extends MenuScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void timeout() {
|
public void timeout() {
|
||||||
addMessage(game.messages.get("game.message.timeout"));
|
addMessage("game.message.timeout");
|
||||||
closeInteractionOverlay();
|
closeInteractionOverlay();
|
||||||
clearActivePlayer();
|
clearActivePlayer();
|
||||||
}
|
}
|
||||||
@ -582,15 +607,7 @@ public class GameScreen extends MenuScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if (atlas != null) atlas.dispose();
|
assets.unloadGame();
|
||||||
}
|
|
||||||
|
|
||||||
public WizardGame.Data getData() {
|
|
||||||
return game.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public I18NBundle getMessages() {
|
|
||||||
return game.messages;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Action animateJuggle(@NotNull List<CardActor> removed, @NotNull List<CardActor> added) {
|
private Action animateJuggle(@NotNull List<CardActor> removed, @NotNull List<CardActor> added) {
|
||||||
@ -607,7 +624,7 @@ public class GameScreen extends MenuScreen {
|
|||||||
|
|
||||||
var animation = parallel();
|
var animation = parallel();
|
||||||
removed.forEach(actor -> {
|
removed.forEach(actor -> {
|
||||||
game.data.stage.addActor(actor);
|
stage.addActor(actor);
|
||||||
animation.addAction(left.moveToHand(actor, AnimationTimings.JUGGLE));
|
animation.addAction(left.moveToHand(actor, AnimationTimings.JUGGLE));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -22,15 +22,13 @@ public class LoadingScreen extends MenuScreen {
|
|||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
var label = new Label(game.messages.get(key), game.data.skin);
|
var label = new Label(messages.get(key), skin);
|
||||||
|
|
||||||
var content = new VerticalGroup();
|
var content = new VerticalGroup();
|
||||||
content.setPosition(WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT*0.5f);
|
content.setPosition(WizardGame.WIDTH * 0.5f, WizardGame.HEIGHT*0.5f);
|
||||||
content.addActor(label);
|
content.addActor(label);
|
||||||
|
|
||||||
game.data.stage.addActor(content);
|
stage.addActor(content);
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(game.data.stage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,16 +56,16 @@ public class LobbyScreen extends MenuScreen {
|
|||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
buttonBack = new TextButton(game.messages.get("menu.lobby.back"), game.data.skin);
|
buttonBack = new TextButton(messages.get("menu.lobby.back"), skin);
|
||||||
buttonBack.addListener(listener);
|
buttonBack.addListener(listener);
|
||||||
|
|
||||||
buttonJoin = new TextButton(game.messages.get("menu.lobby.join"), game.data.skin);
|
buttonJoin = new TextButton(messages.get("menu.lobby.join"), skin);
|
||||||
buttonJoin.addListener(listener);
|
buttonJoin.addListener(listener);
|
||||||
|
|
||||||
buttonCreate = new TextButton(game.messages.get("menu.lobby.create"), game.data.skin);
|
buttonCreate = new TextButton(messages.get("menu.lobby.create"), skin);
|
||||||
buttonCreate.addListener(listener);
|
buttonCreate.addListener(listener);
|
||||||
|
|
||||||
sessions = new List<>(game.data.skin) {
|
sessions = new List<>(skin) {
|
||||||
@Override
|
@Override
|
||||||
public String toString(SessionData session) {
|
public String toString(SessionData session) {
|
||||||
return session.getName();
|
return session.getName();
|
||||||
@ -79,10 +79,10 @@ public class LobbyScreen extends MenuScreen {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sessionListContainer = new ScrollPane(sessions, game.data.skin);
|
sessionListContainer = new ScrollPane(sessions, skin);
|
||||||
sessionListContainer.layout();
|
sessionListContainer.layout();
|
||||||
|
|
||||||
sessions.addListener(new ResetErrorListener(game.data.skin, sessionListContainer));
|
sessions.addListener(new ResetErrorListener(skin, sessionListContainer));
|
||||||
|
|
||||||
var content = new HorizontalGroup().grow().space(20);
|
var content = new HorizontalGroup().grow().space(20);
|
||||||
content.setPosition(0.25f * WizardGame.WIDTH, 0.3f * WizardGame.HEIGHT);
|
content.setPosition(0.25f * WizardGame.WIDTH, 0.3f * WizardGame.HEIGHT);
|
||||||
@ -98,14 +98,10 @@ public class LobbyScreen extends MenuScreen {
|
|||||||
buttons.addActor(buttonCreate);
|
buttons.addActor(buttonCreate);
|
||||||
buttons.addActor(buttonJoin);
|
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)));
|
buttons.space(Math.max(0, (float) (buttons.getWidth() - StreamSupport.stream(buttons.getChildren().spliterator(), false).mapToDouble(Actor::getWidth).sum()) / (buttons.getChildren().size - 1)));
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(game.data.stage);
|
stage.addActor(content);
|
||||||
game.data.stage.addActor(content);
|
stage.addActor(buttons);
|
||||||
game.data.stage.addActor(buttons);
|
stage.addCaptureListener(new KeyboardFocusManager(sessions, playerName, buttonBack, buttonCreate, buttonJoin));
|
||||||
game.data.stage.addCaptureListener(new KeyboardFocusManager(
|
|
||||||
game.data.stage,
|
|
||||||
java.util.List.of(sessions, playerName, buttonBack, buttonCreate, buttonJoin)
|
|
||||||
));
|
|
||||||
|
|
||||||
buttonBack.setName("button_back");
|
buttonBack.setName("button_back");
|
||||||
buttonJoin.setName("button_join");
|
buttonJoin.setName("button_join");
|
||||||
@ -116,34 +112,70 @@ public class LobbyScreen extends MenuScreen {
|
|||||||
labelSessionConfiguration.setName("session_configuration");
|
labelSessionConfiguration.setName("session_configuration");
|
||||||
labelSessionPlayerCount.setName("session_player_count");
|
labelSessionPlayerCount.setName("session_player_count");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Table createInfoTable() {
|
||||||
|
float infoTableWidth = 0.3f * WizardGame.WIDTH - 20;
|
||||||
|
|
||||||
|
playerName = new TextField(oldPlayerName, skin);
|
||||||
|
playerName.addListener(new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
|
Lobby.setPlayerName(playerName.getText());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
playerName.addListener(new ResetErrorListener(skin));
|
||||||
|
|
||||||
|
labelSessionName = new Label("", skin, "textfield");
|
||||||
|
labelSessionConfiguration = new Label("", skin, "textfield");
|
||||||
|
labelSessionPlayerCount = new Label("", skin, "textfield");
|
||||||
|
|
||||||
|
labelSessionName.setEllipsis(true);
|
||||||
|
labelSessionConfiguration.setEllipsis(true);
|
||||||
|
labelSessionPlayerCount.setEllipsis(true);
|
||||||
|
|
||||||
|
var infoTable = new Table().center().left();
|
||||||
|
infoTable.columnDefaults(0).growX().width(infoTableWidth);
|
||||||
|
infoTable.setSize(infoTableWidth, 400);
|
||||||
|
|
||||||
|
infoTable.add(new Label(messages.get("menu.lobby.player_name.label"), skin)).row();
|
||||||
|
infoTable.add(playerName).row();
|
||||||
|
infoTable.add(new Label(messages.get("menu.lobby.session_name.label"), skin)).row();
|
||||||
|
infoTable.add(labelSessionName).row();
|
||||||
|
infoTable.add(new Label(messages.get("menu.lobby.session_configuration.label"), skin)).row();
|
||||||
|
infoTable.add(labelSessionConfiguration).row();
|
||||||
|
infoTable.add(new Label(messages.get("menu.lobby.session_player_count.label"), skin)).row();
|
||||||
|
infoTable.add(labelSessionPlayerCount).row();
|
||||||
|
|
||||||
|
return infoTable;
|
||||||
|
}
|
||||||
|
|
||||||
public void addSession(SessionData session) {
|
public void addSession(SessionData session) {
|
||||||
this.sessions.getItems().add(session);
|
this.sessions.getItems().add(session);
|
||||||
this.sessions.invalidateHierarchy();
|
this.sessions.invalidateHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSession(UUID session) {
|
public void removeSession(UUID session) {
|
||||||
var index = indexOf(session);
|
var index = indexOf(session);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
this.sessions.getItems().removeIndex(index);
|
this.sessions.getItems().removeIndex(index);
|
||||||
this.sessions.invalidateHierarchy();
|
this.sessions.invalidateHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedSession != null && selectedSession.getUuid().equals(session)) {
|
if (selectedSession != null && selectedSession.getUuid().equals(session)) {
|
||||||
updateData(null);
|
updateData(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void modifySession(SessionData session) {
|
public void modifySession(SessionData session) {
|
||||||
var index = indexOf(session.getUuid());
|
var index = indexOf(session.getUuid());
|
||||||
this.sessions.getItems().set(index, session);
|
this.sessions.getItems().set(index, session);
|
||||||
this.sessions.invalidateHierarchy();
|
this.sessions.invalidateHierarchy();
|
||||||
|
|
||||||
if (selectedSession != null && selectedSession.getUuid().equals(session.getUuid())) {
|
if (selectedSession != null && selectedSession.getUuid().equals(session.getUuid())) {
|
||||||
updateData(session);
|
updateData(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSessions(SessionData... sessions) {
|
public void setSessions(SessionData... sessions) {
|
||||||
var items = this.sessions.getItems();
|
var items = this.sessions.getItems();
|
||||||
items.clear();
|
items.clear();
|
||||||
@ -151,7 +183,7 @@ public class LobbyScreen extends MenuScreen {
|
|||||||
this.selectedSession = null;
|
this.selectedSession = null;
|
||||||
this.sessions.invalidateHierarchy();
|
this.sessions.invalidateHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateData(SessionData data) {
|
private void updateData(SessionData data) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
labelSessionName.setText(data.getName());
|
labelSessionName.setText(data.getName());
|
||||||
@ -165,42 +197,6 @@ public class LobbyScreen extends MenuScreen {
|
|||||||
selectedSession = null;
|
selectedSession = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Table createInfoTable() {
|
|
||||||
float infoTableWidth = 0.3f * WizardGame.WIDTH - 20;
|
|
||||||
|
|
||||||
playerName = new TextField(oldPlayerName, game.data.skin);
|
|
||||||
playerName.addListener(new ChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
|
||||||
Lobby.setPlayerName(playerName.getText());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
playerName.addListener(new ResetErrorListener(game.data.skin));
|
|
||||||
|
|
||||||
labelSessionName = new Label("", game.data.skin, "textfield");
|
|
||||||
labelSessionConfiguration = new Label("", game.data.skin, "textfield");
|
|
||||||
labelSessionPlayerCount = new Label("", game.data.skin, "textfield");
|
|
||||||
|
|
||||||
labelSessionName.setEllipsis(true);
|
|
||||||
labelSessionConfiguration.setEllipsis(true);
|
|
||||||
labelSessionPlayerCount.setEllipsis(true);
|
|
||||||
|
|
||||||
var infoTable = new Table().center().left();
|
|
||||||
infoTable.columnDefaults(0).growX().width(infoTableWidth);
|
|
||||||
infoTable.setSize(infoTableWidth, 400);
|
|
||||||
|
|
||||||
infoTable.add(new Label(game.messages.get("menu.lobby.player_name.label"), game.data.skin)).row();
|
|
||||||
infoTable.add(playerName).row();
|
|
||||||
infoTable.add(new Label(game.messages.get("menu.lobby.session_name.label"), game.data.skin)).row();
|
|
||||||
infoTable.add(labelSessionName).row();
|
|
||||||
infoTable.add(new Label(game.messages.get("menu.lobby.session_configuration.label"), game.data.skin)).row();
|
|
||||||
infoTable.add(labelSessionConfiguration).row();
|
|
||||||
infoTable.add(new Label(game.messages.get("menu.lobby.session_player_count.label"), game.data.skin)).row();
|
|
||||||
infoTable.add(labelSessionPlayerCount).row();
|
|
||||||
|
|
||||||
return infoTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void join() {
|
private void join() {
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
@ -208,13 +204,13 @@ public class LobbyScreen extends MenuScreen {
|
|||||||
String playerName = this.playerName.getText();
|
String playerName = this.playerName.getText();
|
||||||
if (playerName.isBlank()) {
|
if (playerName.isBlank()) {
|
||||||
log.warn("Please choose a player name");
|
log.warn("Please choose a player name");
|
||||||
this.playerName.setStyle(game.data.skin.get("error", TextField.TextFieldStyle.class));
|
this.playerName.setStyle(skin.get("error", TextField.TextFieldStyle.class));
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedSession == null) {
|
if (selectedSession == null) {
|
||||||
log.warn("Please select a session.");
|
log.warn("Please select a session.");
|
||||||
this.sessionListContainer.setStyle(game.data.skin.get("error", ScrollPane.ScrollPaneStyle.class));
|
this.sessionListContainer.setStyle(skin.get("error", ScrollPane.ScrollPaneStyle.class));
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
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.TextButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.MenuAtlas;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.listeners.KeyboardFocusManager;
|
import eu.jonahbauer.wizard.client.libgdx.listeners.KeyboardFocusManager;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.state.Menu;
|
import eu.jonahbauer.wizard.client.libgdx.state.Menu;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MainMenuScreen extends MenuScreen {
|
public class MainMenuScreen extends MenuScreen {
|
||||||
|
|
||||||
private TextButton buttonPlay;
|
private TextButton buttonPlay;
|
||||||
private TextButton buttonQuit;
|
private TextButton buttonQuit;
|
||||||
|
|
||||||
|
private TextureRegion[] symbols;
|
||||||
|
|
||||||
private final ChangeListener listener = new ChangeListener() {
|
private final ChangeListener listener = new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ChangeEvent event, Actor actor) {
|
public void changed(ChangeEvent event, Actor actor) {
|
||||||
@ -36,21 +38,24 @@ public class MainMenuScreen extends MenuScreen {
|
|||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
buttonPlay = new TextButton(game.messages.get("menu.main.play"), game.data.skin);
|
symbols = new TextureRegion[] {
|
||||||
|
atlas.findRegion(MenuAtlas.SYMBOL_0),
|
||||||
|
atlas.findRegion(MenuAtlas.SYMBOL_1),
|
||||||
|
atlas.findRegion(MenuAtlas.SYMBOL_2),
|
||||||
|
atlas.findRegion(MenuAtlas.SYMBOL_3)
|
||||||
|
};
|
||||||
|
|
||||||
|
buttonPlay = new TextButton(messages.get("menu.main.play"), skin);
|
||||||
buttonPlay.setPosition((WizardGame.WIDTH - buttonPlay.getWidth()) / 2f, 192 + 504 - 120f - 125f);
|
buttonPlay.setPosition((WizardGame.WIDTH - buttonPlay.getWidth()) / 2f, 192 + 504 - 120f - 125f);
|
||||||
buttonPlay.addListener(listener);
|
buttonPlay.addListener(listener);
|
||||||
|
|
||||||
buttonQuit = new TextButton(game.messages.get("menu.main.quit"), game.data.skin);
|
buttonQuit = new TextButton(messages.get("menu.main.quit"), skin);
|
||||||
buttonQuit.setPosition((WizardGame.WIDTH - buttonQuit.getWidth()) / 2f, 192 + 120f);
|
buttonQuit.setPosition((WizardGame.WIDTH - buttonQuit.getWidth()) / 2f, 192 + 120f);
|
||||||
buttonQuit.addListener(listener);
|
buttonQuit.addListener(listener);
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(game.data.stage);
|
stage.addActor(buttonPlay);
|
||||||
game.data.stage.addActor(buttonPlay);
|
stage.addActor(buttonQuit);
|
||||||
game.data.stage.addActor(buttonQuit);
|
stage.addCaptureListener(new KeyboardFocusManager(buttonPlay, buttonQuit));
|
||||||
game.data.stage.addCaptureListener(new KeyboardFocusManager(
|
|
||||||
game.data.stage,
|
|
||||||
List.of(buttonPlay, buttonQuit)
|
|
||||||
));
|
|
||||||
|
|
||||||
buttonPlay.setName("button_player");
|
buttonPlay.setName("button_player");
|
||||||
buttonQuit.setName("button_quit");
|
buttonQuit.setName("button_quit");
|
||||||
@ -61,9 +66,9 @@ public class MainMenuScreen extends MenuScreen {
|
|||||||
super.renderForeground(delta);
|
super.renderForeground(delta);
|
||||||
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;
|
||||||
this.game.batch.draw(game.data.symbols[0], left, bottom, width, height);
|
batch.draw(symbols[0], left, bottom, width, height);
|
||||||
this.game.batch.draw(game.data.symbols[1], left, WizardGame.HEIGHT - top - height, width, height);
|
batch.draw(symbols[1], left, WizardGame.HEIGHT - top - height, width, height);
|
||||||
this.game.batch.draw(game.data.symbols[2], WizardGame.WIDTH - right - width, bottom, width, height);
|
batch.draw(symbols[2], WizardGame.WIDTH - right - width, bottom, width, height);
|
||||||
this.game.batch.draw(game.data.symbols[3], WizardGame.WIDTH - right - width, WizardGame.HEIGHT - top - height, width, height);
|
batch.draw(symbols[3], WizardGame.WIDTH - right - width, WizardGame.HEIGHT - top - height, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,69 +2,127 @@ package eu.jonahbauer.wizard.client.libgdx.screens;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
|
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.g2d.BitmapFont;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
|
import com.badlogic.gdx.utils.I18NBundle;
|
||||||
|
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
||||||
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.MenuAtlas;
|
||||||
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.listeners.AutoFocusListener;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.listeners.ButtonKeyListener;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.util.WizardAssetManager;
|
||||||
|
|
||||||
public abstract class MenuScreen implements Screen {
|
public abstract class MenuScreen implements Screen {
|
||||||
protected final float BUTTON_BAR_Y = WizardGame.HEIGHT * 0.15f;
|
protected final float BUTTON_BAR_Y = WizardGame.HEIGHT * 0.15f;
|
||||||
|
|
||||||
protected final WizardGame game;
|
protected final WizardGame game;
|
||||||
|
protected final WizardAssetManager assets;
|
||||||
|
protected final SpriteBatch batch;
|
||||||
|
|
||||||
|
protected Stage stage;
|
||||||
|
protected FitViewport fitViewport;
|
||||||
|
protected ExtendViewport extendViewport;
|
||||||
|
|
||||||
|
// assets
|
||||||
|
protected Skin skin;
|
||||||
|
protected TextureAtlas atlas;
|
||||||
|
protected Sound sfxClick;
|
||||||
|
protected I18NBundle messages;
|
||||||
|
|
||||||
|
// textures
|
||||||
|
protected TextureRegion background;
|
||||||
|
protected TextureRegion title;
|
||||||
|
protected TextureRegion[] corners;
|
||||||
|
|
||||||
public MenuScreen(WizardGame game) {
|
public MenuScreen(WizardGame game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
this.assets = game.assets;
|
||||||
|
this.batch = game.batch;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void show() {
|
public void show() {
|
||||||
if (game.data == null) {
|
assets.loadMenu();
|
||||||
game.data = new WizardGame.Data();
|
assets.finishLoading();
|
||||||
} else {
|
|
||||||
game.data.reset();
|
skin = assets.get(WizardAssetManager.SKIN);
|
||||||
}
|
atlas = assets.get(WizardAssetManager.ATLAS_MENU);
|
||||||
|
sfxClick = assets.get(WizardAssetManager.SFX_CLICK);
|
||||||
|
messages = assets.get(WizardAssetManager.MESSAGES);
|
||||||
|
|
||||||
|
skin.getAll(BitmapFont.class).forEach(entry -> {
|
||||||
|
entry.value.getRegion().getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
|
||||||
|
});
|
||||||
|
|
||||||
|
extendViewport = new ExtendViewport(WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||||
|
fitViewport = new FitViewport(WizardGame.WIDTH, WizardGame.HEIGHT);
|
||||||
|
|
||||||
|
stage = new Stage(fitViewport);
|
||||||
|
stage.addListener(new ButtonKeyListener());
|
||||||
|
stage.addListener(new AutoFocusListener());
|
||||||
|
|
||||||
|
background = atlas.findRegion(MenuAtlas.BACKGROUND);
|
||||||
|
title = atlas.findRegion(MenuAtlas.TITLE);
|
||||||
|
corners = new TextureRegion[] {
|
||||||
|
atlas.findRegion(MenuAtlas.CORNER_TOP_LEFT),
|
||||||
|
atlas.findRegion(MenuAtlas.CORNER_BOTTOM_LEFT),
|
||||||
|
atlas.findRegion(MenuAtlas.CORNER_BOTTOM_RIGHT),
|
||||||
|
atlas.findRegion(MenuAtlas.CORNER_TOP_RIGHT),
|
||||||
|
};
|
||||||
|
|
||||||
|
Gdx.input.setInputProcessor(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void render(float delta) {
|
public final void render(float delta) {
|
||||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling?GL20.GL_COVERAGE_BUFFER_BIT_NV:0));
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling?GL20.GL_COVERAGE_BUFFER_BIT_NV:0));
|
||||||
|
|
||||||
game.data.extendViewport.apply(true);
|
extendViewport.apply(true);
|
||||||
game.batch.setProjectionMatrix(game.data.extendViewport.getCamera().combined);
|
batch.setProjectionMatrix(extendViewport.getCamera().combined);
|
||||||
game.batch.begin();
|
batch.begin();
|
||||||
renderBackground(delta);
|
renderBackground(delta);
|
||||||
game.batch.end();
|
batch.end();
|
||||||
|
|
||||||
game.data.fitViewport.apply();
|
fitViewport.apply();
|
||||||
game.batch.setProjectionMatrix(game.data.fitViewport.getCamera().combined);
|
batch.setProjectionMatrix(fitViewport.getCamera().combined);
|
||||||
game.batch.begin();
|
batch.begin();
|
||||||
renderForeground(delta);
|
renderForeground(delta);
|
||||||
game.batch.end();
|
batch.end();
|
||||||
|
|
||||||
game.data.stage.act(delta);
|
stage.act(delta);
|
||||||
game.data.stage.draw();
|
stage.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderBackground(float delta) {
|
protected void renderBackground(float delta) {
|
||||||
game.batch.setColor(1, 1, 1, 1);
|
batch.setColor(1, 1, 1, 1);
|
||||||
float scale = Math.max(
|
float scale = Math.max(
|
||||||
game.data.extendViewport.getWorldWidth() / WizardGame.WIDTH,
|
extendViewport.getWorldWidth() / WizardGame.WIDTH,
|
||||||
game.data.extendViewport.getWorldHeight() / WizardGame.HEIGHT
|
extendViewport.getWorldHeight() / WizardGame.HEIGHT
|
||||||
);
|
);
|
||||||
game.batch.draw(game.data.background, 0, 0, scale * WizardGame.WIDTH, scale * WizardGame.HEIGHT);
|
batch.draw(background, 0, 0, scale * WizardGame.WIDTH, scale * WizardGame.HEIGHT);
|
||||||
game.batch.draw(game.data.corners[0], 0, game.data.extendViewport.getWorldHeight() - game.data.corners[0].getRegionHeight());
|
batch.draw(corners[0], 0, extendViewport.getWorldHeight() - corners[0].getRegionHeight());
|
||||||
game.batch.draw(game.data.corners[1], 0, 0);
|
batch.draw(corners[1], 0, 0);
|
||||||
game.batch.draw(game.data.corners[2], game.data.extendViewport.getWorldWidth() - game.data.corners[2].getRegionWidth(), 0);
|
batch.draw(corners[2], extendViewport.getWorldWidth() - corners[2].getRegionWidth(), 0);
|
||||||
game.batch.draw(game.data.corners[3], game.data.extendViewport.getWorldWidth() - game.data.corners[3].getRegionWidth(), game.data.extendViewport.getWorldHeight() - game.data.corners[3].getRegionHeight());
|
batch.draw(corners[3], extendViewport.getWorldWidth() - corners[3].getRegionWidth(), extendViewport.getWorldHeight() - corners[3].getRegionHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renderForeground(float delta) {
|
protected void renderForeground(float delta) {
|
||||||
game.batch.setColor(1, 1, 1, 1);
|
batch.setColor(1, 1, 1, 1);
|
||||||
game.batch.draw(game.data.title, 555, WizardGame.HEIGHT - 192 - 96, 810, 192);
|
batch.draw(title, 555, WizardGame.HEIGHT - 192 - 96, 810, 192);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void resize(int width, int height) {
|
public final void resize(int width, int height) {
|
||||||
game.data.extendViewport.update(width, height);
|
extendViewport.update(width, height);
|
||||||
game.data.fitViewport.update(width, height);
|
fitViewport.update(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,9 +135,12 @@ public abstract class MenuScreen implements Screen {
|
|||||||
public void hide() {}
|
public void hide() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {}
|
public void dispose() {
|
||||||
|
assets.unloadMenu();
|
||||||
|
stage.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
protected void sfxClick() {
|
protected void sfxClick() {
|
||||||
game.data.buttonClickSound.play(0.6f);
|
sfxClick.play(0.6f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx.screens;
|
package eu.jonahbauer.wizard.client.libgdx.screens;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||||
@ -51,17 +50,17 @@ public class WaitingScreen extends MenuScreen {
|
|||||||
public void show() {
|
public void show() {
|
||||||
super.show();
|
super.show();
|
||||||
|
|
||||||
buttonLeave = new TextButton(game.messages.get("menu.waiting.leave"), game.data.skin);
|
buttonLeave = new TextButton(messages.get("menu.waiting.leave"), skin);
|
||||||
buttonLeave.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y);
|
buttonLeave.setPosition(WizardGame.WIDTH * 0.275f, BUTTON_BAR_Y);
|
||||||
buttonLeave.addListener(listener);
|
buttonLeave.addListener(listener);
|
||||||
|
|
||||||
buttonReady = new TextButton(game.messages.get("menu.waiting.ready"), game.data.skin);
|
buttonReady = new TextButton(messages.get("menu.waiting.ready"), skin);
|
||||||
buttonReady.setPosition(WizardGame.WIDTH * 0.725f - buttonReady.getWidth(), BUTTON_BAR_Y);
|
buttonReady.setPosition(WizardGame.WIDTH * 0.725f - buttonReady.getWidth(), BUTTON_BAR_Y);
|
||||||
buttonReady.addListener(listener);
|
buttonReady.addListener(listener);
|
||||||
|
|
||||||
players = new List<>(game.data.skin) {
|
players = new List<>(skin) {
|
||||||
private final TextureRegion ready = game.data.menuAtlas.findRegion(MenuAtlas.READY);
|
private final TextureRegion ready = atlas.findRegion(MenuAtlas.READY);
|
||||||
private final TextureRegion notReady = game.data.menuAtlas.findRegion(MenuAtlas.NOT_READY);
|
private final TextureRegion notReady = atlas.findRegion(MenuAtlas.NOT_READY);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(PlayerData player) {
|
public String toString(PlayerData player) {
|
||||||
@ -82,7 +81,7 @@ public class WaitingScreen extends MenuScreen {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var listContainer = new ScrollPane(players, game.data.skin);
|
var listContainer = new ScrollPane(players, skin);
|
||||||
listContainer.layout();
|
listContainer.layout();
|
||||||
|
|
||||||
var content = new HorizontalGroup().grow().space(20);
|
var content = new HorizontalGroup().grow().space(20);
|
||||||
@ -92,14 +91,10 @@ public class WaitingScreen extends MenuScreen {
|
|||||||
content.addActor(createInfoTable());
|
content.addActor(createInfoTable());
|
||||||
content.layout();
|
content.layout();
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(game.data.stage);
|
stage.addActor(buttonLeave);
|
||||||
game.data.stage.addActor(buttonLeave);
|
stage.addActor(buttonReady);
|
||||||
game.data.stage.addActor(buttonReady);
|
stage.addActor(content);
|
||||||
game.data.stage.addActor(content);
|
stage.addCaptureListener(new KeyboardFocusManager(buttonLeave, buttonReady));
|
||||||
game.data.stage.addCaptureListener(new KeyboardFocusManager(
|
|
||||||
game.data.stage,
|
|
||||||
java.util.List.of(buttonLeave, buttonReady)
|
|
||||||
));
|
|
||||||
|
|
||||||
buttonLeave.setName("button_leave");
|
buttonLeave.setName("button_leave");
|
||||||
buttonReady.setName("button_ready");
|
buttonReady.setName("button_ready");
|
||||||
@ -109,12 +104,41 @@ public class WaitingScreen extends MenuScreen {
|
|||||||
labelPlayerName.setName("player_name");
|
labelPlayerName.setName("player_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Table createInfoTable() {
|
||||||
|
float infoTableWidth = 0.3f * WizardGame.WIDTH - 20;
|
||||||
|
|
||||||
|
labelSessionName = new Label("", skin, "textfield");
|
||||||
|
labelSessionUUID = new Label("", skin, "textfield");
|
||||||
|
labelSessionConfiguration = new Label("", skin, "textfield");
|
||||||
|
labelPlayerName = new Label("", skin, "textfield");
|
||||||
|
|
||||||
|
labelSessionName.setEllipsis(true);
|
||||||
|
labelSessionUUID.setEllipsis(true);
|
||||||
|
labelSessionConfiguration.setEllipsis(true);
|
||||||
|
labelPlayerName.setEllipsis(true);
|
||||||
|
|
||||||
|
var infoTable = new Table().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(labelSessionName).row();
|
||||||
|
infoTable.add(new Label(messages.get("menu.waiting.session_uuid.label"), skin)).row();
|
||||||
|
infoTable.add(labelSessionUUID).row();
|
||||||
|
infoTable.add(new Label(messages.get("menu.waiting.session_configuration.label"), skin)).row();
|
||||||
|
infoTable.add(labelSessionConfiguration).row();
|
||||||
|
infoTable.add(new Label(messages.get("menu.waiting.player_name.label"), skin)).row();
|
||||||
|
infoTable.add(labelPlayerName).row();
|
||||||
|
|
||||||
|
return infoTable;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSending(boolean sending) {
|
public void setSending(boolean sending) {
|
||||||
buttonReady.setDisabled(sending);
|
buttonReady.setDisabled(sending);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReady(boolean ready) {
|
public void setReady(boolean ready) {
|
||||||
buttonReady.setText(game.messages.get(ready ? "menu.waiting.not_ready" : "menu.waiting.ready"));
|
buttonReady.setText(messages.get(ready ? "menu.waiting.not_ready" : "menu.waiting.ready"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(PlayerData player) {
|
public void addPlayer(PlayerData player) {
|
||||||
@ -152,35 +176,6 @@ public class WaitingScreen extends MenuScreen {
|
|||||||
public void setPlayerName(String name) {
|
public void setPlayerName(String name) {
|
||||||
this.labelPlayerName.setText(name);
|
this.labelPlayerName.setText(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Table createInfoTable() {
|
|
||||||
float infoTableWidth = 0.3f * WizardGame.WIDTH - 20;
|
|
||||||
|
|
||||||
labelSessionName = new Label("", game.data.skin, "textfield");
|
|
||||||
labelSessionUUID = new Label("", game.data.skin, "textfield");
|
|
||||||
labelSessionConfiguration = new Label("", game.data.skin, "textfield");
|
|
||||||
labelPlayerName = new Label("", game.data.skin, "textfield");
|
|
||||||
|
|
||||||
labelSessionName.setEllipsis(true);
|
|
||||||
labelSessionUUID.setEllipsis(true);
|
|
||||||
labelSessionConfiguration.setEllipsis(true);
|
|
||||||
labelPlayerName.setEllipsis(true);
|
|
||||||
|
|
||||||
var infoTable = new Table().center().left();
|
|
||||||
infoTable.columnDefaults(0).growX().width(infoTableWidth);
|
|
||||||
infoTable.setSize(infoTableWidth, 400);
|
|
||||||
|
|
||||||
infoTable.add(new Label(game.messages.get("menu.waiting.session_name.label"), game.data.skin)).row();
|
|
||||||
infoTable.add(labelSessionName).row();
|
|
||||||
infoTable.add(new Label(game.messages.get("menu.waiting.session_uuid.label"), game.data.skin)).row();
|
|
||||||
infoTable.add(labelSessionUUID).row();
|
|
||||||
infoTable.add(new Label(game.messages.get("menu.waiting.session_configuration.label"), game.data.skin)).row();
|
|
||||||
infoTable.add(labelSessionConfiguration).row();
|
|
||||||
infoTable.add(new Label(game.messages.get("menu.waiting.player_name.label"), game.data.skin)).row();
|
|
||||||
infoTable.add(labelPlayerName).row();
|
|
||||||
|
|
||||||
return infoTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int indexOf(UUID player) {
|
private int indexOf(UUID player) {
|
||||||
var items = this.players.getItems();
|
var items = this.players.getItems();
|
||||||
|
@ -280,7 +280,7 @@ public final class Game extends BaseState {
|
|||||||
case PICK_TRUMP -> currentInteraction.overlay(gameScreen.showPickTrumpOverlay(timeout, werewolf));
|
case PICK_TRUMP -> currentInteraction.overlay(gameScreen.showPickTrumpOverlay(timeout, werewolf));
|
||||||
case MAKE_PREDICTION -> currentInteraction.overlay(gameScreen.showMakePredictionOverlay(round, timeout));
|
case MAKE_PREDICTION -> currentInteraction.overlay(gameScreen.showMakePredictionOverlay(round, timeout));
|
||||||
case CHANGE_PREDICTION -> currentInteraction.overlay(gameScreen.showChangePredictionOverlay(round, predictions.get(player), timeout));
|
case CHANGE_PREDICTION -> currentInteraction.overlay(gameScreen.showChangePredictionOverlay(round, predictions.get(player), timeout));
|
||||||
case PLAY_CARD -> gameScreen.setPersistentMessage(gameScreen.getMessages().get("game.message.play_card.self"));
|
case PLAY_CARD -> gameScreen.setPersistentMessage("game.message.play_card.self");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +306,7 @@ public final class Game extends BaseState {
|
|||||||
int code = nack.getCode();
|
int code = nack.getCode();
|
||||||
if (code == NackMessage.ILLEGAL_ARGUMENT || code == NackMessage.ILLEGAL_STATE) {
|
if (code == NackMessage.ILLEGAL_ARGUMENT || code == NackMessage.ILLEGAL_STATE) {
|
||||||
log.error(nack.getMessage());
|
log.error(nack.getMessage());
|
||||||
gameScreen.addMessage(nack.getMessage(), true);
|
gameScreen.addMessage(true, "game.message.literal", nack.getMessage());
|
||||||
gameScreen.ready(false);
|
gameScreen.ready(false);
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
} else {
|
} else {
|
||||||
@ -345,7 +345,7 @@ public final class Game extends BaseState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gameScreen.addMessage("You cannot do that right now.", true);
|
gameScreen.addMessage(true, "game.message.nack.not_allowed");
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ public final class Game extends BaseState {
|
|||||||
if (isActive() && currentInteraction.action() == PICK_TRUMP) {
|
if (isActive() && currentInteraction.action() == PICK_TRUMP) {
|
||||||
send(client, new PickTrumpMessage(suit));
|
send(client, new PickTrumpMessage(suit));
|
||||||
} else {
|
} else {
|
||||||
gameScreen.addMessage("You cannot do that right now.", true);
|
gameScreen.addMessage(true, "game.message.nack.not_allowed");
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@ -366,7 +366,7 @@ public final class Game extends BaseState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gameScreen.addMessage("You cannot do that right now.", true);
|
gameScreen.addMessage(true, "game.message.nack.not_allowed");
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ public final class Game extends BaseState {
|
|||||||
client.send(new InteractionMessage(message));
|
client.send(new InteractionMessage(message));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
gameScreen.addMessage("Please slow down.", true);
|
gameScreen.addMessage(true, "game.message.nack.too_fast");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package eu.jonahbauer.wizard.client.libgdx;
|
package eu.jonahbauer.wizard.client.libgdx.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
@ -0,0 +1,62 @@
|
|||||||
|
package eu.jonahbauer.wizard.client.libgdx.util;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
|
import com.badlogic.gdx.assets.loaders.I18NBundleLoader;
|
||||||
|
import com.badlogic.gdx.assets.loaders.SkinLoader;
|
||||||
|
import com.badlogic.gdx.audio.Music;
|
||||||
|
import com.badlogic.gdx.audio.Sound;
|
||||||
|
import com.badlogic.gdx.graphics.Pixmap;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
|
import com.badlogic.gdx.utils.I18NBundle;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.GameAtlas;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.MenuAtlas;
|
||||||
|
import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas;
|
||||||
|
import lombok.experimental.Delegate;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class WizardAssetManager {
|
||||||
|
public static final String SKIN = "uiskin.json";
|
||||||
|
public static final String ATLAS_SKIN = UiskinAtlas.$PATH;
|
||||||
|
public static final String ATLAS_GAME = GameAtlas.$PATH;
|
||||||
|
public static final String ATLAS_MENU = MenuAtlas.$PATH;
|
||||||
|
|
||||||
|
public static final String SFX_CLICK = "button_click_s.mp3";
|
||||||
|
public static final String MUSIC_BACKGROUND = "background.mp3";
|
||||||
|
|
||||||
|
public static final String CURSOR = "cursor.png";
|
||||||
|
public static final String MESSAGES = "i18n/messages";
|
||||||
|
|
||||||
|
|
||||||
|
@Delegate
|
||||||
|
private final AssetManager manager = new AssetManager();
|
||||||
|
|
||||||
|
public void loadShared() {
|
||||||
|
manager.load(MUSIC_BACKGROUND, Music.class);
|
||||||
|
manager.load(CURSOR, Pixmap.class);
|
||||||
|
manager.load(MESSAGES, I18NBundle.class, new I18NBundleLoader.I18NBundleParameter(Locale.getDefault()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadMenu() {
|
||||||
|
manager.load(ATLAS_SKIN, TextureAtlas.class);
|
||||||
|
manager.load(ATLAS_MENU, TextureAtlas.class);
|
||||||
|
manager.load(SKIN, Skin.class, new SkinLoader.SkinParameter(ATLAS_SKIN));
|
||||||
|
manager.load(SFX_CLICK, Sound.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unloadMenu() {
|
||||||
|
manager.unload(ATLAS_SKIN);
|
||||||
|
manager.unload(ATLAS_MENU);
|
||||||
|
manager.unload(SKIN);
|
||||||
|
manager.unload(SFX_CLICK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadGame() {
|
||||||
|
manager.load(ATLAS_GAME, TextureAtlas.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unloadGame() {
|
||||||
|
manager.unload(ATLAS_GAME);
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,7 @@ menu.waiting.session_name.label=Session Name
|
|||||||
menu.waiting.session_uuid.label=Session UUID
|
menu.waiting.session_uuid.label=Session UUID
|
||||||
menu.waiting.session_configuration.label=Configuration
|
menu.waiting.session_configuration.label=Configuration
|
||||||
|
|
||||||
|
game.message.literal={0}
|
||||||
|
|
||||||
game.message.play_card.other=It is {0}'s turn to play a card
|
game.message.play_card.other=It is {0}'s turn to play a card
|
||||||
game.message.play_card.all=Everybody must play a card
|
game.message.play_card.all=Everybody must play a card
|
||||||
@ -60,6 +61,8 @@ game.message.change_prediction.all=Everybody must change their prediction
|
|||||||
game.message.change_prediction.self=It is your turn to change your prediction
|
game.message.change_prediction.self=It is your turn to change your prediction
|
||||||
|
|
||||||
game.message.timeout=Timed out
|
game.message.timeout=Timed out
|
||||||
|
game.message.nack.not_allowed=You cannot do that right now
|
||||||
|
game.message.nack.too_fast=Please slow down
|
||||||
|
|
||||||
game.action.play_card.other={0} played a card
|
game.action.play_card.other={0} played a card
|
||||||
game.action.play_card.self=You played a card
|
game.action.play_card.self=You played a card
|
||||||
|
@ -60,6 +60,8 @@ game.message.change_prediction.all=Jeder muss seine Vorhersage ändern
|
|||||||
game.message.change_prediction.self=Du musst deine Vorhersage ändern
|
game.message.change_prediction.self=Du musst deine Vorhersage ändern
|
||||||
|
|
||||||
game.message.timeout=Zeit abgelaufen
|
game.message.timeout=Zeit abgelaufen
|
||||||
|
game.message.nack.not_allowed=Du kannst das jetzt nicht tun
|
||||||
|
game.message.nack.too_fast=Nicht so schnell
|
||||||
|
|
||||||
game.action.play_card.other={0} hat eine Karte gespielt
|
game.action.play_card.other={0} hat eine Karte gespielt
|
||||||
game.action.play_card.self=Du hast eine Karte gespielt
|
game.action.play_card.self=Du hast eine Karte gespielt
|
||||||
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"maxWidth": 2048,
|
"maxWidth": 2048,
|
||||||
"maxHeight": 2048
|
"maxHeight": 2048,
|
||||||
|
"useIndexes": false
|
||||||
}
|
}
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 94 KiB |
Before Width: | Height: | Size: 107 KiB After Width: | Height: | Size: 107 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |