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