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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations