Search in sources :

Example 11 with Position

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

the class GridConnection method draw.

public void draw() {
    Position position = getPosition();
    ElementOrientation orientation = getOrientation();
    connectionType.icon.drawRotated(position.x, position.y, elementSize, new PositionedRect(Position.ORIGIN, elementSize), orientation.rotationValue);
}
Also used : Position(gregtech.api.util.Position) PositionedRect(gregtech.api.util.PositionedRect)

Example 12 with Position

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

the class GridConnection method computePosition.

private Position computePosition() {
    Transformation orientation = TextureArea.createOrientation(parentElementSize, parentOrientation.rotationValue);
    PositionedRect parentRect = TextureArea.transformRect(orientation, parentElementRect);
    switch(getOrientation()) {
        case LEFT:
            return new Position(0, connectionOffset);
        case RIGHT:
            return new Position(parentRect.position.x + parentRect.size.width, connectionOffset);
        case TOP:
            return new Position(connectionOffset, 0);
        case BOTTOM:
            return new Position(connectionOffset, parentRect.position.y + parentRect.size.height);
        default:
            return Position.ORIGIN;
    }
}
Also used : Transformation(codechicken.lib.vec.Transformation) Position(gregtech.api.util.Position) PositionedRect(gregtech.api.util.PositionedRect)

Example 13 with Position

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

the class SliderWidget method mouseClicked.

@Override
public boolean mouseClicked(int mouseX, int mouseY, int button) {
    if (isMouseOverElement(mouseX, mouseY)) {
        Position pos = getPosition();
        Size size = getSize();
        this.sliderPosition = (float) (mouseX - (pos.x + 4)) / (float) (size.width - 8);
        if (this.sliderPosition < 0.0F) {
            this.sliderPosition = 0.0F;
        }
        if (this.sliderPosition > 1.0F) {
            this.sliderPosition = 1.0F;
        }
        this.displayString = this.getDisplayString();
        writeClientAction(1, buffer -> buffer.writeFloat(sliderPosition));
        this.isMouseDown = true;
        return true;
    }
    return false;
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size)

Example 14 with Position

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

the class TankWidget method drawInBackground.

@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    Position pos = getPosition();
    Size size = getSize();
    if (backgroundTexture != null) {
        for (TextureArea textureArea : backgroundTexture) {
            textureArea.draw(pos.x, pos.y, size.width, size.height);
        }
    }
    // do not draw fluids if they are handled by JEI - it draws them itself
    if (lastFluidInTank != null && lastFluidInTank.amount > 0 && !gui.isJEIHandled) {
        GlStateManager.disableBlend();
        RenderUtil.drawFluidForGui(lastFluidInTank, alwaysShowFull ? lastFluidInTank.amount : lastTankCapacity, pos.x + fluidRenderOffset, pos.y + fluidRenderOffset, size.width - fluidRenderOffset, size.height - fluidRenderOffset);
        int bucketsAmount = lastFluidInTank.amount / 1000;
        if (alwaysShowFull && !hideTooltip && bucketsAmount > 0) {
            String s = String.valueOf(bucketsAmount);
            FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
            fontRenderer.drawStringWithShadow(s, pos.x + 1 + size.width - 2 - fontRenderer.getStringWidth(s), pos.y + (size.height / 3) + 3, 0xFFFFFF);
        }
        GlStateManager.enableBlend();
        GlStateManager.color(1.0f, 1.0f, 1.0f);
    }
    if (overlayTexture != null) {
        overlayTexture.draw(pos.x, pos.y, size.width, size.height);
    }
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size) TextureArea(gregtech.api.gui.resources.TextureArea) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 15 with Position

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

the class ToggleButtonWidget method drawInBackground.

@Override
@SideOnly(Side.CLIENT)
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    Position pos = getPosition();
    Size size = getSize();
    if (buttonTexture instanceof SizedTextureArea) {
        ((SizedTextureArea) buttonTexture).drawHorizontalCutSubArea(pos.x, pos.y, size.width, size.height, isPressed ? 0.5 : 0.0, 0.5);
    } else {
        buttonTexture.drawSubArea(pos.x, pos.y, size.width, size.height, 0.0, isPressed ? 0.5 : 0.0, 1.0, 0.5);
    }
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size) SizedTextureArea(gregtech.api.gui.resources.SizedTextureArea) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

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