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

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

Introduction

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

Prototype

public void setStyle(LabelStyle style) 

Source Link

Usage

From source file:ateamproject.kezuino.com.github.render.screens.CreditsScreen.java

private void placeLabels() {
    float lastHorizontalPositionTitel = 0;
    for (Label label : titelLabels) {
        label.setPosition(lastHorizontalPositionTitel, stage.getHeight() - this.titelSpacingVertical);
        label.setFontScale(3);/* w  w  w  .j ava  2  s  . co  m*/
        label.setStyle(titelFont);
        stage.addActor(label);

        lastHorizontalPositionTitel += this.titelSpacingHorizontal;
    }

    int lineNumber = 1;
    float lastHorizontalPositionContent = 0;
    for (Label label : contentLabels) {
        label.setPosition(lastHorizontalPositionContent,
                stage.getHeight() - 60 - (this.contentSpacingVertical * lineNumber));
        label.setStyle(contentFont);
        label.setColor(Color.BLACK);

        if (!label.getText().toString().equals(",")) {
            stage.addActor(label);
            lastHorizontalPositionContent += this.contentSpacingHorizontal;
        } else {
            lineNumber++;
            lastHorizontalPositionContent = 0;
        }
    }
}

From source file:com.badlogic.gdx.ai.tests.btree.BehaviorTreeTestBase.java

License:Apache License

protected void addSeparator(Table table) {
    Label lbl = new Label("", container.skin);
    lbl.setColor(0.75f, 0.75f, 0.75f, 1);
    lbl.setStyle(new LabelStyle(lbl.getStyle()));
    lbl.getStyle().background = container.skin.newDrawable("white");
    table.add(lbl).colspan(2).height(1).width(220).pad(5, 1, 5, 1);
}

From source file:com.gdx.extension.ui.ChoiceDialog.java

License:Apache License

/**
 * Create a {@link ChoiceDialog} with specified style
 * /*from   w  w w .j  a  v  a  2s  .c  om*/
 * @param title the title of the dialog
 * @param message the message of the dialog
 * @param refuse the refuse button label
 * @param accept the accept button label
 * @param skin the skin to use
 * @param styleName the name of the style to use
 */
public ChoiceDialog(String title, String message, String refuse, String accept, Skin skin, String styleName) {
    super(title, skin.get(styleName, WindowStyle.class));

    this.setTitleAlignment(Align.center);
    padTop(Value.percentHeight(0.2f));

    this.style = skin.get(styleName, ChoiceDialogStyle.class);

    refuseButton = new TextButton(refuse, skin);
    refuseButton.setStyle(style.refuseButtonStyle);
    refuseButton.align(Align.center);
    setObject(refuseButton, new ChoiceDialogObject(false));

    acceptButton = new TextButton(accept, skin);
    acceptButton.setStyle(style.acceptButtonStyle);
    acceptButton.align(Align.center);
    setObject(acceptButton, new ChoiceDialogObject(true));

    Label _message = new Label(message, skin);
    _message.setStyle(style.messageStyle);

    getContentTable().add(_message).minWidth(300f).pad(10f);
    getButtonTable().defaults().minWidth(100f).pad(10f);
    getButtonTable().add(refuseButton);
    getButtonTable().add(acceptButton);
    setMovable(false);
    center();
}

From source file:com.lyeeedar.Roguelike3D.Game.GameData.java

License:Open Source License

public static Label getRarityLabel(int i, Skin skin) {
    Rarity r = getRarity(i);/*from w w w.j a  va  2  s  .  c  o m*/

    Label l = new Label("" + r, skin);

    LabelStyle ls = l.getStyle();
    LabelStyle nls = new LabelStyle();
    nls.fontColor = r.getColour();
    nls.background = ls.background;
    nls.font = ls.font;

    l.setStyle(nls);

    return l;
}

From source file:com.lyeeedar.Roguelike3D.Game.Item.Equippable.java

License:Open Source License

public Table getComparison(float a, float b, Skin skin, boolean reverse) {
    Table table = new Table();

    table.add(new Label("" + a + ">", skin));

    Label l = new Label("" + b, skin);

    LabelStyle ls = l.getStyle();//w  ww.j  av a  2s.  c om
    LabelStyle nls = new LabelStyle();
    nls.fontColor = (a == b) ? new Color(1.0f, 1.0f, 1.0f, 1.0f)
            : (reverse) ? (a > b) ? new Color(0.3f, 0.8f, 0.3f, 1.0f) : new Color(0.8f, 0.3f, 0.3f, 1.0f)
                    : (a < b) ? new Color(0.3f, 0.8f, 0.3f, 1.0f) : new Color(0.8f, 0.3f, 0.3f, 1.0f);
    nls.background = ls.background;
    nls.font = ls.font;

    l.setStyle(nls);

    table.add(l);

    return table;
}

From source file:com.lyeeedar.Roguelike3D.Game.Item.Equippable.java

License:Open Source License

public Table getComparison(int a, int b, Skin skin, boolean reverse) {
    Table table = new Table();

    table.add(new Label("" + a + ">", skin));

    Label l = new Label("" + b, skin);

    LabelStyle ls = l.getStyle();//from  ww  w.j  a  va  2  s  . com
    LabelStyle nls = new LabelStyle();
    nls.fontColor = (a == b) ? new Color(1.0f, 1.0f, 1.0f, 1.0f)
            : (reverse) ? (a > b) ? new Color(0.3f, 0.8f, 0.3f, 1.0f) : new Color(0.8f, 0.3f, 0.3f, 1.0f)
                    : (a < b) ? new Color(0.3f, 0.8f, 0.3f, 1.0f) : new Color(0.8f, 0.3f, 0.3f, 1.0f);
    nls.background = ls.background;
    nls.font = ls.font;

    l.setStyle(nls);

    table.add(l);

    return table;
}

From source file:com.packtpub.libgdx.canyonbunny.screens.MenuScreen.java

License:Apache License

private Table buildOptWinButtons() {
    Table tbl = new Table();
    // + Separator
    Label lbl = null;
    lbl = new Label("", skinLibgdx);
    lbl.setColor(0.75f, 0.75f, 0.75f, 1);
    lbl.setStyle(new LabelStyle(lbl.getStyle()));
    lbl.getStyle().background = skinLibgdx.newDrawable("white");
    tbl.add(lbl).colspan(2).height(1).width(220).pad(0, 0, 0, 1);
    tbl.row();//w  ww .  j  a  va2 s .co  m
    lbl = new Label("", skinLibgdx);
    lbl.setColor(0.5f, 0.5f, 0.5f, 1);
    lbl.setStyle(new LabelStyle(lbl.getStyle()));
    lbl.getStyle().background = skinLibgdx.newDrawable("white");
    tbl.add(lbl).colspan(2).height(1).width(220).pad(0, 1, 5, 0);
    tbl.row();
    // + Save Button with event handler
    btnWinOptSave = new TextButton("Save", skinLibgdx);
    tbl.add(btnWinOptSave).padRight(30);
    btnWinOptSave.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            onSaveClicked();
        }
    });
    // + Cancel Button with event handler
    btnWinOptCancel = new TextButton("Cancel", skinLibgdx);
    tbl.add(btnWinOptCancel);
    btnWinOptCancel.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            onCancelClicked();
        }
    });
    return tbl;
}

From source file:com.ray3k.skincomposer.MenuList.java

License:Open Source License

public void setDisabled(int index, boolean disabled) {
    buttons.get(index).setDisabled(disabled);

    if (disabled) {
        if (style.disabledLabelStyle != null && buttons.get(index).getChildren().size > 1) {
            Label label = (Label) buttons.get(index).getChildren().get(1);
            label.setStyle(style.disabledLabelStyle);
        }//from   ww  w .j a  v  a2s. c  o  m
    } else {
        if (style.labelStyle != null && buttons.get(index).getChildren().size > 1) {
            Label label = (Label) buttons.get(index).getChildren().get(1);
            label.setStyle(style.labelStyle);
        }
    }
}

From source file:com.turbogerm.helljump.screens.CreditsScreen.java

License:Open Source License

private float addTitleLabel() {
    LabelStyle labelStyle = new LabelStyle(mGuiSkin.get(LabelStyle.class));
    labelStyle.font = mGuiSkin.getFont("xxxl-font");

    String text = "Credits";
    TextBounds textBounds = labelStyle.font.getBounds(text);

    final float padding = 10.0f;
    final float labelHeight = textBounds.height + 2.0f * padding;

    Label label = new Label(text, mGuiSkin);
    label.setBounds(0.0f, HellJump.VIEWPORT_HEIGHT - labelHeight, HellJump.VIEWPORT_WIDTH, labelHeight);
    label.setStyle(labelStyle);
    label.setAlignment(Align.center);/*www. j  a  va  2  s.  c o  m*/
    mGuiStage.addActor(label);

    return labelHeight;
}

From source file:com.turbogerm.helljump.screens.CreditsScreen.java

License:Open Source License

private void addTextLabel(float offsetFromTop) {
    LabelStyle labelStyle = new LabelStyle(mGuiSkin.get(LabelStyle.class));
    labelStyle.font = mGuiSkin.getFont("medium-font");

    FileHandle creditsFileHandle = Gdx.files.internal(ResourceNames.CREDITS);
    String creditsText = creditsFileHandle.readString();

    TextBounds textBounds = labelStyle.font.getMultiLineBounds(creditsText);
    final float padding = 5.0f;
    final float labelHeight = textBounds.height + padding;

    Label textLabel = new Label(creditsText, mGuiSkin);
    textLabel.setBounds(padding, HellJump.VIEWPORT_HEIGHT - offsetFromTop - labelHeight,
            HellJump.VIEWPORT_WIDTH, labelHeight);
    textLabel.setStyle(labelStyle);
    textLabel.setAlignment(Align.left);//  w w  w  .  j  a  v  a 2s  .  c om
    mGuiStage.addActor(textLabel);
}