|
|
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.Array;
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.listeners.ResetErrorListener;
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.state.AwaitingJoinSession;
|
|
|
|
|
import eu.jonahbauer.wizard.client.libgdx.state.Lobby;
|
|
|
|
|
import eu.jonahbauer.wizard.common.messages.client.CreateSessionMessage;
|
|
|
|
|
import eu.jonahbauer.wizard.common.model.Configuration;
|
|
|
|
|
|
|
|
|
@ -21,6 +22,8 @@ public class CreateGameScreen extends MenuScreen {
|
|
|
|
|
private TextField timeOut;
|
|
|
|
|
private SelectBox<String> configurations;
|
|
|
|
|
|
|
|
|
|
private final Lobby state;
|
|
|
|
|
|
|
|
|
|
private final ChangeListener listener = new ChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void changed(ChangeEvent event, Actor actor) {
|
|
|
|
@ -36,6 +39,7 @@ public class CreateGameScreen extends MenuScreen {
|
|
|
|
|
|
|
|
|
|
public CreateGameScreen(WizardGame game) {
|
|
|
|
|
super(game);
|
|
|
|
|
this.state = (Lobby) game.getClient().getState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -55,31 +59,31 @@ public class CreateGameScreen extends MenuScreen {
|
|
|
|
|
sessionName.addListener(errorListener);
|
|
|
|
|
sessionName.setProgrammaticChangeEvents(true);
|
|
|
|
|
|
|
|
|
|
playerName = new TextField("", game.data.skin);
|
|
|
|
|
playerName = new TextField(state.getPlayerName(), game.data.skin);
|
|
|
|
|
playerName.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.45f);
|
|
|
|
|
playerName.setSize(0.4f * WizardGame.WIDTH, 64);
|
|
|
|
|
playerName.addListener(errorListener);
|
|
|
|
|
playerName.setTextFieldListener(new TextField.TextFieldListener() {
|
|
|
|
|
var playerNameListener = new ChangeListener() {
|
|
|
|
|
private final String format = game.messages.get("menu.create_game.session_name.default");
|
|
|
|
|
private String oldName = "";
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void keyTyped(TextField textField, char c) {
|
|
|
|
|
if (textField == playerName) {
|
|
|
|
|
public void changed(ChangeEvent event, Actor actor) {
|
|
|
|
|
var old = state.getPlayerName();
|
|
|
|
|
state.setPlayerName(playerName.getText());
|
|
|
|
|
|
|
|
|
|
var player = playerName.getText();
|
|
|
|
|
var session = sessionName.getText();
|
|
|
|
|
if (session.isEmpty() || session.equals(format.formatted(oldName))) {
|
|
|
|
|
if (session.isEmpty() || session.equals(format.formatted(old))) {
|
|
|
|
|
if (player.isEmpty()) {
|
|
|
|
|
sessionName.setText("");
|
|
|
|
|
} else {
|
|
|
|
|
sessionName.setText(format.formatted(player));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
oldName = player;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
playerName.addListener(playerNameListener);
|
|
|
|
|
playerNameListener.changed(null, null);
|
|
|
|
|
|
|
|
|
|
timeOut = new TextField("", game.data.skin);
|
|
|
|
|
timeOut.setPosition(WizardGame.WIDTH * 0.3f, WizardGame.HEIGHT * 0.4f);
|
|
|
|
|