Search in sources :

Example 1 with UserCell

use of com.gianlu.pyxreborn.client.UI.ListCells.UserCell in project PretendYoureXyzzyReborn by devgianlu.

the class MainUI method initialize.

@FXML
public void initialize() {
    gamesList.setCellFactory(param -> new GameCell(stage, client, me));
    usersList.setCellFactory(param -> new UserCell());
    refreshGamesList();
    refreshUsersList();
}
Also used : GameCell(com.gianlu.pyxreborn.client.UI.ListCells.GameCell) UserCell(com.gianlu.pyxreborn.client.UI.ListCells.UserCell) FXML(javafx.fxml.FXML)

Example 2 with UserCell

use of com.gianlu.pyxreborn.client.UI.ListCells.UserCell in project PretendYoureXyzzyReborn by devgianlu.

the class GameUI method initialize.

@FXML
public void initialize() {
    JsonObject obj = client.createRequest(Operations.GET_GAME);
    obj.addProperty(Fields.GID.toString(), game.gid);
    try {
        game = new CGame(client.sendMessageBlocking(obj).getAsJsonObject(Fields.GAME.toString()));
    } catch (InterruptedException | PyxException ex) {
        UIClient.notifyException(ex);
        return;
    }
    if (Objects.equals(me.nickname, game.host.nickname)) {
        // I am the host
        if (game.status == Game.Status.LOBBY)
            startGame.setVisible(true);
        else
            startGame.setVisible(false);
    } else {
        // I am not the host
        startGame.setVisible(false);
    }
    spectators.setCellFactory(param -> new UserCell());
    spectators.setItems(spectatorsList);
    players.setCellFactory(param -> new PlayerCell());
    players.setItems(playersList);
    client.addListener((event, request) -> true, this);
    if (isSpectating())
        instructions.setText("You're a spectator!");
}
Also used : CGame(com.gianlu.pyxreborn.Models.Client.CGame) PlayerCell(com.gianlu.pyxreborn.client.UI.ListCells.PlayerCell) JsonObject(com.google.gson.JsonObject) PyxException(com.gianlu.pyxreborn.Exceptions.PyxException) UserCell(com.gianlu.pyxreborn.client.UI.ListCells.UserCell) FXML(javafx.fxml.FXML)

Aggregations

UserCell (com.gianlu.pyxreborn.client.UI.ListCells.UserCell)2 FXML (javafx.fxml.FXML)2 PyxException (com.gianlu.pyxreborn.Exceptions.PyxException)1 CGame (com.gianlu.pyxreborn.Models.Client.CGame)1 GameCell (com.gianlu.pyxreborn.client.UI.ListCells.GameCell)1 PlayerCell (com.gianlu.pyxreborn.client.UI.ListCells.PlayerCell)1 JsonObject (com.google.gson.JsonObject)1