Search in sources :

Example 1 with FaStrings

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());
}
Also used : FaStrings(com.faforever.client.fa.FaStrings) BackgroundImage(javafx.scene.layout.BackgroundImage) BackgroundSize(javafx.scene.layout.BackgroundSize) Background(javafx.scene.layout.Background) MapSize(com.faforever.client.map.MapSize) BackgroundImage(javafx.scene.layout.BackgroundImage) Image(javafx.scene.image.Image)

Example 2 with FaStrings

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()));
}
Also used : LocalDateTime(java.time.LocalDateTime) Player(com.faforever.client.player.Player) Strings(com.google.common.base.Strings) FaStrings(com.faforever.client.fa.FaStrings)

Aggregations

FaStrings (com.faforever.client.fa.FaStrings)2 MapSize (com.faforever.client.map.MapSize)1 Player (com.faforever.client.player.Player)1 Strings (com.google.common.base.Strings)1 LocalDateTime (java.time.LocalDateTime)1 Image (javafx.scene.image.Image)1 Background (javafx.scene.layout.Background)1 BackgroundImage (javafx.scene.layout.BackgroundImage)1 BackgroundSize (javafx.scene.layout.BackgroundSize)1