Search in sources :

Example 6 with IGuiElement

use of buildcraft.lib.gui.IGuiElement 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 7 with IGuiElement

use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.

the class LedgerHelp method drawIcon.

@Override
protected void drawIcon(double x, double y) {
    if (!init) {
        init = true;
        List<HelpPosition> elements = new ArrayList<>();
        for (IGuiElement element : gui.shownElements) {
            element.addHelpElements(elements);
        }
        foundAny = elements.size() > 0;
    }
    ISprite sprite = foundAny ? BCLibSprites.HELP : BCLibSprites.WARNING_MINOR;
    GuiIcon.draw(sprite, x, y, x + 16, y + 16);
}
Also used : HelpPosition(buildcraft.lib.gui.help.ElementHelpInfo.HelpPosition) ISprite(buildcraft.api.core.render.ISprite) ArrayList(java.util.ArrayList) IGuiElement(buildcraft.lib.gui.IGuiElement)

Example 8 with IGuiElement

use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.

the class Ledger_Neptune method calculateMaxSize.

/**
 * The default implementation only works if all the elements are based around {@link #positionLedgerStart}
 */
public void calculateMaxSize() {
    double w = CLOSED_WIDTH;
    double h = CLOSED_HEIGHT;
    for (IGuiElement element : openElements) {
        w = Math.max(w, element.getEndX());
        h = Math.max(h, element.getEndY());
    }
    w -= getX();
    h -= getY();
    maxWidth = w + LEDGER_GAP * 2;
    maxHeight = h + LEDGER_GAP * 2;
}
Also used : IGuiElement(buildcraft.lib.gui.IGuiElement)

Example 9 with IGuiElement

use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.

the class Ledger_Neptune method drawBackground.

@Override
public void drawBackground(float partialTicks) {
    double startX = getX();
    double startY = getY();
    final SpriteNineSliced split;
    interpWidth = interp(lastWidth, currentWidth, partialTicks);
    interpHeight = interp(lastHeight, currentHeight, partialTicks);
    if (expandPositive) {
        split = SPRITE_SPLIT_POS;
    } else {
        split = SPRITE_SPLIT_NEG;
    }
    RenderUtil.setGLColorFromIntPlusAlpha(colour);
    split.draw(startX, startY, interpWidth, interpHeight);
    GlStateManager.color(1, 1, 1, 1);
    IGuiPosition pos2;
    if (expandPositive) {
        pos2 = positionLedgerIconStart;
    } else {
        pos2 = positionLedgerIconStart;
    }
    try (AutoGlScissor a = GuiUtil.scissor(pos2.getX(), pos2.getY(), interpWidth - 4, interpHeight - 8)) {
        for (IGuiElement element : closedElements) {
            element.drawBackground(partialTicks);
        }
        if (shouldDrawOpen()) {
            for (IGuiElement element : openElements) {
                element.drawBackground(partialTicks);
            }
        }
    }
}
Also used : AutoGlScissor(buildcraft.lib.misc.GuiUtil.AutoGlScissor) IGuiElement(buildcraft.lib.gui.IGuiElement) SpriteNineSliced(buildcraft.lib.client.sprite.SpriteNineSliced) IGuiPosition(buildcraft.lib.gui.pos.IGuiPosition)

Example 10 with IGuiElement

use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.

the class Ledger_Neptune method drawForeground.

@Override
public void drawForeground(float partialTicks) {
    double scissorX = positionLedgerIconStart.getX();
    double scissorY = positionLedgerIconStart.getY();
    double scissorWidth = interpWidth - 8;
    double scissorHeight = interpHeight - 8;
    try (AutoGlScissor a = GuiUtil.scissor(scissorX, scissorY, scissorWidth, scissorHeight)) {
        for (IGuiElement element : closedElements) {
            element.drawForeground(partialTicks);
        }
        if (shouldDrawOpen()) {
            for (IGuiElement element : openElements) {
                element.drawForeground(partialTicks);
            }
        }
    }
}
Also used : AutoGlScissor(buildcraft.lib.misc.GuiUtil.AutoGlScissor) IGuiElement(buildcraft.lib.gui.IGuiElement)

Aggregations

IGuiElement (buildcraft.lib.gui.IGuiElement)14 IReference (buildcraft.lib.misc.data.IReference)3 ArrayList (java.util.ArrayList)3 ISprite (buildcraft.api.core.render.ISprite)2 SpriteNineSliced (buildcraft.lib.client.sprite.SpriteNineSliced)2 IContainingElement (buildcraft.lib.gui.IContainingElement)2 HelpPosition (buildcraft.lib.gui.help.ElementHelpInfo.HelpPosition)2 IGuiArea (buildcraft.lib.gui.pos.IGuiArea)2 AutoGlScissor (buildcraft.lib.misc.GuiUtil.AutoGlScissor)2 EnumPipePart (buildcraft.api.core.EnumPipePart)1 IGuiSlot (buildcraft.api.statements.IGuiSlot)1 IStatementParameter (buildcraft.api.statements.IStatementParameter)1 WidgetListSlot (buildcraft.core.list.ContainerList.WidgetListSlot)1 ResourceLoaderContext (buildcraft.lib.client.model.ResourceLoaderContext)1 InvalidExpressionException (buildcraft.lib.expression.api.InvalidExpressionException)1 GuiElementSimple (buildcraft.lib.gui.GuiElementSimple)1 GuiIcon (buildcraft.lib.gui.GuiIcon)1 IInteractionElement (buildcraft.lib.gui.IInteractionElement)1 GuiImageButton (buildcraft.lib.gui.button.GuiImageButton)1 GuiElementContainerHelp (buildcraft.lib.gui.elem.GuiElementContainerHelp)1