use of org.terasology.engine.config.flexible.bindings.SettingBinding in project Terasology by MovingBlocks.
the class ColorConstraintWidgetFactory method bindWidgetToSetting.
@Override
protected void bindWidgetToSetting(UIWidget widget) {
UIImage img = widget.find("image", UIImage.class);
if (img != null) {
ResourceUrn uri = TextureUtil.getTextureUriForColor(Color.WHITE);
Texture tex = assetManager.getAsset(uri, Texture.class).get();
img.setImage(tex);
img.bindTint(new SettingBinding<>(getSetting()));
}
UISlider slider = widget.find("tone", UISlider.class);
slider.setIncrement(0.01f);
// ensure a certain width
Function<Object, String> constant = Functions.constant(" ");
slider.setLabelFunction(constant);
slider.bindValue(new MappingBinding<>(new SettingBinding<>(getSetting()), this::findClosestColor, this::findClosestIndex));
}
Aggregations