@FXML void onMouseClickGameStatus(MouseEvent mouseEvent) { GameStatus gameStatus = playerInfoBean.getGameStatus(); if (gameStatus == GameStatus.NONE) { return; } if (mouseEvent.getButton() == MouseButton.PRIMARY && mouseEvent.getClickCount() == 2) { int uid = playerInfoBean.getGameUid(); if (gameStatus == GameStatus.LOBBY || gameStatus == GameStatus.HOST) { GameInfoBean gameInfoBean = gameService.getByUid(uid); gamesController.onJoinGame( gameInfoBean, null, mouseEvent.getScreenX(), mouseEvent.getScreenY()); } else if (gameStatus == GameStatus.PLAYING) { try { replayService.runLiveReplay(uid, playerInfoBean.getUsername()); } catch (IOException e) { notificationService.addNotification( new ImmediateNotification( i18n.get("errorTitle"), i18n.get("replayCouldNotBeStarted.text"), Severity.ERROR, e, singletonList(new ReportAction(i18n, reportingService, e)))); } } } }
private void moveCorruptedReplayFile(Path replayFile) throws IOException { Path corruptedReplaysDirectory = preferencesService.getCorruptedReplaysDirectory(); Files.createDirectories(corruptedReplaysDirectory); Path target = corruptedReplaysDirectory.resolve(replayFile.getFileName()); logger.debug("Moving corrupted replay file from {} to {}", replayFile, target); Files.move(replayFile, target); notificationService.addNotification( new PersistentNotification( i18n.get("corruptedReplayFiles.notification"), Severity.WARN, Collections.singletonList( new Action( i18n.get("corruptedReplayFiles.show"), event -> { try { // Argh, using AWT since JavaFX doesn't provide a proper method :-( Desktop.getDesktop().open(corruptedReplaysDirectory.toFile()); } catch (IOException e) { logger.warn("Could not reveal corrupted replay directory", e); } })))); }
private void notifyAboutUnlockedAchievement(AchievementDefinition achievementDefinition) { notificationService.addNotification( new TransientNotification( i18n.get("achievement.unlockedTitle"), achievementDefinition.getName(), new Image(achievementDefinition.getUnlockedIconUrl()))); }
private void runReplayFile(Path path) { try { String fileName = path.getFileName().toString(); if (fileName.endsWith(FAF_REPLAY_FILE_ENDING)) { runFafReplayFile(path); } else if (fileName.endsWith(SUP_COM_REPLAY_FILE_ENDING)) { runSupComReplayFile(path); } } catch (IOException e) { logger.warn("Replay could not be started", e); notificationService.addNotification( new PersistentNotification( i18n.get("replayCouldNotBeStarted", path.getFileName()), Severity.ERROR, Collections.singletonList( new Action(i18n.get("report"), event -> reportingService.reportError(e))))); } }