use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class TextureArea method createOrientation.
public static Transformation createOrientation(Size areaSize, int orientation) {
Transformation transformation = new Rotation(Math.toRadians(orientation * 90.0), 0.0, 0.0, 1.0).at(new Vector3(areaSize.width / 2.0, areaSize.height / 2.0, 0.0));
Size orientedSize = transformSize(transformation, areaSize);
double offsetX = (areaSize.width - orientedSize.width) / 2.0;
double offsetY = (areaSize.height - orientedSize.height) / 2.0;
return transformation.with(new Translation(-offsetX, -offsetY, 0.0));
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class TextureArea method transformSize.
public static Size transformSize(Transformation transformation, Size position) {
Vector3 sizeVector = new Vector3(position.width, position.height, 0.0);
Vector3 zeroVector = new Vector3(0.0, 0.0, 0.0);
transformation.apply(zeroVector);
transformation.apply(sizeVector);
sizeVector.subtract(zeroVector);
return new Size((int) Math.abs(sizeVector.x), (int) Math.abs(sizeVector.y));
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class AbstractWidgetGroup method computeDynamicSize.
protected Size computeDynamicSize() {
Position selfPosition = getPosition();
Size currentSize = getSize();
for (Widget widget : widgets) {
Position size = widget.getPosition().add(widget.getSize()).subtract(selfPosition);
if (size.x > currentSize.width) {
currentSize = new Size(size.x, currentSize.height);
}
if (size.y > currentSize.height) {
currentSize = new Size(currentSize.width, size.y);
}
}
return currentSize;
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class TextFieldWidget method onSizeUpdate.
@Override
protected void onSizeUpdate() {
if (isClientSide() && textField != null) {
Size size = getSize();
GuiTextField textField = this.textField;
textField.width = size.width;
textField.height = size.height;
}
}
use of gregtech.api.util.Size in project GregTech by GregTechCE.
the class ComponentGridWidget method canPlaceWidgetAt.
public boolean canPlaceWidgetAt(int x, int y, GridElementDef elementDef, ElementOrientation orientation) {
Size actualSize = elementDef.getSizeWithOrientation(orientation);
for (int i = 0; i < actualSize.width; i++) {
for (int j = 0; j < actualSize.height; j++) {
int positionX = x + i;
int positionY = y + j;
if (widgetBySlotIndex.containsKey(index(positionX, positionY)) || !isValidPosition(positionX, positionY)) {
return false;
}
}
}
return true;
}
Aggregations