@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)))); } } } }
@FXML void onMouseEnterGameStatus() { if (playerInfoBean.getGameStatus() == GameStatus.NONE) { return; } GameStatusTooltipController gameStatusTooltipController = applicationContext.getBean(GameStatusTooltipController.class); gameStatusTooltipController.setGameInfoBean(gameService.getByUid(playerInfoBean.getGameUid())); Tooltip statusTooltip = new Tooltip(); statusTooltip.setGraphic(gameStatusTooltipController.getRoot()); Tooltip.install(statusImageView, statusTooltip); }
@Override public void runLiveReplay(URI uri) throws IOException { 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 mod = queryParams.get("mod"); String mapName = queryParams.get("map"); Integer replayId = Integer.parseInt(queryParams.get(uri.getPath().split("/")[0])); try { URL gpgReplayUrl = new URL(GPGNET_SCHEME, uri.getHost(), uri.getPort(), uri.getPath()); gameService.runWithReplay(gpgReplayUrl, replayId); } catch (MalformedURLException e) { throw new RuntimeException(); } }
private void runFafReplayFile(Path path) throws IOException { String fileName = path.getFileName().toString(); byte[] rawReplayBytes = replayFileReader.readReplayData(path); Path tempSupComReplayFile = preferencesService.getCacheDirectory().resolve(TEMP_SCFA_REPLAY_FILE_NAME); Files.createDirectories(tempSupComReplayFile.getParent()); Files.copy( new ByteArrayInputStream(rawReplayBytes), tempSupComReplayFile, StandardCopyOption.REPLACE_EXISTING); LocalReplayInfo replayInfo = replayFileReader.readReplayInfo(path); String featuredMod = replayInfo.featuredMod; Integer replayId = replayInfo.uid; Map<String, Integer> featuredModVersions = replayInfo.featuredModVersions; String version = parseSupComVersion(rawReplayBytes); gameService.runWithReplay(tempSupComReplayFile, replayId); }
private void runSupComReplayFile(Path path) throws IOException { String fileName = path.getFileName().toString(); String featuredMod = guessModByFileName(fileName); gameService.runWithReplay(path, null); }