Example usage for com.badlogic.gdx.scenes.scene2d.ui TextButton setStyle

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui TextButton setStyle

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui TextButton setStyle.

Prototype

public void setStyle(ButtonStyle style) 

Source Link

Usage

From source file:de.bitbrain.craft.ui.UIFactory.java

License:Open Source License

public static TextButton createAbortButton(String text) {
    TextButton button = createPrimaryButton(text);
    button.setStyle(Styles.BTN_RED);
    return button;
}

From source file:de.fgerbig.spacepeng.screens.CreditsScreen.java

License:Open Source License

@Override
public void show() {
    super.show();

    // retrieve the default table actor
    Table table = super.getTable();
    table.setSkin(game.getSkin());//from   www .  j  ava 2 s  .  c om

    Label label = new Label("Credits", game.getSkin());
    label.setStyle(labelStyle_Heading);
    table.add(label).spaceBottom(25);
    table.row();

    Label creditsText = new Label(CREDITS, game.getSkin());
    Label.LabelStyle labelStyle = creditsText.getStyle();
    labelStyle.font = game.getFont();
    creditsText.setStyle(labelStyle);
    creditsText.setAlignment(Align.center);
    ScrollPane scrollPane = new ScrollPane(creditsText);
    table.add(scrollPane).size(CREDITS_WIDTH, CREDITS_HEIGHT).spaceBottom(25);
    table.row();

    // register the back button
    TextButton backButton = new TextButton("Back", game.getSkin());
    backButton.setStyle(textButtonStyle_Default);
    backButton.addListener(new DefaultInputListener() {
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);
            SpacePeng.soundManager.play(SoundKey.CLICK);
            game.setScreen(new MenuScreen(game));
        }
    });
    table.row();
    table.add(backButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).colspan(3);
}

From source file:es.eucm.ead.editor.view.builders.scene.components.TagsEditor.java

License:Open Source License

@Override
protected void buildContent() {
    countTags = 0;// w  w  w. j av  a2  s.c om

    tagsLayout = new LinearLayout(false);
    tagsList = Q.getComponent(controller.getModel().getGame(), TagsList.class);

    selectTag = new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            TextButton current = ((TextButton) event.getListenerActor());
            TextButton.TextButtonStyle style = current.getStyle();
            TextButton.TextButtonStyle context = skin.get(SkinConstants.STYLE_TEMPLATE,
                    TextButton.TextButtonStyle.class);
            if (style == context) {
                selectTag(current);
            } else {
                current.setStyle(context);
                controller.action(RemoveFromArray.class, tagComponent, tagComponent.getTags(),
                        current.getText().toString());
                countTags--;
            }
        }
    };

    createTag = new TextButton(i18N.m("add_tag"), skin);
    createTag.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            controller.action(CreateTag.class, TagsEditor.this);
        }
    });
    list.add(createTag);
    list.add(tagsLayout);
}

From source file:es.eucm.ead.editor.view.builders.scene.components.TagsEditor.java

License:Open Source License

@Override
protected void read(ModelEntity entity, Tags component) {
    tagsLayout.clearChildren();/*from w  w w.jav a 2 s .  c  om*/

    countTags = 0;
    tagComponent = component;

    tagsList.getTags().sort();
    for (String tag : tagsList.getTags()) {
        TextButton tagButton = new TextButton(tag, skin);
        tagButton.addListener(selectTag);
        tagsLayout.add(tagButton).marginTop(PAD);
        if (tagComponent.getTags().contains(tag, false)) {
            tagButton.setStyle(skin.get(SkinConstants.STYLE_ORANGE, TextButton.TextButtonStyle.class));
            countTags++;
        } else {
            tagButton.setStyle(skin.get(SkinConstants.STYLE_TEMPLATE, TextButton.TextButtonStyle.class));
        }
    }

}

From source file:es.eucm.ead.editor.view.builders.scene.components.TagsEditor.java

License:Open Source License

private void selectTag(TextButton tagButton) {
    tagButton.setStyle(skin.get(SkinConstants.STYLE_ORANGE, TextButton.TextButtonStyle.class));
    controller.action(AddToArray.class, tagComponent, tagComponent.getTags(), tagButton.getText().toString());
    countTags++;/* www . j  a v a 2 s . co  m*/
}

From source file:org.deathsbreedgames.gnp2.renderers.ClassicModeRenderer.java

public ClassicModeRenderer(ClassicModeScreen screen) {
    this.screen = screen;

    // Setup buttons:
    buttonStage = new Stage();
    TextureAtlas buttonAtlas = new TextureAtlas("gfx/buttons.pack");
    Skin buttonSkin = new Skin(buttonAtlas);

    Gdx.input.setInputProcessor(buttonStage);

    BitmapFont buttonFont = new BitmapFont();
    buttonFont.scale(0.1f);/*from  w  w w.j  av  a2s  . c  o  m*/

    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = buttonSkin.getDrawable("button_green");
    buttonStyle.checked = buttonSkin.getDrawable("button_red");
    buttonStyle.font = buttonFont;

    // Inverse is needed for if game starts and sound/music is off
    TextButtonStyle buttonStyleInverse = new TextButtonStyle();
    buttonStyleInverse.up = buttonSkin.getDrawable("button_red");
    buttonStyleInverse.checked = buttonSkin.getDrawable("button_green");
    buttonStyleInverse.font = buttonFont;

    TextButton soundButton = new TextButton("S", buttonStyle);
    if (!GlobalVars.soundOn) {
        soundButton.setStyle(buttonStyleInverse);
    }
    soundButton.pad(0, 10, 0, 10);
    soundButton.setPosition(Gdx.graphics.getWidth() - soundButton.getWidth(),
            Gdx.graphics.getHeight() - soundButton.getHeight());
    buttonStage.addActor(soundButton);
    soundButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            // Turn sound on/off accordingly
            if (getSoundOn()) {
                setSoundOff();
            } else {
                setSoundOn();
            }
        }
    });

    TextButton musicButton = new TextButton("M", buttonStyle);
    if (!GlobalVars.musicOn) {
        musicButton.setStyle(buttonStyleInverse);
    }
    musicButton.setPosition(soundButton.getX() - musicButton.getWidth(),
            Gdx.graphics.getHeight() - musicButton.getHeight());
    buttonStage.addActor(musicButton);
    musicButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            // Turn music on/off accordingly
            if (getMusicOn()) {
                setMusicOff();
            } else {
                setMusicOn();
            }
        }
    });

    // Setup drawing fonts
    scoreFont = new BitmapFont();
    pausedFont = new BitmapFont();
    pausedFont.scale(1.5f);

    // Setup graphics
    batch = new SpriteBatch();
    bg = new Texture(Gdx.files.internal("gfx/bg.jpg"));
    TextureAtlas spriteAtlas = new TextureAtlas("gfx/sprites.pack");
    pBlue = spriteAtlas.createSprite("Paddle_blue");
    pRed = spriteAtlas.createSprite("Paddle_red");
    ball = spriteAtlas.createSprite("Ball_orange");
}

From source file:org.deathsbreedgames.gnp2.renderers.GroupModeRenderer.java

public GroupModeRenderer(GroupModeScreen screen) {
    this.screen = screen;

    // Setup buttons
    buttonStage = new Stage();
    TextureAtlas buttonAtlas = new TextureAtlas("gfx/buttons.pack");
    Skin buttonSkin = new Skin(buttonAtlas);

    Gdx.input.setInputProcessor(buttonStage);

    BitmapFont buttonFont = new BitmapFont();
    buttonFont.scale(0.1f);//from  w  ww .  ja  va2s. co m

    TextButtonStyle buttonStyle = new TextButtonStyle();
    buttonStyle.up = buttonSkin.getDrawable("button_green");
    buttonStyle.checked = buttonSkin.getDrawable("button_red");
    buttonStyle.font = buttonFont;

    // Inverse is needed for if game starts and sound/music is off
    TextButtonStyle buttonStyleInverse = new TextButtonStyle();
    buttonStyleInverse.up = buttonSkin.getDrawable("button_red");
    buttonStyleInverse.checked = buttonSkin.getDrawable("button_green");
    buttonStyleInverse.font = buttonFont;

    TextButton soundButton = new TextButton("S", buttonStyle);
    if (!GlobalVars.soundOn) {
        soundButton.setStyle(buttonStyleInverse);
    }
    soundButton.pad(0, 10, 0, 10);
    soundButton.setPosition(Gdx.graphics.getWidth() - soundButton.getWidth(),
            Gdx.graphics.getHeight() - soundButton.getHeight());
    buttonStage.addActor(soundButton);
    soundButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            // Turn sound on/off accordingly
            if (getSoundOn()) {
                setSoundOff();
            } else {
                setSoundOn();
            }
        }
    });

    TextButton musicButton = new TextButton("M", buttonStyle);
    if (!GlobalVars.musicOn) {
        musicButton.setStyle(buttonStyleInverse);
    }
    musicButton.setPosition(soundButton.getX() - musicButton.getWidth(),
            Gdx.graphics.getHeight() - musicButton.getHeight());
    buttonStage.addActor(musicButton);
    musicButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            // Turn music on/off accordingly
            if (getMusicOn()) {
                setMusicOff();
            } else {
                setMusicOn();
            }
        }
    });

    // Setup drawing fonts
    scoreFont = new BitmapFont();
    pausedFont = new BitmapFont();
    pausedFont.scale(1.5f);

    // Setup graphics
    batch = new SpriteBatch();
    bg = new Texture(Gdx.files.internal("gfx/bg.jpg"));
    TextureAtlas spriteAtlas = new TextureAtlas("gfx/sprites.pack");
    pBlue = spriteAtlas.createSprite("Paddle_blue");
    pRed = spriteAtlas.createSprite("Paddle_red");
    pGreen = spriteAtlas.createSprite("Paddle_green");
    pPurple = spriteAtlas.createSprite("Paddle_purple");
    ball = spriteAtlas.createSprite("Ball_orange");
}

From source file:se.theodor.quiz.TeamsEditingPanel.java

License:Apache License

private static Table getTable() {
    Table table = new Table();
    table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    Label teamNameLabel = new Label(team.getTeamName(), LABEL_STYLE);
    Label pointsLabel = new Label("Pong", LABEL_STYLE);

    TextButton back = new TextButton("Tillbaka", GREEN_TEXT_BUTTON_STYLE);
    final TextButton setTurn = new TextButton(team.getTeamName() + " ska svara p nstan frga",
            GREEN_TEXT_BUTTON_STYLE);/*from w w  w  . j a  v  a  2s . c  o m*/

    pointsField = new TextField("" + team.getPoints(), GREEN_TEXT_FIELD_STYLE);

    table.add(teamNameLabel).colspan(2).center();
    table.row();
    table.add(pointsLabel).center();
    table.add(pointsField);
    table.row();
    table.add(setTurn);
    table.add(back);

    back.addListener(new ClickListener() {
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (button == Buttons.LEFT) {
                if (pointsField.getText().equals("")) {
                    points = 0;
                } else {
                    points = Integer.parseInt(pointsField.getText());
                }
                close();
            }
        }
    });

    setTurn.addListener(new ClickListener() {
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            if (button == Buttons.LEFT) {
                if (!setTurnBoo) {
                    setTurn.setStyle(RED_TEXT_BUTTON_STYLE);
                    setTurnBoo = true;
                } else {
                    setTurn.setStyle(GREEN_TEXT_BUTTON_STYLE);
                    setTurnBoo = false;
                }
            }
        }
    });

    pointsField.setTextFieldListener(new TextFieldListener() {

        @Override
        public void keyTyped(TextField textField, char c) {
            removeLetters(pointsField);
        }

    });

    return table;
}