Search in sources :

Example 6 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class ModDetailController method setModVersion.

public void setModVersion(ModVersion modVersion) {
    this.modVersion = modVersion;
    thumbnailImageView.setImage(modService.loadThumbnail(modVersion));
    nameLabel.setText(modVersion.getDisplayName());
    authorLabel.setText(modVersion.getUploader());
    boolean modInstalled = modService.isModInstalled(modVersion.getUid());
    installButton.setVisible(!modInstalled);
    uninstallButton.setVisible(modInstalled);
    modDescriptionLabel.setText(modVersion.getDescription());
    modService.getInstalledModVersions().addListener(new WeakListChangeListener<>(installStatusChangeListener));
    setInstalled(modService.isModInstalled(modVersion.getUid()));
    updatedLabel.setText(timeService.asDate(modVersion.getUpdateTime()));
    sizeLabel.setText(Bytes.formatSize(getModSize(), i18n.getUserSpecificLocale()));
    installationsLabel.setText(String.format(i18n.getUserSpecificLocale(), "%d", modVersion.getDownloads()));
    versionLabel.setText(modVersion.getVersion().toString());
    Player player = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("No current player is available"));
    reviewsController.setCanWriteReview(modService.isModInstalled(modVersion.getUid()));
    reviewsController.setOnSendReviewListener(this::onSendReview);
    reviewsController.setOnDeleteReviewListener(this::onDeleteReview);
    reviewsController.setReviews(modVersion.getReviews());
    reviewsController.setOwnReview(modVersion.getReviews().stream().filter(review -> review.getPlayer().getId() == player.getId()).findFirst());
}
Also used : Player(com.faforever.client.player.Player)

Example 7 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class ModDetailController method onSendReview.

private void onSendReview(Review review) {
    boolean isNew = review.getId() == null;
    Player player = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("No current player is available"));
    review.setPlayer(player);
    reviewService.saveModVersionReview(review, modVersion.getId()).thenRun(() -> {
        if (isNew) {
            modVersion.getReviews().add(review);
        }
        reviewsController.setOwnReview(Optional.of(review));
    }).exceptionally(throwable -> {
        log.warn("Review could not be saved", throwable);
        return null;
    });
}
Also used : Player(com.faforever.client.player.Player)

Example 8 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class MapDetailController method onSendReview.

private void onSendReview(Review review) {
    boolean isNew = review.getId() == null;
    Player player = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("No current player is available"));
    review.setPlayer(player);
    reviewService.saveMapVersionReview(review, map.getId()).thenRun(() -> {
        if (isNew) {
            map.getReviews().add(review);
        }
        reviewsController.setOwnReview(Optional.of(review));
    }).exceptionally(throwable -> {
        log.warn("Review could not be saved", throwable);
        return null;
    });
}
Also used : Player(com.faforever.client.player.Player)

Example 9 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class ReplayDetailController method onSendReview.

private void onSendReview(Review review) {
    boolean isNew = review.getId() == null;
    Player player = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("No current player is available"));
    review.setPlayer(player);
    reviewService.saveGameReview(review, replay.getId()).thenRun(() -> {
        if (isNew) {
            replay.getReviews().add(review);
        }
        reviewsController.setOwnReview(Optional.of(review));
    }).exceptionally(throwable -> {
        log.warn("Review could not be saved", throwable);
        return null;
    });
}
Also used : Player(com.faforever.client.player.Player)

Example 10 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class AchievementServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    instance = new AchievementServiceImpl(fafService, playerService, assetService);
    Player player = new Player("abc");
    player.setId(PLAYER_ID);
    when(playerService.getCurrentPlayer()).thenReturn(Optional.of(player));
    instance.postConstruct();
}
Also used : Player(com.faforever.client.player.Player) Before(org.junit.Before)

Aggregations

Player (com.faforever.client.player.Player)51 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)17 Test (org.junit.Test)17 Pane (javafx.scene.layout.Pane)8 I18n (com.faforever.client.i18n.I18n)7 PlayerService (com.faforever.client.player.PlayerService)7 UiService (com.faforever.client.theme.UiService)7 ClientProperties (com.faforever.client.config.ClientProperties)6 Controller (com.faforever.client.fx.Controller)6 ArrayList (java.util.ArrayList)6 Platform (javafx.application.Platform)6 Node (javafx.scene.Node)6 Scope (org.springframework.context.annotation.Scope)6 Component (org.springframework.stereotype.Component)6 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)5 NotificationService (com.faforever.client.notification.NotificationService)5 TimeService (com.faforever.client.util.TimeService)5 Collection (java.util.Collection)5 List (java.util.List)5 Map (java.util.Map)5