Search in sources :

Example 1 with CCompactCardSet

use of com.gianlu.pyxreborn.Models.Client.CCompactCardSet in project PretendYoureXyzzyReborn by devgianlu.

the class GameOptionsUI method initialize.

@FXML
public void initialize() {
    NumberStringFilteredConverter numberFormatter = new NumberStringFilteredConverter();
    maxPlayers.setTextFormatter(new TextFormatter<>(numberFormatter, 0, numberFormatter.getFilter()));
    maxPlayers.setText(String.valueOf(game.options.maxPlayers));
    maxPlayers.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.isEmpty())
            newOptions.maxPlayers = Integer.parseInt(newValue);
    });
    maxSpectators.setTextFormatter(new TextFormatter<>(numberFormatter, 0, numberFormatter.getFilter()));
    maxSpectators.setText(String.valueOf(game.options.maxSpectators));
    maxSpectators.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.isEmpty())
            newOptions.maxSpectators = Integer.parseInt(newValue);
    });
    List<CCompactCardSet> allCardSets;
    try {
        allCardSets = Utils.toList(client.sendMessageBlocking(client.createRequest(Operations.LIST_CARD_SETS)).getAsJsonArray(Fields.CARD_SET.toString()), CCompactCardSet.class);
    } catch (InterruptedException | PyxException ex) {
        UIClient.notifyException(ex);
        return;
    }
    boolean amHost = Objects.equals(game.host, me);
    cardSets.setCellFactory(param -> new CheckboxCardSetCell(newOptions, amHost));
    cardSets.setItems(new ObservableListWrapper<>(allCardSets));
    maxPlayers.setDisable(!amHost);
    maxSpectators.setDisable(!amHost);
    apply.setDisable(!amHost);
}
Also used : CheckboxCardSetCell(com.gianlu.pyxreborn.client.UI.ListCells.CheckboxCardSetCell) CCompactCardSet(com.gianlu.pyxreborn.Models.Client.CCompactCardSet) PyxException(com.gianlu.pyxreborn.Exceptions.PyxException) NumberStringFilteredConverter(com.gianlu.pyxreborn.client.UI.NumberStringFilteredConverter) FXML(javafx.fxml.FXML)

Aggregations

PyxException (com.gianlu.pyxreborn.Exceptions.PyxException)1 CCompactCardSet (com.gianlu.pyxreborn.Models.Client.CCompactCardSet)1 CheckboxCardSetCell (com.gianlu.pyxreborn.client.UI.ListCells.CheckboxCardSetCell)1 NumberStringFilteredConverter (com.gianlu.pyxreborn.client.UI.NumberStringFilteredConverter)1 FXML (javafx.fxml.FXML)1