for (Team t : zone.getTeams()) {
// team name
String teamStr = t.getName() + " (" + t.getPlayers().size() + "/" + t.getTeamConfig().resolveInt(TeamConfig.TEAMSIZE) + ")";
line = new GenericLabel(teamStr);
if (t.getPlayers().size() == 0) {
line.setTextColor(new Color(100,100,100));
}
else {
line.setText(t.getKind().getColor() + teamStr.replace("(", ChatColor.GRAY + "(" + ChatColor.WHITE).replace(")", ChatColor.GRAY + ")" + ChatColor.WHITE));
}
line.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3)
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
.setWidth(GenericLabel.getStringWidth(line.getText()))
.setHeight(LINE_HEIGHT);
teamlines.add(line);
lineCounter++;
}
// We need to find the longest name
for (GenericLabel l : teamlines) {
if (GenericLabel.getStringWidth(l.getText()) > teamMax) {
teamMax = GenericLabel.getStringWidth(l.getText());
}
if (teamsHeaderWidth > teamMax) {
teamMax = teamsHeaderWidth;
}
}
// points header
GenericLabel pointsHeader = new GenericLabel(ChatColor.GRAY + "score");
int pointsHeaderWidth = GenericLabel.getStringWidth(pointsHeader.getText());
pointsHeader.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 2)
.setY(2)
.setWidth(pointsHeaderWidth)
.setHeight(LINE_HEIGHT);
lines.add(pointsHeader);
lineCounter = 1;
for (Team t : zone.getTeams()) {
// scores
line = new GenericLabel(t.getPoints() + "/" + t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE));
if (t.getPlayers().size() == 0) line.setTextColor(new Color(100, 100, 100));
line.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 4)
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
.setWidth(GenericLabel.getStringWidth(line.getText()))
.setHeight(LINE_HEIGHT);
scorelines.add(line);
lineCounter++;
}
for (GenericLabel l : scorelines) {
if (GenericLabel.getStringWidth(l.getText()) > scoreMax) {
scoreMax = GenericLabel.getStringWidth(l.getText());
}
}
if (pointsHeaderWidth > scoreMax) {
scoreMax = pointsHeaderWidth;
}
// lifepool header
GenericLabel livesHeader = new GenericLabel(ChatColor.GRAY + "lives");
int livesHeaderWidth = GenericLabel.getStringWidth(livesHeader.getText());
livesHeader.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 4 + scoreMax + 2)
.setY(2)
.setWidth(livesHeaderWidth)
.setHeight(LINE_HEIGHT);
lines.add(livesHeader);
// and finally, lives.
lineCounter = 1;
for (Team t : zone.getTeams()) {
line = new GenericLabel(t.getRemainingLifes() + "/" + t.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
if (t.getPlayers().size() == 0) line.setTextColor(new Color(100, 100, 100));
line.setAnchor(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 4 + scoreMax + 4)
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
.setWidth(GenericLabel.getStringWidth(line.getText()))
.setHeight(LINE_HEIGHT);