Search in sources :

Example 1 with GuiElementContainerResizing

use of buildcraft.lib.gui.elem.GuiElementContainerResizing in project BuildCraft by BuildCraft.

the class ElementType method deserialize.

public final IGuiElement deserialize(BuildCraftJsonGui gui, IGuiPosition parent, JsonGuiInfo info, JsonGuiElement json) {
    IGuiElement element = deserialize0(gui, parent, info, json);
    if (element instanceof GuiElementSimple) {
        ((GuiElementSimple) element).name = json.fullName;
    }
    gui.context.putConstant(json.fullName + ".pos", IGuiPosition.class, element);
    gui.context.putConstant(json.fullName + ".area", IGuiArea.class, element);
    gui.varData.addNodes(json.createTickableNodes());
    List<IGuiElement> children = new ArrayList<>();
    IContainingElement container;
    if (element instanceof IContainingElement) {
        container = (IContainingElement) element;
    } else {
        container = new GuiElementContainerResizing(gui, element);
        container.getChildElements().add(element);
    }
    addChildren(gui, container.getChildElementPosition(), info, json, "children", children::add);
    // Special case tooltips + help
    if (json.json.has("help") && !(this instanceof ElementTypeHelp)) {
        addType(gui, parent, info, json, "help", children::add, ElementTypeHelp.INSTANCE);
    }
    if (json.json.has("tooltip") && !(this instanceof ElementTypeToolTip)) {
        addType(gui, parent, info, json, "tooltip", children::add, ElementTypeToolTip.INSTANCE);
    }
    if (!children.isEmpty()) {
        element = container;
        container.getChildElements().addAll(children);
        container.calculateSizes();
    }
    return element;
}
Also used : IContainingElement(buildcraft.lib.gui.IContainingElement) GuiElementSimple(buildcraft.lib.gui.GuiElementSimple) ArrayList(java.util.ArrayList) IGuiElement(buildcraft.lib.gui.IGuiElement) GuiElementContainerResizing(buildcraft.lib.gui.elem.GuiElementContainerResizing)

Example 2 with GuiElementContainerResizing

use of buildcraft.lib.gui.elem.GuiElementContainerResizing 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);
    }
}
Also used : IGuiArea(buildcraft.lib.gui.pos.IGuiArea) GuiElementContainerScissor(buildcraft.lib.gui.elem.GuiElementContainerScissor) GuiElementContainerResizing(buildcraft.lib.gui.elem.GuiElementContainerResizing) FunctionContext(buildcraft.lib.expression.FunctionContext) IGuiPosition(buildcraft.lib.gui.pos.IGuiPosition)

Aggregations

GuiElementContainerResizing (buildcraft.lib.gui.elem.GuiElementContainerResizing)2 FunctionContext (buildcraft.lib.expression.FunctionContext)1 GuiElementSimple (buildcraft.lib.gui.GuiElementSimple)1 IContainingElement (buildcraft.lib.gui.IContainingElement)1 IGuiElement (buildcraft.lib.gui.IGuiElement)1 GuiElementContainerScissor (buildcraft.lib.gui.elem.GuiElementContainerScissor)1 IGuiArea (buildcraft.lib.gui.pos.IGuiArea)1 IGuiPosition (buildcraft.lib.gui.pos.IGuiPosition)1 ArrayList (java.util.ArrayList)1