Search in sources :

Example 1 with ContainerAmadron

use of me.desht.pneumaticcraft.common.inventory.ContainerAmadron in project pnc-repressurized by TeamPneumatic.

the class GuiAmadron method updateScreen.

@Override
public void updateScreen() {
    super.updateScreen();
    ContainerAmadron container = (ContainerAmadron) inventorySlots;
    if (needsRefreshing || page != scrollbar.getState()) {
        setPage(scrollbar.getState());
    }
    for (WidgetAmadronOffer offer : widgetOffers) {
        offer.setCanBuy(container.buyableOffers[container.offers.indexOf(offer.getOffer())]);
        offer.setShoppingAmount(container.getShoppingCartAmount(offer.getOffer()));
    }
    if (!hadProblem && container.problemState != EnumProblemState.NO_PROBLEMS) {
        problemTab.openWindow();
    }
    hadProblem = container.problemState != EnumProblemState.NO_PROBLEMS;
    addTradeButton.enabled = container.currentOffers < container.maxOffers;
    List<String> tooltip = PneumaticCraftUtils.convertStringIntoList(I18n.format("gui.amadron.button.addTrade.tooltip"), 40);
    tooltip.add((addTradeButton.enabled ? TextFormatting.GRAY : TextFormatting.RED) + I18n.format("gui.amadron.button.addTrade.tooltip.offerCount", container.currentOffers, container.maxOffers == Integer.MAX_VALUE ? "\u221E" : container.maxOffers));
    addTradeButton.setTooltipText(tooltip);
}
Also used : ContainerAmadron(me.desht.pneumaticcraft.common.inventory.ContainerAmadron) WidgetAmadronOffer(me.desht.pneumaticcraft.client.gui.widget.WidgetAmadronOffer)

Example 2 with ContainerAmadron

use of me.desht.pneumaticcraft.common.inventory.ContainerAmadron in project pnc-repressurized by TeamPneumatic.

the class GuiAmadron method updateVisibleOffers.

public void updateVisibleOffers() {
    needsRefreshing = false;
    final ContainerAmadron container = (ContainerAmadron) inventorySlots;
    int invSize = ContainerAmadron.ROWS * 2;
    container.clearStacks();
    List<AmadronOffer> offers = container.offers;
    List<AmadronOffer> visibleOffers = new ArrayList<AmadronOffer>();
    int skippedOffers = 0;
    int applicableOffers = 0;
    for (AmadronOffer offer : offers) {
        if (offer.passesQuery(searchBar.getText())) {
            applicableOffers++;
            if (skippedOffers < page * invSize) {
                skippedOffers++;
            } else if (visibleOffers.size() < invSize) {
                visibleOffers.add(offer);
            }
        }
    }
    scrollbar.setStates(Math.max(1, (applicableOffers + invSize - 1) / invSize - 1));
    widgets.removeAll(widgetOffers);
    for (int i = 0; i < visibleOffers.size(); i++) {
        AmadronOffer offer = visibleOffers.get(i);
        if (offer.getInput() instanceof ItemStack) {
            container.inventorySlots.get(i * 2).putStack((ItemStack) offer.getInput());
        }
        if (offer.getOutput() instanceof ItemStack) {
            container.inventorySlots.get(i * 2 + 1).putStack((ItemStack) offer.getOutput());
        }
        WidgetAmadronOffer widget = new WidgetAmadronOffer(i, guiLeft + 6 + 73 * (i % 2), guiTop + 55 + 35 * (i / 2), offer) {

            @Override
            public void onMouseClicked(int mouseX, int mouseY, int button) {
                NetworkHandler.sendToServer(new PacketAmadronOrderUpdate(container.offers.indexOf(getOffer()), button, PneumaticCraftRepressurized.proxy.isSneakingInGui()));
            }
        };
        addWidget(widget);
        widgetOffers.add(widget);
    }
    // the server also needs to know what's in the tablet, or the next
    // "window items" packet will empty all the client-side slots
    NetworkHandler.sendToServer(new PacketAmadronInvSync(container.getInventory()));
}
Also used : AmadronOffer(me.desht.pneumaticcraft.common.recipes.AmadronOffer) WidgetAmadronOffer(me.desht.pneumaticcraft.client.gui.widget.WidgetAmadronOffer) ArrayList(java.util.ArrayList) ContainerAmadron(me.desht.pneumaticcraft.common.inventory.ContainerAmadron) WidgetAmadronOffer(me.desht.pneumaticcraft.client.gui.widget.WidgetAmadronOffer) PacketAmadronInvSync(me.desht.pneumaticcraft.common.network.PacketAmadronInvSync) ItemStack(net.minecraft.item.ItemStack) PacketAmadronOrderUpdate(me.desht.pneumaticcraft.common.network.PacketAmadronOrderUpdate)

Example 3 with ContainerAmadron

use of me.desht.pneumaticcraft.common.inventory.ContainerAmadron in project pnc-repressurized by TeamPneumatic.

the class GuiAmadron method addProblems.

@Override
protected void addProblems(List curInfo) {
    super.addProblems(curInfo);
    EnumProblemState problemState = ((ContainerAmadron) inventorySlots).problemState;
    if (problemState != EnumProblemState.NO_PROBLEMS) {
        curInfo.add(problemState.getLocalizationKey());
    }
}
Also used : EnumProblemState(me.desht.pneumaticcraft.common.inventory.ContainerAmadron.EnumProblemState) ContainerAmadron(me.desht.pneumaticcraft.common.inventory.ContainerAmadron)

Aggregations

ContainerAmadron (me.desht.pneumaticcraft.common.inventory.ContainerAmadron)3 WidgetAmadronOffer (me.desht.pneumaticcraft.client.gui.widget.WidgetAmadronOffer)2 ArrayList (java.util.ArrayList)1 EnumProblemState (me.desht.pneumaticcraft.common.inventory.ContainerAmadron.EnumProblemState)1 PacketAmadronInvSync (me.desht.pneumaticcraft.common.network.PacketAmadronInvSync)1 PacketAmadronOrderUpdate (me.desht.pneumaticcraft.common.network.PacketAmadronOrderUpdate)1 AmadronOffer (me.desht.pneumaticcraft.common.recipes.AmadronOffer)1 ItemStack (net.minecraft.item.ItemStack)1