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.storage.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(skin.get("error", TextField.TextFieldStyle.class)); uriField.setStyle(getTextFieldErrorStyle());
} }
sfxClick(); sfxClick();

@ -139,14 +139,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(skin.get("error", TextField.TextFieldStyle.class)); this.sessionName.setStyle(getTextFieldErrorStyle());
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(skin.get("error", TextField.TextFieldStyle.class)); this.playerName.setStyle(getTextFieldErrorStyle());
error = true; error = true;
} }
@ -155,7 +155,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(skin.get("error", TextField.TextFieldStyle.class)); this.timeOut.setStyle(getTextFieldErrorStyle());
error = true; error = true;
} }
@ -165,7 +165,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(skin.get("error", SelectBox.SelectBoxStyle.class)); this.configurations.setStyle(getSelectBoxErrorStyle());
error = true; error = true;
} }

@ -197,13 +197,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(skin.get("error", TextField.TextFieldStyle.class)); this.playerName.setStyle(getTextFieldErrorStyle());
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(skin.get("error", ScrollPane.ScrollPaneStyle.class)); this.sessionListContainer.setStyle(getScrollPaneErrorStyle());
error = true; error = true;
} }

@ -1,8 +1,7 @@
package eu.jonahbauer.wizard.client.libgdx.screens; package eu.jonahbauer.wizard.client.libgdx.screens;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup; import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.Layout; import com.badlogic.gdx.scenes.scene2d.utils.Layout;
import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas; import eu.jonahbauer.wizard.client.libgdx.UiskinAtlas;
import eu.jonahbauer.wizard.client.libgdx.WizardGame; import eu.jonahbauer.wizard.client.libgdx.WizardGame;
@ -14,6 +13,13 @@ public abstract class MenuScreen extends WizardScreen {
@Getter(value = AccessLevel.PROTECTED, lazy = true) @Getter(value = AccessLevel.PROTECTED, lazy = true)
private final HorizontalGroup buttonGroup = createButtonGroup(); 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) { public MenuScreen(WizardGame game) {
super(game); super(game);
} }

Loading…
Cancel
Save