Search in sources :

Example 6 with BorderedGrid

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

the class QueueScreen method show.

@Override
public void show() {
    this.camera = new OrthographicCamera(1920 / 4, 1080 / 4);
    this.stage = ComputerCombatGame.makeNewStage(camera);
    isRanked = false;
    isLive = true;
    Gdx.input.setInputProcessor(stage);
    Table table = new Table();
    table.defaults().space(3);
    table.pad(3);
    table.setFillParent(true);
    Table titleTable = new Table(skin);
    titleTable.setBackground("border");
    Label title = new Label("Play", 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.getServerAPI().sendMessage(new Message(Type.CANCEL_QUEUE, game.getCurrentProfile().getUID()));
            game.popScreen();
        }
    });
    titleTable.add(backButton);
    titleTable.add(title).growX().row();
    table.add(titleTable).growX().row();
    BorderedGrid mainTable = new BorderedGrid(skin);
    decksTable = new Table(skin);
    decksTable.defaults().space(3);
    Label decksTitle = new Label("Decks", skin, "title");
    decksTitle.setAlignment(Align.center);
    decks = new Table();
    decks.defaults().space(5).height(60).width(70);
    populateDecks();
    ScrollPane decksScroll = new ScrollPane(decks, skin);
    decksScroll.setFadeScrollBars(false);
    TextButton updateButton = new TextButton("Edit Decks", skin);
    updateButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            game.getServerAPI().sendMessage(new Message(Type.CANCEL_QUEUE, game.getCurrentProfile().getUID()));
            while (game.getServerAPI().hasMessage() == false) {
            }
            game.getServerAPI().readMessage();
            queued = false;
            canceled = false;
            game.pushScreen(new DecksScreen(game));
        }
    });
    decksTable.add(decksTitle).growX().row();
    decksTable.add(decksScroll).grow().row();
    decksTable.add(updateButton).growX();
    mainTable.add(decksTable).left().width(120).growY().pad(5);
    Table playTable = new Table();
    playTable.defaults().space(3);
    playTable.pad(5);
    playTable.top();
    Table toggleRankedButton = new Table(skin);
    toggleRankedButton.setBackground("border");
    toggleRankedButton.defaults().space(3);
    toggleRankedButton.pad(10);
    TextButton rankedButton = new TextButton("Ranked", skin);
    TextButton casualButton = new TextButton("Casual", skin);
    rankedButton.setColor(Color.LIGHT_GRAY);
    casualButton.setColor(Color.WHITE);
    rankedButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            rankedButton.setColor(Color.WHITE);
            casualButton.setColor(Color.LIGHT_GRAY);
            isRanked = true;
        }
    });
    casualButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            rankedButton.setColor(Color.LIGHT_GRAY);
            casualButton.setColor(Color.WHITE);
            isRanked = false;
        }
    });
    toggleRankedButton.add(rankedButton, casualButton);
    Table modeToggleButton = new Table(skin);
    modeToggleButton.pad(10);
    modeToggleButton.defaults().space(3);
    modeToggleButton.setBackground("border");
    TextButton liveMatchButton = new TextButton("Live\n-----\nPlay against an opponent in real time", skin);
    TextButton raidMatchButton = new TextButton("Raid\n-----\nPlay against an offline player's defenses", skin);
    liveMatchButton.getLabel().setWrap(true);
    raidMatchButton.getLabel().setWrap(true);
    raidMatchButton.setColor(Color.LIGHT_GRAY);
    liveMatchButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            raidMatchButton.setColor(Color.LIGHT_GRAY);
            liveMatchButton.setColor(Color.WHITE);
            isLive = true;
        }
    });
    raidMatchButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            liveMatchButton.setColor(Color.LIGHT_GRAY);
            raidMatchButton.setColor(Color.WHITE);
            isLive = false;
        }
    });
    modeToggleButton.add(liveMatchButton).grow();
    modeToggleButton.add(raidMatchButton).grow();
    TextButton playButton = new TextButton("Play", skin);
    playButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (!queued && selectedDeck != null) {
                Json json = new Json();
                List<String> data = new ArrayList<>();
                data.add(json.toJson(game.getCurrentProfile()));
                data.add(json.toJson(selectedDeck.getDeck()));
                data.add(json.toJson(new boolean[] { isRanked, isLive }));
                Message requestQueue = new Message(Type.JOIN_QUEUE_REQUEST, json.toJson(data));
                game.getServerAPI().sendMessage(requestQueue);
            }
        }
    });
    queueStatusTable = new Table(skin);
    queueStatusTable.setBackground("border");
    cancelQueue = new TextButton("Cancel", skin);
    cancelQueue.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            game.getServerAPI().sendMessage(new Message(Type.CANCEL_QUEUE, game.getCurrentProfile().getUID()));
            canceled = true;
        }
    });
    queueStatus = new Label("Press Play to Queue", skin);
    queueStatus.setAlignment(Align.center);
    queueStatusTable.add(queueStatus).growX().row();
    // queueStatusTable.add(cancelQueue);
    playTable.add(toggleRankedButton).row();
    playTable.add(modeToggleButton).grow().row();
    playTable.add(playButton).growX().row();
    playTable.add(queueStatusTable).growX().row();
    mainTable.add(playTable).grow().row();
    table.add(mainTable).grow().row();
    stage.addActor(table);
}
Also used : TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Message(com.janfic.games.computercombat.network.Message) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) Json(com.badlogic.gdx.utils.Json) BorderedGrid(com.janfic.games.computercombat.actors.BorderedGrid) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) ArrayList(java.util.ArrayList) List(java.util.List) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)6 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)6 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)6 BorderedGrid (com.janfic.games.computercombat.actors.BorderedGrid)6 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)5 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)5 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)4 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)4 Message (com.janfic.games.computercombat.network.Message)3 TextFieldFilter (com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldFilter)2 BorderedArea (com.janfic.games.computercombat.actors.BorderedArea)2 Panel (com.janfic.games.computercombat.actors.Panel)2 Texture (com.badlogic.gdx.graphics.Texture)1 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)1 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)1 TextTooltip (com.badlogic.gdx.scenes.scene2d.ui.TextTooltip)1 Json (com.badlogic.gdx.utils.Json)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1