Search in sources :

Example 1 with OTHER

use of com.faforever.client.chat.SocialStatus.OTHER in project downlords-faf-client by FAForever.

the class ChannelTabController method onUserJoinedChannel.

private synchronized void onUserJoinedChannel(ChatUser chatUser) {
    JavaFxUtil.assertBackgroundThread();
    ChatPrefs chatPrefs = preferencesService.getPreferences().getChat();
    String username = chatUser.getUsername();
    Player player = playerService.createAndGetPlayerForUsername(username);
    player.moderatorForChannelsProperty().bind(chatUser.moderatorInChannelsProperty());
    player.usernameProperty().addListener((observable, oldValue, newValue) -> {
        Map<Pane, ChatUserItemController> userItemControllers = userToChatUserControls.get(oldValue);
        if (userItemControllers == null) {
            return;
        }
        for (Map.Entry<Pane, ChatUserItemController> entry : userItemControllers.entrySet()) {
            Pane pane = entry.getKey();
            ChatUserItemController chatUserItemController = entry.getValue();
            pane.getChildren().remove(chatUserItemController.getRoot());
            addChatUserItemSorted(pane, chatUserItemController);
        }
    });
    player.usernameProperty().bind(chatUser.usernameProperty());
    player.socialStatusProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue == OTHER && player.isChatOnly()) {
            addToPane(player, chatOnlyPane);
            setUserMessageClass(player, CSS_CLASS_CHAT_ONLY);
        } else {
            addToPane(player, getPaneForSocialStatus(newValue));
            setUserMessageClass(player, newValue.getCssClass());
        }
        if (chatPrefs.getHideFoeMessages() && newValue == FOE) {
            updateUserMessageDisplay(player, "none");
        }
        if (oldValue == OTHER && player.isChatOnly()) {
            removeFromPane(player, chatOnlyPane);
            removeUserMessageClass(player, CSS_CLASS_CHAT_ONLY);
        } else {
            removeFromPane(player, getPaneForSocialStatus(oldValue));
            removeUserMessageClass(player, oldValue.getCssClass());
        }
        if (chatPrefs.getHideFoeMessages() && oldValue == FOE) {
            updateUserMessageDisplay(player, "");
        }
    });
    player.chatOnlyProperty().addListener((observable, oldValue, newValue) -> {
        if (player.getSocialStatus() == OTHER && !chatUser.getModeratorInChannels().contains(username)) {
            if (newValue) {
                removeFromPane(player, othersPane);
                addToPane(player, chatOnlyPane);
                setUserMessageClass(player, CSS_CLASS_CHAT_ONLY);
            } else {
                removeFromPane(player, chatOnlyPane);
                addToPane(player, getPaneForSocialStatus(player.getSocialStatus()));
                removeUserMessageClass(player, CSS_CLASS_CHAT_ONLY);
            }
        }
    });
    player.getModeratorForChannels().addListener((SetChangeListener<String>) change -> {
        if (change.wasAdded()) {
            addToPane(player, moderatorsPane);
            removeFromPane(player, othersPane);
            removeFromPane(player, chatOnlyPane);
            setUserMessageClass(player, CSS_CLASS_MODERATOR);
        } else {
            removeFromPane(player, moderatorsPane);
            SocialStatus socialStatus = player.getSocialStatus();
            if (socialStatus == OTHER || socialStatus == SELF) {
                addToPane(player, othersPane);
            }
            removeUserMessageClass(player, CSS_CLASS_MODERATOR);
        }
    });
    chatPrefs.hideFoeMessagesProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue && player.getSocialStatus() == FOE) {
            updateUserMessageDisplay(player, "none");
        } else {
            updateUserMessageDisplay(player, "");
        }
    });
    chatUser.colorProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> updateUserMessageColor(chatUser)));
    Collection<Pane> targetPanesForUser = getTargetPanesForUser(player);
    for (Pane pane : targetPanesForUser) {
        ChatUserItemController chatUserItemController = createChatUserControlForPlayerIfNecessary(pane, player);
        // Apply filter if exists
        if (!userSearchTextField.textProperty().get().isEmpty()) {
            chatUserItemController.setVisible(isUsernameMatch(chatUserItemController));
        }
        if (filterUserPopup.isShowing()) {
            userFilterController.filterUser(chatUserItemController);
        }
    }
}
Also used : Button(javafx.scene.control.Button) UiService(com.faforever.client.theme.UiService) TextInputControl(javafx.scene.control.TextInputControl) Date(java.util.Date) ImageUploadService(com.faforever.client.uploader.ImageUploadService) ReportingService(com.faforever.client.reporting.ReportingService) VBox(javafx.scene.layout.VBox) AudioService(com.faforever.client.audio.AudioService) TimeService(com.faforever.client.util.TimeService) Gson(com.google.gson.Gson) Duration(java.time.Duration) Map(java.util.Map) OTHER(com.faforever.client.chat.SocialStatus.OTHER) ChatPrefs(com.faforever.client.preferences.ChatPrefs) SELF(com.faforever.client.chat.SocialStatus.SELF) PlayerService(com.faforever.client.player.PlayerService) Pane(javafx.scene.layout.Pane) ClientProperties(com.faforever.client.config.ClientProperties) HBox(javafx.scene.layout.HBox) TextField(javafx.scene.control.TextField) MapChangeListener(javafx.collections.MapChangeListener) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TaskScheduler(org.springframework.scheduling.TaskScheduler) KeyEvent(javafx.scene.input.KeyEvent) Instant(java.time.Instant) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) ObservableList(javafx.collections.ObservableList) Bounds(javafx.geometry.Bounds) PreferencesService(com.faforever.client.preferences.PreferencesService) WeakChangeListener(javafx.beans.value.WeakChangeListener) DEFAULT(com.faforever.client.chat.ChatColorMode.DEFAULT) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) SetChangeListener(javafx.collections.SetChangeListener) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) UserService(com.faforever.client.user.UserService) Scope(org.springframework.context.annotation.Scope) ArrayList(java.util.ArrayList) PlatformService(com.faforever.client.fx.PlatformService) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) KeyCode(javafx.scene.input.KeyCode) WebView(javafx.scene.web.WebView) TitledPane(javafx.scene.control.TitledPane) PopupWindow(javafx.stage.PopupWindow) ClanService(com.faforever.client.clan.ClanService) JavaFxUtil(com.faforever.client.fx.JavaFxUtil) Node(javafx.scene.Node) ReplayService(com.faforever.client.replay.ReplayService) FOE(com.faforever.client.chat.SocialStatus.FOE) WebViewConfigurer(com.faforever.client.fx.WebViewConfigurer) Popup(javafx.stage.Popup) ActionEvent(javafx.event.ActionEvent) Component(org.springframework.stereotype.Component) Tab(javafx.scene.control.Tab) ExternalReplayInfoGenerator(com.faforever.client.replay.ExternalReplayInfoGenerator) VisibleForTesting(com.google.common.annotations.VisibleForTesting) I18n(com.faforever.client.i18n.I18n) ChangeListener(javafx.beans.value.ChangeListener) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) Player(com.faforever.client.player.Player) ChatPrefs(com.faforever.client.preferences.ChatPrefs) Pane(javafx.scene.layout.Pane) TitledPane(javafx.scene.control.TitledPane) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Aggregations

AudioService (com.faforever.client.audio.AudioService)1 DEFAULT (com.faforever.client.chat.ChatColorMode.DEFAULT)1 FOE (com.faforever.client.chat.SocialStatus.FOE)1 OTHER (com.faforever.client.chat.SocialStatus.OTHER)1 SELF (com.faforever.client.chat.SocialStatus.SELF)1 ClanService (com.faforever.client.clan.ClanService)1 ClientProperties (com.faforever.client.config.ClientProperties)1 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)1 PlatformService (com.faforever.client.fx.PlatformService)1 WebViewConfigurer (com.faforever.client.fx.WebViewConfigurer)1 I18n (com.faforever.client.i18n.I18n)1 NotificationService (com.faforever.client.notification.NotificationService)1 Player (com.faforever.client.player.Player)1 PlayerService (com.faforever.client.player.PlayerService)1 ChatPrefs (com.faforever.client.preferences.ChatPrefs)1 PreferencesService (com.faforever.client.preferences.PreferencesService)1 ExternalReplayInfoGenerator (com.faforever.client.replay.ExternalReplayInfoGenerator)1 ReplayService (com.faforever.client.replay.ReplayService)1 ReportingService (com.faforever.client.reporting.ReportingService)1 UiService (com.faforever.client.theme.UiService)1