Search in sources :

Example 1 with Faction

use of com.faforever.client.game.Faction in project downlords-faf-client by FAForever.

the class Ladder1v1Controller method onPlayButtonClicked.

public void onPlayButtonClicked() {
    if (preferencesService.getPreferences().getForgedAlliance().getPath() == null) {
        eventBus.post(new MissingGamePathEvent(true));
        return;
    }
    setFactionButtonsDisabled(true);
    ObservableList<Faction> factions = preferencesService.getPreferences().getLadder1v1Prefs().getFactions();
    Faction randomFaction = factions.get(random.nextInt(factions.size()));
    gameService.startSearchLadder1v1(randomFaction);
}
Also used : MissingGamePathEvent(com.faforever.client.preferences.event.MissingGamePathEvent) Faction(com.faforever.client.game.Faction)

Example 2 with Faction

use of com.faforever.client.game.Faction in project downlords-faf-client by FAForever.

the class Ladder1v1Controller method initialize.

@Override
public void initialize() {
    super.initialize();
    cancelButton.managedProperty().bind(cancelButton.visibleProperty());
    playButton.managedProperty().bind(playButton.visibleProperty());
    ratingLabel.managedProperty().bind(ratingLabel.visibleProperty());
    ratingProgressIndicator.managedProperty().bind(ratingProgressIndicator.visibleProperty());
    factionsToButtons = new HashMap<>();
    factionsToButtons.put(AEON, aeonButton);
    factionsToButtons.put(UEF, uefButton);
    factionsToButtons.put(CYBRAN, cybranButton);
    factionsToButtons.put(SERAPHIM, seraphimButton);
    setSearching(false);
    gameService.searching1v1Property().addListener((observable, oldValue, newValue) -> setSearching(newValue));
    ObservableList<Faction> factions = preferencesService.getPreferences().getLadder1v1Prefs().getFactions();
    for (Faction faction : EnumSet.of(AEON, CYBRAN, UEF, SERAPHIM)) {
        factionsToButtons.get(faction).setSelected(factions.contains(faction));
    }
    playButton.setDisable(factionsToButtons.values().stream().noneMatch(ToggleButton::isSelected));
    preferencesService.addUpdateListener(preferences -> {
        if (preferencesService.getPreferences().getForgedAlliance().getPath() == null) {
            onCancelButtonClicked();
        }
    });
    playerService.currentPlayerProperty().addListener((observable, oldValue, newValue) -> Platform.runLater(() -> setCurrentPlayer(newValue)));
    playerService.getCurrentPlayer().ifPresent(this::setCurrentPlayer);
}
Also used : Faction(com.faforever.client.game.Faction)

Aggregations

Faction (com.faforever.client.game.Faction)2 MissingGamePathEvent (com.faforever.client.preferences.event.MissingGamePathEvent)1