use of org.terasology.nui.widgets.UIImage in project Terasology by MovingBlocks.
the class StartPlayingScreen method onOpened.
@Override
public void onOpened() {
super.onOpened();
UIImage previewImage = find("preview", UIImage.class);
previewImage.setImage(texture);
UILabel subitle = find("subtitle", UILabel.class);
subitle.setText(translationSystem.translate("${engine:menu#start-playing}") + " in " + targetWorld.getWorldName().toString());
}
use of org.terasology.nui.widgets.UIImage 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));
}
use of org.terasology.nui.widgets.UIImage in project Terasology by MovingBlocks.
the class SelectionScreen method loadPreviewImages.
private void loadPreviewImages(final GameInfo gameInfo) {
List<Texture> textures = new ArrayList<>();
if (gameInfo != null && gameInfo.getSavePath() != null) {
final List<BufferedImage> bufferedImages = GamePreviewImageProvider.getAllPreviewImages(gameInfo.getSavePath());
textures = bufferedImages.stream().map(buffImage -> {
TextureData textureData;
try {
textureData = AWTTextureFormat.convertToTextureData(buffImage, Texture.FilterMode.LINEAR);
} catch (IOException e) {
logger.error("Converting preview image to texture data {} failed", e);
return null;
}
return Assets.generateAsset(new ResourceUrn(PREVIEW_IMAGE_URI_PATTERN + bufferedImages.indexOf(buffImage)), textureData, Texture.class);
}).filter(Objects::nonNull).collect(Collectors.toList());
}
if (textures.isEmpty()) {
textures.add(Assets.getTexture(DEFAULT_PREVIEW_IMAGE_URI).get());
}
previewSlideshow.clean();
textures.forEach(tex -> {
UIImage image = new UIImage(null, tex, true);
previewSlideshow.addImage(image);
});
}
Aggregations