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;
}
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);
}
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?!");
}
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);
}
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);
}
Aggregations