Search in sources :

Example 11 with IArea

use of binnie.core.api.gui.IArea 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 12 with IArea

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

the class ControlSlide method setSlide.

public void setSlide(final boolean b) {
    this.slideActive = b;
    final IArea area = this.isSlideActive() ? this.expanded : this.shrunk;
    this.setSize(area.size());
    this.setPosition(area.pos());
}
Also used : IArea(binnie.core.api.gui.IArea)

Example 13 with IArea

use of binnie.core.api.gui.IArea 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)

Example 14 with IArea

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

the class TextureRenderer method texture.

public void texture(@Nullable final ITexture texture, final IPoint position) {
    if (texture == null) {
        return;
    }
    this.setTexture(texture);
    final IPoint point = position.sub(texture.getBorder().getLeft(), texture.getBorder().getTop());
    final IArea textureArea = texture.getArea().outset(texture.getBorder());
    GuiUtils.drawTexturedModalRect(point.xPos(), point.yPos(), textureArea.pos().xPos(), textureArea.pos().yPos(), textureArea.size().xPos(), textureArea.size().yPos(), 0);
}
Also used : IArea(binnie.core.api.gui.IArea) IPoint(binnie.core.api.gui.IPoint)

Aggregations

IArea (binnie.core.api.gui.IArea)14 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)8 IPoint (binnie.core.api.gui.IPoint)7 Point (binnie.core.gui.geometry.Point)6 Area (binnie.core.gui.geometry.Area)4 ITexture (binnie.core.api.gui.ITexture)2 IWidget (binnie.core.api.gui.IWidget)2 GuiCraftGUI (binnie.core.gui.minecraft.GuiCraftGUI)2 CraftGUITexture (binnie.core.gui.resource.textures.CraftGUITexture)2 ArrayList (java.util.ArrayList)2 Alignment (binnie.core.api.gui.Alignment)1 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)1 ControlTabIcon (binnie.core.gui.minecraft.control.ControlTabIcon)1 EnumMap (java.util.EnumMap)1 List (java.util.List)1 Map (java.util.Map)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 Fluid (net.minecraftforge.fluids.Fluid)1