visual improvements

main
Jonah Bauer 3 years ago
parent 10ca1ac9db
commit 991ae427da

@ -1,7 +1,6 @@
package eu.jonahbauer.wizard.client.libgdx.actors.game;
import com.badlogic.gdx.scenes.scene2d.*;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
import eu.jonahbauer.wizard.client.libgdx.screens.GameScreen;
import lombok.Data;

@ -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) {
var player = playerName.getText();
var session = sessionName.getText();
if (session.isEmpty() || session.equals(format.formatted(oldName))) {
if (player.isEmpty()) {
sessionName.setText("");
} else {
sessionName.setText(format.formatted(player));
}
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(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);

@ -8,6 +8,7 @@ import eu.jonahbauer.wizard.client.libgdx.WizardGame;
import eu.jonahbauer.wizard.client.libgdx.actors.AutoFocusScrollPane;
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.client.libgdx.state.Menu;
import eu.jonahbauer.wizard.common.messages.client.JoinSessionMessage;
import eu.jonahbauer.wizard.common.messages.data.SessionData;
@ -33,6 +34,8 @@ public class LobbyScreen extends MenuScreen {
private List<SessionData> sessions;
private ScrollPane sessionListContainer;
private final Map<UUID, SessionData> sessionData = new HashMap<>();
private final Lobby state;
private final ChangeListener listener = new ChangeListener() {
@Override
@ -52,6 +55,7 @@ public class LobbyScreen extends MenuScreen {
public LobbyScreen(WizardGame game) {
super(game);
this.state = (Lobby) game.getClient().getState();
}
@Override
@ -60,7 +64,6 @@ public class LobbyScreen extends MenuScreen {
buttonBack = new TextButton(game.messages.get("menu.lobby.back"), game.data.skin);
buttonJoin = new TextButton(game.messages.get("menu.lobby.join"), game.data.skin);
buttonJoin.setDisabled(true);
buttonCreate = new TextButton(game.messages.get("menu.lobby.create"), game.data.skin);
sessions = new List<>(game.data.skin) {
@ -165,14 +168,19 @@ public class LobbyScreen extends MenuScreen {
labelSessionConfiguration.setText("");
selectedSession = null;
}
buttonJoin.setDisabled(data == null);
}
private Table createInfoTable() {
float infoTableWidth = 0.3f * WizardGame.WIDTH - 20;
playerName = new TextField("", game.data.skin);
playerName = new TextField(state.getPlayerName(), game.data.skin);
playerName.addListener(new ResetErrorListener(game.data.skin));
playerName.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
state.setPlayerName(playerName.getText());
}
});
labelSessionName = new Label("", game.data.skin, "textfield");
labelSessionConfiguration = new Label("", game.data.skin, "textfield");

@ -29,7 +29,6 @@ public abstract class MenuScreen implements Screen {
@Override
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);
game.data.extendViewport.apply(true);
game.batch.setProjectionMatrix(game.data.extendViewport.getCamera().combined);
@ -48,6 +47,7 @@ public abstract class MenuScreen implements Screen {
}
protected void renderBackground(float delta) {
game.batch.setColor(1, 1, 1, 1);
float scale = Math.max(
game.data.extendViewport.getWorldWidth() / WizardGame.WIDTH,
game.data.extendViewport.getWorldHeight() / WizardGame.HEIGHT
@ -60,6 +60,7 @@ public abstract class MenuScreen implements Screen {
}
protected void renderForeground(float delta) {
game.batch.setColor(1, 1, 1, 1);
game.batch.draw(game.data.title, 555, WizardGame.HEIGHT - 192 - 96, 810, 192);
}

@ -1,11 +1,11 @@
package eu.jonahbauer.wizard.client.libgdx.state;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import eu.jonahbauer.wizard.client.libgdx.Client;
import eu.jonahbauer.wizard.client.libgdx.screens.CreateGameScreen;
import eu.jonahbauer.wizard.client.libgdx.screens.LobbyScreen;
import eu.jonahbauer.wizard.common.messages.data.SessionData;
import eu.jonahbauer.wizard.common.messages.server.*;
import lombok.Getter;
import lombok.Setter;
import java.util.Optional;
@ -13,7 +13,10 @@ public final class Lobby extends BaseState {
private SessionListMessage list;
private LobbyScreen lobbyScreen;
private CreateGameScreen createScreen;
@Getter
@Setter
private String playerName = "";
public Lobby(SessionListMessage list) {
this.list = list;
@ -43,10 +46,6 @@ public final class Lobby extends BaseState {
} else if (message instanceof SessionListMessage list) {
lobbyScreen.setSessions(list.getSessions().toArray(new SessionData[0]));
return Optional.empty();
} else if (message instanceof SessionJoinedMessage joined) {
//TODO find solution
createScreen = new CreateGameScreen(client.getGame());
return Optional.empty();
} else {
return unexpectedMessage(client, message);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 153 KiB

@ -16,6 +16,7 @@
"red": { "a": 1.0, "b": 0.0, "g": 0.0, "r": 1.0 },
"black": { "a": 1.0, "b": 0.0, "g": 0.0, "r": 0.0 },
"gold": { "a": 1.0, "b": 0.318, "g": 0.753, "r": 0.89 },
"darkened_gold": { "a": 1.0, "b": 0.176, "g": 0.659, "r": 0.845 },
"dark_gold": { "a": 1.0, "b": 0.034, "g": 0.565, "r": 0.80 },
"darker_gold": { "a": 1.0, "b": 0.191, "g": 0.452, "r": 0.534 },
"light_gray": { "a": 1.0, "b": 0.6, "g": 0.6, "r": 0.6}
@ -47,6 +48,7 @@
"font": "enchanted",
"fontColor": "gold",
"downFontColor": "dark_gold",
"overFontColor": "darkened_gold",
"disabledFontColor" : "darker_gold"
},
"simple": {
@ -192,7 +194,7 @@
"default": {
"minus": "tree-minus",
"plus": "tree-plus",
"selection": "default-select-selection"
"selection": "selection"
}
},
"TextTooltipStyle": {

Loading…
Cancel
Save