Search in sources :

Example 1 with GraphBoxImpl

use of com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl in project gdx-graph by MarcinSc.

the class PropertyBoxImpl method createPropertyBox.

@Override
public GraphBox createPropertyBox(Skin skin, String id, float x, float y) {
    final String name = getName();
    GraphBoxImpl result = new GraphBoxImpl(id, new PropertyNodeConfiguration(name, propertyType)) {

        @Override
        public JsonValue getData() {
            JsonValue result = new JsonValue(JsonValue.ValueType.object);
            result.addChild("name", new JsonValue(name));
            result.addChild("type", new JsonValue(propertyType));
            return result;
        }
    };
    result.addOutputGraphPart(new ValueGraphNodeOutput(name, propertyType));
    ShaderFieldType shaderFieldType = ShaderFieldTypeRegistry.findShaderFieldType(propertyType);
    if (shaderFieldType != null && shaderFieldType.isTexture()) {
        result.addGraphBoxPart(new TextureSettingsGraphBoxPart());
    }
    return result;
}
Also used : GraphBoxImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl) PropertyNodeConfiguration(com.gempukku.libgdx.graph.config.PropertyNodeConfiguration) JsonValue(com.badlogic.gdx.utils.JsonValue) ValueGraphNodeOutput(com.gempukku.libgdx.graph.ui.producer.ValueGraphNodeOutput) ShaderFieldType(com.gempukku.libgdx.graph.shader.field.ShaderFieldType)

Example 2 with GraphBoxImpl

use of com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl in project gdx-graph by MarcinSc.

the class UIPipelineConfigurer method processBoxProducer.

private static void processBoxProducer(JsonValue boxProducer) {
    String producerType = boxProducer.name();
    String producerName = boxProducer.getString("name");
    String menuLocation = boxProducer.getString("menuLocation");
    NodeConfigurationImpl nodeConfiguration = new NodeConfigurationImpl(producerType, producerName, menuLocation);
    JsonValue inputs = boxProducer.get("inputs");
    if (inputs != null) {
        for (JsonValue input : inputs) {
            String id = input.getString("id");
            String name = input.getString("name");
            boolean required = input.getBoolean("required", false);
            boolean mainConnection = input.getBoolean("mainConnection", false);
            boolean acceptMultiple = input.getBoolean("acceptMultiple", false);
            JsonValue type = input.get("type");
            String[] types = convertToArrayOfStrings(type);
            GraphNodeInputImpl nodeInput = new GraphNodeInputImpl(id, name, required, mainConnection, acceptMultiple, types);
            nodeConfiguration.addNodeInput(nodeInput);
        }
    }
    JsonValue outputs = boxProducer.get("outputs");
    if (outputs != null) {
        for (JsonValue output : outputs) {
            String id = output.getString("id");
            String name = output.getString("name");
            boolean mainConnection = output.getBoolean("mainConnection", false);
            JsonValue validation = output.get("validation");
            Function<ObjectMap<String, Array<String>>, String> validationFunction = convertToValidationFunction(validation);
            JsonValue type = output.get("type");
            String[] types = convertToArrayOfStrings(type);
            GraphNodeOutputImpl nodeOutput = new GraphNodeOutputImpl(id, name, mainConnection, validationFunction, types);
            nodeConfiguration.addNodeOutput(nodeOutput);
        }
    }
    final JsonValue fields = boxProducer.get("fields");
    GraphBoxProducerImpl producer = new GraphBoxProducerImpl(nodeConfiguration) {

        @Override
        public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
            GraphBoxImpl result = createGraphBox(id);
            if (fields != null) {
                for (JsonValue field : fields) {
                    String fieldType = field.getString("type");
                    GraphBoxPart fieldGraphBoxPart = createFieldGraphBoxPart(fieldType, field);
                    fieldGraphBoxPart.initialize(data);
                    result.addGraphBoxPart(fieldGraphBoxPart);
                }
            }
            addConfigurationInputsAndOutputs(result);
            return result;
        }
    };
    UIPipelineConfiguration.register(producer);
}
Also used : GraphBoxImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl) JsonValue(com.badlogic.gdx.utils.JsonValue) GraphBoxProducerImpl(com.gempukku.libgdx.graph.ui.producer.GraphBoxProducerImpl) GraphBoxPart(com.gempukku.libgdx.graph.ui.graph.GraphBoxPart) ObjectMap(com.badlogic.gdx.utils.ObjectMap) NodeConfigurationImpl(com.gempukku.libgdx.graph.data.NodeConfigurationImpl) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) GraphNodeOutputImpl(com.gempukku.libgdx.graph.pipeline.producer.node.GraphNodeOutputImpl) GraphNodeInputImpl(com.gempukku.libgdx.graph.pipeline.producer.node.GraphNodeInputImpl)

Example 3 with GraphBoxImpl

use of com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl in project gdx-graph by MarcinSc.

the class DitherShaderBoxProducer method createPipelineGraphBox.

@Override
public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
    final GraphBoxImpl result = createGraphBox(id);
    SelectBoxPart ditherSizeSelect = new SelectBoxPart("Dither size:", "ditherSize", "2", "4", "8");
    ditherSizeSelect.initialize(data);
    result.addGraphBoxPart(ditherSizeSelect);
    addConfigurationInputsAndOutputs(result);
    return result;
}
Also used : GraphBoxImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl) SelectBoxPart(com.gempukku.libgdx.graph.ui.part.SelectBoxPart)

Example 4 with GraphBoxImpl

use of com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl in project gdx-graph by MarcinSc.

the class RemapVectorShaderBoxProducer method createPipelineGraphBox.

@Override
public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
    String x = "X";
    String y = "Y";
    String z = "Z";
    String w = "W";
    if (data != null) {
        x = data.getString("x", x);
        y = data.getString("y", y);
        z = data.getString("z", z);
        w = data.getString("W", w);
    }
    GraphBoxImpl result = createGraphBox(id);
    addConfigurationInputsAndOutputs(result);
    final VisSelectBox<String> xBox = createSelectBox(x);
    final VisSelectBox<String> yBox = createSelectBox(y);
    final VisSelectBox<String> zBox = createSelectBox(z);
    final VisSelectBox<String> wBox = createSelectBox(w);
    VisTable table = new VisTable();
    table.add("X: ");
    table.add(xBox);
    table.add("Y: ");
    table.add(yBox);
    table.row();
    table.add("Z: ");
    table.add(zBox);
    table.add("W: ");
    table.add(wBox);
    table.row();
    result.addGraphBoxPart(new GraphBoxPartImpl(table, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(JsonValue object) {
            object.addChild("x", new JsonValue(xBox.getSelected()));
            object.addChild("y", new JsonValue(yBox.getSelected()));
            object.addChild("z", new JsonValue(zBox.getSelected()));
            object.addChild("w", new JsonValue(wBox.getSelected()));
        }
    }));
    return result;
}
Also used : GraphBoxImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl) VisTable(com.kotcrab.vis.ui.widget.VisTable) JsonValue(com.badlogic.gdx.utils.JsonValue) GraphBoxPartImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxPartImpl)

Example 5 with GraphBoxImpl

use of com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl in project gdx-graph by MarcinSc.

the class PropertyShaderGraphBoxProducer method createPipelineGraphBox.

@Override
public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
    final String name = data.getString("name");
    final String propertyType = data.getString("type");
    GraphBoxImpl result = new GraphBoxImpl(id, new PropertyNodeConfiguration(name, propertyType)) {

        @Override
        public JsonValue getData() {
            JsonValue result = super.getData();
            if (result == null)
                result = new JsonValue(JsonValue.ValueType.object);
            result.addChild("name", new JsonValue(name));
            result.addChild("type", new JsonValue(propertyType));
            return result;
        }
    };
    result.addOutputGraphPart(new ValueGraphNodeOutput(name, propertyType));
    if (ShaderFieldTypeRegistry.findShaderFieldType(propertyType).isTexture()) {
        TextureSettingsGraphBoxPart textureSettings = new TextureSettingsGraphBoxPart();
        textureSettings.initialize(data);
        result.addGraphBoxPart(textureSettings);
    }
    return result;
}
Also used : GraphBoxImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl) TextureSettingsGraphBoxPart(com.gempukku.libgdx.graph.ui.graph.property.TextureSettingsGraphBoxPart) PropertyNodeConfiguration(com.gempukku.libgdx.graph.config.PropertyNodeConfiguration) JsonValue(com.badlogic.gdx.utils.JsonValue) ValueGraphNodeOutput(com.gempukku.libgdx.graph.ui.producer.ValueGraphNodeOutput)

Aggregations

GraphBoxImpl (com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl)33 StringBoxPart (com.gempukku.libgdx.graph.ui.part.StringBoxPart)10 JsonValue (com.badlogic.gdx.utils.JsonValue)7 GraphChangedEvent (com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent)6 Graph (com.gempukku.libgdx.graph.data.Graph)4 GraphConnection (com.gempukku.libgdx.graph.data.GraphConnection)4 GraphNode (com.gempukku.libgdx.graph.data.GraphNode)4 GraphProperty (com.gempukku.libgdx.graph.data.GraphProperty)4 IndexBoxPart (com.gempukku.libgdx.graph.ui.part.IndexBoxPart)4 SelectBoxPart (com.gempukku.libgdx.graph.ui.part.SelectBoxPart)4 PropertyNodeConfiguration (com.gempukku.libgdx.graph.config.PropertyNodeConfiguration)3 GraphBoxPartImpl (com.gempukku.libgdx.graph.ui.graph.GraphBoxPartImpl)3 CheckboxBoxPart (com.gempukku.libgdx.graph.ui.part.CheckboxBoxPart)3 EnumSelectBoxPart (com.gempukku.libgdx.graph.ui.part.EnumSelectBoxPart)3 ValueGraphNodeOutput (com.gempukku.libgdx.graph.ui.producer.ValueGraphNodeOutput)3 VisTable (com.kotcrab.vis.ui.widget.VisTable)3 Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 RenderOrder (com.gempukku.libgdx.graph.pipeline.RenderOrder)2 ClampMethod (com.gempukku.libgdx.graph.shader.ClampMethod)2