Search in sources :

Example 1 with HelpPosition

use of buildcraft.lib.gui.help.ElementHelpInfo.HelpPosition 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 HelpPosition

use of buildcraft.lib.gui.help.ElementHelpInfo.HelpPosition 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)

Aggregations

IGuiElement (buildcraft.lib.gui.IGuiElement)2 HelpPosition (buildcraft.lib.gui.help.ElementHelpInfo.HelpPosition)2 ArrayList (java.util.ArrayList)2 ISprite (buildcraft.api.core.render.ISprite)1 SpriteNineSliced (buildcraft.lib.client.sprite.SpriteNineSliced)1 GuiElementContainerHelp (buildcraft.lib.gui.elem.GuiElementContainerHelp)1 IGuiArea (buildcraft.lib.gui.pos.IGuiArea)1