Search in sources :

Example 1 with PositionedRect

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

the class TextureArea method transformRect.

public static PositionedRect transformRect(Transformation transformation, PositionedRect positionedRect) {
    Position pos1 = transformPos(transformation, positionedRect.position);
    Position pos2 = transformPos(transformation, positionedRect.position.add(positionedRect.size));
    return new PositionedRect(pos1, pos2);
}
Also used : Position(gregtech.api.util.Position) PositionedRect(gregtech.api.util.PositionedRect)

Example 2 with PositionedRect

use of gregtech.api.util.PositionedRect 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 3 with PositionedRect

use of gregtech.api.util.PositionedRect 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 4 with PositionedRect

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

the class PipeGridElementWidget method drawInBackground.

@Override
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
    super.drawInBackground(mouseX, mouseY, context);
    int conn = determineConnections();
    TextureHolder textureHolder = getIconMap().get(conn);
    if (textureHolder == null) {
        textureHolder = new TextureHolder(createSpriteMap().get(TextureSprite.STRAIGHT), orientation.ordinal());
    }
    textureHolder.sprite.drawRotated(getPosition().x, getPosition().y, new Size(slotSize, slotSize), new PositionedRect(0, 0, slotSize, slotSize), textureHolder.orientation);
}
Also used : Size(gregtech.api.util.Size) PositionedRect(gregtech.api.util.PositionedRect)

Example 5 with PositionedRect

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

the class MetaTileEntityArmorTable method createUI.

@Override
protected ModularUI createUI(EntityPlayer entityPlayer) {
    int horizontalGridSize = 12;
    int verticalGridSize = 7;
    ComponentGridWidget gridWidget = new ComponentGridWidget(11, 11, 20, 3, horizontalGridSize, verticalGridSize).setGridColor(0xFF5B5B5B);
    GridElementDef elementDef = new GridElementDef(4, 3, (elementSize, slotSize) -> {
        SimpleGridElementWidget elementWidget = new SimpleGridElementWidget(elementSize, slotSize, GuiTextures.COMPONENT_BATTERY, new PositionedRect(0, 5, 70, 50));
        elementWidget.addConnection(1, ConnectionType.POWER, ElementOrientation.RIGHT);
        return elementWidget;
    });
    gridWidget.placeWidgetAt(3, 2, elementDef, ElementOrientation.TOP);
    return ModularUI.builder(GuiTextures.BOXED_BACKGROUND, 28 + horizontalGridSize * 20, 28 + verticalGridSize * 20).widget(gridWidget).build(getHolder(), entityPlayer);
}
Also used : PositionedRect(gregtech.api.util.PositionedRect)

Aggregations

PositionedRect (gregtech.api.util.PositionedRect)6 Position (gregtech.api.util.Position)4 Size (gregtech.api.util.Size)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Transformation (codechicken.lib.vec.Transformation)1 Vector3 (codechicken.lib.vec.Vector3)1 ArrayList (java.util.ArrayList)1