Search in sources :

Example 21 with Position

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;
}
Also used : Position(gregtech.api.util.Position) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 22 with Position

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;
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size) INativeWidget(gregtech.api.gui.INativeWidget) Widget(gregtech.api.gui.Widget)

Example 23 with Position

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;
    }
}
Also used : Position(gregtech.api.util.Position) GuiTextField(net.minecraft.client.gui.GuiTextField)

Example 24 with Position

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;
}
Also used : Position(gregtech.api.util.Position) Widget(gregtech.api.gui.Widget)

Example 25 with Position

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);
}
Also used : Position(gregtech.api.util.Position) Size(gregtech.api.util.Size)

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