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);
}
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);
}
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;
}
}
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);
}
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);
}
Aggregations