Search in sources :

Example 11 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class RenderUtil method drawText.

public static void drawText(final IArea area, final TextJustification justification, final String text, final int colour) {
    final IPoint pos = area.pos();
    if (area.size().xPos() <= 0.0f) {
        return;
    }
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    final List<String> wrappedStrings = fontRenderer.listFormattedStringToWidth(text, area.size().xPos());
    final float totalHeight = wrappedStrings.size() * getTextHeight();
    float posY = pos.yPos();
    if (area.size().yPos() > totalHeight) {
        posY += (area.size().yPos() - totalHeight) * justification.getYOffset();
    }
    for (final String string : wrappedStrings) {
        final float stringWidth = getTextWidth(string);
        float posX = area.size().xPos() - stringWidth;
        posX *= justification.getXOffset();
        GlStateManager.disableDepth();
        fontRenderer.drawString(string, (int) (pos.xPos() + posX), (int) posY, colour);
        posY += getTextHeight();
    }
    GlStateManager.color(1.0f, 1.0f, 1.0f);
}
Also used : IPoint(binnie.core.api.gui.IPoint) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 12 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class Widget method setOffset.

@Override
public final void setOffset(final IPoint vector) {
    if (vector != this.offset) {
        this.offset = new Point(vector);
        this.callEvent(new EventWidget.ChangeOffset(this));
    }
}
Also used : EventWidget(binnie.core.gui.events.EventWidget) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point)

Example 13 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class Widget method calculateIsMouseOver.

@Override
public final boolean calculateIsMouseOver() {
    final IPoint mouse = this.getRelativeMousePosition();
    if (!this.cropped || this.cropArea == null) {
        return this.isMouseOverWidget(mouse);
    }
    final IWidget cropRelative = (this.cropWidget != null) ? this.cropWidget : this;
    final IPoint pos = Point.sub(cropRelative.getAbsolutePosition(), this.getAbsolutePosition());
    final IPoint size = new Point(this.cropArea.size().xPos(), this.cropArea.size().yPos());
    final boolean inCrop = mouse.xPos() > pos.xPos() && mouse.yPos() > pos.yPos() && mouse.xPos() < pos.xPos() + size.xPos() && mouse.yPos() < pos.yPos() + size.yPos();
    return inCrop && this.isMouseOverWidget(mouse);
}
Also used : IPoint(binnie.core.api.gui.IPoint) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) IWidget(binnie.core.api.gui.IWidget)

Example 14 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class ControlLiquidTank method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    CraftGUI.RENDER.texture(this.horizontal ? CraftGUITexture.HORIZONTAL_LIQUID_TANK : CraftGUITexture.LIQUID_TANK, Point.ZERO);
    GuiCraftGUI gui = Window.get(this).getGui();
    if (this.isMouseOver() && gui.isHelpMode()) {
        final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.HELP);
        RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
    } else if (ControlLiquidTank.tankError.contains(this.tankID)) {
        final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.ERROR);
        RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
    } else if (this.getTopParent().getMousedOverWidget() == this) {
        if (!gui.getDraggedItem().isEmpty()) {
            RenderUtil.drawGradientRect(this.getArea().inset(1), -1426089575, -1426089575);
        } else {
            RenderUtil.drawGradientRect(this.getArea().inset(1), -2130706433, -2130706433);
        }
    }
    if (this.isTankValid()) {
        final int height = this.horizontal ? 16 : 58;
        final int squaled = Math.round(height * (this.getTank().getAmount() / this.getTank().getCapacity()));
        final int yPos = height + 1;
        final Fluid fluid = this.getTank().getLiquid().getFluid();
        final int hex = fluid.getColor(this.getTank().getLiquid());
        final int r = (hex & 0xFF0000) >> 16;
        final int g = (hex & 0xFF00) >> 8;
        final int b = hex & 0xFF;
        GlStateManager.color(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
        GlStateManager.enableBlend();
        {
            GlStateManager.blendFunc(770, 771);
            final IPoint pos = this.getAbsolutePosition();
            final IPoint offset = new Point(0, height - squaled);
            final IArea limited = this.getArea().inset(1);
            if (this.horizontal) {
                limited.setSize(new Point(limited.width() - 1, limited.height()));
            }
            CraftGUI.RENDER.limitArea(new Area(limited.pos().add(pos).add(offset), limited.size().sub(offset)), guiWidth, guiHeight);
            GL11.glEnable(GL11.GL_SCISSOR_TEST);
            {
                BinnieCore.getBinnieProxy().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
                for (int y = 0; y < height; y += 16) {
                    for (int x = 0; x < (this.horizontal ? 58 : 16); x += 16) {
                        final TextureAtlasSprite icon = BinnieCore.getBinnieProxy().getTextureAtlasSprite(fluid.getStill());
                        RenderUtil.drawSprite(new Point(1 + x, 1 + y), icon);
                    }
                }
            }
            GL11.glDisable(GL11.GL_SCISSOR_TEST);
        }
        GlStateManager.disableBlend();
        GlStateManager.color(1, 1, 1, 1);
    }
}
Also used : Area(binnie.core.gui.geometry.Area) IArea(binnie.core.api.gui.IArea) IArea(binnie.core.api.gui.IArea) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Fluid(net.minecraftforge.fluids.Fluid) GuiCraftGUI(binnie.core.gui.minecraft.GuiCraftGUI) IPoint(binnie.core.api.gui.IPoint) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 15 with IPoint

use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.

the class TextureRenderer method preRender.

public final void preRender(final IWidget widget, int guiWidth, int guiHeight) {
    GlStateManager.pushMatrix();
    GlStateManager.translate(widget.getPosition().xPos(), widget.getPosition().yPos(), 0.0f);
    RenderUtil.setColour(widget.getColor());
    if (widget.isCroppedWidet()) {
        final IWidget cropRelative = (widget.getCropWidget() != null) ? widget.getCropWidget() : widget;
        final IPoint pos = cropRelative.getAbsolutePosition();
        final IArea cropZone = widget.getCroppedZone();
        GL11.glEnable(GL11.GL_SCISSOR_TEST);
        this.limitArea(new Area(pos.add(cropZone.pos()), cropZone.size()), guiWidth, guiHeight);
    }
    GlStateManager.disableDepth();
}
Also used : Area(binnie.core.gui.geometry.Area) IArea(binnie.core.api.gui.IArea) IArea(binnie.core.api.gui.IArea) IPoint(binnie.core.api.gui.IPoint) IWidget(binnie.core.api.gui.IWidget)

Aggregations

IPoint (binnie.core.api.gui.IPoint)17 Point (binnie.core.gui.geometry.Point)10 IArea (binnie.core.api.gui.IArea)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 Area (binnie.core.gui.geometry.Area)4 EventWidget (binnie.core.gui.events.EventWidget)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 IWidget (binnie.core.api.gui.IWidget)2 ItemStack (net.minecraft.item.ItemStack)2 Fluid (net.minecraftforge.fluids.Fluid)2 IFieldKitPlugin (binnie.core.api.genetics.IFieldKitPlugin)1 ControlText (binnie.core.gui.controls.ControlText)1 WindowAbstractDatabase (binnie.core.gui.database.WindowAbstractDatabase)1 GuiCraftGUI (binnie.core.gui.minecraft.GuiCraftGUI)1 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)1 FenceType (binnie.extratrees.blocks.decor.FenceType)1 IPlankType (binnie.extratrees.wood.planks.IPlankType)1 IChromosomeType (forestry.api.genetics.IChromosomeType)1 Map (java.util.Map)1 Block (net.minecraft.block.Block)1