Example usage for com.badlogic.gdx.scenes.scene2d.ui Container getMaxWidth

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Container getMaxWidth

Introduction

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

Prototype

public float getMaxWidth() 

Source Link

Usage

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

License:Open Source License

@Override
protected void initialize() {
    Table content = new Table(Config.skin);
    content.setBackground("ui-creature-info-background");
    content.setTouchable(Touchable.enabled);
    content.defaults().pad(2);//  ww  w  .j av a  2 s  .com
    Array<Ability> potions = new Array<Ability>();
    for (Ability ability : Config.abilities.byType(Ability.Type.potion)) {
        potions.add(ability);
    }
    potions.sort(Ability.COST_COMPARATOR);

    potionsList = new Table();
    Image selection = new Image(Config.skin.getDrawable("selection/turn"));
    potionsList.addActor(selection);

    potionName = new LocLabel("");
    potionDescription = new LocLabel("");
    potionDescription.setAlignment(Align.center | Align.top);
    potionDescription.setWrap(true);

    ingredientsTable = new Table(Config.skin);
    ingredientsTable.defaults().pad(2);

    Table viewRow = new Table();
    potionsList.add(viewRow).row();
    viewRow.defaults().pad(2);
    int i = 0;
    ActorGestureListener l = null;
    for (Ability ability : potions) {
        AbilityIconCounter icon = new AbilityIconCounter(ability, 0);
        icon.image.setOrigin(icon.image.getWidth() / 2, icon.image.getHeight() / 2);
        potionIcons.put(ability, icon);
        ActorGestureListener listener = createPotionTapListener(icon, ability, selection, potionsList,
                potionName, potionDescription, ingredientsTable);
        if (l == null) {
            l = listener;
        }
        iconListeners.put(ability, listener);
        icon.addListener(listener);
        i++;
        viewRow.add(icon);
        if (i % 5 == 0) {
            viewRow = new Table();
            viewRow.defaults().pad(2);
            potionsList.add(viewRow).row();
        }
    }

    craftingPane = new CraftingPane(3, potions);

    Table craftTable = new Table(Config.skin);
    craftTable.setBackground("ui-craft-content");
    craftTable.defaults().pad(4);
    craftTable.add(craftingPane).row();
    craftTable.add(ingredientsContainer).row();

    content.add(potionsList).row();
    content.add(new Tile("ui-creature-info-line")).size(80, 1).row();
    content.add(potionName).row();
    content.add(ingredientsTable).padTop(5).padBottom(1).row();
    content.add(potionDescription).size(130, 48).row();
    content.add(craftTable).expandX().fillX().pad(-2).row();

    Container contentContainer = new Container(content);
    contentContainer.width(content.getPrefWidth());
    scrollPane = new ScrollPane(contentContainer);
    scrollPane.setOverscroll(false, false);
    scrollPane.setCancelTouchFocus(false);
    table.add(scrollPane).width(contentContainer.getMaxWidth());

    if (l != null) {
        table.invalidate();
        table.validate();
        l.tap(null, 0, 0, 0, 0);
    }
}