use of com.almuradev.almura.feature.exchange.client.gui.component.UIExchangeOfferContainer in project Almura by AlmuraDev.
the class ExchangeOfferScreen method construct.
@Override
public void construct() {
this.guiscreenBackground = false;
// Form
final BasicForm form = new BasicForm(this, 400, 325, I18n.format("almura.feature.exchange.title.offer"));
// Fixes issue overlapping draws from parent
form.setZIndex(10);
form.setBackgroundAlpha(255);
// OK/Cancel buttons
final UIButton buttonOk = new UIButtonBuilder(this).width(40).text(I18n.format("almura.button.ok")).x(1).anchor(Anchor.BOTTOM | Anchor.RIGHT).onClick(this::transact).build("button.ok");
final UIButton buttonCancel = new UIButtonBuilder(this).width(40).text(I18n.format("almura.button.cancel")).x(getPaddedX(buttonOk, 2, Anchor.RIGHT)).anchor(Anchor.BOTTOM | Anchor.RIGHT).onClick(this::close).build("button.cancel");
// Swap container
final NonNullList<ItemStack> mainInventory = Minecraft.getMinecraft().player.inventory.mainInventory;
final int totalItemsForSale = this.exchange.getForSaleItemsFor(Minecraft.getMinecraft().player.getUniqueID()).map(List::size).orElse(0);
this.offerContainer = new UIExchangeOfferContainer(this, getPaddedWidth(form), getPaddedHeight(form) - 20, TextFormatting.WHITE + I18n.format("almura.feature.exchange.text.inventory"), TextFormatting.WHITE + I18n.format("almura.feature.exchange.text.unlisted_items"), mainInventory.size(), this.limit, totalItemsForSale);
this.offerContainer.register(this);
// Populate offer container
final List<VanillaStack> inventoryOffers = new ArrayList<>();
mainInventory.stream().filter(i -> !i.isEmpty() && i.getItem() != null).forEach(i -> inventoryOffers.add(new BasicVanillaStack(i)));
this.offerContainer.setItems(this.pendingItems, BasicDualListContainer.SideType.RIGHT);
this.offerContainer.setItems(inventoryOffers, BasicDualListContainer.SideType.LEFT);
form.add(this.offerContainer, buttonOk, buttonCancel);
addToScreen(form);
}
Aggregations