Search in sources :

Example 11 with Size

use of gregtech.api.util.Size 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 12 with Size

use of gregtech.api.util.Size 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 13 with Size

use of gregtech.api.util.Size 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)

Example 14 with Size

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

the class Widget method isMouseOverElement.

public boolean isMouseOverElement(int mouseX, int mouseY) {
    Position position = getPosition();
    Size size = getSize();
    return isMouseOver(position.x, position.y, size.width, size.height, mouseX, mouseY);
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size)

Example 15 with Size

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

the class Widget method toRectangleBox.

public Rectangle toRectangleBox() {
    Position pos = getPosition();
    Size size = getSize();
    return new Rectangle(pos.x, pos.y, size.width, size.height);
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size)

Aggregations

Size (gregtech.api.util.Size)30 Position (gregtech.api.util.Position)19 FontRenderer (net.minecraft.client.gui.FontRenderer)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 Vector3 (codechicken.lib.vec.Vector3)3 SizedTextureArea (gregtech.api.gui.resources.SizedTextureArea)3 Widget (gregtech.api.gui.Widget)2 TextureArea (gregtech.api.gui.resources.TextureArea)2 PositionedRect (gregtech.api.util.PositionedRect)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Rotation (codechicken.lib.vec.Rotation)1 Transformation (codechicken.lib.vec.Transformation)1 Translation (codechicken.lib.vec.Translation)1 INativeWidget (gregtech.api.gui.INativeWidget)1 ArrayList (java.util.ArrayList)1 GuiTextField (net.minecraft.client.gui.GuiTextField)1