Search in sources :

Example 11 with Widget

use of gregtech.api.gui.Widget in project GregTech by GregTechCE.

the class AbstractWidgetGroup method handleClientAction.

@Override
public void handleClientAction(int id, PacketBuffer buffer) {
    if (id == 1) {
        int widgetIndex = buffer.readVarInt();
        int widgetUpdateId = buffer.readVarInt();
        Widget widget = widgets.get(widgetIndex);
        widget.handleClientAction(widgetUpdateId, buffer);
    }
}
Also used : INativeWidget(gregtech.api.gui.INativeWidget) Widget(gregtech.api.gui.Widget)

Example 12 with Widget

use of gregtech.api.gui.Widget in project GregTech by GregTechCE.

the class AbstractWidgetGroup method initWidget.

@Override
public void initWidget() {
    this.initialized = true;
    for (Widget widget : widgets) {
        widget.setGui(gui);
        widget.setSizes(sizes);
        widget.initWidget();
    }
}
Also used : INativeWidget(gregtech.api.gui.INativeWidget) Widget(gregtech.api.gui.Widget)

Example 13 with Widget

use of gregtech.api.gui.Widget in project GregTech by GregTechCE.

the class AbstractWidgetGroup method getIngredientOverMouse.

@Override
public Object getIngredientOverMouse(int mouseX, int mouseY) {
    if (!isVisible) {
        return Collections.emptyList();
    }
    for (Widget widget : widgets) {
        if (widget instanceof IIngredientSlot) {
            IIngredientSlot ingredientSlot = (IIngredientSlot) widget;
            Object result = ingredientSlot.getIngredientOverMouse(mouseX, mouseY);
            if (result != null)
                return result;
        }
    }
    return null;
}
Also used : INativeWidget(gregtech.api.gui.INativeWidget) Widget(gregtech.api.gui.Widget) IIngredientSlot(gregtech.api.gui.igredient.IIngredientSlot)

Example 14 with Widget

use of gregtech.api.gui.Widget in project GregTech by GregTechCE.

the class AbstractWidgetGroup method computeDynamicSize.

protected Size computeDynamicSize() {
    Position selfPosition = getPosition();
    Size currentSize = getSize();
    for (Widget widget : widgets) {
        Position size = widget.getPosition().add(widget.getSize()).subtract(selfPosition);
        if (size.x > currentSize.width) {
            currentSize = new Size(size.x, currentSize.height);
        }
        if (size.y > currentSize.height) {
            currentSize = new Size(currentSize.width, size.y);
        }
    }
    return currentSize;
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size) INativeWidget(gregtech.api.gui.INativeWidget) Widget(gregtech.api.gui.Widget)

Example 15 with Widget

use of gregtech.api.gui.Widget in project GregTech by GregTechCE.

the class ComponentGridWidget method mouseClicked.

@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
    if (isMouseOverElement(mouseX, mouseY)) {
        int mouseSlotX = (mouseX - getPosition().x - offset) / slotSize;
        int mouseSlotY = (mouseY - getPosition().y - offset) / slotSize;
        if (isValidPosition(mouseSlotX, mouseSlotY)) {
            Widget widget = getWidgetAt(mouseSlotX, mouseSlotY);
            if (button == 1) {
                if (widget != null) {
                    removeWidget(widget);
                    return true;
                }
            } else if (button == 0 && widget == null) {
                GridElementDef elementDef = new GridElementDef(1, 1, GridElementCable::new);
                if (canPlaceWidgetAt(mouseSlotX, mouseSlotY, elementDef, ElementOrientation.TOP)) {
                    placeWidgetAt(mouseSlotX, mouseSlotY, elementDef, ElementOrientation.TOP);
                    return true;
                }
            }
        }
    }
    return super.mouseClicked(mouseX, mouseY, button);
}
Also used : Widget(gregtech.api.gui.Widget)

Aggregations

Widget (gregtech.api.gui.Widget)20 INativeWidget (gregtech.api.gui.INativeWidget)9 Position (gregtech.api.util.Position)4 Consumer (java.util.function.Consumer)3 ScrollableListWidget (gregtech.api.gui.widgets.ScrollableListWidget)2 SlotWidget (gregtech.api.gui.widgets.SlotWidget)2 TankWidget (gregtech.api.gui.widgets.TankWidget)2 PacketUIWidgetUpdate (gregtech.api.net.PacketUIWidgetUpdate)2 Size (gregtech.api.util.Size)2 ItemStack (net.minecraft.item.ItemStack)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 FluidTankList (gregtech.api.capability.impl.FluidTankList)1 GuiTextures (gregtech.api.gui.GuiTextures)1 IRenderContext (gregtech.api.gui.IRenderContext)1 ModularUI (gregtech.api.gui.ModularUI)1 IGhostIngredientTarget (gregtech.api.gui.igredient.IGhostIngredientTarget)1 IIngredientSlot (gregtech.api.gui.igredient.IIngredientSlot)1 IRecipeTransferHandlerWidget (gregtech.api.gui.igredient.IRecipeTransferHandlerWidget)1 LabelWidget (gregtech.api.gui.widgets.LabelWidget)1