Search in sources :

Example 1 with Action

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

the class GameServiceImpl method onCurrentGameEnded.

private void onCurrentGameEnded() {
    synchronized (currentGame) {
        int currentGameId = currentGame.get().getId();
        notificationService.addNotification(new PersistentNotification(i18n.get("game.ended", currentGame.get().getTitle()), Severity.INFO, singletonList(new Action(i18n.get("game.rate"), actionEvent -> replayService.findById(currentGameId).thenAccept(replay -> externalReplayInfoGenerator.showExternalReplayInfo(replay, String.valueOf(currentGameId)))))));
    }
}
Also used : Arrays(java.util.Arrays) RehostRequestEvent(com.faforever.client.fa.relay.event.RehostRequestEvent) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) LoggerFactory(org.slf4j.LoggerFactory) ReadOnlyBooleanProperty(javafx.beans.property.ReadOnlyBooleanProperty) ReportingService(com.faforever.client.reporting.ReportingService) ConnectionState(com.faforever.client.net.ConnectionState) GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) Collections.singletonList(java.util.Collections.singletonList) ListChangeListener(javafx.collections.ListChangeListener) Map(java.util.Map) GameStatus(com.faforever.client.remote.domain.GameStatus) URI(java.net.URI) PlayerService(com.faforever.client.player.PlayerService) Path(java.nio.file.Path) ClientProperties(com.faforever.client.config.ClientProperties) CancellationException(java.util.concurrent.CancellationException) MethodHandles(java.lang.invoke.MethodHandles) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ObservableMap(javafx.collections.ObservableMap) Observable(javafx.beans.Observable) DismissAction(com.faforever.client.notification.DismissAction) FeaturedMod(com.faforever.client.mod.FeaturedMod) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) Nullable(org.jetbrains.annotations.Nullable) RatingMode(com.faforever.client.fa.RatingMode) BooleanProperty(javafx.beans.property.BooleanProperty) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ForgedAllianceService(com.faforever.client.fa.ForgedAllianceService) PostConstruct(javax.annotation.PostConstruct) ModService(com.faforever.client.mod.ModService) Lazy(org.springframework.context.annotation.Lazy) ObservableList(javafx.collections.ObservableList) NotNull(org.jetbrains.annotations.NotNull) PreferencesService(com.faforever.client.preferences.PreferencesService) WeakChangeListener(javafx.beans.value.WeakChangeListener) GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage) LoginMessage(com.faforever.client.remote.domain.LoginMessage) FXCollections(javafx.collections.FXCollections) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) IceAdapter(com.faforever.client.fa.relay.ice.IceAdapter) PlatformService(com.faforever.client.fx.PlatformService) GameUpdater(com.faforever.client.patch.GameUpdater) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) HashSet(java.util.HashSet) NotificationService(com.faforever.client.notification.NotificationService) Service(org.springframework.stereotype.Service) ERROR(com.faforever.client.notification.Severity.ERROR) Subscribe(com.google.common.eventbus.Subscribe) ReportAction(com.faforever.client.notification.ReportAction) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Collections.emptySet(java.util.Collections.emptySet) Executor(java.util.concurrent.Executor) JavaFxUtil(com.faforever.client.fx.JavaFxUtil) Action(com.faforever.client.notification.Action) ReplayService(com.faforever.client.replay.ReplayService) IOException(java.io.IOException) MatchmakerMessage(com.faforever.client.rankedmatch.MatchmakerMessage) PersistentNotification(com.faforever.client.notification.PersistentNotification) FafService(com.faforever.client.remote.FafService) Consumer(java.util.function.Consumer) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Severity(com.faforever.client.notification.Severity) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) LADDER_1V1(com.faforever.client.game.KnownFeaturedMod.LADDER_1V1) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) NONE(com.faforever.client.fa.RatingMode.NONE) ExternalReplayInfoGenerator(com.faforever.client.replay.ExternalReplayInfoGenerator) VisibleForTesting(com.google.common.annotations.VisibleForTesting) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) Collections(java.util.Collections) NoCatch.noCatch(com.github.nocatch.NoCatch.noCatch) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) Action(com.faforever.client.notification.Action) PersistentNotification(com.faforever.client.notification.PersistentNotification)

Example 2 with Action

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

the class MissingGamePathNotifier method onMissingGamePathEvent.

@Subscribe
public void onMissingGamePathEvent(MissingGamePathEvent event) {
    List<Action> actions = Collections.singletonList(new Action(i18n.get("missingGamePath.locate"), chooseEvent -> eventBus.post(new GameDirectoryChooseEvent())));
    String notificationText = i18n.get("missingGamePath.notification");
    if (event.isImmediateUserActionRequired()) {
        notificationService.addNotification(new ImmediateNotification(notificationText, notificationText, Severity.WARN, actions));
    } else {
        notificationService.addNotification(new PersistentNotification(notificationText, Severity.WARN, actions));
    }
}
Also used : Action(com.faforever.client.notification.Action) PersistentNotification(com.faforever.client.notification.PersistentNotification) MissingGamePathEvent(com.faforever.client.preferences.event.MissingGamePathEvent) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) Component(org.springframework.stereotype.Component) List(java.util.List) Severity(com.faforever.client.notification.Severity) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) PostConstruct(javax.annotation.PostConstruct) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) Subscribe(com.google.common.eventbus.Subscribe) I18n(com.faforever.client.i18n.I18n) Collections(java.util.Collections) Action(com.faforever.client.notification.Action) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) PersistentNotification(com.faforever.client.notification.PersistentNotification) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with Action

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

the class ReplayServiceImpl method moveCorruptedReplayFile.

private void moveCorruptedReplayFile(Path replayFile) {
    Path corruptedReplaysDirectory = preferencesService.getCorruptedReplaysDirectory();
    noCatch(() -> createDirectories(corruptedReplaysDirectory));
    Path target = corruptedReplaysDirectory.resolve(replayFile.getFileName());
    logger.debug("Moving corrupted replay file from {} to {}", replayFile, target);
    noCatch(() -> move(replayFile, target));
    notificationService.addNotification(new PersistentNotification(i18n.get("corruptedReplayFiles.notification"), WARN, singletonList(new Action(i18n.get("corruptedReplayFiles.show"), event -> platformService.reveal(replayFile)))));
}
Also used : Path(java.nio.file.Path) GameService(com.faforever.client.game.GameService) SneakyThrows(lombok.SneakyThrows) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) ReportingService(com.faforever.client.reporting.ReportingService) Collections.singletonList(java.util.Collections.singletonList) DirectoryStream(java.nio.file.DirectoryStream) ByteArrayInputStream(java.io.ByteArrayInputStream) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) URI(java.net.URI) Splitter(com.google.common.base.Splitter) Path(java.nio.file.Path) ClientProperties(com.faforever.client.config.ClientProperties) URIBuilder(org.apache.http.client.utils.URIBuilder) UrlEscapers(com.google.common.net.UrlEscapers) MethodHandles(java.lang.invoke.MethodHandles) Collection(java.util.Collection) Set(java.util.Set) Files.createDirectories(java.nio.file.Files.createDirectories) DismissAction(com.faforever.client.notification.DismissAction) Collectors(java.util.stream.Collectors) Bytes(com.google.common.primitives.Bytes) FeaturedMod(com.faforever.client.mod.FeaturedMod) List(java.util.List) Optional(java.util.Optional) ModService(com.faforever.client.mod.ModService) Lazy(org.springframework.context.annotation.Lazy) TaskService(com.faforever.client.task.TaskService) PreferencesService(com.faforever.client.preferences.PreferencesService) Files.move(java.nio.file.Files.move) GameOption(com.faforever.client.replay.Replay.GameOption) CompletableFuture(java.util.concurrent.CompletableFuture) ChatMessage(com.faforever.client.replay.Replay.ChatMessage) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) PlatformService(com.faforever.client.fx.PlatformService) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) KnownFeaturedMod(com.faforever.client.game.KnownFeaturedMod) Service(org.springframework.stereotype.Service) WARN(com.faforever.client.notification.Severity.WARN) ReplayData(com.faforever.commons.replay.ReplayData) SortConfig(com.faforever.client.vault.search.SearchController.SortConfig) ReportAction(com.faforever.client.notification.ReportAction) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Collections.emptySet(java.util.Collections.emptySet) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Action(com.faforever.client.notification.Action) IOException(java.io.IOException) ApplicationContext(org.springframework.context.ApplicationContext) PersistentNotification(com.faforever.client.notification.PersistentNotification) URLDecoder.decode(java.net.URLDecoder.decode) FafService(com.faforever.client.remote.FafService) US_ASCII(java.nio.charset.StandardCharsets.US_ASCII) Severity(com.faforever.client.notification.Severity) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) VisibleForTesting(com.google.common.annotations.VisibleForTesting) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) NoCatch.noCatch(com.github.nocatch.NoCatch.noCatch) Game(com.faforever.client.game.Game) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) Action(com.faforever.client.notification.Action) PersistentNotification(com.faforever.client.notification.PersistentNotification)

Example 4 with Action

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

the class GameServiceImpl method notifyCantPlayReplay.

private void notifyCantPlayReplay(@Nullable Integer replayId, Throwable throwable) {
    logger.error("Could not play replay '" + replayId + "'", throwable);
    notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("replayCouldNotBeStarted", replayId), ERROR, throwable, singletonList(new Action(i18n.get("report")))));
}
Also used : DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) Action(com.faforever.client.notification.Action) ImmediateNotification(com.faforever.client.notification.ImmediateNotification)

Example 5 with Action

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

the class MockFafServerAccessor method connectAndLogIn.

@Override
public CompletableFuture<LoginMessage> connectAndLogIn(String username, String password) {
    return taskService.submitTask(new CompletableTask<LoginMessage>(HIGH) {

        @Override
        protected LoginMessage call() throws Exception {
            updateTitle(i18n.get("login.progress.message"));
            Player player = new Player();
            player.setId(4812);
            player.setLogin(USER_NAME);
            player.setClan("ABC");
            player.setCountry("A1");
            player.setGlobalRating(new float[] { 1500, 220 });
            player.setLadderRating(new float[] { 1500, 220 });
            player.setNumberOfGames(330);
            PlayersMessage playersMessage = new PlayersMessage();
            playersMessage.setPlayers(singletonList(player));
            eventBus.post(new LoginSuccessEvent(username, password, player.getId()));
            messageListeners.getOrDefault(playersMessage.getClass(), Collections.emptyList()).forEach(consumer -> consumer.accept(playersMessage));
            timer.schedule(new TimerTask() {

                @Override
                public void run() {
                    UpdatedAchievementsMessage updatedAchievementsMessage = new UpdatedAchievementsMessage();
                    UpdatedAchievement updatedAchievement = new UpdatedAchievement();
                    updatedAchievement.setAchievementId("50260d04-90ff-45c8-816b-4ad8d7b97ecd");
                    updatedAchievement.setNewlyUnlocked(true);
                    updatedAchievementsMessage.setUpdatedAchievements(Arrays.asList(updatedAchievement));
                    messageListeners.getOrDefault(updatedAchievementsMessage.getClass(), Collections.emptyList()).forEach(consumer -> consumer.accept(updatedAchievementsMessage));
                }
            }, 7000);
            timer.schedule(new TimerTask() {

                @Override
                public void run() {
                    MatchmakerMessage matchmakerServerMessage = new MatchmakerMessage();
                    matchmakerServerMessage.setQueues(singletonList(new MatchmakerQueue("ladder1v1", singletonList(new RatingRange(100, 200)), singletonList(new RatingRange(100, 200)))));
                    messageListeners.getOrDefault(matchmakerServerMessage.getClass(), Collections.emptyList()).forEach(consumer -> consumer.accept(matchmakerServerMessage));
                }
            }, 7000);
            List<GameInfoMessage> gameInfoMessages = Arrays.asList(createGameInfo(1, "Mock game 500 - 800", PUBLIC, "faf", "scmp_010", 1, 6, "Mock user"), createGameInfo(2, "Mock game 500+", PUBLIC, "faf", "scmp_011", 2, 6, "Mock user"), createGameInfo(3, "Mock game +500", PUBLIC, "faf", "scmp_012", 3, 6, "Mock user"), createGameInfo(4, "Mock game <1000", PUBLIC, "faf", "scmp_013", 4, 6, "Mock user"), createGameInfo(5, "Mock game >1000", PUBLIC, "faf", "scmp_014", 5, 6, "Mock user"), createGameInfo(6, "Mock game ~600", PASSWORD, "faf", "scmp_015", 6, 6, "Mock user"), createGameInfo(7, "Mock game 7", PASSWORD, "faf", "scmp_016", 7, 6, "Mock user"));
            gameInfoMessages.forEach(gameInfoMessage -> messageListeners.getOrDefault(gameInfoMessage.getClass(), Collections.emptyList()).forEach(consumer -> consumer.accept(gameInfoMessage)));
            notificationService.addNotification(new PersistentNotification("How about a long-running (7s) mock task?", Severity.INFO, Arrays.asList(new Action("Execute", event -> taskService.submitTask(new CompletableTask<Void>(HIGH) {

                @Override
                protected Void call() throws Exception {
                    updateTitle("Mock task");
                    Thread.sleep(2000);
                    for (int i = 0; i < 5; i++) {
                        updateProgress(i, 5);
                        Thread.sleep(1000);
                    }
                    return null;
                }
            })), new Action("Nope"))));
            LoginMessage sessionInfo = new LoginMessage();
            sessionInfo.setId(123);
            sessionInfo.setLogin(USER_NAME);
            return sessionInfo;
        }
    }).getFuture();
}
Also used : NewGameInfo(com.faforever.client.game.NewGameInfo) Arrays(java.util.Arrays) PUBLIC(com.faforever.client.remote.domain.GameAccess.PUBLIC) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) Timer(java.util.Timer) Faction(com.faforever.client.game.Faction) ConnectionState(com.faforever.client.net.ConnectionState) GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) Collections.singletonList(java.util.Collections.singletonList) HIGH(com.faforever.client.task.CompletableTask.Priority.HIGH) IceServer(com.faforever.client.remote.domain.IceServersServerMessage.IceServer) GameStatus(com.faforever.client.remote.domain.GameStatus) TimerTask(java.util.TimerTask) FafClientApplication(com.faforever.client.FafClientApplication) Collections.emptyList(java.util.Collections.emptyList) MethodHandles(java.lang.invoke.MethodHandles) Collection(java.util.Collection) PASSWORD(com.faforever.client.remote.domain.GameAccess.PASSWORD) PlayersMessage(com.faforever.client.remote.domain.PlayersMessage) List(java.util.List) Lazy(org.springframework.context.annotation.Lazy) TaskService(com.faforever.client.task.TaskService) Player(com.faforever.client.remote.domain.Player) LoginSuccessEvent(com.faforever.client.user.event.LoginSuccessEvent) MatchmakerQueue(com.faforever.client.rankedmatch.MatchmakerMessage.MatchmakerQueue) GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage) Avatar(com.faforever.client.remote.domain.Avatar) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) CompletableTask(com.faforever.client.task.CompletableTask) LoginMessage(com.faforever.client.remote.domain.LoginMessage) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) GameAccess(com.faforever.client.remote.domain.GameAccess) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) KnownFeaturedMod(com.faforever.client.game.KnownFeaturedMod) LinkedList(java.util.LinkedList) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) Action(com.faforever.client.notification.Action) MatchmakerMessage(com.faforever.client.rankedmatch.MatchmakerMessage) Profile(org.springframework.context.annotation.Profile) PersistentNotification(com.faforever.client.notification.PersistentNotification) Consumer(java.util.function.Consumer) ServerMessage(com.faforever.client.remote.domain.ServerMessage) Component(org.springframework.stereotype.Component) RatingRange(com.faforever.client.remote.domain.RatingRange) Severity(com.faforever.client.notification.Severity) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) I18n(com.faforever.client.i18n.I18n) Collections(java.util.Collections) GpgGameMessage(com.faforever.client.fa.relay.GpgGameMessage) Player(com.faforever.client.remote.domain.Player) Action(com.faforever.client.notification.Action) MatchmakerMessage(com.faforever.client.rankedmatch.MatchmakerMessage) CompletableTask(com.faforever.client.task.CompletableTask) PlayersMessage(com.faforever.client.remote.domain.PlayersMessage) MatchmakerQueue(com.faforever.client.rankedmatch.MatchmakerMessage.MatchmakerQueue) TimerTask(java.util.TimerTask) RatingRange(com.faforever.client.remote.domain.RatingRange) GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) LoginMessage(com.faforever.client.remote.domain.LoginMessage) LoginSuccessEvent(com.faforever.client.user.event.LoginSuccessEvent) PersistentNotification(com.faforever.client.notification.PersistentNotification)

Aggregations

Action (com.faforever.client.notification.Action)8 I18n (com.faforever.client.i18n.I18n)7 NotificationService (com.faforever.client.notification.NotificationService)7 PersistentNotification (com.faforever.client.notification.PersistentNotification)7 Inject (javax.inject.Inject)7 Severity (com.faforever.client.notification.Severity)6 Collections (java.util.Collections)5 Lazy (org.springframework.context.annotation.Lazy)5 ImmediateNotification (com.faforever.client.notification.ImmediateNotification)4 EventBus (com.google.common.eventbus.EventBus)4 IOException (java.io.IOException)4 MethodHandles (java.lang.invoke.MethodHandles)4 Collections.singletonList (java.util.Collections.singletonList)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 ClientProperties (com.faforever.client.config.ClientProperties)3 PlatformService (com.faforever.client.fx.PlatformService)3 DismissAction (com.faforever.client.notification.DismissAction)3 ReportAction (com.faforever.client.notification.ReportAction)3