Search in sources :

Example 26 with Size

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

the class PhantomFluidWidget method drawInBackground.

@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    Position pos = getPosition();
    Size size = getSize();
    if (backgroundTexture != null) {
        backgroundTexture.draw(pos.x, pos.y, size.width, size.height);
    }
    if (lastFluidStack != null) {
        GlStateManager.disableBlend();
        RenderUtil.drawFluidForGui(lastFluidStack, lastFluidStack.amount, pos.x + 1, pos.y + 1, size.width - 1, size.height - 1);
        GlStateManager.enableBlend();
        GlStateManager.color(1.0f, 1.0f, 1.0f);
    }
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size)

Example 27 with Size

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

the class ProgressWidget method drawInBackground.

@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    Position pos = getPosition();
    Size size = getSize();
    if (emptyBarArea != null) {
        emptyBarArea.draw(pos.x, pos.y, size.width, size.height);
    }
    if (filledBarArea != null) {
        // fuck this precision-dependent things, they are so fucking annoying
        if (moveType == MoveType.HORIZONTAL) {
            filledBarArea.drawSubArea(pos.x, pos.y, (int) (size.width * lastProgressValue), size.height, 0.0, 0.0, ((int) (size.width * lastProgressValue)) / (size.width * 1.0), 1.0);
        } else if (moveType == MoveType.VERTICAL) {
            int progressValueScaled = (int) (size.height * lastProgressValue);
            filledBarArea.drawSubArea(pos.x, pos.y + size.height - progressValueScaled, size.width, progressValueScaled, 0.0, 1.0 - (progressValueScaled / (size.height * 1.0)), 1.0, (progressValueScaled / (size.height * 1.0)));
        } else if (moveType == MoveType.VERTICAL_INVERTED) {
            int progressValueScaled = (int) (size.height * lastProgressValue);
            filledBarArea.drawSubArea(pos.x, pos.y, size.width, progressValueScaled, 0.0, 0.0, 1.0, (progressValueScaled / (size.height * 1.0)));
        }
    }
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size)

Example 28 with Size

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

the class SliderWidget method drawInBackground.

@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    Position pos = getPosition();
    Size size = getSize();
    if (backgroundArea != null) {
        backgroundArea.draw(pos.x, pos.y, size.width, size.height);
    }
    if (displayString == null) {
        this.displayString = getDisplayString();
    }
    sliderIcon.draw(pos.x + (int) (this.sliderPosition * (float) (size.width - 8)), pos.y, sliderWidth, size.height);
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
    fontRenderer.drawString(displayString, pos.x + size.width / 2 - fontRenderer.getStringWidth(displayString) / 2, pos.y + size.height / 2 - fontRenderer.FONT_HEIGHT / 2, textColor);
    GlStateManager.color(1.0f, 1.0f, 1.0f);
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 29 with Size

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

the class SliderWidget method mouseDragged.

@Override
public boolean mouseDragged(int mouseX, int mouseY, int button, long timeDragged) {
    if (this.isMouseDown) {
        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));
        return true;
    }
    return false;
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size)

Example 30 with Size

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

the class StonePileModelGenerator method generateCuboidList.

private static List<IndexedCuboid6> generateCuboidList(Random random) {
    ArrayList<IndexedCuboid6> result = new ArrayList<>();
    List<PositionedRect> occupiedAreas = new ArrayList<>();
    int stonePlaceAttempts = 64;
    int maxStones = 8;
    int stonesPlaced = 0;
    for (int i = 0; i < stonePlaceAttempts && stonesPlaced < maxStones; i++) {
        int sizeX = 2 + random.nextInt(3);
        int sizeZ = 2 + random.nextInt(3);
        int stoneHeight = 4 + random.nextInt(4);
        int posX = random.nextInt(16 - sizeX);
        int posZ = random.nextInt(16 - sizeZ);
        PositionedRect rect = new PositionedRect(new Position(posX, posZ), new Size(sizeX, sizeZ));
        if (occupiedAreas.stream().noneMatch(rect::intersects)) {
            Vector3 minVector = new Vector3(posX / 16.0, 0 / 16.0, posZ / 16.0);
            Cuboid6 bounds = new Cuboid6(minVector, minVector.copy());
            bounds.max.add(sizeX / 16.0, stoneHeight / 16.0, sizeZ / 16.0);
            int brightness = 100 + random.nextInt(130);
            result.add(new IndexedCuboid6(brightness, bounds));
            occupiedAreas.add(rect);
            stonesPlaced++;
        }
    }
    return result;
}
Also used : IndexedCuboid6(codechicken.lib.raytracer.IndexedCuboid6) Position(gregtech.api.util.Position) Size(gregtech.api.util.Size) ArrayList(java.util.ArrayList) Vector3(codechicken.lib.vec.Vector3) IndexedCuboid6(codechicken.lib.raytracer.IndexedCuboid6) Cuboid6(codechicken.lib.vec.Cuboid6) PositionedRect(gregtech.api.util.PositionedRect)

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