Search in sources :

Example 1 with GuiImageButton

use of buildcraft.lib.gui.button.GuiImageButton in project BuildCraft by BuildCraft.

the class GuiDiamondWoodPipe method initGui.

@Override
public void initGui() {
    super.initGui();
    this.whiteListButton = new GuiImageButton(mainGui, WHITE_LIST_BUTTON_ID, this.guiLeft + 7, this.guiTop + 41, 18, TEXTURE_BUTTON, 19, 19);
    this.whiteListButton.setToolTip(ToolTip.createLocalized("tip.PipeItemsEmerald.whitelist"));
    this.whiteListButton.registerListener(this);
    this.mainGui.shownElements.add(this.whiteListButton);
    this.blackListButton = new GuiImageButton(mainGui, BLACK_LIST_BUTTON_ID, this.guiLeft + 7 + 18, this.guiTop + 41, 18, TEXTURE_BUTTON, 37, 19);
    this.blackListButton.setToolTip(ToolTip.createLocalized("tip.PipeItemsEmerald.blacklist"));
    this.blackListButton.registerListener(this);
    this.mainGui.shownElements.add(this.blackListButton);
    if (pipe.pipe.getFlow() instanceof IFlowItems) {
        // Don't show round robin for the fluid pipe - its not yet implemented
        this.roundRobinButton = new GuiImageButton(mainGui, ROUND_ROBIN_BUTTON_ID, this.guiLeft + 7 + 36, this.guiTop + 41, 18, TEXTURE_BUTTON, 55, 19);
        this.roundRobinButton.setToolTip(ToolTip.createLocalized("tip.PipeItemsEmerald.roundrobin"));
        this.roundRobinButton.registerListener(this);
        this.mainGui.shownElements.add(this.roundRobinButton);
        IButtonBehaviour.createAndSetRadioButtons(whiteListButton, blackListButton, roundRobinButton);
    } else {
        IButtonBehaviour.createAndSetRadioButtons(whiteListButton, blackListButton);
    }
    switch(pipe.filterMode) {
        case WHITE_LIST:
            this.whiteListButton.activate();
            break;
        case BLACK_LIST:
            this.blackListButton.activate();
            break;
        case ROUND_ROBIN:
            if (roundRobinButton != null) {
                this.roundRobinButton.activate();
            }
            break;
    }
}
Also used : GuiImageButton(buildcraft.lib.gui.button.GuiImageButton) IFlowItems(buildcraft.api.transport.pipe.IFlowItems)

Example 2 with GuiImageButton

use of buildcraft.lib.gui.button.GuiImageButton in project BuildCraft by BuildCraft.

the class GuiDiamondWoodPipe method handleButtonClick.

@Override
public void handleButtonClick(IButtonClickEventTrigger sender, int buttonKey) {
    if (!(sender instanceof GuiImageButton)) {
        return;
    }
    int id = Integer.parseInt(((GuiImageButton) sender).id);
    FilterMode newFilterMode = FilterMode.get(id);
    this.pipe.filterMode = newFilterMode;
    container.sendNewFilterMode(newFilterMode);
}
Also used : GuiImageButton(buildcraft.lib.gui.button.GuiImageButton) FilterMode(buildcraft.transport.pipe.behaviour.PipeBehaviourWoodDiamond.FilterMode)

Example 3 with GuiImageButton

use of buildcraft.lib.gui.button.GuiImageButton in project BuildCraft by BuildCraft.

the class GuiList method initGui.

@Override
public void initGui() {
    super.initGui();
    for (int line = 0; line < container.slots.length; line++) {
        WidgetListSlot[] arr = container.slots[line];
        for (int slot = 0; slot < arr.length; slot++) {
            final WidgetListSlot listSlot = arr[slot];
            GuiRectangle rectangle = new GuiRectangle(8 + slot * 18, 32 + line * 34, 16, 16);
            IGuiArea phantomSlotArea = rectangle.offset(mainGui.rootElement);
            mainGui.shownElements.add(listSlot.new GuiElementPhantomSlot(mainGui, phantomSlotArea) {

                @Override
                protected boolean shouldDrawHighlight() {
                    if (listSlot.slotIndex == 0) {
                        return true;
                    }
                    return !GuiList.this.container.lines[listSlot.lineIndex].isOneStackMode();
                }

                @Override
                public void drawBackground(float partialTicks) {
                    if (!shouldDrawHighlight()) {
                        ICON_HIGHLIGHT.drawAt(this);
                    }
                }

                @Nonnull
                @Override
                public ItemStack getStack() {
                    if (shouldDrawHighlight()) {
                        return super.getStack();
                    } else {
                        NonNullList<ItemStack> data = GuiList.this.getExamplesList(listSlot.lineIndex, container.lines[listSlot.lineIndex].getSortingType());
                        if (data.size() >= listSlot.slotIndex) {
                            return data.get(listSlot.slotIndex - 1);
                        } else {
                            return StackUtil.EMPTY;
                        }
                    }
                }

                @Override
                public void onMouseClicked(int button) {
                    super.onMouseClicked(button);
                    if (contains(gui.mouse)) {
                        clearExamplesCache(listSlot.lineIndex);
                    }
                }
            });
        }
    }
    buttonList.clear();
    for (int sy = 0; sy < ListHandler.HEIGHT; sy++) {
        int bOff = sy * BUTTON_COUNT;
        int bOffX = this.guiLeft + 8 + ListHandler.WIDTH * 18 - BUTTON_COUNT * 11;
        int bOffY = this.guiTop + 32 + sy * 34 + 18;
        GuiImageButton buttonPrecise = new GuiImageButton(mainGui, bOff + 0, bOffX, bOffY, 11, TEXTURE_BASE, 176, 16, 176, 28);
        buttonPrecise.setToolTip(ToolTip.createLocalized("gui.list.nbt"));
        buttonPrecise.setBehaviour(IButtonBehaviour.TOGGLE);
        mainGui.shownElements.add(buttonPrecise);
        GuiImageButton buttonType = new GuiImageButton(mainGui, bOff + 1, bOffX + 11, bOffY, 11, TEXTURE_BASE, 176, 16, 185, 28);
        buttonType.setToolTip(ToolTip.createLocalized("gui.list.metadata"));
        buttonType.setBehaviour(IButtonBehaviour.TOGGLE);
        mainGui.shownElements.add(buttonType);
        GuiImageButton buttonMaterial = new GuiImageButton(mainGui, bOff + 2, bOffX + 22, bOffY, 11, TEXTURE_BASE, 176, 16, 194, 28);
        buttonMaterial.setToolTip(ToolTip.createLocalized("gui.list.oredict"));
        buttonMaterial.setBehaviour(IButtonBehaviour.TOGGLE);
        mainGui.shownElements.add(buttonMaterial);
    }
    for (IGuiElement elem : mainGui.shownElements) {
        if (elem instanceof GuiImageButton) {
            GuiImageButton b = (GuiImageButton) elem;
            int id = Integer.parseInt(b.id);
            int lineId = id / BUTTON_COUNT;
            int buttonId = id % BUTTON_COUNT;
            if (container.lines[lineId].getOption(buttonId)) {
                b.activate();
            }
            b.registerListener(this);
        }
    }
    textField = new GuiTextField(6, this.fontRenderer, guiLeft + 10, guiTop + 10, 156, 12);
    textField.setMaxStringLength(32);
    textField.setText(BCCoreItems.list.getName(container.getListItemStack()));
    textField.setFocused(false);
}
Also used : IGuiArea(buildcraft.lib.gui.pos.IGuiArea) GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) Nonnull(javax.annotation.Nonnull) GuiTextField(net.minecraft.client.gui.GuiTextField) WidgetListSlot(buildcraft.core.list.ContainerList.WidgetListSlot) GuiImageButton(buildcraft.lib.gui.button.GuiImageButton) NonNullList(net.minecraft.util.NonNullList) IGuiElement(buildcraft.lib.gui.IGuiElement) ItemStack(net.minecraft.item.ItemStack)

Aggregations

GuiImageButton (buildcraft.lib.gui.button.GuiImageButton)3 IFlowItems (buildcraft.api.transport.pipe.IFlowItems)1 WidgetListSlot (buildcraft.core.list.ContainerList.WidgetListSlot)1 IGuiElement (buildcraft.lib.gui.IGuiElement)1 GuiRectangle (buildcraft.lib.gui.pos.GuiRectangle)1 IGuiArea (buildcraft.lib.gui.pos.IGuiArea)1 FilterMode (buildcraft.transport.pipe.behaviour.PipeBehaviourWoodDiamond.FilterMode)1 Nonnull (javax.annotation.Nonnull)1 GuiTextField (net.minecraft.client.gui.GuiTextField)1 ItemStack (net.minecraft.item.ItemStack)1 NonNullList (net.minecraft.util.NonNullList)1