Search in sources :

Example 16 with GuiRectangle

use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.

the class GuiEngineIron_BC8 method initGui.

@Override
public void initGui() {
    super.initGui();
    mainGui.shownElements.add(container.widgetTankFuel.createGuiElement(mainGui, new GuiRectangle(26, 18, 16, 60).offset(mainGui.rootElement), ICON_TANK_OVERLAY));
    mainGui.shownElements.add(container.widgetTankCoolant.createGuiElement(mainGui, new GuiRectangle(80, 18, 16, 60).offset(mainGui.rootElement), ICON_TANK_OVERLAY));
    mainGui.shownElements.add(container.widgetTankResidue.createGuiElement(mainGui, new GuiRectangle(134, 18, 16, 60).offset(mainGui.rootElement), ICON_TANK_OVERLAY));
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle)

Example 17 with GuiRectangle

use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.

the class GuideChapter method isMouseInside.

protected boolean isMouseInside() {
    IFontRenderer font = gui.getCurrentFont();
    String text = chapter.text;
    int width = (int) (font.getStringWidth(text) + getHoverWidth(0));
    int y = gui.minY + 20 * (gui.getChapterIndex(this) + 1);
    if (lastDrawn == EnumGuiSide.LEFT) {
        int x = gui.minX - width - 4 + 11;
        GuiRectangle drawRect = new GuiRectangle(x, y - 4, width + GuiGuide.CHAPTER_MARKER_LEFT.width, 16);
        if (drawRect.contains(gui.mouse)) {
            return true;
        }
    } else if (lastDrawn == EnumGuiSide.RIGHT) {
        int x = gui.minX + GuiGuide.PAGE_LEFT.width + GuiGuide.PAGE_RIGHT.width - 11;
        GuiRectangle drawRect = new GuiRectangle(x, y - 4, width + GuiGuide.CHAPTER_MARKER_RIGHT.width, 16);
        if (drawRect.contains(gui.mouse)) {
            return true;
        }
    }
    return false;
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) IFontRenderer(buildcraft.lib.client.guide.font.IFontRenderer)

Example 18 with GuiRectangle

use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.

the class GuidePageBase method handleMouseClick.

public void handleMouseClick(int x, int y, int width, int height, int mouseX, int mouseY, int mouseButton, int index, boolean isEditing) {
    // Even => first page, test page back button and first page text clicks
    if (index % 2 == 0) {
        if (index != 0) {
            GuiIcon icon = GuiGuide.TURN_BACK;
            GuiRectangle turnBox = new GuiRectangle(x, y + height, icon.width, icon.height);
            if (turnBox.contains(gui.mouse)) {
                lastPage();
            }
        }
    } else {
        // Odd => second page, test forward page button
        if (index + 1 < numPages) {
            GuiIcon icon = GuiGuide.TURN_FORWARDS;
            GuiRectangle turnBox = new GuiRectangle(x + width - icon.width, y + height, icon.width, icon.height);
            if (turnBox.contains(gui.mouse)) {
                nextPage();
            }
        }
    }
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) GuiIcon(buildcraft.lib.gui.GuiIcon)

Example 19 with GuiRectangle

use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.

the class GuideAssembly method handleMouseClick.

@Override
public PagePosition handleMouseClick(int x, int y, int width, int height, PagePosition current, int index, int mouseX, int mouseY) {
    if (current.pixel + PIXEL_HEIGHT > height) {
        current = current.newPage();
    }
    x += OFFSET.x;
    y += OFFSET.y + current.pixel;
    if (current.page == index) {
        for (int i = 0; i < input.length; i++) {
            GuiRectangle rect = ITEM_POSITION[i];
            ItemStack stack = input[i].get();
            testClickItemStack(stack, x + (int) rect.x, y + (int) rect.y);
        }
        testClickItemStack(output.get(), x + (int) OUT_POSITION.x, y + (int) OUT_POSITION.y);
    }
    current = current.nextLine(PIXEL_HEIGHT, height);
    return current;
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) ItemStack(net.minecraft.item.ItemStack) ChangingItemStack(buildcraft.lib.recipe.ChangingItemStack)

Example 20 with GuiRectangle

use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.

the class GuiEmzuliPipe_BC8 method addButton.

private void addButton(SlotIndex index, int x, int y) {
    Supplier<EnumDyeColor> getter = () -> container.behaviour.slotColours.get(index);
    Consumer<EnumDyeColor> setter = c -> container.paintWidgets.get(index).setColour(c);
    IGuiPosition elem = mainGui.rootElement.offset(x, y);
    GuiButtonDrawable button = new GuiButtonDrawable(mainGui, index.name(), elem, PAINT_BUTTON_BUILDER);
    button.registerListener((b, key) -> {
        final EnumDyeColor old = getter.get();
        EnumDyeColor nColour;
        switch(key) {
            case 0:
                {
                    nColour = ColourUtil.getNextOrNull(old);
                    break;
                }
            case 1:
                {
                    nColour = ColourUtil.getPrevOrNull(old);
                    break;
                }
            case 2:
                {
                    nColour = null;
                    break;
                }
            default:
                {
                    return;
                }
        }
        setter.accept(nColour);
    });
    mainGui.shownElements.add(button);
    // Button paintbrush
    IGuiArea area = new GuiRectangle(20, 20).offset(elem);
    ISimpleDrawable paintIcon = (px, py) -> {
        EnumDyeColor colour = getter.get();
        if (colour == null) {
            ICON_NO_PAINT.drawAt(px + 2, py + 2);
        } else {
            ISprite sprite = BCTransportSprites.ACTION_PIPE_COLOUR[colour.ordinal()];
            GuiIcon.drawAt(sprite, px + 2, py + 2, 16);
        }
    };
    mainGui.shownElements.add(new GuiElementDrawable(mainGui, area, paintIcon, false));
    ITooltipElement tooltips = list -> {
        EnumDyeColor colour = getter.get();
        String line;
        if (colour == null) {
            line = LocaleUtil.localize("gui.pipes.emzuli.nopaint");
        } else {
            line = LocaleUtil.localize("gui.pipes.emzuli.paint", ColourUtil.getTextFullTooltip(colour));
        }
        list.add(new ToolTip(line));
    };
    mainGui.shownElements.add(new GuiElementToolTip(mainGui, area, tooltips));
}
Also used : ITooltipElement(buildcraft.lib.gui.ITooltipElement) Supplier(java.util.function.Supplier) ISprite(buildcraft.api.core.render.ISprite) GuiIcon(buildcraft.lib.gui.GuiIcon) SlotIndex(buildcraft.transport.pipe.behaviour.PipeBehaviourEmzuli.SlotIndex) GuiBC8(buildcraft.lib.gui.GuiBC8) GuiElementDrawable(buildcraft.lib.gui.elem.GuiElementDrawable) GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) BCLibSprites(buildcraft.lib.BCLibSprites) ISimpleDrawable(buildcraft.lib.gui.ISimpleDrawable) GuiElementToolTip(buildcraft.lib.gui.GuiElementToolTip) BCTransportSprites(buildcraft.transport.BCTransportSprites) LocaleUtil(buildcraft.lib.misc.LocaleUtil) PipeBehaviourEmzuli(buildcraft.transport.pipe.behaviour.PipeBehaviourEmzuli) Consumer(java.util.function.Consumer) ToolTip(buildcraft.lib.gui.elem.ToolTip) EnumDyeColor(net.minecraft.item.EnumDyeColor) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ResourceLocation(net.minecraft.util.ResourceLocation) ColourUtil(buildcraft.lib.misc.ColourUtil) ContainerEmzuliPipe_BC8(buildcraft.transport.container.ContainerEmzuliPipe_BC8) BCCoreSprites(buildcraft.core.BCCoreSprites) GuiButtonDrawable(buildcraft.lib.gui.button.GuiButtonDrawable) IGuiArea(buildcraft.lib.gui.pos.IGuiArea) IGuiPosition(buildcraft.lib.gui.pos.IGuiPosition) GuiElementToolTip(buildcraft.lib.gui.GuiElementToolTip) ToolTip(buildcraft.lib.gui.elem.ToolTip) IGuiArea(buildcraft.lib.gui.pos.IGuiArea) ISimpleDrawable(buildcraft.lib.gui.ISimpleDrawable) ITooltipElement(buildcraft.lib.gui.ITooltipElement) GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) ISprite(buildcraft.api.core.render.ISprite) GuiButtonDrawable(buildcraft.lib.gui.button.GuiButtonDrawable) GuiElementDrawable(buildcraft.lib.gui.elem.GuiElementDrawable) EnumDyeColor(net.minecraft.item.EnumDyeColor) GuiElementToolTip(buildcraft.lib.gui.GuiElementToolTip) IGuiPosition(buildcraft.lib.gui.pos.IGuiPosition)

Aggregations

GuiRectangle (buildcraft.lib.gui.pos.GuiRectangle)23 ItemStack (net.minecraft.item.ItemStack)5 ISimpleDrawable (buildcraft.lib.gui.ISimpleDrawable)4 IGuiArea (buildcraft.lib.gui.pos.IGuiArea)4 ChangingItemStack (buildcraft.lib.recipe.ChangingItemStack)4 GuiIcon (buildcraft.lib.gui.GuiIcon)3 ISprite (buildcraft.api.core.render.ISprite)2 IFontRenderer (buildcraft.lib.client.guide.font.IFontRenderer)2 FunctionContext (buildcraft.lib.expression.FunctionContext)2 GuiButtonDrawable (buildcraft.lib.gui.button.GuiButtonDrawable)2 GuiElementDrawable (buildcraft.lib.gui.elem.GuiElementDrawable)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 BCCoreSprites (buildcraft.core.BCCoreSprites)1 WidgetListSlot (buildcraft.core.list.ContainerList.WidgetListSlot)1 BCLibSprites (buildcraft.lib.BCLibSprites)1 FormatString (buildcraft.lib.client.guide.node.FormatString)1 Title (buildcraft.lib.client.guide.parts.contents.ContentsList.Title)1 SubHeader (buildcraft.lib.client.guide.parts.contents.ContentsList.Title.SubHeader)1 PageLink (buildcraft.lib.client.guide.parts.contents.ContentsList.Title.SubHeader.PageLink)1 SpriteRaw (buildcraft.lib.client.sprite.SpriteRaw)1