Search in sources :

Example 31 with Position

use of gregtech.api.util.Position 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 32 with Position

use of gregtech.api.util.Position 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 33 with Position

use of gregtech.api.util.Position 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 34 with Position

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

the class MemorizedRecipeWidget method drawInForeground.

@Override
public void drawInForeground(int mouseX, int mouseY) {
    super.drawInForeground(mouseX, mouseY);
    if (recipeLocked) {
        Position pos = getPosition();
        GlStateManager.disableDepth();
        GuiTextures.LOCK.draw(pos.x, pos.y + 10, 8, 8);
        GlStateManager.enableDepth();
    }
}
Also used : Position(gregtech.api.util.Position)

Example 35 with Position

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

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