use of de.gg.game.ui.components.CharacterComponent in project ProjektGG by eskalon.
the class GameBallotScreen method onNewBallot.
@Subscribe
private void onNewBallot(NewBallotEvent ev) {
if (ev.getNewBallot() == null) {
application.getScreenManager().pushScreen("map", "circle_open");
return;
}
World world = application.getClient().getSession().getWorld();
Player localPlayer = application.getClient().getLocalPlayer();
optionTable.clear();
voterTable.clear();
buttons.clear();
infoText.setText(ev.getNewBallot().getInfoText());
// Display the voters
voterTable.add(new Label(Lang.get("screen.vote.voters"), skin, "title")).padBottom(12).row();
for (short s : ev.getNewBallot().getVoters()) {
// PositionType posT = world.getCharacter(s).getPosition();
boolean isLocalPlayer = s == application.getClient().getLocalPlayer().getCurrentlyPlayedCharacterId();
voterTable.add(new CharacterComponent(skin, world.getCharacter(s), isLocalPlayer ? -1 : application.getClient().getOpinionOfOtherCharacter(s))).left().padBottom(25).row();
}
// Display the options (if the player can vote)
if (ev.getNewBallot().getVoters().contains(localPlayer.getCurrentlyPlayedCharacterId())) {
for (BallotOption option : ev.getNewBallot().getOptions()) {
ImageTextButton button = new OffsettableImageTextButton(Lang.get(option), skin, 5);
button.addListener(new ButtonClickListener(application.getSoundManager()) {
@Override
protected void onClick() {
application.getClient().getActionHandler().castVote(option.getValue());
for (Button b : buttons) {
b.setDisabled(true);
b.setTouchable(Touchable.disabled);
}
}
});
buttons.add(button);
if (option.isCharacter() && option.getValue() != application.getClient().getLocalPlayer().getCurrentlyPlayedCharacterId()) {
// PositionType posT = world.getCharacters()
// .get((short) option.getValue()).getPosition();
optionTable.add(new CharacterComponent(skin, world.getCharacter((short) option.getValue()), application.getClient().getOpinionOfOtherCharacter((short) option.getValue()))).right().padBottom(8).row();
}
optionTable.add(button).right().padBottom(15).row();
}
}
}
Aggregations