Search in sources :

Example 1 with IGuiEventListener

use of net.minecraft.client.gui.IGuiEventListener in project iChunUtil by iChun.

the class ElementFertile method changeFocus.

@Override
public // do the default from INestedGuiEventHandler
boolean changeFocus(// do the default from INestedGuiEventHandler
boolean direction) {
    IGuiEventListener iguieventlistener = this.getListener();
    boolean flag = iguieventlistener != null;
    if (flag && iguieventlistener.changeFocus(direction)) {
        return true;
    } else {
        List<? extends IGuiEventListener> list = this.getEventListeners();
        int j = list.indexOf(iguieventlistener);
        int i;
        if (flag && j >= 0) {
            i = j + (direction ? 1 : 0);
        } else if (direction) {
            i = 0;
        } else {
            i = list.size();
        }
        ListIterator<? extends IGuiEventListener> listiterator = list.listIterator(i);
        BooleanSupplier booleansupplier = direction ? listiterator::hasNext : listiterator::hasPrevious;
        Supplier<? extends IGuiEventListener> supplier = direction ? listiterator::next : listiterator::previous;
        while (booleansupplier.getAsBoolean()) {
            IGuiEventListener iguieventlistener1 = supplier.get();
            if (iguieventlistener1.changeFocus(direction)) {
                this.setListener(iguieventlistener1);
                return true;
            }
        }
        this.setListener(null);
        return false;
    }
}
Also used : IGuiEventListener(net.minecraft.client.gui.IGuiEventListener) BooleanSupplier(java.util.function.BooleanSupplier) Constraint(me.ichun.mods.ichunutil.client.gui.bns.window.constraint.Constraint)

Example 2 with IGuiEventListener

use of net.minecraft.client.gui.IGuiEventListener in project iChunUtil by iChun.

the class ElementFertile method getMinWidth.

@Override
public int getMinWidth() {
    int min = 0;
    for (IGuiEventListener child : getEventListeners()) {
        if (child instanceof Fragment<?>) {
            Fragment<?> fragment = (Fragment<?>) child;
            int fragWidth = getConstraintSensitiveMinWidth(fragment);
            if (fragWidth > min) {
                min = fragWidth;
            }
        }
    }
    return min > 0 ? min + (getBorderSize() * 2) : 4;
}
Also used : IGuiEventListener(net.minecraft.client.gui.IGuiEventListener) Fragment(me.ichun.mods.ichunutil.client.gui.bns.window.Fragment) Constraint(me.ichun.mods.ichunutil.client.gui.bns.window.constraint.Constraint)

Example 3 with IGuiEventListener

use of net.minecraft.client.gui.IGuiEventListener in project Mekanism by mekanism.

the class GuiMekanism method mouseClicked.

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
    hasClicked = true;
    // first try to send the mouse event to our overlays
    GuiWindow top = windows.isEmpty() ? null : windows.iterator().next();
    GuiWindow focused = windows.stream().filter(overlay -> overlay.mouseClicked(mouseX, mouseY, button)).findFirst().orElse(null);
    if (focused != null) {
        if (windows.contains(focused)) {
            // Validate that the focused window is still one of our windows, as if it wasn't focused/on top, and
            // it is being closed, we don't want to update and mark it as focused, as our defocusing code won't
            // run as we ran it when we pressed the button
            setFocused(focused);
            if (button == 0) {
                setDragging(true);
            }
            // this check prevents us from moving the window to the top of the stack if the clicked window opened up an additional window
            if (top != focused) {
                top.onFocusLost();
                windows.moveUp(focused);
                focused.onFocused();
            }
        }
        return true;
    }
    // otherwise, we send it to the current element
    for (int i = buttons.size() - 1; i >= 0; i--) {
        IGuiEventListener listener = buttons.get(i);
        if (listener.mouseClicked(mouseX, mouseY, button)) {
            setFocused(listener);
            if (button == 0) {
                setDragging(true);
            }
            return true;
        }
    }
    return super.mouseClicked(mouseX, mouseY, button);
}
Also used : IGuiEventListener(net.minecraft.client.gui.IGuiEventListener) GuiWindow(mekanism.client.gui.element.window.GuiWindow)

Example 4 with IGuiEventListener

use of net.minecraft.client.gui.IGuiEventListener in project SophisticatedBackpacks by P3pp3rF1y.

the class BackpackScreen method mouseDragged.

@Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
    for (IGuiEventListener child : children) {
        if (child.isMouseOver(mouseX, mouseY) && child.mouseDragged(mouseX, mouseY, button, dragX, dragY)) {
            return true;
        }
    }
    Slot slot = findSlot(mouseX, mouseY);
    ItemStack itemstack = minecraft.player.inventory.getCarried();
    if (isQuickCrafting && slot != null && !itemstack.isEmpty() && (itemstack.getCount() > quickCraftSlots.size() || quickCraftingType == 2) && BackpackContainer.canMergeItemToSlot(slot, itemstack) && slot.mayPlace(itemstack) && menu.canDragTo(slot)) {
        quickCraftSlots.add(slot);
        recalculateQuickCraftRemaining();
    }
    return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
}
Also used : IGuiEventListener(net.minecraft.client.gui.IGuiEventListener) Slot(net.minecraft.inventory.container.Slot) BackpackInventorySlot(net.p3pp3rf1y.sophisticatedbackpacks.common.gui.BackpackInventorySlot) ItemStack(net.minecraft.item.ItemStack)

Example 5 with IGuiEventListener

use of net.minecraft.client.gui.IGuiEventListener in project BoundingBoxOutlineReloaded by irtimaled.

the class ListScreen method mouseClicked.

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
    for (IGuiEventListener control : this.children()) {
        if (control.mouseClicked(mouseX, mouseY, button)) {
            IGuiEventListener focused = getFocused();
            if (focused instanceof IFocusableControl && focused != control) {
                ((IFocusableControl) focused).clearFocus();
            }
            this.setFocused(control);
            if (button == 0)
                this.setDragging(true);
            return true;
        }
    }
    return false;
}
Also used : IGuiEventListener(net.minecraft.client.gui.IGuiEventListener)

Aggregations

IGuiEventListener (net.minecraft.client.gui.IGuiEventListener)11 Constraint (me.ichun.mods.ichunutil.client.gui.bns.window.constraint.Constraint)3 Fragment (me.ichun.mods.ichunutil.client.gui.bns.window.Fragment)2 GuiElement (mekanism.client.gui.element.GuiElement)2 Widget (net.minecraft.client.gui.widget.Widget)2 ArrayList (java.util.ArrayList)1 BooleanSupplier (java.util.function.BooleanSupplier)1 Nullable (javax.annotation.Nullable)1 GuiWindow (mekanism.client.gui.element.window.GuiWindow)1 IJEIGhostTarget (mekanism.client.jei.interfaces.IJEIGhostTarget)1 IGhostIngredientConsumer (mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostIngredientConsumer)1 IJEIIngredientHelper (mekanism.client.jei.interfaces.IJEIIngredientHelper)1 Slot (net.minecraft.inventory.container.Slot)1 ItemStack (net.minecraft.item.ItemStack)1 BackpackInventorySlot (net.p3pp3rf1y.sophisticatedbackpacks.common.gui.BackpackInventorySlot)1