List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Table clearChildren
public void clearChildren()
From source file:com.agateau.pixelwheels.screens.SelectTrackScreen.java
License:Open Source License
private void updateRecordLabel(Table table, ArrayList<TrackResult> results) { table.clearChildren(); mTableRowCreator.setTable(table);//from w w w.j a v a2s . c o m for (int idx = 0, n = results.size(); idx < n; ++idx) { TrackResult result = results.get(idx); mTableRowCreator.addRow(String.format(Locale.US, "%d", idx + 1), result.vehicle, StringUtils.formatRaceTime(result.value)); } table.setHeight(table.getPrefHeight()); }
From source file:com.vlaaad.dice.ui.windows.LevelUpWindow.java
License:Open Source License
@Override protected void doShow(final GiveExpResult result) { this.result = result; Image back = new Image(Config.skin, "ui-levelup-window-background"); back.setTouchable(Touchable.disabled); back.setPosition(getStage().getWidth() / 2 - back.getWidth() / 2, getStage().getHeight() / 2 - back.getHeight() / 2); table.addActor(back);/* ww w.j a va 2 s. c o m*/ back.setOrigin(back.getWidth() / 2f, back.getHeight() / 2f); rotateContinuously(back); // gather new abilities Array<Ability> newStoreAbilities = new Array<Ability>(); Die creatureDie = result.creature.description; Die currentState = new Die(creatureDie.profession, creatureDie.name, result.creature.getCurrentExp(), creatureDie.abilities, creatureDie.inventory); Die nextState = new Die(creatureDie.profession, creatureDie.name, result.creature.getCurrentExp() + result.exp, creatureDie.abilities, creatureDie.inventory); Array<Ability> prevAbilities = currentState.getProfessionAbilities(); final Array<Ability> newProfessionAbilities = nextState.getProfessionAbilities(); newProfessionAbilities.removeAll(prevAbilities, true); for (Ability ability : Config.abilities.byType(Ability.Type.wearable)) { if (ability.cost >= 0 && ability.requirement.isSatisfied(nextState) && !ability.requirement.isSatisfied(currentState)) { newStoreAbilities.add(ability); } } // buttons LocTextButton continueButton = new LocTextButton("ui-level-up-continue"); ImageButton share = new ImageButton(Config.skin, "share"); SoundHelper.initButton(share); share.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Config.mobileApi.share(Config.thesaurus.localize("ui-level-up-share", Thesaurus.params().with("die", result.creature.description.nameLocKey()).with("level", String.valueOf(result.creature.description.profession .getLevel(result.exp + result.creature.getCurrentExp()))))); } }); Table buttons = new Table(); buttons.defaults().pad(2); buttons.add(continueButton).width(67); buttons.add(share).size(19); final Table newItemsTable = new Table(Config.skin); final Table content = new Table(Config.skin); content.defaults().pad(3); content.setTouchable(Touchable.enabled); content.setBackground("ui-inventory-ability-window-background"); content.add( new LocLabel( "ui-level-up-title", Thesaurus.params() .with("die", result.creature.description.nameLocKey()) .with("level", String.valueOf(result.creature.description.profession .getLevel(result.exp + result.creature.getCurrentExp()))))) .row(); content.add(new Image(Config.skin, "ui-creature-info-line")).width(66).row(); content.add(newItemsTable).row(); final Ref<Boolean> shownStore = new Ref<Boolean>(false); if (newStoreAbilities.size > 0) { addAbilities(newItemsTable, newStoreAbilities, false); shownStore.set(true); } else if (newProfessionAbilities.size > 0) { addAbilities(newItemsTable, newProfessionAbilities, true); content.setBackground("ui-creature-info-background"); table.layout(); } content.add(buttons); table.add(content).width(126); continueButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (shownStore.get() && newProfessionAbilities.size > 0) { shownStore.set(false); newItemsTable.clearChildren(); addAbilities(newItemsTable, newProfessionAbilities, true); content.setBackground("ui-creature-info-background"); table.layout(); } else { hide(); } } }); }
From source file:com.vlaaad.dice.ui.windows.PotionsWindow.java
License:Open Source License
private ActorGestureListener createPotionTapListener(final AbilityIconCounter icon, final Ability ability, final Image selection, final Table viewsList, final LocLabel name, final LocLabel desc, final Table ingredientsTable) { return new ActorGestureListener() { @Override/*from w ww .j a v a 2 s . co m*/ public void tap(InputEvent event, float x, float y, int tapCount, int button) { Vector2 pos = icon.localToAscendantCoordinates(viewsList, tmp.set(0, 0)); selection.setPosition(pos.x, pos.y); name.setKey(ability.locNameKey()); desc.setKey(ability.locDescKey()); desc.setParams(ability.fillDescriptionParams(params, null)); Array<ItemIcon> icons = new Array<ItemIcon>(); for (Item item : ability.ingredients.keys()) { int count = ability.ingredients.get(item, 0); for (int i = 0; i < count; i++) { icons.add(new ItemIcon(item)); } } icons.sort(ItemIcon.ORDER_COMPARATOR); ingredientsTable.clearChildren(); int i = 0; for (final ItemIcon itemIcon : icons) { i++; ingredientsTable.add(itemIcon).pad(-4); itemIcon.addListener(ingredientListener(itemIcon.item)); if (i != icons.size) { ingredientsTable.add(new Tile("ui-plus")); } } } }; }