use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class AdvancedTextWidget method getTextUnderMouse.
protected ITextComponent getTextUnderMouse(int mouseX, int mouseY) {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
Position position = getPosition();
int selectedLine = (mouseY - position.y) / (fontRenderer.FONT_HEIGHT + 2);
if (mouseX >= position.x && selectedLine >= 0 && selectedLine < displayText.size()) {
ITextComponent selectedComponent = displayText.get(selectedLine);
int mouseOffset = mouseX - position.x;
int currentOffset = 0;
for (ITextComponent lineComponent : selectedComponent) {
currentOffset += fontRenderer.getStringWidth(lineComponent.getUnformattedComponentText());
if (currentOffset >= mouseOffset) {
return lineComponent;
}
}
}
return null;
}
use of gregtech.api.util.Position 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.Position in project GregTech by GregTechCE.
the class TextFieldWidget method onPositionUpdate.
@Override
protected void onPositionUpdate() {
if (isClientSide() && textField != null) {
Position position = getPosition();
GuiTextField textField = this.textField;
textField.x = position.x;
textField.y = position.y;
}
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class PipeGridElementWidget method determineConnections.
private int determineConnections() {
ComponentGridWidget gridWidget = parentWidget;
if (gridWidget == null) {
return 0;
}
Position self = gridWidget.getWidgetOrigin(this);
int resultConnections = 0;
for (ElementOrientation orientation : ElementOrientation.values()) {
Position position = new Position(self.x + orientation.offsetX, self.y + orientation.offsetY);
Widget widget = gridWidget.getWidgetAt(position.x, position.y);
Position origin = gridWidget.getWidgetOrigin(widget);
Position relativePos = position.subtract(origin);
if (widget instanceof GridElementWidget && ((GridElementWidget) widget).canConnect(orientation.getOpposite(), relativePos, connectionType)) {
resultConnections |= 1 << orientation.ordinal();
}
}
return resultConnections;
}
use of gregtech.api.util.Position in project GregTech by GregTechCE.
the class ScrollableListWidget method isOnScrollPane.
private boolean isOnScrollPane(int mouseX, int mouseY) {
Position pos = getPosition();
Size size = getSize();
return isMouseOver(pos.x + size.width - scrollPaneWidth, pos.y, scrollPaneWidth, size.height, mouseX, mouseY);
}
Aggregations