use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.
the class RenderUtil method drawText.
public static void drawText(final IArea area, final TextJustification justification, final String text, final int colour) {
final IPoint pos = area.pos();
if (area.size().xPos() <= 0.0f) {
return;
}
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
final List<String> wrappedStrings = fontRenderer.listFormattedStringToWidth(text, area.size().xPos());
final float totalHeight = wrappedStrings.size() * getTextHeight();
float posY = pos.yPos();
if (area.size().yPos() > totalHeight) {
posY += (area.size().yPos() - totalHeight) * justification.getYOffset();
}
for (final String string : wrappedStrings) {
final float stringWidth = getTextWidth(string);
float posX = area.size().xPos() - stringWidth;
posX *= justification.getXOffset();
GlStateManager.disableDepth();
fontRenderer.drawString(string, (int) (pos.xPos() + posX), (int) posY, colour);
posY += getTextHeight();
}
GlStateManager.color(1.0f, 1.0f, 1.0f);
}
use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.
the class Widget method setOffset.
@Override
public final void setOffset(final IPoint vector) {
if (vector != this.offset) {
this.offset = new Point(vector);
this.callEvent(new EventWidget.ChangeOffset(this));
}
}
use of binnie.core.api.gui.IPoint in project Binnie by ForestryMC.
the class Widget method calculateIsMouseOver.
@Override
public final boolean calculateIsMouseOver() {
final IPoint mouse = this.getRelativeMousePosition();
if (!this.cropped || this.cropArea == null) {
return this.isMouseOverWidget(mouse);
}
final IWidget cropRelative = (this.cropWidget != null) ? this.cropWidget : this;
final IPoint pos = Point.sub(cropRelative.getAbsolutePosition(), this.getAbsolutePosition());
final IPoint size = new Point(this.cropArea.size().xPos(), this.cropArea.size().yPos());
final boolean inCrop = mouse.xPos() > pos.xPos() && mouse.yPos() > pos.yPos() && mouse.xPos() < pos.xPos() + size.xPos() && mouse.yPos() < pos.yPos() + size.yPos();
return inCrop && this.isMouseOverWidget(mouse);
}
use of binnie.core.api.gui.IPoint 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);
}
}
use of binnie.core.api.gui.IPoint 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();
}
Aggregations