Search in sources :

Example 1 with IReference

use of buildcraft.lib.misc.data.IReference in project BuildCraft by BuildCraft.

the class GuiElementStatementDrag method drawForeground.

@Override
public void drawForeground(float partialTicks) {
    if (isDragging) {
        boolean canPlace = false;
        for (IGuiElement element : gui.getElementsAt(gui.mouse.getX(), gui.mouse.getY())) {
            if (element instanceof IReference<?>) {
                if (checkCanSet((IReference<?>) element, dragging)) {
                    canPlace = true;
                    break;
                }
            }
        }
        GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
        if (!canPlace) {
            GlStateManager.color(1.0f, 0.7f, 0.7f);
        }
        double x = gui.mouse.getX() - 9;
        double y = gui.mouse.getY() - 9;
        if (dragging instanceof IStatementParameter) {
            ParameterRenderer.draw((IStatementParameter) dragging, x, y);
        } else {
            GuiIcon background = GuiElementStatement.SLOT_COLOUR;
            if (dragging instanceof StatementWrapper) {
                EnumPipePart part = ((StatementWrapper) dragging).sourcePart;
                if (part != EnumPipePart.CENTER) {
                    background = background.offset(0, (1 + part.getIndex()) * 18);
                }
            }
            background.drawAt(x, y);
            if (dragging != null) {
                ISprite sprite = dragging.getSprite();
                if (sprite != null) {
                    GuiIcon.drawAt(sprite, x + 1, y + 1, 16);
                }
            }
        }
        GlStateManager.color(1, 1, 1);
    }
}
Also used : StatementWrapper(buildcraft.lib.statement.StatementWrapper) ISprite(buildcraft.api.core.render.ISprite) EnumPipePart(buildcraft.api.core.EnumPipePart) IGuiElement(buildcraft.lib.gui.IGuiElement) IStatementParameter(buildcraft.api.statements.IStatementParameter) IReference(buildcraft.lib.misc.data.IReference) GuiIcon(buildcraft.lib.gui.GuiIcon)

Example 2 with IReference

use of buildcraft.lib.misc.data.IReference in project BuildCraft by BuildCraft.

the class GuiElementStatementDrag method onMouseClicked.

// IInteractableElement
@Override
public void onMouseClicked(int button) {
    if (button != 1) {
        return;
    }
    for (IGuiElement element : gui.getElementsAt(gui.mouse.getX(), gui.mouse.getY())) {
        if (element instanceof IReference<?>) {
            IReference<?> ref = (IReference<?>) element;
            Object obj = ref.get();
            if (obj == null || obj instanceof IGuiSlot) {
                startDragging((IGuiSlot) obj);
                break;
            }
        }
    }
}
Also used : IGuiSlot(buildcraft.api.statements.IGuiSlot) IGuiElement(buildcraft.lib.gui.IGuiElement) IReference(buildcraft.lib.misc.data.IReference)

Example 3 with IReference

use of buildcraft.lib.misc.data.IReference in project BuildCraft by BuildCraft.

the class GuiElementStatementDrag method onMouseReleased.

@Override
public void onMouseReleased(int button) {
    if (!isDragging) {
        return;
    }
    for (IGuiElement element : gui.getElementsAt(gui.mouse.getX(), gui.mouse.getY())) {
        if (element instanceof IReference<?>) {
            IReference<?> ref = (IReference<?>) element;
            ref.setIfCan(dragging);
        }
    }
    isDragging = false;
    dragging = null;
    if (gui.currentMenu == this) {
        gui.currentMenu = null;
    }
}
Also used : IGuiElement(buildcraft.lib.gui.IGuiElement) IReference(buildcraft.lib.misc.data.IReference)

Aggregations

IGuiElement (buildcraft.lib.gui.IGuiElement)3 IReference (buildcraft.lib.misc.data.IReference)3 EnumPipePart (buildcraft.api.core.EnumPipePart)1 ISprite (buildcraft.api.core.render.ISprite)1 IGuiSlot (buildcraft.api.statements.IGuiSlot)1 IStatementParameter (buildcraft.api.statements.IStatementParameter)1 GuiIcon (buildcraft.lib.gui.GuiIcon)1 StatementWrapper (buildcraft.lib.statement.StatementWrapper)1