Example usage for com.badlogic.gdx.scenes.scene2d.ui Table align

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Table align

Introduction

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

Prototype

int align

To view the source code for com.badlogic.gdx.scenes.scene2d.ui Table align.

Click Source Link

Usage

From source file:com.bsencan.openchess.view.GameRenderer.java

License:Apache License

private void initUpperUI() {
    this.upperTextHud = new Table(Assets.skin);
    this.upperTextHud.add(this.scoreLabel);
    this.upperTextHud.setTransform(true);
    this.upperTextHud.setScale(0.5f / this.resetButton.getHeight());
    this.scoreLabel.setColor(Color.WHITE);
    this.scoreLabel.setAlignment(Align.left);
    this.upperTextHud.align(Align.left);
    this.upperTextHud.setPosition(0.7f, VIEWPORT_HEIGHT - 0.52f);
    this.stage.addActor(this.upperTextHud);

    Table highScoreTable = new Table(Assets.skin);
    highScoreTable.add(this.highScoreLabel);
    highScoreTable.setTransform(true);/*from w w  w  . j a  v  a  2  s.  c o  m*/
    highScoreTable.setScale(0.5f / this.resetButton.getHeight());
    highScoreLabel.setColor(Color.WHITE);
    highScoreLabel.setAlignment(Align.left);
    highScoreTable.align(Align.left);
    highScoreTable.setPosition(VIEWPORT_WIDTH / 2 + 0.7f, VIEWPORT_HEIGHT - 0.52f);
    stage.addActor(highScoreTable);
}

From source file:com.jmstudios.pointandhit.OptionsScreen.java

License:Open Source License

public OptionsScreen(final OneShotGame game) {
    this.game = game;
    this.scale = game.scale;
    Vector2 screenSize = new Vector2(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    // Font//from  w  w w.  ja v a 2s.  c o  m
    textFont = new BitmapFont(Gdx.files.internal("fonts/deja_vu_sans_medium.fnt"));
    textFont.setScale(scale);
    BitmapFont titleFont = new BitmapFont(Gdx.files.internal("fonts/deja_vu_sans_large.fnt"));
    titleFont.setScale(scale);

    // Checkbox style
    Texture checkBoxes = new Texture(Gdx.files.internal("buttons/radiobutton.png"));
    TextureRegionDrawable checkBoxUnchecked = new TextureRegionDrawable(
            new TextureRegion(checkBoxes, 0, 0, 64, 64));
    TextureRegionDrawable checkBoxChecked = new TextureRegionDrawable(
            new TextureRegion(checkBoxes, 64, 0, 64, 64));
    checkBoxStyle = new CheckBox.CheckBoxStyle(checkBoxUnchecked, checkBoxChecked, textFont, Color.WHITE);

    CheckBox verySensitive = newRadioButton("Very sensitive"), sensitive = newRadioButton("Sensitive"),
            normal = newRadioButton("Normal"), forgiving = newRadioButton("Forgiving"),
            veryForgiving = newRadioButton("Very forgiving"),
            invertControls = newRadioButton("Invert the controls");

    sensitivityGroup = new ButtonGroup<CheckBox>(verySensitive, sensitive, normal, forgiving, veryForgiving,
            invertControls);

    int startSetting = game.preferences.getInteger("sensitivity", 2);
    sensitivityGroup.uncheckAll();
    sensitivityGroup.getButtons().get(startSetting).setChecked(true);

    float padding = 20 * scale;

    // Title
    Table titleTable = new Table();
    titleTable.align(Align.topLeft);
    Pixmap backgroundPixmap = new Pixmap(1, 1, Format.RGBA8888);
    backgroundPixmap.setColor(new Color(0.9f, 0.35f, 0.1f, 1));
    backgroundPixmap.fill();
    titleTable.setBackground(new TextureRegionDrawable(new TextureRegion(new Texture(backgroundPixmap))));
    Label.LabelStyle titleLabelStyle = new Label.LabelStyle(titleFont, Color.WHITE);
    Label titleLabel = new Label("Control sensitivity", titleLabelStyle);
    titleLabel.setWrap(true);
    titleLabel.setWidth(screenSize.x - padding * 2);
    titleLabel.setAlignment(Align.center);
    titleTable.add(titleLabel).align(Align.topLeft).pad(2 * padding).width(screenSize.x - padding * 2);

    // Checkboxes
    optionsTable = new Table();
    optionsTable.align(Align.topLeft);
    optionsTable.defaults().align(Align.topLeft).pad(padding).padBottom(0).padLeft(2 * padding);
    optionsTable.row();
    optionsTable.add(verySensitive);
    optionsTable.row();
    optionsTable.add(sensitive);
    optionsTable.row();
    optionsTable.add(normal);
    optionsTable.row();
    optionsTable.add(forgiving);
    optionsTable.row();
    optionsTable.add(veryForgiving);
    optionsTable.row();
    optionsTable.add(invertControls);

    optionsTable.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            int newSensitivity = sensitivityGroup.getCheckedIndex();
            if (newSensitivity == -1)
                newSensitivity = 2;
            game.preferences.putInteger("sensitivity", newSensitivity);
            game.preferences.flush();
        }
    });

    mainTable = new Table();
    mainTable.setFillParent(true);
    mainTable.align(Align.top);
    mainTable.add(titleTable).pad(0).padBottom(padding * 4).fill(10, 1).align(Align.topLeft);
    mainTable.row();
    mainTable.add(optionsTable).align(Align.left);

    mainStage = new Stage();
    mainStage.addActor(mainTable);

    // Input
    inputMultiplexer = new InputMultiplexer();
    inputMultiplexer.addProcessor(mainStage);
    inputMultiplexer.addProcessor(this);
}

From source file:com.vlaaad.dice.game.tutorial.tasks.ArrowForceClickDiePane.java

License:Open Source License

@Override
protected Table getMessageTable() {
    Table result = new Table();
    result.align(Align.top);
    LocLabel label = new LocLabel(locKey);
    label.setWrap(true);//  w  w  w .  j  av  a 2s .  c o m
    label.setAlignment(Align.center);
    result.add(label).width(stage.getWidth() / 1.5f);
    return result;
}

From source file:com.vlaaad.dice.game.tutorial.tasks.ArrowForceClickInventory.java

License:Open Source License

@Override
protected Table getMessageTable() {
    Table table = new Table(Config.skin);
    table.align(Align.top);
    Label label = new LocLabel("tutorial-open-dice-window");
    label.setWrap(true);/*w w w . ja v a 2  s  . c  o  m*/
    label.setAlignment(Align.center);
    table.add(label);
    return table;
}

From source file:com.vlaaad.dice.game.tutorial.tasks.ArrowForceClickStoreIcon.java

License:Open Source License

@Override
protected Table getMessageTable() {
    Table result = new Table();
    result.align(Align.bottom);
    LocLabel label = new LocLabel(locKey);
    label.setWrap(true);/* w  w w .  j ava  2 s  .c  om*/
    label.setAlignment(Align.center);
    result.add(label).width(stage.getWidth() / 1.5f);
    return result;
}

From source file:com.vlaaad.dice.game.tutorial.tasks.ArrowMessageNet.java

License:Open Source License

@Override
protected Table getMessageTable() {

    LocLabel label = new LocLabel(locKey);
    label.setWrap(true);/* w w w  . j a v  a2  s.  com*/
    label.setAlignment(Align.center);

    Label tapToContinue = new LocLabel("tap-to-continue", ShowTutorialMessage.Message.TAP_TO_CONTINUE);
    tapToContinue.setWrap(true);
    tapToContinue.setAlignment(Align.center);

    Table result = new Table();
    result.align(Align.top);
    result.add(label).width(stage.getWidth() / 1.5f).row();
    result.add(new Image(Config.skin, "ui-creature-info-line")).width(120).padTop(4).row();
    result.add(tapToContinue);
    return result;
}

From source file:com.vlaaad.dice.ui.components.DieStore.java

License:Open Source License

public void refresh() {
    table.clearChildren();/*from  w  ww. j  a  va2s.c om*/
    iconsByAbilities.clear();
    Array<Ability> availableAbilities = new Array<Ability>();
    for (Ability ability : Config.abilities.byType(Ability.Type.wearable)) {
        if (ability.cost < 0 || !ability.requirement.canBeSatisfied(die))
            continue;
        availableAbilities.add(ability);
    }
    availableAbilities.sort(shopComparator);
    for (int i = 0; i < NUM_ROWS; i++) {
        Table row = new Table(Config.skin);
        row.setBackground("ui/dice-window/store-background");
        row.align(Align.top | Align.left);
        for (int j = 0; j < NUM_ITEMS; j++) {
            int idx = i * NUM_ITEMS + j;
            if (availableAbilities.size > idx) {
                Ability ability = availableAbilities.get(idx);
                StoreIcon icon = new StoreIcon(ability, die, userData, createCallback(ability));
                SoundHelper.init(icon);
                iconsByAbilities.put(ability, icon);
                row.add(icon).padLeft(2).padRight(2).padTop(-2).size(20, 20);
            }
        }
        table.add(row).fillX().height(22).row();
    }
}

From source file:com.vlaaad.dice.ui.windows.CreatureInfoWindow.java

License:Open Source License

@Override
protected void doShow(final Params params) {
    this.params = params;
    table.clearChildren();/*from w w  w .ja  va2 s  . c  o  m*/
    Table info = new Table(Config.skin);
    info.setBackground(Config.skin.getDrawable("ui-creature-info-background"));

    Ability current = params.creature.getCurrentAbility();
    LocLabel itemDescriptionLabel = new LocLabel("ui-creature-info-window-ability-description",
            Thesaurus.params().with("name", current.locNameKey()).with("desc", current.locDescKey()),
            DESCRIPTION);
    itemDescriptionLabel.setWrap(true);
    itemDescriptionLabel.setAlignment(Align.center);

    LocLabel effectDescriptionLabel = new LocLabel("ui-creature-info-window-no-effects",
            Thesaurus.params().with("name", params.creature.description.nameLocKey()), DESCRIPTION);
    effectDescriptionLabel.setWrap(true);
    effectDescriptionLabel.setAlignment(Align.center);

    Image itemSelection = new Image(Config.skin.getDrawable("ui-creature-info-ability-selection"));
    Table abilityIcons = new Table();
    abilityIcons.padTop(5);
    boolean selected = false;
    int i = 0;
    for (Ability ability : params.creature) {
        AbilityIcon image = new AbilityIcon(ability);
        Group imageGroup = new Group();
        imageGroup.setSize(image.getWidth(), image.getHeight());
        imageGroup.addActor(image);
        abilityIcons.add(imageGroup);
        ClickListener listener = createListener(imageGroup, itemSelection, itemDescriptionLabel, ability,
                params.creature);
        if (!selected && i == params.creature.getCurrentAbilityIndex()) {
            selected = true;
            listener.clicked(null, 0, 0);
        }
        image.addListener(listener);
        if (i == 3) {
            abilityIcons.row();
            abilityIcons.add();
        }
        i++;
    }

    Image effectSelection = new Image(Config.skin.getDrawable("ui-creature-info-ability-selection"));
    Table effectsIcons = new Table();
    effectsIcons.padTop(5);
    i = 0;
    boolean hasEffects = params.creature.effects.size > 0;
    for (CreatureEffect effect : params.creature.effects) {
        if (effect.isHidden())
            continue;
        Image effectIcon = new Image(Config.skin, effect.getUiIconName());
        Group imageGroup = new Group();
        imageGroup.setSize(24, 24);
        imageGroup.addActor(effectIcon);
        effectIcon.setPosition(imageGroup.getWidth() / 2 - effectIcon.getWidth() / 2,
                imageGroup.getHeight() / 2 - effectIcon.getHeight() / 2);
        effectsIcons.add(imageGroup);
        ClickListener listener = createListener(imageGroup, effectSelection, effectDescriptionLabel, effect,
                params.creature);
        if (i == 0) {
            listener.clicked(null, 0, 0);
        }
        effectIcon.addListener(listener);
        if (i == 3) {
            abilityIcons.row();
        }
        i++;
    }

    WorldObjectView view = ViewController.createView(params.world.viewer, params.world.playerColors,
            params.creature);
    view.removeSubView("name");
    view.removeSubView(CreatureEffect.class);

    Table headerLabels = new Table();
    headerLabels.align(Align.left);
    headerLabels.add(new LocLabel("ui-creature-info-name",
            Thesaurus.params().with("name", params.creature.description.nameLocKey()).with("profession",
                    params.creature.profession.locKey())))
            .expandX().fillX().row();
    if (params.creature.player == params.world.viewer) {
        headerLabels
                .add(new LocLabel("ui-creature-info-ally-info",
                        Thesaurus.params().with("level", String.valueOf(params.creature.getCurrentLevel()))))
                .padTop(-4).expandX().fillX().row();
    } else {
        headerLabels.add(new LocLabel("ui-creature-info-enemy-info")).expandX().fillX().padTop(-4).row();
    }

    Table header = new Table(Config.skin);
    header.align(Align.left);
    header.add(view).padTop(7).padRight(4).left();
    header.add(headerLabels).left().row();
    if (params.creature.player == params.world.viewer) {
        float progress = params.creature.description.profession
                .getLevelProgress(params.creature.getCurrentExp());
        header.add(new ExpBar(progress)).width(ViewController.CELL_SIZE * 4).padLeft(3).padTop(4).left()
                .colspan(2).row();
    }
    Array<Ability> professionAbilities = params.creature.profession.getAvailableAbilities();
    Table pa = new Table();
    pa.defaults().padTop(4);
    for (Ability a : professionAbilities) {
        ProfessionAbilityIcon icon = new ProfessionAbilityIcon(params.creature, a);
        pa.add(icon).row();
        icon.addListener(createProfessionAbilityListener(params.creature, a));
        if (!a.requirement.isSatisfied(params.creature.description)) {
            icon.getColor().a = 0.3f;
        }
    }

    Table headerTable = new Table();
    headerTable.add(header);
    headerTable.add(pa).expandX().right().padRight(3).padTop(2);

    info.add(headerTable).expandX().fillX().left().row();

    final TabPane tabPane = new TabPane(Config.skin);

    Table itemsHeader = new Table();
    itemsHeader.align(Align.left);
    itemsHeader.add(new Image(Config.skin, "ui-creature-info-window-icon-items")).padRight(2);
    itemsHeader.add(new LocLabel("ui-creature-info-items")).padTop(-4).expandX().fillX().align(Align.left);

    Table effectsHeader = new Table();
    effectsHeader.align(Align.left);
    effectsHeader.add(new Image(Config.skin, "ui-creature-info-window-icon-effects")).padRight(2);
    effectsHeader.add(new LocLabel("ui-creature-info-effects")).padTop(-4).expandX().fillX().align(Align.left);

    Table itemsTab = new Table();

    itemsTab.add(abilityIcons).padTop(5).row();
    itemsTab.add(new Image(Config.skin.getDrawable("ui-creature-info-line")))
            .width(ViewController.CELL_SIZE * 4 - 16).padTop(5).row();
    itemsTab.add(itemDescriptionLabel).width(ViewController.CELL_SIZE * 4 + 32).height(50).pad(5);

    Table effectsTab = new Table();
    if (hasEffects) {
        effectsTab.add(effectsIcons).minHeight(48).padTop(10).row();
        effectsTab.add(new Image(Config.skin.getDrawable("ui-creature-info-line")))
                .width(ViewController.CELL_SIZE * 4 - 16).padTop(5).row();
    }
    effectsTab.add(effectDescriptionLabel).width(ViewController.CELL_SIZE * 4 + 32).height(50).pad(5);

    tabPane.addTab(itemsHeader, itemsTab);
    tabPane.addTab(effectsHeader, effectsTab);

    info.add(tabPane).padTop(5).padBottom(-2).padLeft(-2).padRight(-2);
    info.setTouchable(Touchable.enabled);

    table.add(info);
}

From source file:de.r2soft.empires.client.screens.gameplay.HexMapScreen.java

License:Open Source License

private void selectionBox() {
    Table table = new Table(Assets.R2_UI_SKIN);
    table.setPosition(Values.HEX_MAP_BASE_OFFSET.x + Values.HEX_MAP_BASE_SIZE.x + Values.R2_UI_PIXEL_PAD_SMALL,
            Values.HEX_MAP_BASE_OFFSET.y);
    table.setSize(300f, 200f);//  w w w .  j  a  v a 2s. c  o  m
    table.setBackground("default-window");

    table.add(new Label("Owner: ", Assets.R2_UI_SKIN)).left().padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.add(systemOwner = new Label("Null", Assets.R2_UI_SKIN)).prefWidth(999)
            .padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.row();
    table.add(new Label("Size: ", Assets.R2_UI_SKIN)).expandX().left().padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.add(systemSize = new Label("Null", Assets.R2_UI_SKIN)).prefWidth(999)
            .padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.row();
    table.add(new Label("Coordinates: ", Assets.R2_UI_SKIN)).left().padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.add(systemPos = new Label("NaN - NaN", Assets.R2_UI_SKIN)).prefWidth(999)
            .padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.row();
    table.add(new Label("Units: ", Assets.R2_UI_SKIN)).left().padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.add(systemPopulation = new Label("NaN", Assets.R2_UI_SKIN)).prefWidth(999)
            .padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.row();
    table.add(new Label("Exploration: ", Assets.R2_UI_SKIN)).left().padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.add(systemExploration = new Label("NaN", Assets.R2_UI_SKIN)).prefWidth(999)
            .padLeft(Values.R2_UI_PIXEL_PAD_TINY);
    table.row();
    table.add(enterSystem).width(Values.SIZE_UI_FIELD_CONTENT).colspan(2);

    Label title = new Label("Currently selected Solarsystem", Assets.R2_UI_SKIN);
    title.setColor(Color.PINK);
    Table nested = new Table(Assets.R2_UI_SKIN);
    nested.align(Align.center);
    nested.setPosition(Values.HEX_MAP_BASE_OFFSET.x + Values.HEX_MAP_BASE_SIZE.x + Values.R2_UI_PIXEL_PAD_SMALL,
            Values.HEX_MAP_BASE_OFFSET.y + (table.getHeight() / 2) - (title.getHeight() / 2) + 3f);
    nested.setSize(300f, 200f);
    nested.add(title).top();

    stage.addActor(table);
    stage.addActor(nested);
}

From source file:es.eucm.ead.editor.control.actions.editor.ShowInfoPanel.java

License:Open Source License

private Actor createPage(String text, String image) {

    Table page = new Table(skin) {
        @Override//from   w  w  w. j a v a  2 s.c o m
        public float getPrefWidth() {
            return Gdx.graphics.getWidth();
        }
    };
    page.setWidth(Gdx.graphics.getWidth());
    page.align(Align.top);

    Label label = new Label(text, skin);
    label.setAlignment(Align.center);

    page.add(new Image(skin.getDrawable(image))).top();
    page.row();
    page.add(label).padTop(NORMAL_PAD);

    return page;
}