Search in sources :

Example 1 with IStatementContainer

use of buildcraft.api.statements.IStatementContainer in project BuildCraft by BuildCraft.

the class ElementTypeStatementParam method deserialize0.

@Override
public IGuiElement deserialize0(BuildCraftJsonGui gui, IGuiPosition parent, JsonGuiInfo info, JsonGuiElement json) {
    FunctionContext ctx = createContext(json);
    if (!json.properties.containsKey("size[0]")) {
        json.properties.put("size[0]", "18");
    }
    if (!json.properties.containsKey("size[1]")) {
        json.properties.put("size[1]", "18");
    }
    inheritProperty(json, "pos[0]", "area[0]");
    inheritProperty(json, "pos[1]", "area[1]");
    inheritProperty(json, "size[0]", "area[2]");
    inheritProperty(json, "size[1]", "area[3]");
    IGuiArea area = resolveArea(json, "area", parent, ctx);
    String source;
    if (json.properties.containsKey("source")) {
        source = json.properties.get("source");
    } else {
        source = resolveEquation(json, "source_expression", ctx);
        if (source == null) {
            throw new JsonSyntaxException("Expected either 'source' or 'source_expression' for " + NAME);
        }
    }
    boolean draw = !"false".equals(json.properties.get("draw"));
    int index = resolveEquationInt(json, "index", ctx);
    FullStatement<?> fullStatement = gui.properties.get(source, FullStatement.class);
    IStatementContainer statementContainer = gui.properties.get("statement.container", IStatementContainer.class);
    return new GuiElementStatementParam(gui, area, statementContainer, fullStatement, index, draw);
}
Also used : IGuiArea(buildcraft.lib.gui.pos.IGuiArea) JsonSyntaxException(com.google.gson.JsonSyntaxException) IStatementContainer(buildcraft.api.statements.IStatementContainer) GuiElementStatementParam(buildcraft.lib.gui.statement.GuiElementStatementParam) FunctionContext(buildcraft.lib.expression.FunctionContext)

Aggregations

IStatementContainer (buildcraft.api.statements.IStatementContainer)1 FunctionContext (buildcraft.lib.expression.FunctionContext)1 IGuiArea (buildcraft.lib.gui.pos.IGuiArea)1 GuiElementStatementParam (buildcraft.lib.gui.statement.GuiElementStatementParam)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1