use of com.faforever.client.preferences.ChatPrefs in project downlords-faf-client by FAForever.
the class PrivateChatTabController method onChatMessage.
@Override
public void onChatMessage(ChatMessage chatMessage) {
Player player = playerService.getPlayerForUsername(chatMessage.getUsername());
ChatPrefs chatPrefs = preferencesService.getPreferences().getChat();
if (player != null && player.getSocialStatus() == FOE && chatPrefs.getHideFoeMessages()) {
return;
}
super.onChatMessage(chatMessage);
if (!hasFocus()) {
audioService.playPrivateMessageSound();
showNotificationIfNecessary(chatMessage);
setUnread(true);
incrementUnreadMessagesCount(1);
eventBus.post(new UnreadPrivateMessageEvent(chatMessage));
}
}
use of com.faforever.client.preferences.ChatPrefs in project downlords-faf-client by FAForever.
the class PircBotXChatService method getOrCreateChatUser.
@Override
public ChatUser getOrCreateChatUser(User user) {
synchronized (chatUsersByName) {
String username = user.getNick();
String lowerUsername = username.toLowerCase(US);
if (!chatUsersByName.containsKey(lowerUsername)) {
ChatPrefs chatPrefs = preferencesService.getPreferences().getChat();
Color color = null;
if (chatPrefs.getChatColorMode() == CUSTOM && chatPrefs.getUserToColor().containsKey(lowerUsername)) {
color = chatPrefs.getUserToColor().get(lowerUsername);
} else if (chatPrefs.getChatColorMode() == RANDOM) {
color = ColorGeneratorUtil.generateRandomColor(lowerUsername.hashCode());
}
chatUsersByName.put(lowerUsername, ChatUser.fromIrcUser(user, color));
}
return chatUsersByName.get(lowerUsername);
}
}
use of com.faforever.client.preferences.ChatPrefs in project downlords-faf-client by FAForever.
the class ChatUserContextMenuController method setPlayer.
public void setPlayer(Player player) {
this.player = player;
showUserInfo.visibleProperty().bind(Bindings.createBooleanBinding(() -> player.getId() > 0, player.idProperty()));
ChatPrefs chatPrefs = preferencesService.getPreferences().getChat();
String lowerCaseUsername = player.getUsername().toLowerCase(US);
if (chatPrefs.getUserToColor().containsKey(lowerCaseUsername)) {
colorPicker.setValue(chatPrefs.getUserToColor().get(lowerCaseUsername));
} else {
colorPicker.setValue(null);
}
colorPicker.valueProperty().addListener((observable, oldValue, newValue) -> {
String lowerUsername = player.getUsername().toLowerCase(US);
if (newValue == null) {
chatPrefs.getUserToColor().remove(lowerUsername);
} else {
chatPrefs.getUserToColor().put(lowerUsername, newValue);
}
ChatUser chatUser = chatService.getOrCreateChatUser(lowerUsername);
chatUser.setColor(newValue);
chatUserContextMenuRoot.hide();
});
removeCustomColorItem.visibleProperty().bind(chatPrefs.chatColorModeProperty().isEqualTo(CUSTOM).and(colorPicker.valueProperty().isNotNull()).and(player.socialStatusProperty().isNotEqualTo(SELF)));
colorPickerMenuItem.visibleProperty().bind(chatPrefs.chatColorModeProperty().isEqualTo(CUSTOM).and(player.socialStatusProperty().isNotEqualTo(SELF)));
if (player.getSocialStatus() != SocialStatus.SELF) {
avatarPickerMenuItem.setVisible(false);
} else {
loadAvailableAvatars();
}
kickItem.visibleProperty().bind(player.socialStatusProperty().isNotEqualTo(SELF));
banItem.visibleProperty().bind(player.socialStatusProperty().isNotEqualTo(SELF));
moderatorActionSeparator.visibleProperty().bind(player.socialStatusProperty().isNotEqualTo(SELF));
sendPrivateMessageItem.visibleProperty().bind(player.socialStatusProperty().isNotEqualTo(SELF));
addFriendItem.visibleProperty().bind(player.socialStatusProperty().isNotEqualTo(FRIEND).and(player.socialStatusProperty().isNotEqualTo(SELF)));
removeFriendItem.visibleProperty().bind(player.socialStatusProperty().isEqualTo(FRIEND));
addFoeItem.visibleProperty().bind(player.socialStatusProperty().isNotEqualTo(FOE).and(player.socialStatusProperty().isNotEqualTo(SELF)));
removeFoeItem.visibleProperty().bind(player.socialStatusProperty().isEqualTo(FOE));
joinGameItem.visibleProperty().bind(player.socialStatusProperty().isNotEqualTo(SELF).and(player.statusProperty().isEqualTo(PlayerStatus.LOBBYING).or(player.statusProperty().isEqualTo(PlayerStatus.HOSTING))));
watchGameItem.visibleProperty().bind(player.statusProperty().isEqualTo(PlayerStatus.PLAYING));
inviteItem.visibleProperty().bind(player.socialStatusProperty().isNotEqualTo(SELF).and(player.statusProperty().isNotEqualTo(PlayerStatus.PLAYING)));
socialSeparator.visibleProperty().bind(addFriendItem.visibleProperty().or(removeFriendItem.visibleProperty().or(addFoeItem.visibleProperty().or(removeFoeItem.visibleProperty()))));
}
use of com.faforever.client.preferences.ChatPrefs in project downlords-faf-client by FAForever.
the class ChatUserContextMenuControllerTest method setUp.
@Before
public void setUp() throws Exception {
instance = new ChatUserContextMenuController(userService, chatService, preferencesService, playerService, gameService, replayService, notificationService, i18n, eventBus, joinGameHelper, avatarService, uiService);
Preferences preferences = mock(Preferences.class);
ChatPrefs chatPrefs = mock(ChatPrefs.class);
ObjectProperty<ChatColorMode> chatColorModeObjectProperty = new SimpleObjectProperty<>();
when(preferencesService.getPreferences()).thenReturn(preferences);
when(preferences.getChat()).thenReturn(chatPrefs);
when(chatPrefs.getUserToColor()).thenReturn(mock(ObservableMap.class));
when(chatPrefs.chatColorModeProperty()).thenReturn(chatColorModeObjectProperty);
when(avatarService.getAvailableAvatars()).thenReturn(CompletableFuture.completedFuture(Arrays.asList(new AvatarBean(new URL("http://www.example.com/avatar1.png"), "Avatar Number #1"), new AvatarBean(new URL("http://www.example.com/avatar2.png"), "Avatar Number #2"), new AvatarBean(new URL("http://www.example.com/avatar3.png"), "Avatar Number #3"))));
loadFxml("theme/chat/chat_user_context_menu.fxml", clazz -> instance);
player = PlayerBuilder.create(TEST_USER_NAME).socialStatus(SELF).avatar(null).game(new Game()).get();
instance.setPlayer(player);
}
use of com.faforever.client.preferences.ChatPrefs in project downlords-faf-client by FAForever.
the class ChatUserItemController method initialize.
public void initialize() {
userActivityListener = (observable) -> Platform.runLater(this::onUserActivity);
// TODO until server side support is available, the presence status is initially set to "unknown" until the user
// does something
presenceStatusIndicator.setText("\uF10C");
setIdle(false);
chatUserItemRoot.setUserData(this);
countryImageView.managedProperty().bind(countryImageView.visibleProperty());
countryImageView.setVisible(false);
statusLabel.managedProperty().bind(statusLabel.visibleProperty());
statusLabel.visibleProperty().bind(statusLabel.textProperty().isNotEmpty());
clanMenu.managedProperty().bind(clanMenu.visibleProperty());
clanMenu.setVisible(false);
ChatPrefs chatPrefs = preferencesService.getPreferences().getChat();
colorModeChangeListener = (observable, oldValue, newValue) -> configureColor();
colorPerUserMapChangeListener = change -> {
String lowerUsername = player.getUsername().toLowerCase(US);
if (lowerUsername.equalsIgnoreCase(change.getKey())) {
Color newColor = chatPrefs.getUserToColor().get(lowerUsername);
assignColor(newColor);
}
};
avatarChangeListener = (observable, oldValue, newValue) -> Platform.runLater(() -> setAvatarUrl(newValue));
clanChangeListener = (observable, oldValue, newValue) -> Platform.runLater(() -> setClanTag(newValue));
gameStatusChangeListener = (observable, oldValue, newValue) -> Platform.runLater(this::updateGameStatus);
}
Aggregations