use of com.gianlu.pyxreborn.client.UI.NumberStringFilteredConverter 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);
}
Aggregations