Search in sources :

Example 6 with GuiRectangle

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

the class GuidePageBase method renderPage.

protected void renderPage(int x, int y, int width, int height, int index) {
    // Even => first page, draw page back button and first page index
    if (index % 2 == 0) {
        // Back page button
        if (index != 0) {
            GuiIcon icon = GuiGuide.TURN_BACK;
            GuiRectangle turnBox = new GuiRectangle(x, y + height, icon.width, icon.height);
            if (turnBox.contains(gui.mouse)) {
                icon = GuiGuide.TURN_BACK_HOVERED;
            }
            icon.drawAt(turnBox);
        }
        // Page index
        String text = (index + 1) + " / " + numPages;
        double textX = x + GuiGuide.PAGE_LEFT_TEXT.width / 2 - getFontRenderer().getStringWidth(text) / 2;
        getFontRenderer().drawString(text, (int) textX, (int) (y + height) + 6, 0);
    } else {
        // Back 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)) {
                icon = GuiGuide.TURN_FORWARDS_HOVERED;
            }
            icon.drawAt(turnBox);
        }
        // Page index
        if (index + 1 <= numPages) {
            String text = (index + 1) + " / " + numPages;
            double textX = x + (GuiGuide.PAGE_RIGHT_TEXT.width - getFontRenderer().getStringWidth(text)) / 2;
            getFontRenderer().drawString(text, (int) textX, (int) (y + height) + 6, 0);
        }
    }
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) GuiIcon(buildcraft.lib.gui.GuiIcon)

Example 7 with GuiRectangle

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

the class GuiElectronicLibrary method iterateSnapshots.

private void iterateSnapshots(ISnapshotIterator iterator) {
    List<Snapshot.Key> list = getSnapshots().getList();
    GuiRectangle rect = new GuiRectangle(mainGui.rootElement.getX() + 8, mainGui.rootElement.getY() + 22, 154, 8);
    for (int i = 0; i < list.size(); i++) {
        iterator.call(i, rect, list.get(i));
        rect = rect.offset(0, 8);
    }
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle)

Example 8 with GuiRectangle

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

the class GuiUtil method moveAreaToCentre.

public static IGuiArea moveAreaToCentre(IGuiArea area) {
    if (area instanceof GuiRectangle || area instanceof IConstantNode) {
        return moveRectangleToCentre(area.asImmutable());
    }
    DoubleSupplier posX = () -> (AREA_WHOLE_SCREEN.getWidth() - area.getWidth()) / 2;
    DoubleSupplier posY = () -> (AREA_WHOLE_SCREEN.getHeight() - area.getHeight()) / 2;
    return IGuiArea.create(posX, posY, area::getWidth, area::getHeight);
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle) DoubleSupplier(java.util.function.DoubleSupplier) IConstantNode(buildcraft.lib.expression.api.IConstantNode)

Example 9 with GuiRectangle

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

the class GuiUtil method scissor0.

private static void scissor0() {
    GuiRectangle total = null;
    for (GuiRectangle rect2 : scissorRegions) {
        if (total == null) {
            total = rect2;
            continue;
        }
        double minX = Math.max(total.x, rect2.x);
        double minY = Math.max(total.y, rect2.y);
        double maxX = Math.min(total.getEndX(), rect2.getEndX());
        double maxY = Math.min(total.getEndY(), rect2.getEndY());
        total = new GuiRectangle(minX, minY, maxX - minX, maxY - minY);
    }
    if (total == null) {
        throw new IllegalStateException("Cannot call scissor0 when there are no more regions!");
    }
    scissor0(total);
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle)

Example 10 with GuiRectangle

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

the class GuiElementStatementSource method iterateSlots.

private void iterateSlots(ISlotIter<S> iter) {
    int dx = left ? -1 : 1;
    int sx = left ? 3 : 0;
    int ex = sx + dx * 4;
    int x = sx;
    int y = 0;
    for (StatementGroup<S> group : ctx.getAllPossible()) {
        int visited = 0;
        for (S slot : group.getValues()) {
            double px = getX() + x * 18;
            double py = getY() + y * 18;
            iter.iterate(slot, new GuiRectangle(px, py, 18, 18));
            visited++;
            x += dx;
            if (x == ex) {
                x = sx;
                y++;
            }
        }
        if (visited > 0 && x != sx) {
            x = sx;
            y++;
        }
    }
}
Also used : GuiRectangle(buildcraft.lib.gui.pos.GuiRectangle)

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