refactoring

main
Jonah Bauer 3 years ago
parent 2d3062dcc3
commit 4d98c939a0

@ -37,7 +37,7 @@ public class ConnectScreen extends MenuScreen {
game.storage.uri = uriString;
game.getClient().execute(Menu.class, (s, c) -> s.connect(c, uri));
} catch (URISyntaxException e) {
uriField.setStyle(skin.get("error", TextField.TextFieldStyle.class));
uriField.setStyle(getTextFieldErrorStyle());
}
sfxClick();

@ -139,14 +139,14 @@ public class CreateGameScreen extends MenuScreen {
String sessionName = this.sessionName.getText();
if (sessionName.isBlank()) {
log.warn("Please choose a session name.");
this.sessionName.setStyle(skin.get("error", TextField.TextFieldStyle.class));
this.sessionName.setStyle(getTextFieldErrorStyle());
error = true;
}
String playerName = this.playerName.getText();
if (playerName.isBlank()) {
log.warn("Please choose a name.");
this.playerName.setStyle(skin.get("error", TextField.TextFieldStyle.class));
this.playerName.setStyle(getTextFieldErrorStyle());
error = true;
}
@ -155,7 +155,7 @@ public class CreateGameScreen extends MenuScreen {
timeout = Long.parseLong(this.timeOut.getText());
} catch (NumberFormatException e) {
log.warn("Please choose a valid timeout.");
this.timeOut.setStyle(skin.get("error", TextField.TextFieldStyle.class));
this.timeOut.setStyle(getTextFieldErrorStyle());
error = true;
}
@ -165,7 +165,7 @@ public class CreateGameScreen extends MenuScreen {
config = Configuration.values()[selected];
} catch (ArrayIndexOutOfBoundsException e) {
log.warn("Please select a valid configuration.");
this.configurations.setStyle(skin.get("error", SelectBox.SelectBoxStyle.class));
this.configurations.setStyle(getSelectBoxErrorStyle());
error = true;
}

@ -197,13 +197,13 @@ public class LobbyScreen extends MenuScreen {
String playerName = this.playerName.getText();
if (playerName.isBlank()) {
log.warn("Please choose a player name");
this.playerName.setStyle(skin.get("error", TextField.TextFieldStyle.class));
this.playerName.setStyle(getTextFieldErrorStyle());
error = true;
}
if (selectedSession == null) {
log.warn("Please select a session.");
this.sessionListContainer.setStyle(skin.get("error", ScrollPane.ScrollPaneStyle.class));
this.sessionListContainer.setStyle(getScrollPaneErrorStyle());
error = true;
}

@ -1,8 +1,7 @@
package eu.jonahbauer.wizard.client.libgdx.screens;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.Layout;
import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas;
import eu.jonahbauer.wizard.client.libgdx.WizardGame;
@ -14,6 +13,13 @@ public abstract class MenuScreen extends WizardScreen {
@Getter(value = AccessLevel.PROTECTED, lazy = true)
private final HorizontalGroup buttonGroup = createButtonGroup();
@Getter(value = AccessLevel.PROTECTED, lazy = true)
private final TextField.TextFieldStyle textFieldErrorStyle = skin.get("error", TextField.TextFieldStyle.class);
@Getter(value = AccessLevel.PROTECTED, lazy = true)
private final ScrollPane.ScrollPaneStyle scrollPaneErrorStyle = skin.get("error", ScrollPane.ScrollPaneStyle.class);
@Getter(value = AccessLevel.PROTECTED, lazy = true)
private final SelectBox.SelectBoxStyle selectBoxErrorStyle = skin.get("error", SelectBox.SelectBoxStyle.class);
public MenuScreen(WizardGame game) {
super(game);
}

Loading…
Cancel
Save