Search in sources :

Example 1 with DeckActor

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

the class QueueScreen method populateDecks.

public void populateDecks() {
    game.getCurrentProfile().getDecks().clear();
    game.getCurrentProfile().getDecks().addAll(SQLAPI.getSingleton().getPlayerDecks(game.getCurrentProfile().getUID()));
    decks.clearChildren();
    for (Deck deck : game.getCurrentProfile().getDecks()) {
        DeckActor d = new DeckActor(deck, skin);
        d.setColor(Color.LIGHT_GRAY);
        d.addListener(new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                if (selectedDeck != null) {
                    selectedDeck.unselect();
                }
                if (d.getDeck().getCardCount(-1) != 8) {
                    Window window = new Window("Invalid Deck", skin);
                    window.setSize(stage.getWidth() / 2f, stage.getHeight() / 2f);
                    window.setPosition(stage.getWidth() / 4f, stage.getHeight() / 4f);
                    Label info = new Label("This is an invalid deck and cannot be played with: Invalid amount of cards.", skin);
                    info.setWrap(true);
                    info.setAlignment(Align.center);
                    TextButton okay = new TextButton("Okay", skin);
                    okay.addListener(new ClickListener() {

                        @Override
                        public void clicked(InputEvent event, float x, float y) {
                            window.remove();
                        }
                    });
                    window.add(info).grow().row();
                    window.add(okay).growX().row();
                    stage.addActor(window);
                } else {
                    selectedDeck = d;
                    selectedDeck.select();
                }
            }
        });
        decks.add(d).row();
    }
}
Also used : Window(com.badlogic.gdx.scenes.scene2d.ui.Window) TextButton(com.badlogic.gdx.scenes.scene2d.ui.TextButton) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Deck(com.janfic.games.computercombat.model.Deck) DeckActor(com.janfic.games.computercombat.actors.DeckActor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)1 Window (com.badlogic.gdx.scenes.scene2d.ui.Window)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 DeckActor (com.janfic.games.computercombat.actors.DeckActor)1 Deck (com.janfic.games.computercombat.model.Deck)1