use of com.faforever.client.fa.FaStrings in project downlords-faf-client by FAForever.
the class CreateGameController method setSelectedMap.
private void setSelectedMap(MapBean newValue) {
JavaFxUtil.assertApplicationThread();
if (newValue == null) {
mapNameLabel.setText("");
return;
}
preferencesService.getPreferences().setLastMap(newValue.getFolderName());
preferencesService.storeInBackground();
Image largePreview = mapService.loadPreview(newValue.getFolderName(), PreviewSize.LARGE);
mapPreviewPane.setBackground(new Background(new BackgroundImage(largePreview, NO_REPEAT, NO_REPEAT, CENTER, new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, false, false, true, false))));
MapSize mapSize = newValue.getSize();
mapSizeLabel.setText(i18n.get("mapPreview.size", mapSize.getWidthInPixels(), mapSize.getHeightInPixels()));
mapNameLabel.setText(newValue.getDisplayName());
mapPlayersLabel.setText(i18n.number(newValue.getPlayers()));
mapDescriptionLabel.setText(Optional.ofNullable(newValue.getDescription()).map(Strings::emptyToNull).map(FaStrings::removeLocalizationTag).orElseGet(() -> i18n.get("map.noDescriptionAvailable")));
versionLabel.setText(newValue.getVersion().toString());
}
use of com.faforever.client.fa.FaStrings in project downlords-faf-client by FAForever.
the class MapDetailController method setMap.
public void setMap(MapBean map) {
this.map = map;
if (map.getLargeThumbnailUrl() != null) {
thumbnailImageView.setImage(mapService.loadPreview(map, PreviewSize.LARGE));
} else {
thumbnailImageView.setImage(IdenticonUtil.createIdenticon(map.getId()));
}
nameLabel.setText(map.getDisplayName());
authorLabel.setText(Optional.ofNullable(map.getAuthor()).orElse(i18n.get("map.unknownAuthor")));
maxPlayersLabel.setText(i18n.number(map.getPlayers()));
MapSize mapSize = map.getSize();
dimensionsLabel.setText(i18n.get("mapPreview.size", mapSize.getWidthInKm(), mapSize.getHeightInKm()));
LocalDateTime createTime = map.getCreateTime();
dateLabel.setText(timeService.asDate(createTime));
boolean mapInstalled = mapService.isInstalled(map.getFolderName());
installButton.setVisible(!mapInstalled);
Player player = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("No user is logged in"));
reviewsController.setCanWriteReview(false);
mapService.hasPlayedMap(player.getId(), map.getId()).thenAccept(hasPlayed -> reviewsController.setCanWriteReview(hasPlayed));
reviewsController.setOnSendReviewListener(this::onSendReview);
reviewsController.setOnDeleteReviewListener(this::onDeleteReview);
reviewsController.setReviews(map.getReviews());
reviewsController.setOwnReview(map.getReviews().stream().filter(review -> review.getPlayer().getId() == player.getId()).findFirst());
mapService.getFileSize(map.getDownloadUrl()).thenAccept(mapFileSize -> Platform.runLater(() -> {
if (mapFileSize > -1) {
installButton.setText(i18n.get("mapVault.installButtonFormat", Bytes.formatSize(mapFileSize, i18n.getUserSpecificLocale())));
installButton.setDisable(false);
} else {
installButton.setText(i18n.get("notAvailable"));
installButton.setDisable(true);
}
}));
uninstallButton.setVisible(mapInstalled);
mapDescriptionLabel.textProperty().bind(Bindings.createStringBinding(() -> Optional.ofNullable(map.getDescription()).map(Strings::emptyToNull).map(FaStrings::removeLocalizationTag).orElseGet(() -> i18n.get("map.noDescriptionAvailable")), map.descriptionProperty()));
ObservableList<MapBean> installedMaps = mapService.getInstalledMaps();
synchronized (installedMaps) {
installedMaps.addListener(new WeakListChangeListener<>(installStatusChangeListener));
}
setInstalled(mapService.isInstalled(map.getFolderName()));
}
Aggregations