Search in sources :

Example 6 with Area

use of binnie.core.gui.geometry.Area in project Binnie by ForestryMC.

the class ControlScrollBar method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    final Area renderArea = this.getRenderArea();
    Object texture = CraftGUITexture.SCROLL_DISABLED;
    if (this.isMouseOver()) {
        texture = CraftGUITexture.SCROLL_HIGHLIGHTED;
    } else if (this.isEnabled()) {
        texture = CraftGUITexture.SCROLL;
    }
    CraftGUI.RENDER.texture(texture, renderArea);
}
Also used : Area(binnie.core.gui.geometry.Area) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with Area

use of binnie.core.gui.geometry.Area in project Binnie by ForestryMC.

the class ControlSlide method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    super.onRenderBackground(guiWidth, guiHeight);
    if (this.label != null) {
        final int lw = RenderUtil.getTextWidth(this.label) + 16;
        final int lh = RenderUtil.getTextHeight() + 16;
        final boolean hor = this.anchor.x() != 0;
        final IArea ar = this.isSlideActive() ? this.expanded : this.shrunk;
        IArea tabArea = new Area(hor ? (-lh / 2) : (-lw / 2), hor ? (-lw / 2) : (-lh / 2), hor ? lh : lw, hor ? lw : lh);
        final Point shift = new Point(ar.width() * (1 - this.anchor.x()) / 2, ar.height() * (1 - this.anchor.y()) / 2);
        tabArea = tabArea.shift(shift.xPos() - (-3 + lh / 2) * this.anchor.x(), shift.yPos() - (-3 + lh / 2) * this.anchor.y());
        ITexture texture = CraftGUI.RENDER.getTexture(this.isSlideActive() ? CraftGUITexture.TAB : CraftGUITexture.TAB_DISABLED).crop(this.anchor.opposite(), 8);
        CraftGUI.RENDER.texture(texture, tabArea);
        texture = CraftGUI.RENDER.getTexture(CraftGUITexture.TAB_OUTLINE).crop(this.anchor.opposite(), 8);
        CraftGUI.RENDER.texture(texture, tabArea.inset(2));
        final Area labelArea = new Area(-lw / 2, 0, lw, lh);
        GlStateManager.pushMatrix();
        GlStateManager.translate(shift.xPos() + this.anchor.x() * 2, shift.yPos() + this.anchor.y() * 2, 0);
        if (this.anchor.x() != 0) {
            GlStateManager.rotate(90.0f, 0.0f, 0.0f, this.anchor.x());
        }
        if (this.anchor.y() > 0) {
            GlStateManager.translate(0.0f, -lh, 0.0f);
        }
        RenderUtil.drawText(labelArea, TextJustification.MIDDLE_CENTER, this.label, 16777215);
        GlStateManager.popMatrix();
    }
    CraftGUI.RENDER.texture(CraftGUITexture.WINDOW, this.getArea());
    final Object slideTexture = (this.anchor == Alignment.BOTTOM) ? CraftGUITexture.SLIDE_DOWN : ((this.anchor == Alignment.TOP) ? CraftGUITexture.SLIDE_UP : ((this.anchor == Alignment.LEFT) ? CraftGUITexture.SLIDE_LEFT : CraftGUITexture.SLIDE_RIGHT));
    CraftGUI.RENDER.texture(slideTexture, new Point((this.anchor.x() + 1) * this.getWidth() / 2 - 8, (this.anchor.y() + 1) * this.getHeight() / 2 - 8));
}
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) Point(binnie.core.gui.geometry.Point) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) CraftGUITexture(binnie.core.gui.resource.textures.CraftGUITexture) ITexture(binnie.core.api.gui.ITexture) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with Area

use of binnie.core.gui.geometry.Area in project Binnie by ForestryMC.

the class TextureRenderer method texturePercentage.

public void texturePercentage(final ITexture texture, final IArea area, final Alignment direction, final float percentage) {
    final int dist = (direction == Alignment.TOP || direction == Alignment.BOTTOM) ? Math.round(percentage * texture.height()) : Math.round(percentage * texture.width());
    final int dim = (direction == Alignment.TOP || direction == Alignment.BOTTOM) ? texture.height() : texture.width();
    int x = area.pos().xPos();
    int y = area.pos().yPos();
    int w = area.size().xPos();
    int h = area.size().yPos();
    switch(direction) {
        case TOP:
            {
                h *= percentage;
                break;
            }
        case RIGHT:
            {
                x += (1.0f - percentage) * w;
                w *= percentage;
                break;
            }
        case LEFT:
            {
                w *= percentage;
                break;
            }
        case BOTTOM:
            {
                y += h - (int) (percentage * h);
                h *= percentage;
                break;
            }
    }
    this.texture(texture.crop(direction, dim - dist), new Area(x, y, w, h));
}
Also used : Area(binnie.core.gui.geometry.Area) IArea(binnie.core.api.gui.IArea) IPoint(binnie.core.api.gui.IPoint)

Example 9 with Area

use of binnie.core.gui.geometry.Area in project Binnie by ForestryMC.

the class ControlLumbermillProgress method onRenderForeground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderForeground(int guiWidth, int guiHeight) {
    GlStateManager.disableLighting();
    final int sawX = (int) (63 * this.progress);
    CraftGUI.RENDER.texture(ControlLumbermillProgress.SAW, new Point(sawX, -8 + Math.round(6 * (float) Math.sin(this.animation))));
    final ItemStack item = Window.get(this).getInventory().getStackInSlot(LumbermillMachine.SLOT_LOG);
    if (item.isEmpty()) {
        return;
    }
    GlStateManager.disableLighting();
    Block block = null;
    if (item.getItem() instanceof ItemBlock) {
        block = ((ItemBlock) item.getItem()).getBlock();
    }
    if (block == null) {
        return;
    }
    // TODO RENDERING
    // final IIcon icon = block.getIcon(2, item.getItemDamage());
    TextureAtlasSprite icon = getWoodSprite(item);
    for (int i = 0; i < 4; ++i) {
        // CraftGUI.Render.iconBlock(new IPoint(1 + i * 16, 1), icon);
        RenderUtil.drawSprite(new Point(1 + i * 16, 1), icon);
    }
    final ItemStack result = LumbermillRecipeManager.getPlankProduct(item, Minecraft.getMinecraft().world);
    if (result.isEmpty()) {
        return;
    }
    Block block2 = null;
    if (result.getItem() instanceof ItemBlock) {
        block2 = ((ItemBlock) result.getItem()).getBlock();
    }
    if (block2 == null) {
        return;
    }
    // final IIcon icon2 = block2.getIcon(2, result.getItemDamage());
    TextureAtlasSprite sprite = getWoodSprite(result);
    final IPoint pos = this.getAbsolutePosition();
    CraftGUI.RENDER.limitArea(new Area(pos.add(Point.ZERO), new Point(Math.round(this.progress * 64) + 2, 18)), guiWidth, guiHeight);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    for (int j = 0; j < 4; ++j) {
        // TODO RENDERING
        RenderUtil.drawSprite(new Point(1 + j * 16, 1), sprite);
    }
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    CraftGUI.RENDER.texture(ControlLumbermillProgress.SAW, new Point(sawX, -8 + Math.round(6 * (float) Math.sin(this.animation))));
    CraftGUI.RENDER.texture(ControlLumbermillProgress.SAW_2, new Point(sawX + 2, -8 + Math.round(6 * (float) Math.sin(this.animation))));
}
Also used : Area(binnie.core.gui.geometry.Area) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IPoint(binnie.core.api.gui.IPoint) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) IPoint(binnie.core.api.gui.IPoint) Point(binnie.core.gui.geometry.Point) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 10 with Area

use of binnie.core.gui.geometry.Area in project Binnie by ForestryMC.

the class ControlDistilleryProgress method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    CraftGUI.RENDER.texture(DISTILLERY_BASE, Point.ZERO);
    CraftGUI.RENDER.texturePercentage(LIQUID_FLOW, new Area(18, 0, 38, 66), Alignment.LEFT, this.progress);
    final DistilleryLogic component = Machine.getInterface(DistilleryLogic.class, Window.get(this).getInventory());
    FluidStack stack = null;
    if (component != null) {
        stack = component.getCurrentFluid();
    }
    if (stack != null) {
        for (int y = 0; y < 4; ++y) {
            RenderUtil.drawFluid(new Point(1, 1 + y * 16), stack);
        }
    }
}
Also used : Area(binnie.core.gui.geometry.Area) FluidStack(net.minecraftforge.fluids.FluidStack) DistilleryLogic(binnie.extratrees.machines.distillery.DistilleryLogic) Point(binnie.core.gui.geometry.Point) Point(binnie.core.gui.geometry.Point) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

Area (binnie.core.gui.geometry.Area)34 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)22 Point (binnie.core.gui.geometry.Point)14 ControlText (binnie.core.gui.controls.ControlText)10 IPoint (binnie.core.api.gui.IPoint)6 IArea (binnie.core.api.gui.IArea)5 ItemStack (net.minecraft.item.ItemStack)5 WindowAbstractDatabase (binnie.core.gui.database.WindowAbstractDatabase)4 ControlPlayerInventory (binnie.core.gui.minecraft.control.ControlPlayerInventory)4 IAllele (forestry.api.genetics.IAllele)4 ControlScrollableContent (binnie.core.gui.controls.scroll.ControlScrollableContent)3 ControlSpeciesBox (binnie.core.gui.database.ControlSpeciesBox)3 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)3 ControlSlot (binnie.core.gui.minecraft.control.ControlSlot)3 IAlleleSpecies (forestry.api.genetics.IAlleleSpecies)3 IFlower (binnie.botany.api.genetics.IFlower)2 IBreedingSystem (binnie.core.api.genetics.IBreedingSystem)2 Control (binnie.core.gui.controls.core.Control)2 Border (binnie.core.gui.geometry.Border)2 GuiCraftGUI (binnie.core.gui.minecraft.GuiCraftGUI)2