use of buildcraft.lib.gui.pos.IGuiPosition in project BuildCraft by BuildCraft.
the class ElementTypeSlot method deserialize0.
// pos: the position of the slot
// slot: The slot to be moved
// index: If the slot was an InventorySlotHolder then this is the index of the slot in the list
// visible: If false then the slot won't be visible
@Override
protected IGuiElement deserialize0(BuildCraftJsonGui gui, IGuiPosition parent, JsonGuiInfo info, JsonGuiElement json) {
FunctionContext ctx = createContext(json);
String slotName = json.properties.get("slot");
IGuiPosition pos = resolvePosition(json, "pos", parent, ctx);
Slot slot = gui.properties.get(slotName, Slot.class);
INodeBoolean visible = getEquationBool(json, "visible", ctx, true);
if (slot != null) {
return new GuiElementSlotMover(gui, pos, visible, slot);
}
InventorySlotHolder holder = gui.properties.get(slotName, InventorySlotHolder.class);
if (holder == null) {
throw new JsonSyntaxException("Unknown slot '" + slotName + "'");
}
int index = resolveEquationInt(json, "index", ctx);
if (index < 0 || index >= holder.slots.length) {
throw new JsonSyntaxException("Invalid slot index! (" + index + ", min = 0, max = " + (holder.slots.length - 1) + ")");
}
return new GuiElementSlotMover(gui, pos, visible, holder.slots[index]);
}
use of buildcraft.lib.gui.pos.IGuiPosition in project BuildCraft by BuildCraft.
the class ElementType method resolvePosition.
public static IGuiPosition resolvePosition(JsonGuiElement json, String name, IGuiPosition parent, FunctionContext ctx) {
String eqn = json.properties.get(name);
if (eqn == null) {
INodeDouble x = getEquationDouble(json, name + "[0]", ctx);
INodeDouble y = getEquationDouble(json, name + "[1]", ctx);
return IGuiPosition.create(x, y).offset(parent);
}
try {
return GenericExpressionCompiler.compileExpressionObject(IGuiPosition.class, eqn, ctx).evaluate();
} catch (InvalidExpressionException e) {
throw new JsonSyntaxException("Failed to resolve a position for " + json.fullName, e);
}
}
use of buildcraft.lib.gui.pos.IGuiPosition in project BuildCraft by BuildCraft.
the class ElementTypeContainer method deserialize0.
@Override
protected IGuiElement deserialize0(BuildCraftJsonGui gui, IGuiPosition parent, JsonGuiInfo info, JsonGuiElement json) {
FunctionContext ctx = createContext(json);
boolean scissor = resolveEquationBool(json, "limit", ctx, false);
if (scissor) {
IGuiArea area = resolveArea(json, "area", parent, ctx);
return new GuiElementContainerScissor(gui, area);
} else {
IGuiPosition pos = resolvePosition(json, "pos", parent, ctx);
return new GuiElementContainerResizing(gui, pos);
}
}
use of buildcraft.lib.gui.pos.IGuiPosition in project BuildCraft by BuildCraft.
the class GuiAbstractButton method createTextElement.
public GuiElementText createTextElement(Supplier<String> text) {
FontRenderer fr = gui.mc.fontRenderer;
DoubleSupplier x = () -> -fr.getStringWidth(text.get()) / 2;
DoubleSupplier y = () -> -fr.FONT_HEIGHT / 2;
IGuiPosition pos = getCenter().offset(x, y);
return new GuiElementText(gui, pos, text, this::getColourForText);
}
use of buildcraft.lib.gui.pos.IGuiPosition 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);
}
}
}
}
Aggregations