use of org.terasology.rendering.nui.properties.Property in project Terasology by MovingBlocks.
the class PreviewWorldScreen method configureProperties.
private void configureProperties() {
PropertyLayout propLayout = find("properties", PropertyLayout.class);
propLayout.setOrdering(PropertyOrdering.byLabel());
propLayout.clear();
WorldConfigurator worldConfig = worldGenerator.getConfigurator();
Map<String, Component> params = worldConfig.getProperties();
for (String key : params.keySet()) {
Class<? extends Component> clazz = params.get(key).getClass();
Component comp = config.getModuleConfig(worldGenerator.getUri(), key, clazz);
if (comp != null) {
// use the data from the config instead of defaults
worldConfig.setProperty(key, comp);
}
}
ComponentLibrary compLib = subContext.get(ComponentLibrary.class);
for (String label : params.keySet()) {
PropertyProvider provider = new PropertyProvider() {
@Override
protected <T> Binding<T> createTextBinding(Object target, FieldMetadata<Object, T> fieldMetadata) {
return new WorldConfigBinding<>(worldConfig, label, compLib, fieldMetadata);
}
@Override
protected Binding<Float> createFloatBinding(Object target, FieldMetadata<Object, ?> fieldMetadata) {
return new WorldConfigNumberBinding(worldConfig, label, compLib, fieldMetadata);
}
};
Component target = params.get(label);
List<Property<?, ?>> properties = provider.createProperties(target);
propLayout.addProperties(label, properties);
}
}
use of org.terasology.rendering.nui.properties.Property in project Terasology by MovingBlocks.
the class PropertyLayout method expand.
private void expand(Collection<Property<?, ?>> properties, MigLayout layout) {
List<Property<?, ?>> props = Lists.newArrayList(properties);
Collections.sort(props, propertyComparator);
for (Property<?, ?> property : props) {
UILabel label = property.getLabel();
UIWidget editor = property.getEditor();
editor.setTooltip(property.getDescription());
layout.addWidget(label, new CCHint("newline"));
layout.addWidget(editor, new CCHint());
}
invalidate();
}
use of org.terasology.rendering.nui.properties.Property in project Terasology by MovingBlocks.
the class BehaviorEditorScreen method onEntitySelected.
private void onEntitySelected(Interpreter value, PropertyProvider provider) {
if (selectedInterpreter != null) {
selectedInterpreter.setCallback(null);
}
selectedInterpreter = value;
if (selectedInterpreter != null) {
EntityRef entity = value.actor().getEntity();
onTreeSelected(selectedInterpreter.getTree());
entityProperties.clear();
for (Component component : entity.iterateComponents()) {
String name = component.getClass().getSimpleName().replace("Component", "");
List<Property<?, ?>> componentProperties = provider.createProperties(component);
entityProperties.addProperties(name, componentProperties);
}
selectedInterpreter.setCallback(behaviorEditor);
}
}
Aggregations