use of com.faforever.client.game.Game in project downlords-faf-client by FAForever.
the class CoopController method initialize.
public void initialize() {
missionComboBox.setCellFactory(param -> missionListCell());
missionComboBox.setButtonCell(missionListCell());
missionComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> setSelectedMission(newValue));
playButton.disableProperty().bind(titleTextField.textProperty().isEmpty());
numberOfPlayersComboBox.setButtonCell(numberOfPlayersCell());
numberOfPlayersComboBox.setCellFactory(param -> numberOfPlayersCell());
numberOfPlayersComboBox.getSelectionModel().select(2);
numberOfPlayersComboBox.getSelectionModel().selectedItemProperty().addListener(observable -> loadLeaderboard());
// TODO don't use API object but bean instead
rankColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getRanking()));
rankColumn.setCellFactory(param -> new StringCell<>(String::valueOf));
playerCountColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getPlayerCount()));
playerCountColumn.setCellFactory(param -> new StringCell<>(String::valueOf));
playerNamesColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getPlayerNames()));
playerNamesColumn.setCellFactory(param -> new StringCell<>(String::valueOf));
secondaryObjectivesColumn.setCellValueFactory(param -> new SimpleBooleanProperty(param.getValue().isSecondaryObjectives()));
secondaryObjectivesColumn.setCellFactory(param -> new StringCell<>(aBoolean -> aBoolean ? i18n.get("yes") : i18n.get("no")));
timeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getDuration()));
timeColumn.setCellFactory(param -> new StringCell<>(timeService::shortDuration));
replayColumn.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getId()));
replayColumn.setCellFactory(param -> new NodeTableCell<>((replayId) -> {
ReplayButtonController button = uiService.loadFxml("theme/play/coop/replay_button.fxml");
button.setReplayId(replayId);
button.setOnClickedAction(this::onReplayButtonClicked);
return button.getRoot();
}));
webViewConfigurer.configureWebView(descriptionWebView);
ObservableList<Game> games = gameService.getGames();
FilteredList<Game> filteredItems = new FilteredList<>(games);
filteredItems.setPredicate(OPEN_COOP_GAMES_PREDICATE);
GamesTableController gamesTableController = uiService.loadFxml("theme/play/games_table.fxml");
gamesTableController.initializeGameTable(filteredItems);
Node root = gamesTableController.getRoot();
populateContainer(root);
coopService.getMissions().thenAccept(coopMaps -> {
Platform.runLater(() -> missionComboBox.setItems(observableList(coopMaps)));
SingleSelectionModel<CoopMission> selectionModel = missionComboBox.getSelectionModel();
if (selectionModel.isEmpty()) {
Platform.runLater(selectionModel::selectFirst);
}
}).exceptionally(throwable -> {
notificationService.addPersistentErrorNotification(throwable, "coop.couldNotLoad", throwable.getLocalizedMessage());
return null;
});
}
use of com.faforever.client.game.Game in project downlords-faf-client by FAForever.
the class OnGameFullNotifier method onGameFull.
@Subscribe
public void onGameFull(GameFullEvent event) {
executor.execute(() -> {
platformService.startFlashingWindow(faWindowTitle);
while (gameService.isGameRunning() && !platformService.isWindowFocused(faWindowTitle)) {
noCatch(() -> sleep(500));
}
platformService.stopFlashingWindow(faWindowTitle);
});
Game currentGame = gameService.getCurrentGame();
if (currentGame == null) {
throw new ProgrammingError("Got a GameFull notification but player is not in a game");
}
if (platformService.isWindowFocused(faWindowTitle)) {
return;
}
notificationService.addNotification(new TransientNotification(i18n.get("game.full"), i18n.get("game.full.action"), mapService.loadPreview(currentGame.getMapFolderName(), PreviewSize.SMALL), v -> platformService.focusWindow(faWindowTitle)));
}
use of com.faforever.client.game.Game in project downlords-faf-client by FAForever.
the class ReplayServerImpl method finishReplayInfo.
private void finishReplayInfo() {
Game game = gameService.getByUid(replayInfo.getUid());
replayInfo.updateFromGameInfoBean(game);
replayInfo.setGameEnd(pythonTime());
replayInfo.setRecorder(userService.getUsername());
replayInfo.setState(GameStatus.CLOSED);
replayInfo.setComplete(true);
}
use of com.faforever.client.game.Game in project downlords-faf-client by FAForever.
the class LiveReplayController method initializeGameTable.
private void initializeGameTable(ObservableList<Game> games) {
SortedList<Game> sortedList = new SortedList<>(games);
sortedList.comparatorProperty().bind(liveReplayControllerRoot.comparatorProperty());
mapPreviewColumn.setCellFactory(param -> new MapPreviewTableCell(uiService));
mapPreviewColumn.setCellValueFactory(param -> Bindings.createObjectBinding(() -> mapService.loadPreview(param.getValue().getMapFolderName(), PreviewSize.SMALL), param.getValue().mapFolderNameProperty()));
gameTitleColumn.setCellValueFactory(param -> param.getValue().titleProperty());
gameTitleColumn.setCellFactory(param -> new StringCell<>(title -> title));
playersColumn.setCellValueFactory(param -> param.getValue().numPlayersProperty());
playersColumn.setCellFactory(param -> new StringCell<>(number -> i18n.number(number.intValue())));
hostColumn.setCellValueFactory(param -> param.getValue().hostProperty());
hostColumn.setCellFactory(param -> new StringCell<>(String::toString));
modsColumn.setCellValueFactory(this::modCell);
modsColumn.setCellFactory(param -> new StringCell<>(String::toString));
watchColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue()));
watchColumn.setCellFactory(param -> new NodeTableCell<>(this::watchReplayButton));
liveReplayControllerRoot.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> selectedGame.set(newValue)));
liveReplayControllerRoot.setItems(games);
}
use of com.faforever.client.game.Game in project downlords-faf-client by FAForever.
the class FriendJoinedGameNotifier method onFriendJoinedGame.
@Subscribe
public void onFriendJoinedGame(FriendJoinedGameEvent event) {
Player player = event.getPlayer();
Game game = event.getGame();
audioService.playFriendJoinsGameSound();
if (preferencesService.getPreferences().getNotification().isFriendJoinsGameToastEnabled()) {
notificationService.addNotification(new TransientNotification(i18n.get("friend.joinedGameNotification.title", player.getUsername(), game.getTitle()), i18n.get("friend.joinedGameNotification.action"), IdenticonUtil.createIdenticon(player.getId()), event1 -> joinGameHelper.join(player.getGame())));
}
}
Aggregations