use of org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo in project Terasology by MovingBlocks.
the class SelectGameScreen method initialise.
@Override
public void initialise() {
setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
initWidgets();
if (isValidScreen()) {
if (gameTypeTitle != null) {
gameTypeTitle.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
if (isLoadingAsServer()) {
return translationSystem.translate("${engine:menu#select-multiplayer-game-sub-title}");
} else {
return translationSystem.translate("${engine:menu#select-singleplayer-game-sub-title}");
}
}
});
}
initSaveGamePathWidget(PathManager.getInstance().getSavesPath());
getGameInfos().subscribeSelection((widget, item) -> {
load.setEnabled(item != null);
delete.setEnabled(item != null);
details.setEnabled(item != null);
updateDescription(item);
});
getGameInfos().subscribe((widget, item) -> loadGame(item));
load.subscribe(e -> {
final GameInfo gameInfo = getGameInfos().getSelection();
if (gameInfo != null) {
loadGame(gameInfo);
}
});
delete.subscribe(e -> {
TwoButtonPopup confirmationPopup = getManager().pushScreen(TwoButtonPopup.ASSET_URI, TwoButtonPopup.class);
confirmationPopup.setMessage(translationSystem.translate("${engine:menu#remove-confirmation-popup" + "-title}"), translationSystem.translate("${engine:menu#remove-confirmation-popup-message}"));
confirmationPopup.setLeftButton(translationSystem.translate("${engine:menu#dialog-yes}"), this::removeSelectedGame);
confirmationPopup.setRightButton(translationSystem.translate("${engine:menu#dialog-no}"), () -> {
});
});
final NewGameScreen newGameScreen = getManager().createScreen(NewGameScreen.ASSET_URI, NewGameScreen.class);
create.subscribe(e -> {
newGameScreen.setUniverseWrapper(universeWrapper);
triggerForwardAnimation(newGameScreen);
});
close.subscribe(e -> triggerBackAnimation());
details.subscribe(e -> {
final GameInfo gameInfo = getGameInfos().getSelection();
if (gameInfo != null) {
final GameDetailsScreen detailsScreen = getManager().createScreen(GameDetailsScreen.ASSET_URI, GameDetailsScreen.class);
detailsScreen.setGameInfo(gameInfo);
detailsScreen.setPreviews(previewSlideshow.getImages());
getManager().pushScreen(detailsScreen);
}
});
}
}
use of org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameInfo 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