Skip to content

Commit

Permalink
Merge d02e61c into f1d7838
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackYps committed Nov 13, 2020
2 parents f1d7838 + d02e61c commit 776e35c
Show file tree
Hide file tree
Showing 31 changed files with 20 additions and 1,117 deletions.
43 changes: 0 additions & 43 deletions src/main/java/com/faforever/client/game/GameService.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,47 +496,6 @@ public Game getByUid(int uid) {
return game;
}

public void addOnMatchmakerQueueNotificationListener(Consumer<MatchmakerInfoMessage> listener) {
fafService.addOnMessageListener(MatchmakerInfoMessage.class, listener);
}

//TODO: remove
// public CompletableFuture<Void> startSearchLadder1v1(Faction faction) {
// if (isRunning()) {
// log.debug("Game is running, ignoring 1v1 search request");
// return completedFuture(null);
// }
//
// if (!preferencesService.isGamePathValid()) {
// CompletableFuture<Path> gameDirectoryFuture = postGameDirectoryChooseEvent();
// return gameDirectoryFuture.thenCompose(path -> startSearchLadder1v1(faction));
// }
//
// searching1v1.set(true);
//
// return modService.getFeaturedMod(LADDER_1V1.getTechnicalName())
// .thenAccept(featuredModBean -> updateGameIfNecessary(featuredModBean, null, emptyMap(), emptySet()))
// .thenCompose(aVoid -> fafService.startSearchLadder1v1(faction))
// .thenAccept((gameLaunchMessage) -> downloadMapIfNecessary(gameLaunchMessage.getMapname())
// .thenRun(() -> {
// gameLaunchMessage.setArgs(new ArrayList<>(gameLaunchMessage.getArgs()));
//
// gameLaunchMessage.getArgs().add("/team " + gameLaunchMessage.getTeam());
// gameLaunchMessage.getArgs().add("/players " + gameLaunchMessage.getExpectedPlayers());
// gameLaunchMessage.getArgs().add("/startspot " + gameLaunchMessage.getMapPosition());
//
// startGame(gameLaunchMessage, faction, RatingMode.LADDER_1V1);
// }))
// .exceptionally(throwable -> {
// if (throwable instanceof CancellationException) {
// log.info("Ranked1v1 search has been cancelled");
// } else {
// log.warn("Ranked1v1 could not be started", throwable);
// }
// return null;
// });
// }

public CompletableFuture<Void> startSearchMatchmaker() {

inMatchmakerQueue.set(true);
Expand Down Expand Up @@ -564,11 +523,9 @@ public CompletableFuture<Void> startSearchMatchmaker() {
});
}

//TODO: disable usages, rename to onMatchmakerSearchStopped
public void onMatchmakerSearchStopped() {
if (inMatchmakerQueue.get()) {
fafService.stopSearchMatchmaker();
fafService.stopSearchingRanked();
inMatchmakerQueue.set(false);
}
}
Expand Down
57 changes: 1 addition & 56 deletions src/main/java/com/faforever/client/main/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.faforever.client.login.LoginController;
import com.faforever.client.main.event.NavigateEvent;
import com.faforever.client.main.event.NavigationItem;
import com.faforever.client.main.event.Open1v1Event;
import com.faforever.client.main.event.OpenTeamMatchmakingEvent;
import com.faforever.client.news.UnreadNewsEvent;
import com.faforever.client.notification.Action;
import com.faforever.client.notification.ImmediateNotification;
Expand Down Expand Up @@ -219,7 +219,6 @@ public void initialize() {
notificationService.addPersistentNotificationListener(change -> runLater(() -> updateNotificationsButton(change.getSet())));
notificationService.addImmediateNotificationListener(notification -> runLater(() -> displayImmediateNotification(notification)));
notificationService.addTransientNotificationListener(notification -> runLater(() -> transientNotificationsController.addNotification(notification)));
gameService.addOnMatchmakerQueueNotificationListener(this::onMatchmakerMessage);
// Always load chat immediately so messages or joined channels don't need to be cached until we display them.
getView(NavigationItem.CHAT);

Expand Down Expand Up @@ -321,60 +320,6 @@ private void updateNotificationsButton(Collection<? extends PersistentNotificati
notificationButton.pseudoClassStateChanged(NOTIFICATION_ERROR_PSEUDO_CLASS, highestSeverity == Severity.ERROR);
}


//TODO: adapt for TMM
private void onMatchmakerMessage(MatchmakerInfoMessage message) {
if (message.getQueues() == null
|| gameService.gameRunningProperty().get()
|| gameService.inMatchmakerQueueProperty().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<MatchmakerInfoMessage.MatchmakerQueue, List<RatingRange>> ratingRangesSupplier;
if (leaderboardRatingDeviation <= deviationFor80PercentQuality) {
ratingRangesSupplier = MatchmakerInfoMessage.MatchmakerQueue::getBoundary80s;
} else if (leaderboardRatingDeviation <= deviationFor75PercentQuality) {
ratingRangesSupplier = MatchmakerInfoMessage.MatchmakerQueue::getBoundary75s;
} else {
return;
}

float leaderboardRatingMean = currentPlayer.getLeaderboardRatingMean();
boolean showNotification = false;
for (MatchmakerInfoMessage.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())
));
}

public void display() {
eventBus.post(UpdateApplicationBadgeEvent.ofNewValue(0));

Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions src/main/java/com/faforever/client/play/PlayController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
import com.faforever.client.fx.AbstractViewController;
import com.faforever.client.game.CustomGamesController;
import com.faforever.client.main.event.NavigateEvent;
import com.faforever.client.main.event.Open1v1Event;
import com.faforever.client.main.event.OpenCoopEvent;
import com.faforever.client.main.event.OpenCustomGamesEvent;
import com.faforever.client.main.event.OpenTeamMatchmakingEvent;
import com.faforever.client.rankedmatch.Ladder1v1Controller;
import com.faforever.client.teammatchmaking.TeamMatchmakingController;
import com.google.common.eventbus.EventBus;
import javafx.scene.Node;
Expand All @@ -18,8 +16,6 @@
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.Objects;

@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class PlayController extends AbstractViewController<Node> {
Expand All @@ -28,11 +24,9 @@ public class PlayController extends AbstractViewController<Node> {
public Tab teamMatchmakingTab;
public Tab customGamesTab;
public Tab coopTab;
public Tab ladderTab;
public TabPane playRootTabPane;
public TeamMatchmakingController teamMatchmakingController;
public CustomGamesController customGamesController;
public Ladder1v1Controller ladderController;
public CoopController coopController;
private boolean isHandlingEvent;
private AbstractViewController<?> lastTabController;
Expand All @@ -55,8 +49,6 @@ public void initialize() {
eventBus.post(new OpenTeamMatchmakingEvent());
} else if (newValue == customGamesTab) {
eventBus.post(new OpenCustomGamesEvent());
} else if (newValue == ladderTab) {
eventBus.post(new Open1v1Event());
} else if (newValue == coopTab) {
eventBus.post(new OpenCoopEvent());
}
Expand All @@ -74,9 +66,6 @@ protected void onDisplay(NavigateEvent navigateEvent) {
} else if (navigateEvent instanceof OpenCustomGamesEvent) {
lastTab = customGamesTab;
lastTabController = customGamesController;
} else if (navigateEvent instanceof Open1v1Event) {
lastTab = ladderTab;
lastTabController = ladderController;
} else if (navigateEvent instanceof OpenCoopEvent) {
lastTab = coopTab;
lastTabController = coopController;
Expand All @@ -92,7 +81,6 @@ protected void onDisplay(NavigateEvent navigateEvent) {
public void onHide() {
teamMatchmakingController.onHide();
customGamesController.onHide();
ladderController.onHide();
coopController.onHide();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class NotificationsPrefs {
private final BooleanProperty errorSoundEnabled;
private final BooleanProperty friendOnlineToastEnabled;
private final BooleanProperty friendOfflineToastEnabled;
private final BooleanProperty ladder1v1ToastEnabled;
private final BooleanProperty friendOnlineSoundEnabled;
private final BooleanProperty friendOfflineSoundEnabled;
private final BooleanProperty friendJoinsGameSoundEnabled;
Expand All @@ -42,7 +41,6 @@ public NotificationsPrefs() {
toastPosition = new SimpleObjectProperty<>(ToastPosition.BOTTOM_RIGHT);
friendOnlineToastEnabled = new SimpleBooleanProperty(true);
friendOfflineToastEnabled = new SimpleBooleanProperty(true);
ladder1v1ToastEnabled = new SimpleBooleanProperty(true);
friendOnlineSoundEnabled = new SimpleBooleanProperty(true);
friendOfflineSoundEnabled = new SimpleBooleanProperty(true);
friendJoinsGameSoundEnabled = new SimpleBooleanProperty(true);
Expand Down Expand Up @@ -153,18 +151,6 @@ public BooleanProperty friendOfflineToastEnabledProperty() {
return friendOfflineToastEnabled;
}

public boolean getLadder1v1ToastEnabled() {
return ladder1v1ToastEnabled.get();
}

public void setLadder1v1ToastEnabled(boolean ladder1v1ToastEnabled) {
this.ladder1v1ToastEnabled.set(ladder1v1ToastEnabled);
}

public BooleanProperty ladder1v1ToastEnabledProperty() {
return ladder1v1ToastEnabled;
}

public boolean isFriendOnlineSoundEnabled() {
return friendOnlineSoundEnabled.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.faforever.client.config.ClientProperties;
import com.faforever.client.fx.Controller;
import com.faforever.client.fx.JavaFxUtil;
import com.faforever.client.fx.NodeListCell;
import com.faforever.client.fx.PlatformService;
import com.faforever.client.fx.StringListCell;
import com.faforever.client.i18n.I18n;
Expand Down Expand Up @@ -112,7 +111,6 @@ public class SettingsController implements Controller<Node> {
public CheckBox playFriendJoinsGameSoundCheckBox;
public CheckBox playFriendPlaysGameSoundCheckBox;
public CheckBox displayPmReceivedToastCheckBox;
public CheckBox displayLadder1v1ToastCheckBox;
public CheckBox playPmReceivedSoundCheckBox;
public CheckBox afterGameReviewCheckBox;
public Region settingsRoot;
Expand Down Expand Up @@ -284,7 +282,6 @@ public void initialize() {
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());
Expand Down
Loading

0 comments on commit 776e35c

Please sign in to comment.