use of buildcraft.lib.misc.data.IReference in project BuildCraft by BuildCraft.
the class GuiElementStatementDrag method drawForeground.
@Override
public void drawForeground(float partialTicks) {
if (isDragging) {
boolean canPlace = false;
for (IGuiElement element : gui.getElementsAt(gui.mouse.getX(), gui.mouse.getY())) {
if (element instanceof IReference<?>) {
if (checkCanSet((IReference<?>) element, dragging)) {
canPlace = true;
break;
}
}
}
GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
if (!canPlace) {
GlStateManager.color(1.0f, 0.7f, 0.7f);
}
double x = gui.mouse.getX() - 9;
double y = gui.mouse.getY() - 9;
if (dragging instanceof IStatementParameter) {
ParameterRenderer.draw((IStatementParameter) dragging, x, y);
} else {
GuiIcon background = GuiElementStatement.SLOT_COLOUR;
if (dragging instanceof StatementWrapper) {
EnumPipePart part = ((StatementWrapper) dragging).sourcePart;
if (part != EnumPipePart.CENTER) {
background = background.offset(0, (1 + part.getIndex()) * 18);
}
}
background.drawAt(x, y);
if (dragging != null) {
ISprite sprite = dragging.getSprite();
if (sprite != null) {
GuiIcon.drawAt(sprite, x + 1, y + 1, 16);
}
}
}
GlStateManager.color(1, 1, 1);
}
}
use of buildcraft.lib.misc.data.IReference in project BuildCraft by BuildCraft.
the class GuiElementStatementDrag method onMouseClicked.
// IInteractableElement
@Override
public void onMouseClicked(int button) {
if (button != 1) {
return;
}
for (IGuiElement element : gui.getElementsAt(gui.mouse.getX(), gui.mouse.getY())) {
if (element instanceof IReference<?>) {
IReference<?> ref = (IReference<?>) element;
Object obj = ref.get();
if (obj == null || obj instanceof IGuiSlot) {
startDragging((IGuiSlot) obj);
break;
}
}
}
}
use of buildcraft.lib.misc.data.IReference in project BuildCraft by BuildCraft.
the class GuiElementStatementDrag method onMouseReleased.
@Override
public void onMouseReleased(int button) {
if (!isDragging) {
return;
}
for (IGuiElement element : gui.getElementsAt(gui.mouse.getX(), gui.mouse.getY())) {
if (element instanceof IReference<?>) {
IReference<?> ref = (IReference<?>) element;
ref.setIfCan(dragging);
}
}
isDragging = false;
dragging = null;
if (gui.currentMenu == this) {
gui.currentMenu = null;
}
}
Aggregations