Search in sources :

Example 26 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class PrivateChatTabController method setReceiver.

@Override
public void setReceiver(String username) {
    super.setReceiver(username);
    privateChatTabRoot.setId(username);
    privateChatTabRoot.setText(username);
    Player player = playerService.getPlayerForUsername(username);
    privateUserInfoController.setPlayer(player);
}
Also used : Player(com.faforever.client.player.Player)

Example 27 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class UserInfoWindowController method setPlayer.

public void setPlayer(Player player) {
    this.player = player;
    usernameLabel.setText(player.getUsername());
    countryFlagService.loadCountryFlag(player.getCountry()).ifPresent(image -> countryImageView.setImage(image));
    avatarImageView.setImage(IdenticonUtil.createIdenticon(player.getId()));
    gamesPlayedLabel.setText(i18n.number(player.getNumberOfGames()));
    ratingLabelGlobal.setText(i18n.number(RatingUtil.getGlobalRating(player)));
    ratingLabel1v1.setText(i18n.number(RatingUtil.getLeaderboardRating(player)));
    updateNameHistory(player);
    CountryCode countryCode = CountryCode.getByCode(player.getCountry());
    if (countryCode != null) {
        // Country code is unknown to CountryCode, like A1 or A2 (from GeoIP)
        countryLabel.setText(countryCode.getName());
    } else {
        countryLabel.setText(player.getCountry());
    }
    globalButton.fire();
    globalButton.setSelected(true);
    loadAchievements();
    eventService.getPlayerEvents(player.getId()).thenAccept(events -> {
        plotFactionsChart(events);
        plotUnitsByCategoriesChart(events);
        plotTechBuiltChart(events);
        plotGamesPlayedChart();
    }).exceptionally(throwable -> {
        notificationService.addImmediateErrorNotification(throwable, "userInfo.statistics.errorLoading");
        log.warn("Could not load player events", throwable);
        return null;
    });
}
Also used : StageStyle(javafx.stage.StageStyle) UiService(com.faforever.client.theme.UiService) AchievementDefinition(com.faforever.client.api.dto.AchievementDefinition) EVENT_BUILT_AIR_UNITS(com.faforever.client.events.EventService.EVENT_BUILT_AIR_UNITS) XYChart(javafx.scene.chart.XYChart) AchievementState(com.faforever.client.achievements.AchievementService.AchievementState) PlayerEvent(com.faforever.client.api.dto.PlayerEvent) InvalidationListener(javafx.beans.InvalidationListener) EVENT_BUILT_NAVAL_UNITS(com.faforever.client.events.EventService.EVENT_BUILT_NAVAL_UNITS) FXCollections.observableList(javafx.collections.FXCollections.observableList) WindowController(com.faforever.client.fx.WindowController) TimeService(com.faforever.client.util.TimeService) ScrollPane(javafx.scene.control.ScrollPane) EVENT_AEON_PLAYS(com.faforever.client.events.EventService.EVENT_AEON_PLAYS) LeaderboardService(com.faforever.client.leaderboard.LeaderboardService) EVENT_UEF_WINS(com.faforever.client.events.EventService.EVENT_UEF_WINS) Map(java.util.Map) TableView(javafx.scene.control.TableView) PlayerService(com.faforever.client.player.PlayerService) Pane(javafx.scene.layout.Pane) Data(javafx.scene.chart.XYChart.Data) Collectors(java.util.stream.Collectors) StatisticsService(com.faforever.client.stats.StatisticsService) AchievementService(com.faforever.client.achievements.AchievementService) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) PieChart(javafx.scene.chart.PieChart) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Region(javafx.scene.layout.Region) OffsetDateTime(java.time.OffsetDateTime) ToggleButton(javafx.scene.control.ToggleButton) EVENT_BUILT_TECH_3_UNITS(com.faforever.client.events.EventService.EVENT_BUILT_TECH_3_UNITS) ObservableList(javafx.collections.ObservableList) NumberAxis(javafx.scene.chart.NumberAxis) NotNull(org.jetbrains.annotations.NotNull) EventService(com.faforever.client.events.EventService) PlayerAchievement(com.faforever.client.api.dto.PlayerAchievement) EVENT_AEON_WINS(com.faforever.client.events.EventService.EVENT_AEON_WINS) StackedBarChart(javafx.scene.chart.StackedBarChart) EVENT_CYBRAN_PLAYS(com.faforever.client.events.EventService.EVENT_CYBRAN_PLAYS) FXCollections(javafx.collections.FXCollections) EVENT_BUILT_TECH_1_UNITS(com.faforever.client.events.EventService.EVENT_BUILT_TECH_1_UNITS) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Bindings(javafx.beans.binding.Bindings) Scope(org.springframework.context.annotation.Scope) TableColumn(javafx.scene.control.TableColumn) Inject(javax.inject.Inject) RatingHistoryDataPoint(com.faforever.client.domain.RatingHistoryDataPoint) NotificationService(com.faforever.client.notification.NotificationService) LineChart(javafx.scene.chart.LineChart) KnownFeaturedMod(com.faforever.client.game.KnownFeaturedMod) EVENT_CYBRAN_WINS(com.faforever.client.events.EventService.EVENT_CYBRAN_WINS) EVENT_UEF_PLAYS(com.faforever.client.events.EventService.EVENT_UEF_PLAYS) UNLOCKED(com.faforever.client.achievements.AchievementService.AchievementState.UNLOCKED) AchievementItemController(com.faforever.client.achievements.AchievementItemController) CountryCode(com.neovisionaries.i18n.CountryCode) OffsetDateTimeCell(com.faforever.client.fx.OffsetDateTimeCell) Modality(javafx.stage.Modality) RatingUtil(com.faforever.client.util.RatingUtil) Label(javafx.scene.control.Label) IdenticonUtil(com.faforever.client.util.IdenticonUtil) Controller(com.faforever.client.fx.Controller) Node(javafx.scene.Node) CLOSE(com.faforever.client.fx.WindowController.WindowButtonType.CLOSE) StringConverter(javafx.util.StringConverter) EVENT_SERAPHIM_WINS(com.faforever.client.events.EventService.EVENT_SERAPHIM_WINS) EVENT_SERAPHIM_PLAYS(com.faforever.client.events.EventService.EVENT_SERAPHIM_PLAYS) EVENT_BUILT_TECH_2_UNITS(com.faforever.client.events.EventService.EVENT_BUILT_TECH_2_UNITS) Assert(com.faforever.client.util.Assert) Component(org.springframework.stereotype.Component) Stage(javafx.stage.Stage) ImageView(javafx.scene.image.ImageView) EVENT_BUILT_LAND_UNITS(com.faforever.client.events.EventService.EVENT_BUILT_LAND_UNITS) DateTimeFormatter(java.time.format.DateTimeFormatter) NameRecord(com.faforever.client.player.NameRecord) Window(javafx.stage.Window) I18n(com.faforever.client.i18n.I18n) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) Collections(java.util.Collections) CountryCode(com.neovisionaries.i18n.CountryCode)

Example 28 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class ChatUserItemControllerTest method testOnContextMenuRequested.

@Test
public void testOnContextMenuRequested() throws Exception {
    WaitForAsyncUtils.asyncFx(() -> getRoot().getChildren().setAll(instance.chatUserItemRoot));
    Player player = PlayerBuilder.create("junit").defaultValues().get();
    instance.setPlayer(player);
    WaitForAsyncUtils.waitForFxEvents();
    ChatUserContextMenuController contextMenuController = mock(ChatUserContextMenuController.class);
    ContextMenu contextMenu = mock(ContextMenu.class);
    when(contextMenuController.getContextMenu()).thenReturn(contextMenu);
    when(uiService.loadFxml("theme/chat/chat_user_context_menu.fxml")).thenReturn(contextMenuController);
    ContextMenuEvent event = mock(ContextMenuEvent.class);
    instance.onContextMenuRequested(event);
    verify(uiService).loadFxml("theme/chat/chat_user_context_menu.fxml");
    verify(contextMenuController).setPlayer(player);
    verify(contextMenu).show(any(Window.class), anyDouble(), anyDouble());
}
Also used : Window(javafx.stage.Window) Player(com.faforever.client.player.Player) ContextMenu(javafx.scene.control.ContextMenu) ContextMenuEvent(javafx.scene.input.ContextMenuEvent) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 29 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class ChatUserItemControllerTest method testOpenGameSetsStatusToWaiting.

@Test
public void testOpenGameSetsStatusToWaiting() throws Exception {
    Player player = PlayerBuilder.create("junit").defaultValues().get();
    instance.setPlayer(player);
    assertThat(instance.statusLabel.getText(), is(""));
    player.setGame(GameBuilder.create().defaultValues().get());
    WaitForAsyncUtils.waitForFxEvents();
    assertThat(instance.statusLabel.getText(), is("Waiting"));
}
Also used : Player(com.faforever.client.player.Player) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 30 with Player

use of com.faforever.client.player.Player in project downlords-faf-client by FAForever.

the class ChatUserItemControllerTest method testGetPlayer.

@Test
public void testGetPlayer() throws Exception {
    Player player = PlayerBuilder.create("junit").defaultValues().get();
    instance.setPlayer(player);
    assertThat(instance.getPlayer(), is(player));
}
Also used : Player(com.faforever.client.player.Player) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Aggregations

Player (com.faforever.client.player.Player)51 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)17 Test (org.junit.Test)17 Pane (javafx.scene.layout.Pane)8 I18n (com.faforever.client.i18n.I18n)7 PlayerService (com.faforever.client.player.PlayerService)7 UiService (com.faforever.client.theme.UiService)7 ClientProperties (com.faforever.client.config.ClientProperties)6 Controller (com.faforever.client.fx.Controller)6 ArrayList (java.util.ArrayList)6 Platform (javafx.application.Platform)6 Node (javafx.scene.Node)6 Scope (org.springframework.context.annotation.Scope)6 Component (org.springframework.stereotype.Component)6 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)5 NotificationService (com.faforever.client.notification.NotificationService)5 TimeService (com.faforever.client.util.TimeService)5 Collection (java.util.Collection)5 List (java.util.List)5 Map (java.util.Map)5