Search in sources :

Example 1 with ITexture

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

the class Texture method crop.

@Override
public ITexture crop(final IBorder crop) {
    final Texture copy = new Texture(this.area, this.padding, this.border, this.binnieTexture);
    if (crop.getBottom() > 0) {
        copy.border.setBottom(0);
        copy.padding.setBottom(copy.padding.getBottom() - Math.min(crop.getBottom(), copy.padding.getBottom()));
        copy.area.setHeight(copy.area.height() - crop.getBottom());
    }
    if (crop.getTop() > 0) {
        copy.border.setTop(0);
        copy.padding.setTop(copy.padding.getTop() - Math.min(crop.getTop(), copy.padding.getTop()));
        copy.area.setHeight(copy.area.height() - crop.getTop());
        copy.area.setYPos(copy.area.yPos() + crop.getTop());
    }
    if (crop.getRight() > 0) {
        copy.border.setRight(0);
        copy.padding.setRight(copy.padding.getRight() - Math.min(crop.getRight(), copy.padding.getRight()));
        copy.area.setWidth(copy.area.width() - crop.getRight());
    }
    if (crop.getLeft() > 0) {
        copy.border.setLeft(0);
        copy.padding.setLeft(copy.padding.getLeft() - Math.min(crop.getLeft(), copy.padding.getLeft()));
        copy.area.setWidth(copy.area.width() - crop.getLeft());
        copy.area.setXPos(copy.area.xPos() + crop.getLeft());
    }
    return copy;
}
Also used : IBinnieTexture(binnie.core.resource.IBinnieTexture) ITexture(binnie.core.api.gui.ITexture)

Example 2 with ITexture

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

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

the class ControlChromosome method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    if (breedingSystem == null) {
        return;
    }
    super.onRenderBackground(guiWidth, guiHeight);
    ITexture texture = getTypeTexture();
    CraftGUI.RENDER.texture(texture, Point.ZERO);
}
Also used : ITexture(binnie.core.api.gui.ITexture) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with ITexture

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

the class ControlTab method onRenderBackground.

@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
    Object texture = CraftGUITexture.TAB_DISABLED;
    if (this.isMouseOver()) {
        texture = CraftGUITexture.TAB_HIGHLIGHTED;
    } else if (this.isCurrentSelection()) {
        texture = CraftGUITexture.TAB;
    }
    final ITexture lTexture = CraftGUI.RENDER.getTexture(texture);
    final Alignment alignment = this.getTabPosition();
    ITexture iTexture = lTexture.crop(alignment, 8);
    final IArea area = this.getArea();
    if (texture == CraftGUITexture.TAB_DISABLED) {
        if (alignment == Alignment.TOP || alignment == Alignment.LEFT) {
            area.setPosition(area.getPosition().sub(new Point(4 * alignment.x(), 4 * alignment.y())));
            area.setSize(area.getSize().add(new Point(4 * alignment.x(), 4 * alignment.y())));
        } else {
            area.setSize(area.getSize().sub(new Point(4 * alignment.x(), 4 * alignment.y())));
        }
    }
    CraftGUI.RENDER.texture(iTexture, area);
    if (this instanceof ControlTabIcon) {
        final ControlTabIcon icon = (ControlTabIcon) this;
        final ControlItemDisplay item = (ControlItemDisplay) getFirstChild();
        if (texture == CraftGUITexture.TAB_DISABLED) {
            item.setColor(-1431655766);
        } else {
            item.setColor(-1);
        }
        if (icon.hasOutline()) {
            iTexture = CraftGUI.RENDER.getTexture(CraftGUITexture.TAB_OUTLINE);
            iTexture = iTexture.crop(alignment, 8);
            RenderUtil.setColour(icon.getOutlineColour());
            CraftGUI.RENDER.texture(iTexture, area.inset(2));
        }
    }
}
Also used : Alignment(binnie.core.api.gui.Alignment) ControlItemDisplay(binnie.core.gui.minecraft.control.ControlItemDisplay) IArea(binnie.core.api.gui.IArea) Point(binnie.core.gui.geometry.Point) ControlTabIcon(binnie.core.gui.minecraft.control.ControlTabIcon) CraftGUITexture(binnie.core.gui.resource.textures.CraftGUITexture) ITexture(binnie.core.api.gui.ITexture) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ITexture (binnie.core.api.gui.ITexture)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 IArea (binnie.core.api.gui.IArea)2 Point (binnie.core.gui.geometry.Point)2 CraftGUITexture (binnie.core.gui.resource.textures.CraftGUITexture)2 Alignment (binnie.core.api.gui.Alignment)1 IPoint (binnie.core.api.gui.IPoint)1 Area (binnie.core.gui.geometry.Area)1 ControlItemDisplay (binnie.core.gui.minecraft.control.ControlItemDisplay)1 ControlTabIcon (binnie.core.gui.minecraft.control.ControlTabIcon)1 IBinnieTexture (binnie.core.resource.IBinnieTexture)1