Search in sources :

Example 6 with Preferences

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());
}
Also used : SearchConfig(com.faforever.client.vault.search.SearchController.SearchConfig) Preferences(com.faforever.client.preferences.Preferences) Pane(javafx.scene.layout.Pane) Before(org.junit.Before)

Example 7 with Preferences

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());
}
Also used : LogicalNodeController(com.faforever.client.query.LogicalNodeController) SpecificationController(com.faforever.client.query.SpecificationController) Preferences(com.faforever.client.preferences.Preferences) Pane(javafx.scene.layout.Pane) Before(org.junit.Before)

Example 8 with Preferences

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();
}
Also used : Preferences(com.faforever.client.preferences.Preferences)

Example 9 with Preferences

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);
}
Also used : NumberStringConverter(javafx.util.converter.NumberStringConverter) Preferences(com.faforever.client.preferences.Preferences) NumberFormat(java.text.NumberFormat)

Example 10 with 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());
}
Also used : UiService(com.faforever.client.theme.UiService) ChatColorMode(com.faforever.client.chat.ChatColorMode) ComboBox(javafx.scene.control.ComboBox) TextField(javafx.scene.control.TextField) UnitDataBaseType(com.faforever.client.preferences.Preferences.UnitDataBaseType) Theme(com.faforever.client.theme.Theme) Screen(javafx.stage.Screen) Platform(javafx.application.Platform) Objects(java.util.Objects) NumberStringConverter(javafx.util.converter.NumberStringConverter) Slf4j(lombok.extern.slf4j.Slf4j) Region(javafx.scene.layout.Region) ToggleButton(javafx.scene.control.ToggleButton) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) Toggle(javafx.scene.control.Toggle) ToastPosition(com.faforever.client.preferences.ToastPosition) TimeInfo(com.faforever.client.preferences.TimeInfo) PreferencesService(com.faforever.client.preferences.PreferencesService) WeakChangeListener(javafx.beans.value.WeakChangeListener) FXCollections(javafx.collections.FXCollections) UserService(com.faforever.client.user.UserService) Bindings(javafx.beans.binding.Bindings) Scope(org.springframework.context.annotation.Scope) NumberFormat(java.text.NumberFormat) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) Preferences(com.faforever.client.preferences.Preferences) DEFAULT_THEME(com.faforever.client.theme.UiService.DEFAULT_THEME) StringListCell(com.faforever.client.fx.StringListCell) PasswordField(javafx.scene.control.PasswordField) Label(javafx.scene.control.Label) Controller(com.faforever.client.fx.Controller) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) Action(com.faforever.client.notification.Action) NotificationsPrefs(com.faforever.client.preferences.NotificationsPrefs) PersistentNotification(com.faforever.client.notification.PersistentNotification) PATH_STRING_CONVERTER(com.faforever.client.fx.JavaFxUtil.PATH_STRING_CONVERTER) ActionEvent(javafx.event.ActionEvent) ToggleGroup(javafx.scene.control.ToggleGroup) Component(org.springframework.stereotype.Component) LanguageInfo(com.faforever.client.preferences.LanguageInfo) Severity(com.faforever.client.notification.Severity) I18n(com.faforever.client.i18n.I18n) LocalizationPrefs(com.faforever.client.preferences.LocalizationPrefs) ChangeListener(javafx.beans.value.ChangeListener) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) Collections(java.util.Collections) LanguageInfo(com.faforever.client.preferences.LanguageInfo)

Aggregations

Preferences (com.faforever.client.preferences.Preferences)21 Before (org.junit.Before)16 Pane (javafx.scene.layout.Pane)6 ClientProperties (com.faforever.client.config.ClientProperties)3 Clan (com.faforever.client.clan.Clan)2 Vault (com.faforever.client.config.ClientProperties.Vault)2 NumberFormat (java.text.NumberFormat)2 TabPane (javafx.scene.control.TabPane)2 NumberStringConverter (javafx.util.converter.NumberStringConverter)2 ChatColorMode (com.faforever.client.chat.ChatColorMode)1 AvatarBean (com.faforever.client.chat.avatar.AvatarBean)1 ClanTooltipController (com.faforever.client.clan.ClanTooltipController)1 Website (com.faforever.client.config.ClientProperties.Website)1 Controller (com.faforever.client.fx.Controller)1 PATH_STRING_CONVERTER (com.faforever.client.fx.JavaFxUtil.PATH_STRING_CONVERTER)1 StringListCell (com.faforever.client.fx.StringListCell)1 Game (com.faforever.client.game.Game)1 I18n (com.faforever.client.i18n.I18n)1 Action (com.faforever.client.notification.Action)1 NotificationService (com.faforever.client.notification.NotificationService)1