Search in sources :

Example 1 with TeamCardController

use of com.faforever.client.game.TeamCardController in project downlords-faf-client by FAForever.

the class ReplayDetailController method populateTeamsContainer.

private void populateTeamsContainer() {
    if (!replay.getValidity().equals(Validity.VALID)) {
        showRatingChangeButton.setDisable(true);
        showRatingChangeButton.setText(i18n.get("game.notValid"));
    } else if (!replayService.replayChangedRating(replay)) {
        showRatingChangeButton.setDisable(true);
        showRatingChangeButton.setText(i18n.get("game.notRatedYet"));
    }
    Map<Integer, PlayerStats> statsByPlayerId = teams.values().stream().flatMap(Collection::stream).collect(Collectors.toMap(PlayerStats::getPlayerId, Function.identity()));
    Platform.runLater(() -> teams.forEach((team, value) -> {
        List<Integer> playerIds = value.stream().map(PlayerStats::getPlayerId).collect(Collectors.toList());
        TeamCardController controller = uiService.loadFxml("theme/team_card.fxml");
        teamCardControllers.add(controller);
        playerService.getPlayersByIds(playerIds).thenAccept(players -> controller.setPlayersInTeam(team, players, player -> {
            PlayerStats playerStats = statsByPlayerId.get(player.getId());
            return new Rating(playerStats.getBeforeMean(), playerStats.getBeforeDeviation());
        }, RatingType.EXACT));
        teamsContainer.getChildren().add(controller.getRoot());
    }));
}
Also used : Button(javafx.scene.control.Button) UiService(com.faforever.client.theme.UiService) Rating(com.faforever.client.util.Rating) TimeService(com.faforever.client.util.TimeService) ScrollPane(javafx.scene.control.ScrollPane) Duration(java.time.Duration) Map(java.util.Map) TableView(javafx.scene.control.TableView) PlayerService(com.faforever.client.player.PlayerService) Pane(javafx.scene.layout.Pane) ClientProperties(com.faforever.client.config.ClientProperties) TextField(javafx.scene.control.TextField) Collection(java.util.Collection) ObservableMap(javafx.collections.ObservableMap) MapBean(com.faforever.client.map.MapBean) Collectors(java.util.stream.Collectors) Bytes(com.faforever.commons.io.Bytes) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Clipboard(javafx.scene.input.Clipboard) Optional(java.util.Optional) ClipboardContent(javafx.scene.input.ClipboardContent) Temporal(java.time.temporal.Temporal) Setter(lombok.Setter) PreviewSize(com.faforever.client.map.MapServiceImpl.PreviewSize) MouseEvent(javafx.scene.input.MouseEvent) GameOption(com.faforever.client.replay.Replay.GameOption) Function(java.util.function.Function) Scope(org.springframework.context.annotation.Scope) ChatMessage(com.faforever.client.replay.Replay.ChatMessage) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) TeamCardController(com.faforever.client.game.TeamCardController) ReviewsController(com.faforever.client.vault.review.ReviewsController) StringCell(com.faforever.client.fx.StringCell) RatingUtil(com.faforever.client.util.RatingUtil) Label(javafx.scene.control.Label) Controller(com.faforever.client.fx.Controller) JavaFxUtil(com.faforever.client.fx.JavaFxUtil) Node(javafx.scene.Node) RatingType(com.faforever.client.game.RatingType) Component(org.springframework.stereotype.Component) PlayerStats(com.faforever.client.replay.Replay.PlayerStats) ImageView(javafx.scene.image.ImageView) ReviewService(com.faforever.client.vault.review.ReviewService) RatingService(com.faforever.client.rating.RatingService) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) Validity(com.faforever.client.api.dto.Validity) Image(javafx.scene.image.Image) Review(com.faforever.client.vault.review.Review) Assert(org.springframework.util.Assert) Rating(com.faforever.client.util.Rating) List(java.util.List) ArrayList(java.util.ArrayList) PlayerStats(com.faforever.client.replay.Replay.PlayerStats) TeamCardController(com.faforever.client.game.TeamCardController)

Aggregations

Validity (com.faforever.client.api.dto.Validity)1 ClientProperties (com.faforever.client.config.ClientProperties)1 Controller (com.faforever.client.fx.Controller)1 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)1 StringCell (com.faforever.client.fx.StringCell)1 RatingType (com.faforever.client.game.RatingType)1 TeamCardController (com.faforever.client.game.TeamCardController)1 I18n (com.faforever.client.i18n.I18n)1 MapBean (com.faforever.client.map.MapBean)1 MapService (com.faforever.client.map.MapService)1 PreviewSize (com.faforever.client.map.MapServiceImpl.PreviewSize)1 Player (com.faforever.client.player.Player)1 PlayerService (com.faforever.client.player.PlayerService)1 RatingService (com.faforever.client.rating.RatingService)1 ChatMessage (com.faforever.client.replay.Replay.ChatMessage)1 GameOption (com.faforever.client.replay.Replay.GameOption)1 PlayerStats (com.faforever.client.replay.Replay.PlayerStats)1 UiService (com.faforever.client.theme.UiService)1 Rating (com.faforever.client.util.Rating)1 RatingUtil (com.faforever.client.util.RatingUtil)1