use of com.janfic.games.computercombat.actors.BorderedGrid in project computercombat by janfic.
the class LoginScreen method show.
@Override
public void show() {
this.camera = new OrthographicCamera(1920 / 4, 1080 / 4);
this.stage = ComputerCombatGame.makeNewStage(camera);
this.toolTipManager = TooltipManager.getInstance();
this.toolTipManager.instant();
Gdx.input.setInputProcessor(stage);
Table table = new Table();
table.setFillParent(true);
table.defaults().pad(5);
Table titleTable = new Table(skin);
titleTable.setBackground("border");
Label title = new Label("Login", skin);
title.setAlignment(Align.center);
TextButton backButton = new TextButton("Back", skin);
backButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.popScreen();
}
});
titleTable.add(backButton);
titleTable.add(title).growX().row();
Table leftGroup = new Table();
BorderedGrid grid = new BorderedGrid(skin);
Table usernameTable = new Table(skin);
usernameTable.background("border_filled");
Label userNameFieldLabel = new Label(" Username: ", skin);
Image usernameInfo = new Image(skin, "info_icon");
usernameTable.add(usernameInfo);
usernameTable.add(userNameFieldLabel);
Table passwordTable = new Table(skin);
passwordTable.background("border_filled");
Label passwordFieldLabel = new Label(" Password: ", skin);
Image passwordInfo = new Image(skin, "info_icon");
passwordTable.add(passwordInfo);
passwordTable.add(passwordFieldLabel);
userNameField = new TextField("", skin);
passwordField = new TextField("", skin);
TextButton loginButton = new TextButton("Login", skin);
TextTooltip usernameTip = new TextTooltip("Only alphanumeric characters (A-Z,0-9)", toolTipManager, skin);
usernameInfo.addListener(usernameTip);
TextTooltip passwordTip = new TextTooltip("Minimum 8 alphanumeric characters (A-Z,0-9)", toolTipManager, skin);
passwordInfo.addListener(passwordTip);
TextField.TextFieldFilter alphaNumeric = new TextField.TextFieldFilter() {
@Override
public boolean acceptChar(TextField tf, char c) {
return tf.getText().length() < 12 && (Character.isAlphabetic(c) || Character.isDigit(c));
}
};
userNameField.setTextFieldFilter(alphaNumeric);
passwordField.setTextFieldFilter(alphaNumeric);
userNameFieldLabel.setAlignment(Align.right);
passwordFieldLabel.setAlignment(Align.right);
passwordField.setPasswordMode(true);
passwordField.setPasswordCharacter('*');
passwordField.addListener(new InputListener() {
@Override
public boolean keyUp(InputEvent event, int keycode) {
if (keycode == Input.Keys.ENTER) {
boolean validSignUp = true;
if (userNameField.getText().trim().length() <= 0 || userNameField.getText().trim().length() > 12) {
validSignUp = false;
userNameField.setColor(Color.RED);
} else {
userNameField.setColor(Color.WHITE);
}
String password = passwordField.getText().trim();
if (password.length() < 7) {
validSignUp = false;
passwordField.setColor(Color.RED);
} else {
passwordField.setColor(Color.WHITE);
}
if (validSignUp) {
game.getServerAPI().sendMessage(new Message(Type.LOGIN_REQUEST, userNameField.getText().trim() + "," + passwordField.getText().trim()));
}
}
return true;
}
});
grid.pad(10);
grid.defaults().space(6);
leftGroup.defaults().space(10);
// leftGroup.debugAll();
leftGroup.add(usernameTable).growX().minHeight(25);
leftGroup.add(userNameField).minHeight(25).row();
leftGroup.add(passwordTable).growX().minHeight(25);
leftGroup.add(passwordField).minHeight(25).row();
leftGroup.add(loginButton).colspan(2).growX().row();
loginButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
boolean validSignUp = true;
if (userNameField.getText().trim().length() <= 0 || userNameField.getText().trim().length() > 12) {
validSignUp = false;
userNameField.setColor(Color.RED);
} else {
userNameField.setColor(Color.WHITE);
}
String password = passwordField.getText().trim();
if (password.length() < 7) {
validSignUp = false;
passwordField.setColor(Color.RED);
} else {
passwordField.setColor(Color.WHITE);
}
if (validSignUp) {
game.getServerAPI().sendMessage(new Message(Type.LOGIN_REQUEST, userNameField.getText().trim() + "," + passwordField.getText().trim()));
}
}
});
grid.add(leftGroup).grow();
table.add(titleTable).growX().row();
table.add(grid).growY().row();
stage.addActor(table);
}
use of com.janfic.games.computercombat.actors.BorderedGrid in project computercombat by janfic.
the class MatchResultsScreen method show.
@Override
public void show() {
this.camera = new OrthographicCamera(1920 / 4, 1080 / 4);
this.stage = ComputerCombatGame.makeNewStage(camera);
Gdx.input.setInputProcessor(stage);
this.table = new Table(this.skin);
table.setFillParent(true);
table.defaults().space(3);
table.pad(3);
table.top();
stage.addActor(table);
Table titleTable = new Table(skin);
titleTable.setBackground("border");
titleTable.add(new Label("Match Results", skin));
table.add(titleTable).growX().row();
BorderedGrid mainTable = new BorderedGrid(skin);
mainTable.defaults().space(3);
mainTable.pad(8);
mainTable.top();
table.add(mainTable).grow();
Panel matchPanel = new Panel(skin);
matchPanel.defaults().space(3);
matchPanel.top();
matchPanel.pad(5);
Label winOrLossLabel = new Label(this.matchResults.winner ? "Victory" : "Defeat", skin);
winOrLossLabel.setAlignment(Align.center);
matchPanel.add(winOrLossLabel).colspan(3).growX().row();
BorderedArea playerIcon = new BorderedArea(skin);
BorderedArea opponentIcon = new BorderedArea(skin);
matchPanel.add(playerIcon).width(64).height(64);
matchPanel.add(new Label("vs.", skin));
matchPanel.add(opponentIcon).width(64).height(64).row();
Label player1Label = new Label(this.game.getCurrentProfile().getName(), skin);
player1Label.setAlignment(Align.center);
Label player2Label = new Label("Opponent's Turn", skin);
player2Label.setAlignment(Align.center);
matchPanel.add(player1Label).width(64);
matchPanel.add().pad(10);
matchPanel.add(player2Label).width(64).row();
Label matchStartLabel = new Label(getTime(this.matchResults.start) + " - " + getTime(this.matchResults.end), skin);
long seconds = this.matchResults.start.toLocalDateTime().until(this.matchResults.end.toLocalDateTime(), SECONDS);
Label length = new Label("(" + (seconds / 60) + ":" + (seconds % 60) + ")", skin);
matchPanel.add(matchStartLabel).colspan(3).row();
matchPanel.add(length).colspan(3).row();
Panel rewardsPanel = new Panel(skin);
rewardsPanel.defaults().space(3);
rewardsPanel.top();
rewardsPanel.pad(5);
Label rewardsLabel = new Label("Rewards", skin);
rewardsLabel.setAlignment(Align.center);
rewardsPanel.add(rewardsLabel).growX().colspan(2).padBottom(15).row();
for (String string : matchResults.rewards.keySet()) {
Image packetsImage = new Image(game.getAssetManager().get("texture_packs/components.atlas", TextureAtlas.class).findRegion("network"));
Label networkAmount = new Label("" + matchResults.rewards.get(string), skin);
rewardsPanel.add(new Label(string, skin)).expandX().center().colspan(2).row();
rewardsPanel.add(packetsImage).width(24).height(24).right();
rewardsPanel.add(networkAmount).padLeft(5).left().row();
}
Image packetsImage = new Image(game.getAssetManager().get("texture_packs/components.atlas", TextureAtlas.class).findRegion("network"));
rewardsPanel.add(new Label("Total", skin)).expandX().center().colspan(2).row();
rewardsPanel.add(packetsImage).width(24).height(24).right();
rewardsPanel.add(new Label("" + matchResults.totalPacketsEarned, skin)).padLeft(5).left().row();
mainTable.add(matchPanel).grow();
mainTable.add(rewardsPanel).grow().row();
TextButton okayButton = new TextButton("Okay", skin);
okayButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.popScreen();
}
});
mainTable.add(okayButton).colspan(2).width(100).expandX().pad(5).spaceBottom(5);
}
use of com.janfic.games.computercombat.actors.BorderedGrid in project computercombat by janfic.
the class SignUpScreen method show.
@Override
public void show() {
this.camera = new OrthographicCamera(1920 / 4, 1080 / 4);
this.stage = ComputerCombatGame.makeNewStage(camera);
this.toolTipManager = TooltipManager.getInstance();
this.toolTipManager.instant();
Gdx.input.setInputProcessor(stage);
Table table = new Table();
table.setFillParent(true);
table.defaults().pad(5);
Label title = new Label("New Account", skin, "title");
title.setAlignment(Align.center);
Table leftGroup = new Table();
Table rightGroup = new Table();
BorderedGrid grid = new BorderedGrid(skin);
Table usernameTable = new Table(skin);
usernameTable.background("border_filled");
Label userNameFieldLabel = new Label(" Username: ", skin);
Image usernameInfo = new Image(skin, "info_icon");
usernameTable.add(usernameInfo).left();
usernameTable.add(userNameFieldLabel).expand().right();
Label emailFieldLabel = new Label("Email: ", skin, "filled");
Table passwordTable = new Table(skin);
passwordTable.background("border_filled");
Label passwordFieldLabel = new Label(" Create Password: ", skin);
Image passwordInfo = new Image(skin, "info_icon");
passwordTable.add(passwordInfo).left();
passwordTable.add(passwordFieldLabel).expand().right();
Label confirmFieldLabel = new Label(" Confirm Password: ", skin, "filled");
userNameField = new TextField("", skin);
emailField = new TextField("", skin);
passwordField = new TextField("", skin);
confirmField = new TextField("", skin);
TextButton createAccountButton = new TextButton("Create Account", skin);
TextTooltip usernameToolTip = new TextTooltip("Only alphanumeric characters (A-Z,0-9)", toolTipManager, skin);
usernameInfo.addListener(usernameToolTip);
TextTooltip passwordToolTip = new TextTooltip("Minimum 8 alphanumeric characters (A-Z,0-9)", toolTipManager, skin);
passwordInfo.addListener(passwordToolTip);
TextFieldFilter alphaNumeric = new TextFieldFilter() {
@Override
public boolean acceptChar(TextField tf, char c) {
return tf.getText().length() < 12 && (Character.isAlphabetic(c) || Character.isDigit(c));
}
};
userNameField.setTextFieldFilter(alphaNumeric);
passwordField.setTextFieldFilter(alphaNumeric);
userNameFieldLabel.setAlignment(Align.right);
emailFieldLabel.setAlignment(Align.right);
passwordFieldLabel.setAlignment(Align.right);
confirmFieldLabel.setAlignment(Align.right);
passwordField.setPasswordMode(true);
passwordField.setPasswordCharacter('*');
confirmField.setPasswordMode(true);
confirmField.setPasswordCharacter('*');
grid.pad(10);
grid.defaults().space(6);
leftGroup.defaults().space(5);
// leftGroup.debugAll();
leftGroup.add(usernameTable).growX().minHeight(25);
leftGroup.add(userNameField).minHeight(25).row();
leftGroup.add(emailFieldLabel).growX().minHeight(25);
leftGroup.add(emailField).minHeight(25).row();
leftGroup.add(passwordTable).growX().minHeight(25);
leftGroup.add(passwordField).minHeight(25).row();
leftGroup.add(confirmFieldLabel).growX().minHeight(25);
leftGroup.add(confirmField).minHeight(25).row();
leftGroup.add(createAccountButton).colspan(2).row();
createAccountButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Matcher matcher = VALID_EMAIL_ADDRESS_REGEX.matcher(emailField.getText().trim());
boolean validSignUp = true;
if (!matcher.find()) {
validSignUp = false;
emailField.setColor(Color.RED);
} else {
emailField.setColor(Color.WHITE);
}
if (userNameField.getText().trim().length() <= 0 || userNameField.getText().trim().length() > 12) {
validSignUp = false;
userNameField.setColor(Color.RED);
// stage.addActor(toolTip.getContainer());
// stage.addActor(toolTip.getContainer().getActor());
// toolTip.getContainer().setPosition(0, 0);
// toolTip.getContainer().setSize(toolTip.getActor().getWidth(), toolTip.getActor().getHeight());
} else {
userNameField.setColor(Color.WHITE);
}
String password = passwordField.getText().trim();
if (password.length() < 7) {
validSignUp = false;
passwordField.setColor(Color.RED);
} else {
passwordField.setColor(Color.WHITE);
}
if (!passwordField.getText().trim().equals(confirmField.getText().trim())) {
validSignUp = false;
confirmField.setColor(Color.RED);
} else {
confirmField.setColor(Color.WHITE);
}
if (validSignUp) {
game.getServerAPI().sendMessage(new Message(Type.NEW_PROFILE_REQUEST, userNameField.getText().trim() + "," + emailField.getText().trim() + "," + passwordField.getText().trim()));
}
}
});
Panel divider = new Panel(skin);
rightGroup.defaults().space(6);
TextButton signUpWithGoogle = new TextButton("Sign Up With Google", skin);
signUpWithGoogle.getLabel().setWrap(true);
TextButton signUpWithFacebook = new TextButton("Sign Up With Facebook", skin);
signUpWithFacebook.getLabel().setWrap(true);
TextButton signUpWithApple = new TextButton("Sign Up With Apple", skin);
signUpWithApple.getLabel().setWrap(true);
rightGroup.add(signUpWithGoogle).width(100).row();
rightGroup.add(signUpWithFacebook).width(100).row();
rightGroup.add(signUpWithApple).width(100);
grid.add(leftGroup).grow();
grid.add(divider).growY();
grid.add(rightGroup).grow();
Table navGrid = new Table();
TextButton backButton = new TextButton("Back", skin);
backButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.popScreen();
}
});
navGrid.add(backButton).expand().width(150).left();
table.add(title).grow().row();
table.add(grid).expand().grow().row();
table.add(navGrid).growX();
stage.addActor(table);
}
use of com.janfic.games.computercombat.actors.BorderedGrid in project computercombat by janfic.
the class MainMenuScreen method show.
@Override
public void show() {
this.camera = new OrthographicCamera(1920 / 4, 1080 / 4);
this.stage = ComputerCombatGame.makeNewStage(camera);
Gdx.input.setInputProcessor(stage);
Table table = new Table();
table.setFillParent(true);
table.defaults().space(10);
table.pad(10);
Image image = new Image(game.getAssetManager().get(Assets.TITLE, Texture.class));
Image backgroundImage = new Image(game.getAssetManager().get(Assets.MAIN_MENU_BACKGROUND, Texture.class));
BorderedGrid grid = new BorderedGrid(skin);
TextButton loginButton = new TextButton("Login", skin);
TextButton accountButton = new TextButton("New Account", skin);
TextButton exitButton = new TextButton("Exit", skin);
grid.add(loginButton).pad(10).growX().row();
grid.add(accountButton).pad(10).growX().row();
grid.add(exitButton).pad(10).growX();
loginButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.pushScreen(new LoginScreen(game));
}
});
accountButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.pushScreen(new SignUpScreen(game));
}
});
exitButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
}
});
table.add(image).width(220).height(70).row();
table.add(grid).width(150).height(150).expand();
backgroundImage.setSize(1920 / 4, 1080 / 4);
stage.addActor(backgroundImage);
stage.addActor(table);
}
use of com.janfic.games.computercombat.actors.BorderedGrid in project computercombat by janfic.
the class PlayScreen method show.
@Override
public void show() {
this.game.setCurrentProfile(SQLAPI.getSingleton().loadProfile(game.getCurrentProfile().getUID()));
this.camera = new OrthographicCamera(1920 / 4, 1080 / 4);
this.stage = ComputerCombatGame.makeNewStage(camera);
Gdx.input.setInputProcessor(stage);
Image image = new Image(background);
image.setSize(stage.getWidth(), stage.getHeight());
TextButton playButton = new TextButton("Play", skin);
TextButton upgradeButton = new TextButton("Upgrade", skin);
TextButton collectionButton = new TextButton("Collection", skin);
TextButton decksButton = new TextButton("Decks", skin);
TextButton settingsButton = new TextButton("Settings", skin);
TextButton downloadButton = new TextButton("Download", skin);
stage.addActor(image);
stage.addActor(playButton);
stage.addActor(upgradeButton);
stage.addActor(decksButton);
stage.addActor(collectionButton);
stage.addActor(settingsButton);
stage.addActor(downloadButton);
playButton.setPosition(190, 170);
playButton.setWidth(collectionButton.getWidth());
settingsButton.setPosition(290, 230);
settingsButton.setWidth(collectionButton.getWidth());
upgradeButton.setPosition(300, 90);
upgradeButton.setWidth(collectionButton.getWidth());
downloadButton.setPosition(20, 230);
downloadButton.setWidth(collectionButton.getWidth());
decksButton.setPosition(220, 20);
decksButton.setWidth(collectionButton.getWidth());
collectionButton.setPosition(20, 100);
Table table = new Table();
table.setFillParent(true);
BorderedGrid grid = new BorderedGrid(skin);
grid.pad(9);
grid.defaults().space(5).growX();
grid.top();
BorderedArea imageArea = new BorderedArea(skin);
TextButton profileButton = new TextButton("Profile", skin);
TextButton defenseButton = new TextButton("Defense", skin);
Image packetsImage = new Image(game.getAssetManager().get("texture_packs/components.atlas", TextureAtlas.class).findRegion("network"));
Table packetTable = new Table(skin);
packetTable.defaults().space(10);
packetTable.add(packetsImage).size(24, 24);
packetTable.add(new Label("" + game.getCurrentProfile().getPackets(), skin));
grid.add(imageArea).growX().height(80).row();
grid.add(profileButton).row();
grid.add(defenseButton).row();
grid.add(packetTable).expand().bottom().row();
table.add(grid).expand().growY().right().width(100);
stage.addActor(table);
playButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.pushScreen(new QueueScreen(game));
}
});
collectionButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.pushScreen(new CollectionScreen(game));
}
});
decksButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.pushScreen(new DecksScreen(game));
}
});
downloadButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.pushScreen(new DownloadScreen(game));
}
});
}
Aggregations