use of com.faforever.client.notification.TransientNotification in project downlords-faf-client by FAForever.
the class FriendJoinedGameNotifierTest method onFriendJoinedGame.
@Test
public void onFriendJoinedGame() throws Exception {
Game game = GameBuilder.create().defaultValues().title("My Game").get();
Player player = PlayerBuilder.create("junit").id(1).game(game).get();
when(notification.isFriendJoinsGameToastEnabled()).thenReturn(true);
when(i18n.get("friend.joinedGameNotification.title", "junit", "My Game")).thenReturn("junit joined My Game");
when(i18n.get("friend.joinedGameNotification.action")).thenReturn("Click to join");
instance.onFriendJoinedGame(new FriendJoinedGameEvent(player, game));
ArgumentCaptor<TransientNotification> captor = ArgumentCaptor.forClass(TransientNotification.class);
verify(notificationService).addNotification(captor.capture());
TransientNotification notification = captor.getValue();
assertThat(notification.getTitle(), is("junit joined My Game"));
assertThat(notification.getText(), is("Click to join"));
assertThat(notification.getImage(), notNullValue());
}
use of com.faforever.client.notification.TransientNotification in project downlords-faf-client by FAForever.
the class AchievementUnlockedNotifierTest method newlyUnlocked.
@Test
public void newlyUnlocked() throws Exception {
AchievementDefinition achievementDefinition = new AchievementDefinition();
achievementDefinition.setType(AchievementType.STANDARD);
achievementDefinition.setName("Test Achievement");
when(achievementService.getImage(achievementDefinition, UNLOCKED)).thenReturn(mock(Image.class));
triggerUpdatedAchievementsMessage(achievementDefinition, true);
verify(audioService).playAchievementUnlockedSound();
ArgumentCaptor<TransientNotification> notificationCaptor = ArgumentCaptor.forClass(TransientNotification.class);
verify(notificationService).addNotification(notificationCaptor.capture());
TransientNotification notification = notificationCaptor.getValue();
assertThat(notification.getImage(), notNullValue());
assertThat(notification.getTitle(), is("Achievement unlocked"));
assertThat(notification.getText(), is("Test Achievement"));
}
use of com.faforever.client.notification.TransientNotification in project downlords-faf-client by FAForever.
the class AchievementUnlockedNotifier method notifyAboutUnlockedAchievement.
private void notifyAboutUnlockedAchievement(AchievementDefinition achievementDefinition) {
if (lastSoundPlayed < System.currentTimeMillis() - 1000) {
audioService.playAchievementUnlockedSound();
lastSoundPlayed = System.currentTimeMillis();
}
notificationService.addNotification(new TransientNotification(i18n.get("achievement.unlockedTitle"), achievementDefinition.getName(), achievementService.getImage(achievementDefinition, AchievementState.UNLOCKED)));
}
use of com.faforever.client.notification.TransientNotification in project downlords-faf-client by FAForever.
the class OnGameFullNotifier method onGameFull.
@Subscribe
public void onGameFull(GameFullEvent event) {
executor.execute(() -> {
platformService.startFlashingWindow(faWindowTitle);
while (gameService.isGameRunning() && !platformService.isWindowFocused(faWindowTitle)) {
noCatch(() -> sleep(500));
}
platformService.stopFlashingWindow(faWindowTitle);
});
Game currentGame = gameService.getCurrentGame();
if (currentGame == null) {
throw new ProgrammingError("Got a GameFull notification but player is not in a game");
}
if (platformService.isWindowFocused(faWindowTitle)) {
return;
}
notificationService.addNotification(new TransientNotification(i18n.get("game.full"), i18n.get("game.full.action"), mapService.loadPreview(currentGame.getMapFolderName(), PreviewSize.SMALL), v -> platformService.focusWindow(faWindowTitle)));
}
use of com.faforever.client.notification.TransientNotification in project downlords-faf-client by FAForever.
the class MainController method onMatchmakerMessage.
private void onMatchmakerMessage(MatchmakerMessage message) {
if (message.getQueues() == null || gameService.gameRunningProperty().get() || !preferencesService.getPreferences().getNotification().getLadder1v1ToastEnabled() || !playerService.getCurrentPlayer().isPresent()) {
return;
}
Player currentPlayer = playerService.getCurrentPlayer().get();
int deviationFor80PercentQuality = (int) (ratingBeta / 2.5f);
int deviationFor75PercentQuality = (int) (ratingBeta / 1.25f);
float leaderboardRatingDeviation = currentPlayer.getLeaderboardRatingDeviation();
Function<MatchmakerMessage.MatchmakerQueue, List<RatingRange>> ratingRangesSupplier;
if (leaderboardRatingDeviation <= deviationFor80PercentQuality) {
ratingRangesSupplier = MatchmakerMessage.MatchmakerQueue::getBoundary80s;
} else if (leaderboardRatingDeviation <= deviationFor75PercentQuality) {
ratingRangesSupplier = MatchmakerMessage.MatchmakerQueue::getBoundary75s;
} else {
return;
}
float leaderboardRatingMean = currentPlayer.getLeaderboardRatingMean();
boolean showNotification = false;
for (MatchmakerMessage.MatchmakerQueue matchmakerQueue : message.getQueues()) {
if (!Objects.equals("ladder1v1", matchmakerQueue.getQueueName())) {
continue;
}
List<RatingRange> ratingRanges = ratingRangesSupplier.apply(matchmakerQueue);
for (RatingRange ratingRange : ratingRanges) {
if (ratingRange.getMin() <= leaderboardRatingMean && leaderboardRatingMean <= ratingRange.getMax()) {
showNotification = true;
break;
}
}
}
if (!showNotification) {
return;
}
notificationService.addNotification(new TransientNotification(i18n.get("ranked1v1.notification.title"), i18n.get("ranked1v1.notification.message"), uiService.getThemeImage(UiService.LADDER_1V1_IMAGE), event -> eventBus.post(new Open1v1Event())));
}
Aggregations