Search in sources :

Example 6 with FeaturedMod

use of com.faforever.client.mod.FeaturedMod in project downlords-faf-client by FAForever.

the class GameStatusTooltipController method setGameInfoBean.

// TODO use or remove
public void setGameInfoBean(Game game) {
    gameTypeLabel.textProperty().bind(Bindings.createStringBinding(() -> {
        FeaturedMod gameType = modService.getFeaturedMod(game.getFeaturedMod()).get();
        String fullName = gameType != null ? gameType.getDisplayName() : null;
        return StringUtils.defaultString(fullName);
    }, game.featuredModProperty()));
    gameTitleLabel.textProperty().bind(game.titleProperty());
    hostLabel.textProperty().bind(game.hostProperty());
    gameMapLabel.textProperty().bind(game.mapFolderNameProperty());
    numberOfPlayersLabel.textProperty().bind(Bindings.createStringBinding(() -> i18n.get("game.players.format", game.getNumPlayers(), game.getMaxPlayers()), game.numPlayersProperty()));
    modsLabel.textProperty().bind(Bindings.createStringBinding(() -> Joiner.on(i18n.get("textSeparator")).join(game.getSimMods().values()), game.mapFolderNameProperty()));
    lockIconLabel.visibleProperty().bind(game.passwordProtectedProperty());
    // TODO display "unknown map" image first since loading may take a while
    mapImageView.imageProperty().bind(Bindings.createObjectBinding(() -> mapService.loadPreview(game.getMapFolderName(), PreviewSize.SMALL), game.mapFolderNameProperty()));
    GameTooltipController gameTooltipController = uiService.loadFxml("theme/play/game_tooltip.fxml");
    gameTooltipController.setGameInfoBean(game);
    gameStatusTooltipRoot.getChildren().add(gameTooltipController.getRoot());
    gameStatusTooltipRoot.getChildren();
}
Also used : FeaturedMod(com.faforever.client.mod.FeaturedMod) GameTooltipController(com.faforever.client.game.GameTooltipController)

Example 7 with FeaturedMod

use of com.faforever.client.mod.FeaturedMod in project downlords-faf-client by FAForever.

the class ReplayServiceImpl method getLocalReplays.

@Override
@SneakyThrows
public Collection<Replay> getLocalReplays() {
    Collection<Replay> replayInfos = new ArrayList<>();
    String replayFileGlob = clientProperties.getReplay().getReplayFileGlob();
    Path replaysDirectory = preferencesService.getReplaysDirectory();
    if (Files.notExists(replaysDirectory)) {
        noCatch(() -> createDirectories(replaysDirectory));
    }
    try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(replaysDirectory, replayFileGlob)) {
        for (Path replayFile : directoryStream) {
            try {
                LocalReplayInfo replayInfo = replayFileReader.parseMetaData(replayFile);
                FeaturedMod featuredMod = modService.getFeaturedMod(replayInfo.getFeaturedMod()).getNow(FeaturedMod.UNKNOWN);
                mapService.findByMapFolderName(replayInfo.getMapname()).thenAccept(mapBean -> {
                    if (!mapBean.isPresent()) {
                        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("mapNotFound", replayInfo.getMapname()), WARN));
                        return;
                    }
                    replayInfos.add(new Replay(replayInfo, replayFile, featuredMod, mapBean.get()));
                });
            } catch (Exception e) {
                logger.warn("Could not read replay file '{}'", replayFile, e);
                moveCorruptedReplayFile(replayFile);
            }
        }
    }
    return replayInfos;
}
Also used : Path(java.nio.file.Path) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ArrayList(java.util.ArrayList) FeaturedMod(com.faforever.client.mod.FeaturedMod) KnownFeaturedMod(com.faforever.client.game.KnownFeaturedMod) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) SneakyThrows(lombok.SneakyThrows)

Example 8 with FeaturedMod

use of com.faforever.client.mod.FeaturedMod in project downlords-faf-client by FAForever.

the class CreateGameController method selectLastOrDefaultGameType.

private void selectLastOrDefaultGameType() {
    String lastGameMod = preferencesService.getPreferences().getLastGameType();
    if (lastGameMod == null) {
        lastGameMod = KnownFeaturedMod.DEFAULT.getTechnicalName();
    }
    for (FeaturedMod mod : featuredModListView.getItems()) {
        if (Objects.equals(mod.getTechnicalName(), lastGameMod)) {
            featuredModListView.getSelectionModel().select(mod);
            featuredModListView.scrollTo(mod);
            break;
        }
    }
}
Also used : FeaturedMod(com.faforever.client.mod.FeaturedMod)

Example 9 with FeaturedMod

use of com.faforever.client.mod.FeaturedMod in project downlords-faf-client by FAForever.

the class ReplayDetailControllerTest method setReplay.

@Test
public void setReplay() throws Exception {
    Replay replay = new Replay();
    replay.setValidity(Validity.VALID);
    replay.setFeaturedMod(new FeaturedMod());
    replay.getReviews().setAll(FXCollections.emptyObservableList());
    when(replayService.getSize(replay.getId())).thenReturn(CompletableFuture.completedFuture(1024));
    instance.setReplay(replay);
}
Also used : FeaturedMod(com.faforever.client.mod.FeaturedMod) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Aggregations

FeaturedMod (com.faforever.client.mod.FeaturedMod)9 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)6 Test (org.junit.Test)6 Path (java.nio.file.Path)2 GameTooltipController (com.faforever.client.game.GameTooltipController)1 KnownFeaturedMod (com.faforever.client.game.KnownFeaturedMod)1 ImmediateNotification (com.faforever.client.notification.ImmediateNotification)1 Player (com.faforever.client.player.Player)1 GameLaunchMessage (com.faforever.client.remote.domain.GameLaunchMessage)1 Review (com.faforever.client.vault.review.Review)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 SneakyThrows (lombok.SneakyThrows)1