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();
}
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;
}
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;
}
}
}
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);
}
Aggregations