Search in sources :

Example 6 with ReportAction

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

the class FafServerAccessorImpl method onUIDNotExecuted.

@VisibleForTesting
protected void onUIDNotExecuted(Exception e) {
    logger.error("UID.exe not executed", e);
    if (e.getMessage() == null) {
        return;
    }
    notificationService.addNotification(new ImmediateNotification(i18n.get("UIDNotExecuted"), e.getMessage(), Severity.ERROR, Collections.singletonList(new ReportAction(i18n, reportingService, e))));
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ReportAction(com.faforever.client.notification.ReportAction) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 7 with ReportAction

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

the class ReplayServiceImpl method runLiveReplay.

@Override
public void runLiveReplay(URI uri) {
    logger.debug("Running replay from URL: {}", uri);
    if (!uri.getScheme().equals(FAF_LIFE_PROTOCOL)) {
        throw new IllegalArgumentException("Invalid protocol: " + uri.getScheme());
    }
    Map<String, String> queryParams = Splitter.on('&').trimResults().withKeyValueSeparator("=").split(uri.getQuery());
    String gameType = queryParams.get("mod");
    String mapName = noCatch(() -> decode(queryParams.get("map"), UTF_8.name()));
    Integer gameId = Integer.parseInt(uri.getPath().split("/")[1]);
    try {
        URI replayUri = new URI(GPGNET_SCHEME, null, uri.getHost(), uri.getPort(), uri.getPath(), null, null);
        gameService.runWithLiveReplay(replayUri, gameId, gameType, mapName).exceptionally(throwable -> {
            notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("liveReplayCouldNotBeStarted"), Severity.ERROR, throwable, asList(new DismissAction(i18n), new ReportAction(i18n, reportingService, throwable))));
            return null;
        });
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 8 with ReportAction

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

the class JoinGameHelper method join.

public void join(Game game, String password, boolean ignoreRating) {
    Player currentPlayer = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("Player has not been set"));
    int playerRating = RatingUtil.getRoundedGlobalRating(currentPlayer);
    if (!preferencesService.isGamePathValid()) {
        CompletableFuture<Path> gameDirectoryFuture = new CompletableFuture<>();
        eventBus.post(new GameDirectoryChooseEvent(gameDirectoryFuture));
        gameDirectoryFuture.thenAccept(path -> Optional.ofNullable(path).ifPresent(path1 -> join(game, password, ignoreRating)));
        return;
    }
    if (!ignoreRating && (playerRating < game.getMinRating() || playerRating > game.getMaxRating())) {
        showRatingOutOfBoundsConfirmation(playerRating, game, password);
        return;
    }
    if (game.getPasswordProtected() && password == null) {
        EnterPasswordController enterPasswordController = uiService.loadFxml("theme/enter_password.fxml");
        enterPasswordController.setOnPasswordEnteredListener(this::join);
        enterPasswordController.setGame(game);
        enterPasswordController.setIgnoreRating(ignoreRating);
        enterPasswordController.showPasswordDialog(StageHolder.getStage());
    } else {
        gameService.joinGame(game, password).exceptionally(throwable -> {
            logger.warn("Game could not be joined", throwable);
            notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("games.couldNotJoin"), ERROR, throwable, asList(new DismissAction(i18n), new ReportAction(i18n, reportingService, throwable))));
            return null;
        });
    }
}
Also used : Path(java.nio.file.Path) PreferencesService(com.faforever.client.preferences.PreferencesService) UiService(com.faforever.client.theme.UiService) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) ReportingService(com.faforever.client.reporting.ReportingService) Scope(org.springframework.context.annotation.Scope) EventBus(com.google.common.eventbus.EventBus) NotificationService(com.faforever.client.notification.NotificationService) Arrays.asList(java.util.Arrays.asList) ERROR(com.faforever.client.notification.Severity.ERROR) PlayerService(com.faforever.client.player.PlayerService) Path(java.nio.file.Path) ReportAction(com.faforever.client.notification.ReportAction) RatingUtil(com.faforever.client.util.RatingUtil) Logger(org.slf4j.Logger) MethodHandles(java.lang.invoke.MethodHandles) Action(com.faforever.client.notification.Action) DismissAction(com.faforever.client.notification.DismissAction) Player(com.faforever.client.player.Player) StageHolder(com.faforever.client.ui.StageHolder) Component(org.springframework.stereotype.Component) Severity(com.faforever.client.notification.Severity) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) Optional(java.util.Optional) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) I18n(com.faforever.client.i18n.I18n) Player(com.faforever.client.player.Player) CompletableFuture(java.util.concurrent.CompletableFuture) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent)

Example 9 with ReportAction

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

the class ModDetailController method onInstallButtonClicked.

public void onInstallButtonClicked() {
    installButton.setVisible(false);
    modService.downloadAndInstallMod(modVersion, progressBar.progressProperty(), progressLabel.textProperty()).thenRun(() -> uninstallButton.setVisible(true)).exceptionally(throwable -> {
        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("modVault.installationFailed", modVersion.getDisplayName(), throwable.getLocalizedMessage()), Severity.ERROR, throwable, singletonList(new ReportAction(i18n, reportingService, throwable))));
        return null;
    });
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ReportAction(com.faforever.client.notification.ReportAction)

Example 10 with ReportAction

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

the class MapDetailController method onInstallButtonClicked.

public void onInstallButtonClicked() {
    installButton.setVisible(false);
    mapService.downloadAndInstallMap(map, progressBar.progressProperty(), progressLabel.textProperty()).thenRun(() -> setInstalled(true)).exceptionally(throwable -> {
        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("mapVault.installationFailed", map.getDisplayName(), throwable.getLocalizedMessage()), Severity.ERROR, throwable, singletonList(new ReportAction(i18n, reportingService, throwable))));
        setInstalled(false);
        return null;
    });
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ReportAction(com.faforever.client.notification.ReportAction)

Aggregations

ReportAction (com.faforever.client.notification.ReportAction)12 ImmediateNotification (com.faforever.client.notification.ImmediateNotification)11 DismissAction (com.faforever.client.notification.DismissAction)6 I18n (com.faforever.client.i18n.I18n)4 NotificationService (com.faforever.client.notification.NotificationService)4 Severity (com.faforever.client.notification.Severity)4 ReportingService (com.faforever.client.reporting.ReportingService)4 Player (com.faforever.client.player.Player)3 PlayerService (com.faforever.client.player.PlayerService)3 PreferencesService (com.faforever.client.preferences.PreferencesService)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 MethodHandles (java.lang.invoke.MethodHandles)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 ClientProperties (com.faforever.client.config.ClientProperties)2 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)2 PlatformService (com.faforever.client.fx.PlatformService)2 NavigateEvent (com.faforever.client.main.event.NavigateEvent)2 PersistentNotification (com.faforever.client.notification.PersistentNotification)2 UiService (com.faforever.client.theme.UiService)2