Search in sources :

Example 1 with ControlTabIcon

use of binnie.core.gui.minecraft.control.ControlTabIcon 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

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