Search in sources :

Example 6 with Position

use of gregtech.api.util.Position in project GregTech by GregTechCE.

the class DynamicLabelWidget method drawInForeground.

@Override
@SideOnly(Side.CLIENT)
public void drawInForeground(int mouseX, int mouseY) {
    String suppliedText = textSupplier.get();
    if (!suppliedText.equals(lastTextValue)) {
        this.lastTextValue = suppliedText;
        updateSize();
    }
    String[] split = textSupplier.get().split("\n");
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    Position position = getPosition();
    for (int i = 0; i < split.length; i++) {
        fontRenderer.drawString(split[i], position.x, position.y + (i * (fontRenderer.FONT_HEIGHT + 2)), color);
    }
}
Also used : Position(gregtech.api.util.Position) FontRenderer(net.minecraft.client.gui.FontRenderer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 7 with Position

use of gregtech.api.util.Position in project GregTech by GregTechCE.

the class ImageWidget method drawInBackground.

@Override
@SideOnly(Side.CLIENT)
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    if (!this.isVisible || area == null)
        return;
    Position position = getPosition();
    Size size = getSize();
    area.draw(position.x, position.y, size.width, size.height);
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with Position

use of gregtech.api.util.Position in project GregTech by GregTechCE.

the class LabelWidget method drawInBackground.

@Override
@SideOnly(Side.CLIENT)
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    String resultText = getResultText();
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    Position pos = getPosition();
    if (!xCentered) {
        fontRenderer.drawString(resultText, pos.x, pos.y, color);
    } else {
        fontRenderer.drawString(resultText, pos.x - fontRenderer.getStringWidth(resultText) / 2, pos.y, color);
    }
    GlStateManager.color(1.0f, 1.0f, 1.0f);
}
Also used : Position(gregtech.api.util.Position) FontRenderer(net.minecraft.client.gui.FontRenderer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with Position

use of gregtech.api.util.Position in project GregTech by GregTechCE.

the class ScrollableListWidget method drawInBackground.

@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    // make sure mouse is not hovered on any element when outside of bounds
    if (!isPositionInsideScissor(mouseX, mouseY)) {
        mouseX = Integer.MAX_VALUE;
        mouseY = Integer.MAX_VALUE;
    }
    int finalMouseX = mouseX;
    int finalMouseY = mouseY;
    Position position = getPosition();
    Size size = getSize();
    int paneSize = scrollPaneWidth;
    int scrollX = position.x + size.width - paneSize;
    drawSolidRect(scrollX, position.y, paneSize, size.height, 0xFF666666);
    drawSolidRect(scrollX + 1, position.y + 1, paneSize - 2, size.height - 2, 0xFF888888);
    int maxScrollOffset = totalListHeight - getSize().height;
    float scrollPercent = maxScrollOffset == 0 ? 0 : scrollOffset / (maxScrollOffset * 1.0f);
    int scrollSliderHeight = 14;
    int scrollSliderY = Math.round(position.y + (size.height - scrollSliderHeight) * scrollPercent);
    drawGradientRect(scrollX + 1, scrollSliderY, paneSize - 2, scrollSliderHeight, 0xFF555555, 0xFF454545);
    RenderUtil.useScissor(position.x, position.y, size.width - paneSize, size.height, () -> super.drawInBackground(finalMouseX, finalMouseY, context));
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size)

Example 10 with Position

use of gregtech.api.util.Position in project GregTech by GregTechCE.

the class SimpleTextWidget method drawInBackground.

@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    String text = formatLocale.isEmpty() ? (I18n.hasKey(lastText) ? I18n.format(lastText) : lastText) : I18n.format(formatLocale, lastText);
    Position position = getPosition();
    fontRenderer.drawString(text, position.x - fontRenderer.getStringWidth(text) / 2, position.y - fontRenderer.FONT_HEIGHT / 2, color);
    GlStateManager.color(1.0f, 1.0f, 1.0f);
}
Also used : Position(gregtech.api.util.Position) FontRenderer(net.minecraft.client.gui.FontRenderer)

Aggregations

Position (gregtech.api.util.Position)35 Size (gregtech.api.util.Size)19 FontRenderer (net.minecraft.client.gui.FontRenderer)9 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 Widget (gregtech.api.gui.Widget)4 PositionedRect (gregtech.api.util.PositionedRect)4 SizedTextureArea (gregtech.api.gui.resources.SizedTextureArea)3 Vector3 (codechicken.lib.vec.Vector3)2 INativeWidget (gregtech.api.gui.INativeWidget)2 TextureArea (gregtech.api.gui.resources.TextureArea)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Transformation (codechicken.lib.vec.Transformation)1 IItemInfo (gregtech.common.inventory.IItemInfo)1 ArrayList (java.util.ArrayList)1 GuiTextField (net.minecraft.client.gui.GuiTextField)1 ItemStack (net.minecraft.item.ItemStack)1