Fixed Spout stats header alignment and font display in fullscreen. Made notifications and text stick longer because you can't re-read it through chat. Add 5 message limit in War message feed to counter large message inflows.

This commit is contained in:
taoneill 2012-01-12 22:41:52 -05:00
parent ad1c591acd
commit 6a452ebb8f
6 changed files with 74 additions and 43 deletions

View File

@ -67,7 +67,7 @@ public class WarBlockListener extends BlockListener {
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
team.getKind().getMaterial(),
team.getKind().getData(),
5000);
10000);
}
}
}
@ -222,7 +222,7 @@ public class WarBlockListener extends BlockListener {
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "freed by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
ownerTeam.getKind().getMaterial(),
ownerTeam.getKind().getData(),
5000);
10000);
}
}
}

View File

@ -520,7 +520,7 @@ public class WarPlayerListener extends PlayerListener {
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
victim.getKind().getMaterial(),
victim.getKind().getData(),
5000);
10000);
}
}
}

View File

@ -55,7 +55,7 @@ public class RenameZoneCommand extends AbstractZoneMakerCommand {
War.war.getWarzones().remove(zone);
// rename zone file
(new File(War.war.getDataFolder().getPath() + "/warzone-" + zone.getName() + ".txt")).renameTo(new File(War.war.getDataFolder().getPath() + "/warzone-" + this.args[0] + ".txt"));
(new File(War.war.getDataFolder().getPath() + "/warzone-" + zone.getName() + ".yml")).renameTo(new File(War.war.getDataFolder().getPath() + "/warzone-" + this.args[0] + ".yml"));
// rename zone folder
(new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + zone.getName())).renameTo(new File(War.war.getDataFolder().getPath() + "/dat/warzone-" + this.args[0]));
@ -69,7 +69,7 @@ public class RenameZoneCommand extends AbstractZoneMakerCommand {
(new File(oldStart + "invs")).renameTo(new File(newStart + "invs"));
// set new name
PropertiesFile warzoneConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/warzone-" + this.args[0] + ".txt");
PropertiesFile warzoneConfig = new PropertiesFile(War.war.getDataFolder().getPath() + "/warzone-" + this.args[0] + ".yml");
warzoneConfig.setString("name", this.args[0]);
warzoneConfig.save();
warzoneConfig.close();

View File

@ -730,7 +730,7 @@ public class Warzone {
SpoutMessenger.cleanForNotification("ran out of lives."),
playerTeam.getKind().getMaterial(),
playerTeam.getKind().getData(),
5000);
10000);
}
}
}

View File

@ -35,7 +35,7 @@ public class ScoreCapReachedJob implements Runnable {
SpoutMessenger.cleanForNotification(SpoutMessenger.addMissingColor(winnersStr, zone)),
Material.CAKE,
(short)0,
5000);
10000);
}
}
}

View File

@ -23,18 +23,28 @@ import com.tommytony.war.config.TeamConfig;
public class SpoutMessenger {
private static int LINE_HEIGHT = 5;
private static int LINE_HEIGHT_WITH_MARGIN = 8;
Map<String, List<PlayerMessage>> playerMessages = new HashMap<String, List<PlayerMessage>>();
public void msg(SpoutPlayer sp, String message) {
if (!playerMessages.containsKey(sp.getName())) {
playerMessages.put(sp.getName(), new ArrayList<PlayerMessage>());
}
playerMessages.get(sp.getName()).add(new PlayerMessage(message));
List<PlayerMessage> messages = playerMessages.get(sp.getName());
messages.add(new PlayerMessage(message));
// prevent huge stack of messages, 5 max
if (messages.size() > 5) {
// remove first
messages.remove(0);
}
List<Integer> statsOffset = new ArrayList<Integer>();
List<GenericLabel> lines = getStatsLines(Warzone.getZoneByPlayerName(sp.getName()), statsOffset);
drawMessages(sp.getName(), lines, statsOffset);
drawMessages(sp.getName(), lines, statsOffset);
}
public void fadeOutOldMessages() {
@ -43,7 +53,7 @@ public class SpoutMessenger {
List<PlayerMessage> toRemove = new ArrayList<PlayerMessage>();
for (PlayerMessage message : messages) {
if (System.currentTimeMillis() - message.getSendTime() > 12000) {
if (System.currentTimeMillis() - message.getSendTime() > 15000) {
toRemove.add(message);
}
@ -126,12 +136,16 @@ public class SpoutMessenger {
List<GenericLabel> playerlines = new ArrayList<GenericLabel>();
List<GenericLabel> scorelines = new ArrayList<GenericLabel>();
List<GenericLabel> lifelines = new ArrayList<GenericLabel>();
int teamMax = 5, scoreMax = 5, lifeMax = 5;
int teamMax = 0, scoreMax = 0, lifeMax = 0;
GenericLabel line;
GenericLabel teamsHeader = new GenericLabel(ChatColor.GRAY + "War> " + ChatColor.WHITE + zone.getName());
int teamsHeaderWidth = GenericLabel.getStringWidth(teamsHeader.getText());
teamsHeader.setAlign(WidgetAnchor.TOP_LEFT).setX(3).setY(2).setWidth(teamsHeaderWidth);
int teamsHeaderWidth = GenericLabel.getStringWidth(teamsHeader.getText()) + 1;
teamsHeader.setAlign(WidgetAnchor.TOP_LEFT)
.setX(3)
.setY(2)
.setWidth(teamsHeaderWidth)
.setHeight(LINE_HEIGHT);
lines.add(teamsHeader);
// First, we collect all the team names
@ -146,8 +160,11 @@ public class SpoutMessenger {
else {
line.setText(t.getKind().getColor() + teamStr.replace("(", ChatColor.GRAY + "(" + ChatColor.WHITE).replace(")", ChatColor.GRAY + ")" + ChatColor.WHITE));
}
line.setTooltip("Warzone: " + zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
line.setAlign(WidgetAnchor.TOP_LEFT).setX(2).setY(4 + lineCounter * 8).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
line.setAlign(WidgetAnchor.TOP_LEFT)
.setX(3)
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
.setWidth(GenericLabel.getStringWidth(line.getText()))
.setHeight(LINE_HEIGHT);
teamlines.add(line);
lineCounter++;
}
@ -162,29 +179,27 @@ public class SpoutMessenger {
}
}
// First line with headers
int headerOffset = teamMax - 2;
GenericLabel pointsHeader = new GenericLabel(ChatColor.GRAY + "points");
//pointsHeader.setTextColor(new Color(100, 100, 100));
// points header
GenericLabel pointsHeader = new GenericLabel(ChatColor.GRAY + "score");
int pointsHeaderWidth = GenericLabel.getStringWidth(pointsHeader.getText());
pointsHeader.setAlign(WidgetAnchor.TOP_LEFT).setX(headerOffset).setY(2).setWidth(pointsHeaderWidth);
headerOffset += pointsHeaderWidth + 6;
pointsHeader.setAlign(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 2)
.setY(2)
.setWidth(pointsHeaderWidth)
.setHeight(LINE_HEIGHT);
lines.add(pointsHeader);
GenericLabel livesHeader = new GenericLabel(ChatColor.GRAY + "lives");
//livesHeader.setTextColor(new Color(100, 100, 100));
int livesHeaderWidth = GenericLabel.getStringWidth(livesHeader.getText());
livesHeader.setAlign(WidgetAnchor.TOP_LEFT).setX(headerOffset).setY(2).setWidth(livesHeaderWidth);
lines.add(livesHeader);
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.setTooltip("Warzone: " + zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3 + teamMax + 2).setY(4 + lineCounter * 8).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
line.setAlign(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++;
}
@ -198,13 +213,27 @@ public class SpoutMessenger {
scoreMax = pointsHeaderWidth;
}
// lifepool header
GenericLabel livesHeader = new GenericLabel(ChatColor.GRAY + "lives");
int livesHeaderWidth = GenericLabel.getStringWidth(livesHeader.getText());
livesHeader.setAlign(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.setTooltip("Warzone: " + zone.getName()).setAnchor(WidgetAnchor.TOP_LEFT);
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3 + teamMax + 2 + scoreMax + 2).setY(4 + lineCounter * 8).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
line.setAlign(WidgetAnchor.TOP_LEFT)
.setX(3 + teamMax + 4 + scoreMax + 4)
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
.setWidth(GenericLabel.getStringWidth(line.getText()))
.setHeight(LINE_HEIGHT);
lifelines.add(line);
lineCounter++;
}
@ -223,8 +252,8 @@ public class SpoutMessenger {
for (GenericLabel l : scorelines) { lines.add(l); }
for (GenericLabel l : lifelines) { lines.add(l); }
offset.add(3 + teamMax + 2 + scoreMax + 2 + lifeMax + 2);
offset.add(2 + lineCounter * 8);
offset.add(3 + teamMax + 1 + scoreMax + 1 + lifeMax + 2);
offset.add(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN);
}
return lines;
@ -249,9 +278,9 @@ public class SpoutMessenger {
// add bg
GenericGradient gradient = new GenericGradient();
gradient.setAnchor(WidgetAnchor.TOP_LEFT);
gradient.setTopColor(new Color(0.0F, 0.0F, 0.0F, 0.5F)); // (order is Red, Green, Blue, Alpha)
gradient.setTopColor(new Color(0.0F, 0.0F, 0.0F, 0.4F)); // (order is Red, Green, Blue, Alpha)
gradient.setBottomColor(new Color(0.0F, 0.0F, 0.0F, 0.0F));
gradient.setHeight(statsOffset.get(1) + 4).setWidth(statsOffset.get(0) - 3);
gradient.setHeight(statsOffset.get(1) + 4).setWidth((int)(statsOffset.get(0) * 1.15));
player.getMainScreen().attachWidget(War.war, gradient);
@ -260,15 +289,17 @@ public class SpoutMessenger {
teamGradient.setAnchor(WidgetAnchor.TOP_LEFT);
Team team = Team.getTeamByPlayerName(playerName);
Color spoutColor = new Color(250.0F, 250.0F, 250.0F, 1.0F);
if (team != null) {
spoutColor = team.getKind().getSpoutColor();
}
spoutColor.setAlpha(0.5F);
teamGradient.setY(10);
teamGradient.setY(2 + LINE_HEIGHT_WITH_MARGIN);
teamGradient.setTopColor(spoutColor);
teamGradient.setBottomColor(new Color(250.0F, 250.0F, 250.0F, 1.0F));
teamGradient.setHeight(2).setWidth(statsOffset.get(0) - 3);
teamGradient.setBottomColor(new Color(256, 256, 256, 1.0F));
teamGradient.setHeight(2).setWidth((int)(statsOffset.get(0) * 1.15));
player.getMainScreen().attachWidget(War.war, teamGradient);
@ -291,7 +322,7 @@ public class SpoutMessenger {
if (horizontalOffset > 160) {
horizontalOffset = 2;
verticalOffset += 8;
verticalOffset += LINE_HEIGHT_WITH_MARGIN;
}
word = addMissingColor(word, zone);
@ -300,7 +331,7 @@ public class SpoutMessenger {
int width = GenericLabel.getStringWidth(word);
label.setAlign(WidgetAnchor.TOP_LEFT);
label.setWidth(width);
label.setHeight(GenericLabel.getStringHeight(word));
label.setHeight(LINE_HEIGHT);
label.setX(horizontalOffset);
label.setY(verticalOffset);
@ -309,7 +340,7 @@ public class SpoutMessenger {
horizontalOffset += width + 2;
}
verticalOffset += 9;
verticalOffset += LINE_HEIGHT_WITH_MARGIN + 1;
rank++;
}