Search in sources :

Example 1 with SpriteNineSliced

use of buildcraft.lib.client.sprite.SpriteNineSliced in project BuildCraft by BuildCraft.

the class LedgerHelp method drawForeground.

@Override
public void drawForeground(float partialTicks) {
    super.drawForeground(partialTicks);
    if (!shouldDrawOpen()) {
        return;
    }
    boolean set = false;
    List<HelpPosition> elements = new ArrayList<>();
    for (IGuiElement element : gui.shownElements) {
        element.addHelpElements(elements);
        foundAny |= elements.size() > 0;
        for (HelpPosition info : elements) {
            IGuiArea rect = info.target;
            boolean isHovered = rect.contains(gui.mouse);
            if (isHovered) {
                if (selected != element && !set) {
                    selected = element;
                    GuiElementContainerHelp container = new GuiElementContainerHelp(gui, positionLedgerInnerStart);
                    info.info.addGuiElements(container);
                    if (openElements.size() == 2) {
                        openElements.remove(1);
                    }
                    openElements.add(container);
                    title = LocaleUtil.localize("gui.ledger.help") + ": " + LocaleUtil.localize(info.info.title);
                    calculateMaxSize();
                    set = true;
                }
            }
            boolean isSelected = selected == element;
            SpriteNineSliced split = SPRITE_HELP_SPLIT[isHovered ? 1 : 0][isSelected ? 1 : 0];
            RenderUtil.setGLColorFromInt(info.info.colour);
            split.draw(rect);
        }
        elements.clear();
    }
    GlStateManager.color(1, 1, 1);
}
Also used : HelpPosition(buildcraft.lib.gui.help.ElementHelpInfo.HelpPosition) IGuiArea(buildcraft.lib.gui.pos.IGuiArea) ArrayList(java.util.ArrayList) IGuiElement(buildcraft.lib.gui.IGuiElement) GuiElementContainerHelp(buildcraft.lib.gui.elem.GuiElementContainerHelp) SpriteNineSliced(buildcraft.lib.client.sprite.SpriteNineSliced)

Example 2 with SpriteNineSliced

use of buildcraft.lib.client.sprite.SpriteNineSliced 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)

Aggregations

SpriteNineSliced (buildcraft.lib.client.sprite.SpriteNineSliced)2 IGuiElement (buildcraft.lib.gui.IGuiElement)2 GuiElementContainerHelp (buildcraft.lib.gui.elem.GuiElementContainerHelp)1 HelpPosition (buildcraft.lib.gui.help.ElementHelpInfo.HelpPosition)1 IGuiArea (buildcraft.lib.gui.pos.IGuiArea)1 IGuiPosition (buildcraft.lib.gui.pos.IGuiPosition)1 AutoGlScissor (buildcraft.lib.misc.GuiUtil.AutoGlScissor)1 ArrayList (java.util.ArrayList)1