Search in sources :

Example 1 with AchievementItemController

use of com.faforever.client.achievements.AchievementItemController in project downlords-faf-client by FAForever.

the class UserInfoWindowController method setAvailableAchievements.

private void setAvailableAchievements(List<AchievementDefinition> achievementDefinitions) {
    ObservableList<Node> children = lockedAchievementsContainer.getChildren();
    Platform.runLater(children::clear);
    achievementDefinitions.forEach(achievementDefinition -> {
        AchievementItemController controller = uiService.loadFxml("theme/achievement_item.fxml");
        controller.setAchievementDefinition(achievementDefinition);
        achievementDefinitionById.put(achievementDefinition.getId(), achievementDefinition);
        achievementItemById.put(achievementDefinition.getId(), controller);
        Platform.runLater(() -> children.add(controller.getRoot()));
    });
}
Also used : Node(javafx.scene.Node) AchievementItemController(com.faforever.client.achievements.AchievementItemController)

Example 2 with AchievementItemController

use of com.faforever.client.achievements.AchievementItemController in project downlords-faf-client by FAForever.

the class UserInfoWindowController method updatePlayerAchievements.

private void updatePlayerAchievements(List<? extends PlayerAchievement> playerAchievements) {
    PlayerAchievement mostRecentPlayerAchievement = null;
    ObservableList<Node> children = unlockedAchievementsContainer.getChildren();
    Platform.runLater(children::clear);
    for (PlayerAchievement playerAchievement : playerAchievements) {
        AchievementItemController achievementItemController = achievementItemById.get(playerAchievement.getAchievement().getId());
        achievementItemController.setPlayerAchievement(playerAchievement);
        if (isUnlocked(playerAchievement)) {
            Platform.runLater(() -> children.add(achievementItemController.getRoot()));
            if (mostRecentPlayerAchievement == null || playerAchievement.getUpdateTime().compareTo(mostRecentPlayerAchievement.getUpdateTime()) > 0) {
                mostRecentPlayerAchievement = playerAchievement;
            }
        }
    }
    if (mostRecentPlayerAchievement == null) {
        mostRecentAchievementPane.setVisible(false);
    } else {
        mostRecentAchievementPane.setVisible(true);
        AchievementDefinition mostRecentAchievement = achievementDefinitionById.get(mostRecentPlayerAchievement.getAchievement().getId());
        if (mostRecentAchievement == null) {
            return;
        }
        String mostRecentAchievementName = mostRecentAchievement.getName();
        String mostRecentAchievementDescription = mostRecentAchievement.getDescription();
        Platform.runLater(() -> {
            mostRecentAchievementNameLabel.setText(mostRecentAchievementName);
            mostRecentAchievementDescriptionLabel.setText(mostRecentAchievementDescription);
            mostRecentAchievementImageView.setImage(achievementService.getImage(mostRecentAchievement, UNLOCKED));
        });
    }
}
Also used : Node(javafx.scene.Node) PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) AchievementItemController(com.faforever.client.achievements.AchievementItemController) AchievementDefinition(com.faforever.client.api.dto.AchievementDefinition)

Aggregations

AchievementItemController (com.faforever.client.achievements.AchievementItemController)2 Node (javafx.scene.Node)2 AchievementDefinition (com.faforever.client.api.dto.AchievementDefinition)1 PlayerAchievement (com.faforever.client.api.dto.PlayerAchievement)1