Search in sources :

Example 6 with IGuiEventListener

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

the class Fragment method unfocus.

public // pass the unfocused event down. Unfocus triggers before focus is set
void unfocus(// pass the unfocused event down. Unfocus triggers before focus is set
@Nullable IGuiEventListener guiReplacing) {
    IGuiEventListener lastFocused = getListener();
    if (lastFocused instanceof Fragment && guiReplacing != lastFocused) {
        ((Fragment<?>) lastFocused).unfocus(guiReplacing);
        // set focus to nothing. MouseClicked will handle the focus of the new object.
        setListener(null);
    }
}
Also used : IGuiEventListener(net.minecraft.client.gui.IGuiEventListener)

Example 7 with IGuiEventListener

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

the class Fragment method setListener.

@Override
public void setListener(@Nullable IGuiEventListener iGuiEventListener) {
    IGuiEventListener lastFocused = getListener();
    if (lastFocused instanceof Fragment && iGuiEventListener != lastFocused) {
        ((Fragment<?>) lastFocused).unfocus(iGuiEventListener);
    }
    focused = iGuiEventListener;
}
Also used : IGuiEventListener(net.minecraft.client.gui.IGuiEventListener)

Example 8 with IGuiEventListener

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

the class Workspace method setListener.

@Override
public void setListener(@Nullable IGuiEventListener gui) {
    IGuiEventListener lastFocused = getListener();
    if (lastFocused instanceof Fragment && gui != lastFocused) {
        ((Fragment<?>) lastFocused).unfocus(gui);
    }
    if (gui instanceof Window) {
        bringToFront((Window<?>) gui);
    }
    super.setListener(gui);
}
Also used : IGuiEventListener(net.minecraft.client.gui.IGuiEventListener)

Example 9 with IGuiEventListener

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

the class ElementFertile method getMinHeight.

@Override
public int getMinHeight() {
    int min = 0;
    for (IGuiEventListener child : getEventListeners()) {
        if (child instanceof Fragment<?>) {
            Fragment<?> fragment = (Fragment<?>) child;
            int fragHeight = getConstraintSensitiveMinHeight(fragment);
            if (fragHeight > min) {
                min = fragHeight;
            }
        }
    }
    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 10 with IGuiEventListener

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

the class GhostIngredientHandler method getTargets.

private <INGREDIENT> List<TargetInfo<INGREDIENT>> getTargets(List<? extends IGuiEventListener> children, INGREDIENT ingredient) {
    List<TargetInfo<INGREDIENT>> ghostTargets = new ArrayList<>();
    for (IGuiEventListener child : children) {
        if (child instanceof Widget) {
            Widget widget = (Widget) child;
            if (widget.visible) {
                if (widget instanceof GuiElement) {
                    // Start by adding any grandchild ghost targets we have as they are the "top" layer, and we want them
                    // to get checked/interacted with first
                    ghostTargets.addAll(getTargets(((GuiElement) widget).children(), ingredient));
                }
                // Then go ahead and check if our element is a ghost target and if it is, and it supports the ingredient add it
                if (widget instanceof IJEIGhostTarget) {
                    IJEIGhostTarget ghostTarget = (IJEIGhostTarget) widget;
                    IGhostIngredientConsumer ghostHandler = ghostTarget.getGhostHandler();
                    if (ghostHandler != null && ghostHandler.supportsIngredient(ingredient)) {
                        ghostTargets.add(new TargetInfo<>(ghostTarget, ghostHandler, widget.x, widget.y, widget.getWidth(), widget.getHeight()));
                    }
                }
            }
        }
    }
    return ghostTargets;
}
Also used : IGuiEventListener(net.minecraft.client.gui.IGuiEventListener) ArrayList(java.util.ArrayList) Widget(net.minecraft.client.gui.widget.Widget) IJEIGhostTarget(mekanism.client.jei.interfaces.IJEIGhostTarget) IGhostIngredientConsumer(mekanism.client.jei.interfaces.IJEIGhostTarget.IGhostIngredientConsumer) GuiElement(mekanism.client.gui.element.GuiElement)

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