Search in sources :

Example 1 with Panel

use of com.janfic.games.computercombat.actors.Panel 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);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) BorderedArea(com.janfic.games.computercombat.actors.BorderedArea) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) BorderedGrid(com.janfic.games.computercombat.actors.BorderedGrid) Panel(com.janfic.games.computercombat.actors.Panel) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 2 with Panel

use of com.janfic.games.computercombat.actors.Panel 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);
}
Also used : Message(com.janfic.games.computercombat.network.Message) Matcher(java.util.regex.Matcher) TextFieldFilter(com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldFilter) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) BorderedGrid(com.janfic.games.computercombat.actors.BorderedGrid) Panel(com.janfic.games.computercombat.actors.Panel) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 3 with Panel

use of com.janfic.games.computercombat.actors.Panel in project computercombat by janfic.

the class DownloadScreen method show.

@Override
public void show() {
    this.cam = new OrthographicCamera(1920 / 4, 1080 / 4);
    this.stage = ComputerCombatGame.makeNewStage(cam);
    this.collections = SQLAPI.getSingleton().getCollections();
    packs.clear();
    for (Collection collection : collections) {
        packs.add(new CollectionPackActor(game, skin, collection));
    }
    Gdx.input.setInputProcessor(stage);
    Table table = new Table();
    table.setFillParent(true);
    table.defaults().space(5);
    table.pad(4);
    packsTable = new Table(skin);
    packsTable.defaults().space(5);
    ScrollPane scrollPane = new ScrollPane(packsTable, skin);
    makePacks();
    Panel packInfoTable = new Panel(skin);
    packInfoTable.defaults().space(3).pad(2);
    packInfoTable.top();
    Label packInfoLabel = new Label("About", skin, "title");
    packInfoLabel.setAlignment(Align.center);
    packInfoTable.add(packInfoLabel).growX().row();
    packName = new Label("Press a Pack to learn more.", skin);
    packDescription = new Label("Press a Pack to learn more.", skin);
    Label packPriceLabel = new Label("Packets to Download:", skin);
    packPrice = new Label("???", skin);
    packName.setWrap(true);
    packPrice.setWrap(true);
    packDescription.setWrap(true);
    packPriceLabel.setWrap(true);
    packName.setAlignment(Align.center);
    packPrice.setAlignment(Align.center);
    packDescription.setAlignment(Align.center);
    packPriceLabel.setAlignment(Align.center);
    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(packPrice);
    packInfoTable.add(packName).growX().row();
    packInfoTable.add(packDescription).grow().row();
    packInfoTable.add(packPriceLabel).growX().expandY().bottom().row();
    packInfoTable.add(packetTable).growX().row();
    TextButton viewCollectionButton = new TextButton("View Collection", skin);
    final TextButton downloadButton = new TextButton("Download", skin);
    packInfoTable.add(viewCollectionButton).growX().row();
    packInfoTable.add(downloadButton).growX();
    Table titleTable = new Table(skin);
    titleTable.setBackground("border");
    Label title = new Label("Card Packs", 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();
        }
    });
    Image playerPacketImage = new Image(game.getAssetManager().get("texture_packs/components.atlas", TextureAtlas.class).findRegion("network"));
    Table playerPacketTable = new Table(skin);
    playerPacketTable.defaults().padRight(10);
    playerPacketTable.add(new Label("Your Packets: ", skin));
    playerPacketTable.add(playerPacketImage).size(24, 24);
    playerPacketTable.add(new Label("" + game.getCurrentProfile().getPackets(), skin));
    titleTable.add(backButton);
    titleTable.add(title).growX();
    titleTable.add(playerPacketTable).row();
    table.add(scrollPane).grow();
    table.add(packInfoTable).minWidth(200).growY().row();
    table.add(titleTable).growX().colspan(2).row();
    stage.addActor(table);
    downloadButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (game.getCurrentProfile().getPackets() >= collections.get(selected).getPrice()) {
                downloadButton.addAction(Actions.sequence(Actions.touchable(Touchable.disabled), Actions.color(Color.GREEN), Actions.color(Color.WHITE, 1), Actions.run(() -> {
                    game.getCurrentProfile().setPackets(game.getCurrentProfile().getPackets() - collections.get(selected).getPrice());
                    game.pushScreen(new OpenPackScreen(game, collections.get(selected)));
                }), Actions.touchable(Touchable.enabled)));
            } else {
                downloadButton.addAction(Actions.sequence(Actions.touchable(Touchable.disabled), Actions.color(Color.RED), Actions.color(Color.WHITE, 1), Actions.touchable(Touchable.enabled)));
            }
        }
    });
    viewCollectionButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (selected > 0) {
                game.pushScreen(new CollectionScreen(game, collections.get(selected)));
            }
        }
    });
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) Panel(com.janfic.games.computercombat.actors.Panel) CollectionPackActor(com.janfic.games.computercombat.actors.CollectionPackActor) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Collection(com.janfic.games.computercombat.model.Collection) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)3 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)3 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)3 Panel (com.janfic.games.computercombat.actors.Panel)3 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)2 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)2 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)2 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)2 BorderedGrid (com.janfic.games.computercombat.actors.BorderedGrid)2 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)1 TextFieldFilter (com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldFilter)1 BorderedArea (com.janfic.games.computercombat.actors.BorderedArea)1 CollectionPackActor (com.janfic.games.computercombat.actors.CollectionPackActor)1 Collection (com.janfic.games.computercombat.model.Collection)1 Message (com.janfic.games.computercombat.network.Message)1 Matcher (java.util.regex.Matcher)1