use of com.ray3k.stripe.scenecomposer.SimSingleChild in project skin-composer by raeleus.
the class DialogSceneComposerModel method primeStyles.
private void primeStyles(SimActor simActor) {
for (var field : ClassReflection.getFields(simActor.getClass())) {
if (field.getType() == StyleData.class) {
try {
var style = (StyleData) field.get(simActor);
if (style != null) {
StyleData foundStyle = jsonData.findStyle(style.clazz, style.name);
if (foundStyle == null)
foundStyle = jsonData.findStyle(style.clazz, "default");
if (foundStyle == null)
foundStyle = jsonData.findStyle(style.clazz, "default-horizontal");
field.set(simActor, foundStyle);
}
} catch (ReflectionException e) {
e.printStackTrace(System.out);
}
} else if (field.getType() == DrawableData.class) {
try {
var drawable = (DrawableData) field.get(simActor);
if (drawable != null) {
var foundDrawable = atlasData.getDrawable(drawable.name);
field.set(simActor, foundDrawable);
}
} catch (ReflectionException e) {
e.printStackTrace(System.out);
}
}
}
if (simActor instanceof SimMultipleChildren) {
for (var child : ((SimMultipleChildren) simActor).getChildren()) {
if (child != null)
primeStyles(child);
}
}
if (simActor instanceof SimSingleChild) {
var child = ((SimSingleChild) simActor).getChild();
if (child != null)
primeStyles(child);
}
}
Aggregations