Search in sources :

Example 1 with ILabel

use of me.desht.pneumaticcraft.common.progwidgets.ILabel in project pnc-repressurized by TeamPneumatic.

the class GuiUnitProgrammer method showFlow.

private void showFlow() {
    GL11.glLineWidth(1);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBegin(GL11.GL_LINES);
    for (IProgWidget widget : progWidgets) {
        if (widget instanceof IJump) {
            List<String> jumpLocations = ((IJump) widget).getPossibleJumpLocations();
            if (jumpLocations != null) {
                for (String jumpLocation : jumpLocations) {
                    if (jumpLocation != null) {
                        for (IProgWidget w : progWidgets) {
                            if (w instanceof ILabel) {
                                String label = ((ILabel) w).getLabel();
                                if (label != null && jumpLocation.equals(label)) {
                                    int x1 = widget.getX() + widget.getWidth() / 4;
                                    int y1 = widget.getY() + widget.getHeight() / 4;
                                    int x2 = w.getX() + w.getWidth() / 4;
                                    int y2 = w.getY() + w.getHeight() / 4;
                                    double midX = (x2 + x1) / 2D;
                                    double midY = (y2 + y1) / 2D;
                                    GL11.glVertex3d(guiLeft + x1, guiTop + y1, zLevel);
                                    GL11.glVertex3d(guiLeft + x2, guiTop + y2, zLevel);
                                    Vec3d arrowVec = new Vec3d(x1 - x2, y1 - y2, 0).normalize();
                                    float arrowAngle = (float) Math.toRadians(30);
                                    float arrowSize = 5;
                                    arrowVec = new Vec3d(arrowVec.x * arrowSize, 0, arrowVec.y * arrowSize);
                                    arrowVec = arrowVec.rotateYaw(arrowAngle);
                                    GL11.glVertex3d(guiLeft + midX, guiTop + midY, zLevel);
                                    GL11.glVertex3d(guiLeft + midX + arrowVec.x, guiTop + midY + arrowVec.z, zLevel);
                                    arrowVec = arrowVec.rotateYaw(-2 * arrowAngle);
                                    GL11.glVertex3d(guiLeft + midX, guiTop + midY, zLevel);
                                    GL11.glVertex3d(guiLeft + midX + arrowVec.x, guiTop + midY + arrowVec.z, zLevel);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    GL11.glEnd();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
Also used : IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) ILabel(me.desht.pneumaticcraft.common.progwidgets.ILabel) Vec3d(net.minecraft.util.math.Vec3d) IJump(me.desht.pneumaticcraft.common.progwidgets.IJump)

Aggregations

IJump (me.desht.pneumaticcraft.common.progwidgets.IJump)1 ILabel (me.desht.pneumaticcraft.common.progwidgets.ILabel)1 IProgWidget (me.desht.pneumaticcraft.common.progwidgets.IProgWidget)1 Vec3d (net.minecraft.util.math.Vec3d)1