Search in sources :

Example 1 with IProgWidget

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

the class TileEntityProgrammer method previewArea.

public boolean previewArea(int widgetX, int widgetY) {
    for (IProgWidget w : progWidgets) {
        if (w.getX() == widgetX && w.getY() == widgetY && w instanceof IAreaProvider) {
            Set<BlockPos> area = new HashSet<BlockPos>();
            ((IAreaProvider) w).getArea(area);
            AreaShowManager.getInstance().showArea(area, 0x9000FF00, this);
        }
    }
    return true;
}
Also used : IAreaProvider(me.desht.pneumaticcraft.common.progwidgets.IAreaProvider) IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with IProgWidget

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

the class ModelProgrammingPuzzle method process.

@Override
public IModel process(ImmutableMap<String, String> customData) {
    String progWidgetName = customData.get("progWidget");
    IProgWidget widget = WidgetRegistrator.getWidgetFromName(progWidgetName);
    if (widget == null)
        throw new IllegalStateException("Invalid widget: " + progWidgetName);
    // create new model with correct widget
    return new ModelProgrammingPuzzle(widget);
}
Also used : IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget)

Example 3 with IProgWidget

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

the class ItemProgrammingPuzzle method getStackForWidgetKey.

public static ItemStack getStackForWidgetKey(String widgetKey) {
    /*for(IProgWidget widget : TileEntityProgrammer.registeredWidgets) {
            if(widget.getWidgetString().equals(widgetKey)) {
                return new ItemStack(Itemss.programmingPuzzle, 1, widget.getCraftingColorIndex());
            }
        }*/
    IProgWidget widget = WidgetRegistrator.getWidgetFromName(widgetKey);
    int meta = widget == null ? ItemPlastic.BLACK : WidgetRegistrator.getWidgetFromName(widgetKey).getCraftingColorIndex();
    ItemStack stack = new ItemStack(Itemss.PROGRAMMING_PUZZLE, 1, meta);
    NBTTagCompound tag = new NBTTagCompound();
    tag.setString("type", widgetKey);
    stack.setTagCompound(tag);
    return stack;
// throw new IllegalArgumentException("No widget registered with the name " + widgetKey + "! This is not possible?!");
}
Also used : IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 4 with IProgWidget

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

the class GuiProgrammer method setConnectingWidgetsToXY.

private void setConnectingWidgetsToXY(IProgWidget widget, int x, int y) {
    widget.setX(x);
    widget.setY(y);
    IProgWidget[] connectingWidgets = widget.getConnectedParameters();
    if (connectingWidgets != null) {
        for (int i = 0; i < connectingWidgets.length; i++) {
            if (connectingWidgets[i] != null) {
                if (i < connectingWidgets.length / 2) {
                    setConnectingWidgetsToXY(connectingWidgets[i], x + widget.getWidth() / 2, y + i * 11);
                } else {
                    int totalWidth = 0;
                    IProgWidget branch = connectingWidgets[i];
                    while (branch != null) {
                        totalWidth += branch.getWidth() / 2;
                        branch = branch.getConnectedParameters()[0];
                    }
                    setConnectingWidgetsToXY(connectingWidgets[i], x - totalWidth, y + (i - connectingWidgets.length / 2) * 11);
                }
            }
        }
    }
    IProgWidget outputWidget = widget.getOutputWidget();
    if (outputWidget != null)
        setConnectingWidgetsToXY(outputWidget, x, y + widget.getHeight() / 2);
}
Also used : IProgWidget(me.desht.pneumaticcraft.common.progwidgets.IProgWidget) Point(java.awt.Point)

Example 5 with IProgWidget

use of me.desht.pneumaticcraft.common.progwidgets.IProgWidget 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

IProgWidget (me.desht.pneumaticcraft.common.progwidgets.IProgWidget)33 Point (java.awt.Point)10 ItemStack (net.minecraft.item.ItemStack)7 ArrayList (java.util.ArrayList)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 PacketProgrammerUpdate (me.desht.pneumaticcraft.common.network.PacketProgrammerUpdate)4 ProgWidgetStart (me.desht.pneumaticcraft.common.progwidgets.ProgWidgetStart)4 GuiScreen (net.minecraft.client.gui.GuiScreen)3 BlockPos (net.minecraft.util.math.BlockPos)3 IProgrammable (me.desht.pneumaticcraft.api.item.IProgrammable)2 EntityDrone (me.desht.pneumaticcraft.common.entity.living.EntityDrone)2 PacketGuiButton (me.desht.pneumaticcraft.common.network.PacketGuiButton)2 PacketUpdateTextfield (me.desht.pneumaticcraft.common.network.PacketUpdateTextfield)2 IVariableWidget (me.desht.pneumaticcraft.common.progwidgets.IVariableWidget)2 ProgWidgetArea (me.desht.pneumaticcraft.common.progwidgets.ProgWidgetArea)2 ProgWidgetCoordinate (me.desht.pneumaticcraft.common.progwidgets.ProgWidgetCoordinate)2 ProgWidgetCoordinateOperator (me.desht.pneumaticcraft.common.progwidgets.ProgWidgetCoordinateOperator)2 Entity (net.minecraft.entity.Entity)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 Rectangle (java.awt.Rectangle)1