use of binnie.core.api.gui.IArea 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));
}
use of binnie.core.api.gui.IArea in project Binnie by ForestryMC.
the class ControlEnergyBar method onRenderBackground.
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
CraftGUI.RENDER.texture(CraftGUITexture.ENERGY_BAR_BACK, this.getArea());
final float percentage = this.getPercentage() / 100.0f;
int colourFromPercentage = this.getColourFromPercentage(percentage);
RenderUtil.setColour(colourFromPercentage);
final IArea area = this.getArea();
switch(this.direction) {
case TOP:
case BOTTOM:
{
IPoint fullSize = area.size();
final int height = Math.round(fullSize.yPos() * percentage);
area.setSize(new Point(fullSize.xPos(), height));
area.setYPos(fullSize.yPos() - height);
break;
}
case LEFT:
case RIGHT:
{
final int width = Math.round(area.size().xPos() * percentage);
area.setSize(new Point(width, area.size().yPos()));
break;
}
}
if (this.isMouseOver() && Window.get(this).getGui().isHelpMode()) {
final int c = -1442840576 + MinecraftTooltip.getOutline(Tooltip.Type.HELP);
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
} else if (ControlEnergyBar.isError) {
final int c = -1442840576 + MinecraftTooltip.getOutline(MinecraftTooltip.Type.ERROR);
RenderUtil.drawGradientRect(this.getArea().inset(1), c, c);
}
CraftGUI.RENDER.texture(CraftGUITexture.ENERGY_BAR_GLOW, area);
GlStateManager.color(1, 1, 1, 1);
CraftGUI.RENDER.texture(CraftGUITexture.ENERGY_BAR_GLASS, this.getArea());
}
use of binnie.core.api.gui.IArea in project Binnie by ForestryMC.
the class TopLevelWidget method getQueuedWidgets.
private Collection<IWidget> getQueuedWidgets(final IWidget widget) {
List<IWidget> widgets = new ArrayList<>();
boolean addChildren = true;
IArea croppedZone = widget.getCroppedZone();
if (croppedZone != null) {
addChildren = croppedZone.contains(widget.getCropWidget().getRelativeMousePosition());
}
if (addChildren) {
ListIterator<IWidget> iterator = widget.getChildren().listIterator(widget.getChildren().size());
while (iterator.hasPrevious()) {
final IWidget child = iterator.previous();
widgets.addAll(this.getQueuedWidgets(child));
}
}
widgets.add(widget);
return widgets;
}
use of binnie.core.api.gui.IArea in project Binnie by ForestryMC.
the class ControlBreedingProgress method onRenderBackground.
@Override
@SideOnly(Side.CLIENT)
public void onRenderBackground(int guiWidth, int guiHeight) {
CraftGUI.RENDER.texture(CraftGUITexture.PANEL_BLACK, this.getArea());
final IArea area = this.getArea().inset(1);
area.setSize(new Point(Math.round(area.size().xPos() * this.percentage), area.size().yPos()));
RenderUtil.setColour(this.colour);
CraftGUI.RENDER.texture(ControlBreedingProgress.Progress, area);
}
use of binnie.core.api.gui.IArea 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));
}
}
}
Aggregations