use of buildcraft.lib.gui.IGuiElement 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.gui.IGuiElement in project BuildCraft by BuildCraft.
the class LedgerHelp method drawIcon.
@Override
protected void drawIcon(double x, double y) {
if (!init) {
init = true;
List<HelpPosition> elements = new ArrayList<>();
for (IGuiElement element : gui.shownElements) {
element.addHelpElements(elements);
}
foundAny = elements.size() > 0;
}
ISprite sprite = foundAny ? BCLibSprites.HELP : BCLibSprites.WARNING_MINOR;
GuiIcon.draw(sprite, x, y, x + 16, y + 16);
}
use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.
the class Ledger_Neptune method calculateMaxSize.
/**
* The default implementation only works if all the elements are based around {@link #positionLedgerStart}
*/
public void calculateMaxSize() {
double w = CLOSED_WIDTH;
double h = CLOSED_HEIGHT;
for (IGuiElement element : openElements) {
w = Math.max(w, element.getEndX());
h = Math.max(h, element.getEndY());
}
w -= getX();
h -= getY();
maxWidth = w + LEDGER_GAP * 2;
maxHeight = h + LEDGER_GAP * 2;
}
use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.
the class Ledger_Neptune method drawBackground.
@Override
public void drawBackground(float partialTicks) {
double startX = getX();
double startY = getY();
final SpriteNineSliced split;
interpWidth = interp(lastWidth, currentWidth, partialTicks);
interpHeight = interp(lastHeight, currentHeight, partialTicks);
if (expandPositive) {
split = SPRITE_SPLIT_POS;
} else {
split = SPRITE_SPLIT_NEG;
}
RenderUtil.setGLColorFromIntPlusAlpha(colour);
split.draw(startX, startY, interpWidth, interpHeight);
GlStateManager.color(1, 1, 1, 1);
IGuiPosition pos2;
if (expandPositive) {
pos2 = positionLedgerIconStart;
} else {
pos2 = positionLedgerIconStart;
}
try (AutoGlScissor a = GuiUtil.scissor(pos2.getX(), pos2.getY(), interpWidth - 4, interpHeight - 8)) {
for (IGuiElement element : closedElements) {
element.drawBackground(partialTicks);
}
if (shouldDrawOpen()) {
for (IGuiElement element : openElements) {
element.drawBackground(partialTicks);
}
}
}
}
use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.
the class Ledger_Neptune method drawForeground.
@Override
public void drawForeground(float partialTicks) {
double scissorX = positionLedgerIconStart.getX();
double scissorY = positionLedgerIconStart.getY();
double scissorWidth = interpWidth - 8;
double scissorHeight = interpHeight - 8;
try (AutoGlScissor a = GuiUtil.scissor(scissorX, scissorY, scissorWidth, scissorHeight)) {
for (IGuiElement element : closedElements) {
element.drawForeground(partialTicks);
}
if (shouldDrawOpen()) {
for (IGuiElement element : openElements) {
element.drawForeground(partialTicks);
}
}
}
}
Aggregations