use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.
the class OnlineReplayVaultControllerTest method setUp.
@Before
public void setUp() throws Exception {
when(uiService.loadFxml("theme/vault/replay/replay_card.fxml")).thenAnswer(invocation -> {
ReplayCardController controller = mock(ReplayCardController.class);
when(controller.getRoot()).thenReturn(new Pane());
return controller;
});
when(preferencesService.getPreferences()).thenReturn(new Preferences());
sortOrder = preferencesService.getPreferences().getVaultPrefs().getOnlineReplaySortConfig();
standardSearchConfig = new SearchConfig(sortOrder, "query");
instance = new OnlineReplayVaultController(replayService, uiService, notificationService, i18n, preferencesService);
loadFxml("theme/vault/replay/online_replays.fxml", clazz -> {
if (SearchController.class.isAssignableFrom(clazz)) {
return searchController;
}
if (SpecificationController.class.isAssignableFrom(clazz)) {
return specificationController;
}
if (LogicalNodeController.class.isAssignableFrom(clazz)) {
return logicalNodeController;
}
return instance;
});
verify(searchController).setSearchListener(searchListenerCaptor.capture());
}
use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.
the class SearchControllerTest method setUp.
@Before
public void setUp() throws Exception {
when(uiService.loadFxml("theme/vault/search/logical_node.fxml")).thenAnswer(invocation -> {
LogicalNodeController controller = mock(LogicalNodeController.class);
controller.logicalOperatorField = new ChoiceBox<>();
controller.specificationController = mock(SpecificationController.class);
controller.specificationController.propertyField = new ComboBox<>();
controller.specificationController.operationField = new ChoiceBox<>();
controller.specificationController.valueField = new ComboBox<>();
when(controller.getRoot()).thenReturn(new Pane());
return controller;
});
when(preferencesService.getPreferences()).thenReturn(new Preferences());
instance = new SearchController(uiService, i18n, preferencesService);
loadFxml("theme/vault/search/search.fxml", clazz -> {
if (SpecificationController.class.isAssignableFrom(clazz)) {
return specificationController;
}
if (LogicalNodeController.class.isAssignableFrom(clazz)) {
return logicalNodeController;
}
return instance;
});
instance.setSearchableProperties(SearchableProperties.GAME_PROPERTIES);
instance.setSortConfig(preferencesService.getPreferences().getVaultPrefs().onlineReplaySortConfigProperty());
}
use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.
the class SettingsController method onTimeFormatSelected.
public void onTimeFormatSelected() {
log.debug("A new time format was selected: {}", timeComboBox.getValue());
Preferences preferences = preferencesService.getPreferences();
preferences.getChat().setTimeFormat(timeComboBox.getValue());
preferencesService.storeInBackground();
}
use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.
the class SettingsController method initialize.
public void initialize() {
eventBus.register(this);
themeComboBox.setButtonCell(new StringListCell<>(Theme::getDisplayName));
themeComboBox.setCellFactory(param -> new StringListCell<>(Theme::getDisplayName));
toastScreenComboBox.setButtonCell(screenListCell());
toastScreenComboBox.setCellFactory(param -> screenListCell());
toastScreenComboBox.setItems(Screen.getScreens());
NumberFormat integerNumberFormat = NumberFormat.getIntegerInstance();
integerNumberFormat.setGroupingUsed(false);
Preferences preferences = preferencesService.getPreferences();
temporarilyDisableUnsupportedSettings(preferences);
maxMessagesTextField.textProperty().bindBidirectional(preferences.getChat().maxMessagesProperty(), new NumberStringConverter(integerNumberFormat));
imagePreviewCheckBox.selectedProperty().bindBidirectional(preferences.getChat().previewImageUrlsProperty());
enableNotificationsCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().transientNotificationsEnabledProperty());
hideFoeCheckBox.selectedProperty().bindBidirectional(preferences.getChat().hideFoeMessagesProperty());
preferences.getChat().chatColorModeProperty().addListener((observable, oldValue, newValue) -> setSelectedColorMode(newValue));
setSelectedColorMode(preferences.getChat().getChatColorMode());
colorModeToggleGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == defaultColorsToggle) {
preferences.getChat().setChatColorMode(ChatColorMode.DEFAULT);
}
if (newValue == customColorsToggle) {
preferences.getChat().setChatColorMode(ChatColorMode.CUSTOM);
}
if (newValue == randomColorsToggle) {
preferences.getChat().setChatColorMode(ChatColorMode.RANDOM);
}
});
themeChangeListener = (observable, oldValue, newValue) -> {
if (observable == themeComboBox.getSelectionModel().selectedItemProperty()) {
themeComboBox.getSelectionModel().select(newValue);
}
};
preferences.getNotification().toastPositionProperty().addListener((observable, oldValue, newValue) -> setSelectedToastPosition(newValue));
setSelectedToastPosition(preferences.getNotification().getToastPosition());
toastPosition.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == topLeftToastButton) {
preferences.getNotification().setToastPosition(ToastPosition.TOP_LEFT);
}
if (newValue == topRightToastButton) {
preferences.getNotification().setToastPosition(ToastPosition.TOP_RIGHT);
}
if (newValue == bottomLeftToastButton) {
preferences.getNotification().setToastPosition(ToastPosition.BOTTOM_LEFT);
}
if (newValue == bottomRightToastButton) {
preferences.getNotification().setToastPosition(ToastPosition.BOTTOM_RIGHT);
}
});
configureTimeSetting(preferences);
configureLanguageSelection(preferences);
configureThemeSelection(preferences);
configureRememberLastTab(preferences);
configureToastScreen(preferences);
displayFriendOnlineToastCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().friendOnlineToastEnabledProperty());
displayFriendOfflineToastCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().friendOfflineToastEnabledProperty());
displayFriendJoinsGameToastCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().friendJoinsGameToastEnabledProperty());
displayFriendPlaysGameToastCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().friendPlaysGameToastEnabledProperty());
displayPmReceivedToastCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().privateMessageToastEnabledProperty());
displayLadder1v1ToastCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().ladder1v1ToastEnabledProperty());
playFriendOnlineSoundCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().friendOnlineSoundEnabledProperty());
playFriendOfflineSoundCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().friendOfflineSoundEnabledProperty());
playFriendJoinsGameSoundCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().friendJoinsGameSoundEnabledProperty());
playFriendPlaysGameSoundCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().friendPlaysGameSoundEnabledProperty());
playPmReceivedSoundCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().privateMessageSoundEnabledProperty());
notifyOnAtMentionOnly.selectedProperty().bindBidirectional(preferences.getNotification().notifyOnAtMentionOnlyEnabledProperty());
enableSoundsCheckBox.selectedProperty().bindBidirectional(preferences.getNotification().soundsEnabledProperty());
gamePortTextField.textProperty().bindBidirectional(preferences.getForgedAlliance().portProperty(), new NumberStringConverter(integerNumberFormat));
gameLocationTextField.textProperty().bindBidirectional(preferences.getForgedAlliance().pathProperty(), PATH_STRING_CONVERTER);
autoDownloadMapsCheckBox.selectedProperty().bindBidirectional(preferences.getForgedAlliance().autoDownloadMapsProperty());
executableDecoratorField.textProperty().bindBidirectional(preferences.getForgedAlliance().executableDecoratorProperty());
executionDirectoryField.textProperty().bindBidirectional(preferences.getForgedAlliance().executionDirectoryProperty(), PATH_STRING_CONVERTER);
passwordChangeErrorLabel.setVisible(false);
initUnitDatabaseSelection(preferences);
}
use of com.faforever.client.preferences.Preferences in project downlords-faf-client by FAForever.
the class SettingsController method configureLanguageSelection.
private void configureLanguageSelection(Preferences preferences) {
languageComboBox.setButtonCell(new StringListCell<>(languageInfo -> i18n.get(languageInfo.getDisplayNameKey())));
languageComboBox.setCellFactory(param -> new StringListCell<>(languageInfo -> i18n.get(languageInfo.getDisplayNameKey())));
languageComboBox.setItems(FXCollections.observableArrayList(LanguageInfo.values()));
LanguageInfo languageInfo = preferences.getLocalization().getLanguage();
languageComboBox.getSelectionModel().select(languageInfo.ordinal());
}
Aggregations