Search in sources :

Example 1 with TransientNotificationsController

use of com.faforever.client.notification.TransientNotificationsController in project downlords-faf-client by FAForever.

the class MainController method initialize.

public void initialize() {
    newsButton.setUserData(NavigationItem.NEWS);
    chatButton.setUserData(NavigationItem.CHAT);
    playButton.setUserData(NavigationItem.PLAY);
    vaultButton.setUserData(NavigationItem.VAULT);
    leaderboardsButton.setUserData(NavigationItem.LEADERBOARD);
    unitsButton.setUserData(NavigationItem.UNITS);
    eventBus.register(this);
    windowController = uiService.loadFxml("theme/window.fxml");
    PersistentNotificationsController persistentNotificationsController = uiService.loadFxml("theme/persistent_notifications.fxml");
    persistentNotificationsPopup = new Popup();
    persistentNotificationsPopup.getContent().setAll(persistentNotificationsController.getRoot());
    persistentNotificationsPopup.setAnchorLocation(AnchorLocation.CONTENT_TOP_RIGHT);
    persistentNotificationsPopup.setAutoFix(true);
    persistentNotificationsPopup.setAutoHide(true);
    TransientNotificationsController transientNotificationsController = uiService.loadFxml("theme/transient_notifications.fxml");
    transientNotificationsPopup = new Popup();
    transientNotificationsPopup.setAutoFix(true);
    transientNotificationsPopup.getScene().getRoot().getStyleClass().add("transient-notification");
    transientNotificationsPopup.getContent().setAll(transientNotificationsController.getRoot());
    transientNotificationsController.getRoot().getChildren().addListener(new ToastDisplayer(transientNotificationsController));
    updateNotificationsButton(Collections.emptyList());
    notificationService.addPersistentNotificationListener(change -> runLater(() -> updateNotificationsButton(change.getSet())));
    notificationService.addImmediateNotificationListener(notification -> runLater(() -> displayImmediateNotification(notification)));
    notificationService.addTransientNotificationListener(notification -> runLater(() -> transientNotificationsController.addNotification(notification)));
    gameService.addOnRankedMatchNotificationListener(this::onMatchmakerMessage);
    // Always load chat immediately so messages or joined channels don't need to be cached until we display them.
    getView(NavigationItem.CHAT);
}
Also used : Popup(javafx.stage.Popup) PersistentNotificationsController(com.faforever.client.notification.PersistentNotificationsController) TransientNotificationsController(com.faforever.client.notification.TransientNotificationsController)

Aggregations

PersistentNotificationsController (com.faforever.client.notification.PersistentNotificationsController)1 TransientNotificationsController (com.faforever.client.notification.TransientNotificationsController)1 Popup (javafx.stage.Popup)1