Search in sources :

Example 1 with Replay

use of com.faforever.client.replay.Replay in project downlords-faf-client by FAForever.

the class ReplayVaultController method durationCellValueFactory.

@NotNull
private ObservableValue<Duration> durationCellValueFactory(TableColumn.CellDataFeatures<Replay, Duration> param) {
    Replay replay = param.getValue();
    Temporal startTime = replay.getStartTime();
    Temporal endTime = replay.getEndTime();
    if (startTime == null || endTime == null) {
        return new SimpleObjectProperty<>(null);
    }
    return new SimpleObjectProperty<>(Duration.between(startTime, endTime));
}
Also used : SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Temporal(java.time.temporal.Temporal) Replay(com.faforever.client.replay.Replay) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with Replay

use of com.faforever.client.replay.Replay in project downlords-faf-client by FAForever.

the class ReplayVaultController method playersValueFactory.

private ObservableValue<String> playersValueFactory(TableColumn.CellDataFeatures<Replay, String> features) {
    return new StringBinding() {

        @Override
        protected String computeValue() {
            Replay replay = features.getValue();
            ObservableMap<String, List<String>> teams = replay.getTeams();
            if (teams.isEmpty()) {
                return "";
            }
            ArrayList<String> teamsAsStrings = new ArrayList<>();
            for (List<String> playerNames : teams.values()) {
                Collections.sort(playerNames);
                teamsAsStrings.add(Joiner.on(i18n.get("textSeparator")).join(playerNames));
            }
            return Joiner.on(i18n.get("vsSeparator")).join(teamsAsStrings);
        }
    };
}
Also used : StringBinding(javafx.beans.binding.StringBinding) Replay(com.faforever.client.replay.Replay) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 3 with Replay

use of com.faforever.client.replay.Replay in project downlords-faf-client by FAForever.

the class AbstractChatTabControllerTest method start.

@Override
public void start(Stage stage) throws Exception {
    super.start(stage);
    preferences = new Preferences();
    Clan clan = new Clan();
    clan.setId("1234");
    Vault vault = new Vault();
    vault.setReplayDownloadUrlFormat(TEST_REPLAY_BASE_URL);
    when(replayService.findById(any(Integer.class))).thenReturn(completedFuture(Optional.of(new Replay())));
    when(clanService.getClanByTag(sampleClanTag)).thenReturn(completedFuture(Optional.of(clan)));
    when(uiService.loadFxml("theme/chat/clan_tooltip.fxml")).thenReturn(mock(ClanTooltipController.class));
    when(uiService.getThemeFileUrl(any())).thenReturn(getClass().getResource("/theme/chat/chat_section.html"));
    when(timeService.asShortTime(any())).thenReturn("123");
    when(userService.getUsername()).thenReturn("junit");
    when(preferencesService.getPreferences()).thenReturn(preferences);
    when(clientProperties.getVault()).thenReturn(vault);
    instance = new AbstractChatTabController(clanService, webViewConfigurer, userService, chatService, platformService, preferencesService, playerService, audioService, timeService, i18n, imageUploadService, urlPreviewResolver, notificationService, reportingService, uiService, autoCompletionHelper, eventBus, countryFlagService, replayService, clientProperties, externalReplayInfoGenerator) {

        private final Tab root = new Tab();

        private final WebView webView = new WebView();

        private final TextInputControl messageTextField = new TextField();

        @Override
        public Tab getRoot() {
            return root;
        }

        @Override
        protected TextInputControl messageTextField() {
            return messageTextField;
        }

        @Override
        protected WebView getMessagesWebView() {
            return webView;
        }
    };
    TabPane tabPane = new TabPane(instance.getRoot());
    getRoot().getChildren().setAll(tabPane);
    chatReadyLatch = new CountDownLatch(1);
    instance.getMessagesWebView().getEngine().getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
        if (Worker.State.SUCCEEDED.equals(newValue)) {
            chatReadyLatch.countDown();
        }
    });
    instance.initialize();
}
Also used : TabPane(javafx.scene.control.TabPane) CountDownLatch(java.util.concurrent.CountDownLatch) TextInputControl(javafx.scene.control.TextInputControl) Tab(javafx.scene.control.Tab) Clan(com.faforever.client.clan.Clan) Replay(com.faforever.client.replay.Replay) TextField(javafx.scene.control.TextField) Vault(com.faforever.client.config.ClientProperties.Vault) Preferences(com.faforever.client.preferences.Preferences) WebView(javafx.scene.web.WebView) ClanTooltipController(com.faforever.client.clan.ClanTooltipController)

Example 4 with Replay

use of com.faforever.client.replay.Replay in project downlords-faf-client by FAForever.

the class ReplayVaultController method mapCellFactory.

private TableCell<Replay, MapBean> mapCellFactory(TableColumn<Replay, MapBean> column) {
    MapPreviewTableCellController controller = uiService.loadFxml("theme/vault/map/map_preview_table_cell.fxml");
    final ImageView imageView = controller.getRoot();
    TableCell<Replay, MapBean> cell = new TableCell<Replay, MapBean>() {

        @Override
        protected void updateItem(MapBean map, boolean empty) {
            super.updateItem(map, empty);
            if (empty || map == null) {
                setText(null);
                setGraphic(null);
            } else {
                imageView.setImage(mapService.loadPreview(map.getFolderName(), PreviewSize.SMALL));
                setGraphic(imageView);
                setText(map.getDisplayName());
            }
        }
    };
    cell.setGraphic(imageView);
    return cell;
}
Also used : MapPreviewTableCellController(com.faforever.client.vault.map.MapPreviewTableCellController) MapBean(com.faforever.client.map.MapBean) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) TableCell(javafx.scene.control.TableCell) Replay(com.faforever.client.replay.Replay) ImageView(javafx.scene.image.ImageView)

Aggregations

Replay (com.faforever.client.replay.Replay)4 Clan (com.faforever.client.clan.Clan)1 ClanTooltipController (com.faforever.client.clan.ClanTooltipController)1 Vault (com.faforever.client.config.ClientProperties.Vault)1 MapBean (com.faforever.client.map.MapBean)1 Preferences (com.faforever.client.preferences.Preferences)1 MapPreviewTableCellController (com.faforever.client.vault.map.MapPreviewTableCellController)1 Temporal (java.time.temporal.Temporal)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 StringBinding (javafx.beans.binding.StringBinding)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 Tab (javafx.scene.control.Tab)1 TabPane (javafx.scene.control.TabPane)1 TableCell (javafx.scene.control.TableCell)1 TextField (javafx.scene.control.TextField)1 TextInputControl (javafx.scene.control.TextInputControl)1 TextFieldTableCell (javafx.scene.control.cell.TextFieldTableCell)1