diff --git a/src/main/java/com/faforever/client/audio/AudioService.java b/src/main/java/com/faforever/client/audio/AudioService.java index a07846a341..fcabc32ac8 100644 --- a/src/main/java/com/faforever/client/audio/AudioService.java +++ b/src/main/java/com/faforever/client/audio/AudioService.java @@ -27,6 +27,7 @@ public class AudioService implements InitializingBean { private static final String FRIEND_OFFLINE_SOUND = "theme/sounds/friendOfflineSound.mp3"; private static final String FRIEND_JOINS_GAME_SOUND = "theme/sounds/friendJoinsGameSound.mp3"; private static final String FRIEND_PLAYS_GAME_SOUND = "theme/sounds/friendPlaysGameSound.mp3"; + private static final String MATCH_FOUND_SOUND = "theme/sounds/matchFoundSound.mp3"; private final AudioClipPlayer audioClipPlayer; private final ThemeService themeService; @@ -44,6 +45,7 @@ public class AudioService implements InitializingBean { private AudioClip friendOfflineSound; private AudioClip friendJoinsGameSound; private AudioClip friendPlaysGameSound; + private AudioClip playMatchFoundSound; private long lastPlayedSoundTime; @@ -65,6 +67,7 @@ private void loadSounds() throws IOException { friendOfflineSound = loadSound(FRIEND_OFFLINE_SOUND); friendJoinsGameSound = loadSound(FRIEND_JOINS_GAME_SOUND); friendPlaysGameSound = loadSound(FRIEND_PLAYS_GAME_SOUND); + playMatchFoundSound = loadSound(MATCH_FOUND_SOUND); } private AudioClip loadSound(String sound) throws IOException { @@ -148,6 +151,15 @@ public void playFriendPlaysGameSound() { playSound(friendPlaysGameSound); } + + public void playMatchFoundSound() { + if (!notificationPrefs.isMatchFoundSoundEnabled()) { + return; + } + playSound(playMatchFoundSound); + } + + private void playSound(AudioClip audioClip) { if (!playSounds.get()) { return; diff --git a/src/main/java/com/faforever/client/preferences/NotificationPrefs.java b/src/main/java/com/faforever/client/preferences/NotificationPrefs.java index 838760bf11..ca39bb8cdd 100644 --- a/src/main/java/com/faforever/client/preferences/NotificationPrefs.java +++ b/src/main/java/com/faforever/client/preferences/NotificationPrefs.java @@ -32,6 +32,7 @@ public class NotificationPrefs { private final IntegerProperty toastDisplayTime = new SimpleIntegerProperty(5000); private final IntegerProperty silenceBetweenSounds = new SimpleIntegerProperty(30000); private final BooleanProperty afterGameReviewEnabled = new SimpleBooleanProperty(true); + private final BooleanProperty matchFoundSoundEnabled = new SimpleBooleanProperty(true); public boolean isSoundsEnabled() { return soundsEnabled.get(); @@ -285,6 +286,17 @@ public BooleanProperty afterGameReviewEnabledProperty() { return afterGameReviewEnabled; } + public void setMatchFoundSoundEnabled(boolean matchFoundSoundEnabled) { + this.matchFoundSoundEnabled.set(matchFoundSoundEnabled); + } + + public boolean isMatchFoundSoundEnabled() { + return matchFoundSoundEnabled.get(); + } + public BooleanProperty matchFoundSoundEnabledProperty() { + return matchFoundSoundEnabled; + } + public int getSilenceBetweenSounds() { return silenceBetweenSounds.get(); } diff --git a/src/main/java/com/faforever/client/preferences/ui/SettingsController.java b/src/main/java/com/faforever/client/preferences/ui/SettingsController.java index 1a9b651a32..9e1083a9d3 100644 --- a/src/main/java/com/faforever/client/preferences/ui/SettingsController.java +++ b/src/main/java/com/faforever/client/preferences/ui/SettingsController.java @@ -140,6 +140,8 @@ public class SettingsController extends NodeController { public CheckBox playFriendJoinsGameSoundCheckBox; public CheckBox playFriendPlaysGameSoundCheckBox; public CheckBox displayPmReceivedToastCheckBox; + public CheckBox displayMatchFoundNotificationCheckBox; + public CheckBox playMatchFoundSoundCheckBox; public CheckBox playPmReceivedSoundCheckBox; public CheckBox afterGameReviewCheckBox; public CheckBox disableSteamStartCheckBox; @@ -395,6 +397,9 @@ private void bindNotificationPreferences() { .bindBidirectional(notificationPrefs.friendPlaysGameSoundEnabledProperty()); playPmReceivedSoundCheckBox.selectedProperty() .bindBidirectional(notificationPrefs.privateMessageSoundEnabledProperty()); + displayMatchFoundNotificationCheckBox.selectedProperty().setValue(true); + playMatchFoundSoundCheckBox.selectedProperty() + .bindBidirectional(notificationPrefs.matchFoundSoundEnabledProperty()); afterGameReviewCheckBox.selectedProperty().bindBidirectional(notificationPrefs.afterGameReviewEnabledProperty()); notifyOnAtMentionOnlyToggle.selectedProperty() .bindBidirectional(notificationPrefs.notifyOnAtMentionOnlyEnabledProperty()); diff --git a/src/main/java/com/faforever/client/teammatchmaking/TeamMatchmakingService.java b/src/main/java/com/faforever/client/teammatchmaking/TeamMatchmakingService.java index 00b6a0ae8a..947ddc387f 100644 --- a/src/main/java/com/faforever/client/teammatchmaking/TeamMatchmakingService.java +++ b/src/main/java/com/faforever/client/teammatchmaking/TeamMatchmakingService.java @@ -1,6 +1,7 @@ package com.faforever.client.teammatchmaking; import com.faforever.client.api.FafApiAccessor; +import com.faforever.client.audio.AudioService; import com.faforever.client.chat.ChatService; import com.faforever.client.domain.server.MatchmakerQueueInfo; import com.faforever.client.domain.server.PartyInfo; @@ -110,6 +111,7 @@ public class TeamMatchmakingService implements InitializingBean { private final MatchmakerMapper matchmakerMapper; private final MatchmakerPrefs matchmakerPrefs; private final GamePathHandler gamePathHandler; + private final AudioService audioService; @Getter private final PartyInfo party = new PartyInfo(); @@ -342,6 +344,8 @@ private void setTimedOutMatchingStatus(MatchmakerQueueInfo queue, MatchingStatus } private void notifyMatchFound() { + audioService.playMatchFoundSound(); + notificationService.addNotification( new TransientNotification(i18n.get("teammatchmaking.notification.matchFound.title"), i18n.get("teammatchmaking.notification.matchFound.message"))); diff --git a/src/main/resources/i18n/messages.properties b/src/main/resources/i18n/messages.properties index a106dea2a3..9b217afa3d 100644 --- a/src/main/resources/i18n/messages.properties +++ b/src/main/resources/i18n/messages.properties @@ -451,6 +451,7 @@ settings.notifications.toastPosition = Toast position settings.notifications.toastScreen = Screen settings.notifications.playSound = Play sound settings.notifications.pmReceived = PM received +settings.notifications.matchFound = Match Found settings.notifications.ranked1v1 = Ranked 1v1 available settings.sounds = Sounds settings.sounds.enable = Enable Sounds diff --git a/src/main/resources/theme/settings/settings.fxml b/src/main/resources/theme/settings/settings.fxml index 95b15b14e2..eaf2330767 100644 --- a/src/main/resources/theme/settings/settings.fxml +++ b/src/main/resources/theme/settings/settings.fxml @@ -596,11 +596,21 @@ GridPane.columnIndex="2" GridPane.halignment="CENTER" GridPane.rowIndex="5" GridPane.valignment="CENTER"/>