mirror of
https://github.com/taoneill/war.git
synced 2024-11-23 18:55:28 +01:00
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:
parent
ad1c591acd
commit
6a452ebb8f
@ -67,7 +67,7 @@ public class WarBlockListener extends BlockListener {
|
|||||||
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
|
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
|
||||||
team.getKind().getMaterial(),
|
team.getKind().getMaterial(),
|
||||||
team.getKind().getData(),
|
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 + "!"),
|
SpoutMessenger.cleanForNotification(ChatColor.YELLOW + "freed by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
|
||||||
ownerTeam.getKind().getMaterial(),
|
ownerTeam.getKind().getMaterial(),
|
||||||
ownerTeam.getKind().getData(),
|
ownerTeam.getKind().getData(),
|
||||||
5000);
|
10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,7 +520,7 @@ public class WarPlayerListener extends PlayerListener {
|
|||||||
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
|
SpoutMessenger.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
|
||||||
victim.getKind().getMaterial(),
|
victim.getKind().getMaterial(),
|
||||||
victim.getKind().getData(),
|
victim.getKind().getData(),
|
||||||
5000);
|
10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class RenameZoneCommand extends AbstractZoneMakerCommand {
|
|||||||
War.war.getWarzones().remove(zone);
|
War.war.getWarzones().remove(zone);
|
||||||
|
|
||||||
// rename zone file
|
// 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
|
// 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]));
|
(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"));
|
(new File(oldStart + "invs")).renameTo(new File(newStart + "invs"));
|
||||||
|
|
||||||
// set new name
|
// 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.setString("name", this.args[0]);
|
||||||
warzoneConfig.save();
|
warzoneConfig.save();
|
||||||
warzoneConfig.close();
|
warzoneConfig.close();
|
||||||
|
@ -730,7 +730,7 @@ public class Warzone {
|
|||||||
SpoutMessenger.cleanForNotification("ran out of lives."),
|
SpoutMessenger.cleanForNotification("ran out of lives."),
|
||||||
playerTeam.getKind().getMaterial(),
|
playerTeam.getKind().getMaterial(),
|
||||||
playerTeam.getKind().getData(),
|
playerTeam.getKind().getData(),
|
||||||
5000);
|
10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class ScoreCapReachedJob implements Runnable {
|
|||||||
SpoutMessenger.cleanForNotification(SpoutMessenger.addMissingColor(winnersStr, zone)),
|
SpoutMessenger.cleanForNotification(SpoutMessenger.addMissingColor(winnersStr, zone)),
|
||||||
Material.CAKE,
|
Material.CAKE,
|
||||||
(short)0,
|
(short)0,
|
||||||
5000);
|
10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,28 @@ import com.tommytony.war.config.TeamConfig;
|
|||||||
|
|
||||||
public class SpoutMessenger {
|
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>>();
|
Map<String, List<PlayerMessage>> playerMessages = new HashMap<String, List<PlayerMessage>>();
|
||||||
|
|
||||||
public void msg(SpoutPlayer sp, String message) {
|
public void msg(SpoutPlayer sp, String message) {
|
||||||
if (!playerMessages.containsKey(sp.getName())) {
|
if (!playerMessages.containsKey(sp.getName())) {
|
||||||
playerMessages.put(sp.getName(), new ArrayList<PlayerMessage>());
|
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<Integer> statsOffset = new ArrayList<Integer>();
|
||||||
List<GenericLabel> lines = getStatsLines(Warzone.getZoneByPlayerName(sp.getName()), statsOffset);
|
List<GenericLabel> lines = getStatsLines(Warzone.getZoneByPlayerName(sp.getName()), statsOffset);
|
||||||
drawMessages(sp.getName(), lines, statsOffset);
|
|
||||||
|
|
||||||
|
drawMessages(sp.getName(), lines, statsOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fadeOutOldMessages() {
|
public void fadeOutOldMessages() {
|
||||||
@ -43,7 +53,7 @@ public class SpoutMessenger {
|
|||||||
List<PlayerMessage> toRemove = new ArrayList<PlayerMessage>();
|
List<PlayerMessage> toRemove = new ArrayList<PlayerMessage>();
|
||||||
|
|
||||||
for (PlayerMessage message : messages) {
|
for (PlayerMessage message : messages) {
|
||||||
if (System.currentTimeMillis() - message.getSendTime() > 12000) {
|
if (System.currentTimeMillis() - message.getSendTime() > 15000) {
|
||||||
|
|
||||||
toRemove.add(message);
|
toRemove.add(message);
|
||||||
}
|
}
|
||||||
@ -126,12 +136,16 @@ public class SpoutMessenger {
|
|||||||
List<GenericLabel> playerlines = new ArrayList<GenericLabel>();
|
List<GenericLabel> playerlines = new ArrayList<GenericLabel>();
|
||||||
List<GenericLabel> scorelines = new ArrayList<GenericLabel>();
|
List<GenericLabel> scorelines = new ArrayList<GenericLabel>();
|
||||||
List<GenericLabel> lifelines = 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 line;
|
||||||
|
|
||||||
GenericLabel teamsHeader = new GenericLabel(ChatColor.GRAY + "War> " + ChatColor.WHITE + zone.getName());
|
GenericLabel teamsHeader = new GenericLabel(ChatColor.GRAY + "War> " + ChatColor.WHITE + zone.getName());
|
||||||
int teamsHeaderWidth = GenericLabel.getStringWidth(teamsHeader.getText());
|
int teamsHeaderWidth = GenericLabel.getStringWidth(teamsHeader.getText()) + 1;
|
||||||
teamsHeader.setAlign(WidgetAnchor.TOP_LEFT).setX(3).setY(2).setWidth(teamsHeaderWidth);
|
teamsHeader.setAlign(WidgetAnchor.TOP_LEFT)
|
||||||
|
.setX(3)
|
||||||
|
.setY(2)
|
||||||
|
.setWidth(teamsHeaderWidth)
|
||||||
|
.setHeight(LINE_HEIGHT);
|
||||||
lines.add(teamsHeader);
|
lines.add(teamsHeader);
|
||||||
|
|
||||||
// First, we collect all the team names
|
// First, we collect all the team names
|
||||||
@ -146,8 +160,11 @@ public class SpoutMessenger {
|
|||||||
else {
|
else {
|
||||||
line.setText(t.getKind().getColor() + teamStr.replace("(", ChatColor.GRAY + "(" + ChatColor.WHITE).replace(")", ChatColor.GRAY + ")" + ChatColor.WHITE));
|
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)
|
||||||
line.setAlign(WidgetAnchor.TOP_LEFT).setX(2).setY(4 + lineCounter * 8).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
|
.setX(3)
|
||||||
|
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
|
||||||
|
.setWidth(GenericLabel.getStringWidth(line.getText()))
|
||||||
|
.setHeight(LINE_HEIGHT);
|
||||||
teamlines.add(line);
|
teamlines.add(line);
|
||||||
lineCounter++;
|
lineCounter++;
|
||||||
}
|
}
|
||||||
@ -162,29 +179,27 @@ public class SpoutMessenger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// First line with headers
|
// points header
|
||||||
int headerOffset = teamMax - 2;
|
GenericLabel pointsHeader = new GenericLabel(ChatColor.GRAY + "score");
|
||||||
|
|
||||||
GenericLabel pointsHeader = new GenericLabel(ChatColor.GRAY + "points");
|
|
||||||
//pointsHeader.setTextColor(new Color(100, 100, 100));
|
|
||||||
int pointsHeaderWidth = GenericLabel.getStringWidth(pointsHeader.getText());
|
int pointsHeaderWidth = GenericLabel.getStringWidth(pointsHeader.getText());
|
||||||
pointsHeader.setAlign(WidgetAnchor.TOP_LEFT).setX(headerOffset).setY(2).setWidth(pointsHeaderWidth);
|
pointsHeader.setAlign(WidgetAnchor.TOP_LEFT)
|
||||||
headerOffset += pointsHeaderWidth + 6;
|
.setX(3 + teamMax + 2)
|
||||||
|
.setY(2)
|
||||||
|
.setWidth(pointsHeaderWidth)
|
||||||
|
.setHeight(LINE_HEIGHT);
|
||||||
lines.add(pointsHeader);
|
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;
|
lineCounter = 1;
|
||||||
for (Team t : zone.getTeams()) {
|
for (Team t : zone.getTeams()) {
|
||||||
// scores
|
// scores
|
||||||
line = new GenericLabel(t.getPoints() + "/" + t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE));
|
line = new GenericLabel(t.getPoints() + "/" + t.getTeamConfig().resolveInt(TeamConfig.MAXSCORE));
|
||||||
if (t.getPlayers().size() == 0) line.setTextColor(new Color(100, 100, 100));
|
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)
|
||||||
line.setAlign(WidgetAnchor.TOP_LEFT).setX(3 + teamMax + 2).setY(4 + lineCounter * 8).setWidth(GenericLabel.getStringWidth(line.getText())).setHeight(GenericLabel.getStringHeight(line.getText()));
|
.setX(3 + teamMax + 4)
|
||||||
|
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
|
||||||
|
.setWidth(GenericLabel.getStringWidth(line.getText()))
|
||||||
|
.setHeight(LINE_HEIGHT);
|
||||||
scorelines.add(line);
|
scorelines.add(line);
|
||||||
lineCounter++;
|
lineCounter++;
|
||||||
}
|
}
|
||||||
@ -198,13 +213,27 @@ public class SpoutMessenger {
|
|||||||
scoreMax = pointsHeaderWidth;
|
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.
|
// and finally, lives.
|
||||||
lineCounter = 1;
|
lineCounter = 1;
|
||||||
for (Team t : zone.getTeams()) {
|
for (Team t : zone.getTeams()) {
|
||||||
line = new GenericLabel(t.getRemainingLifes() + "/" + t.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
|
line = new GenericLabel(t.getRemainingLifes() + "/" + t.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
|
||||||
if (t.getPlayers().size() == 0) line.setTextColor(new Color(100, 100, 100));
|
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)
|
||||||
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()));
|
.setX(3 + teamMax + 4 + scoreMax + 4)
|
||||||
|
.setY(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN)
|
||||||
|
.setWidth(GenericLabel.getStringWidth(line.getText()))
|
||||||
|
.setHeight(LINE_HEIGHT);
|
||||||
lifelines.add(line);
|
lifelines.add(line);
|
||||||
lineCounter++;
|
lineCounter++;
|
||||||
}
|
}
|
||||||
@ -223,8 +252,8 @@ public class SpoutMessenger {
|
|||||||
for (GenericLabel l : scorelines) { lines.add(l); }
|
for (GenericLabel l : scorelines) { lines.add(l); }
|
||||||
for (GenericLabel l : lifelines) { lines.add(l); }
|
for (GenericLabel l : lifelines) { lines.add(l); }
|
||||||
|
|
||||||
offset.add(3 + teamMax + 2 + scoreMax + 2 + lifeMax + 2);
|
offset.add(3 + teamMax + 1 + scoreMax + 1 + lifeMax + 2);
|
||||||
offset.add(2 + lineCounter * 8);
|
offset.add(4 + lineCounter * LINE_HEIGHT_WITH_MARGIN);
|
||||||
|
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
@ -249,9 +278,9 @@ public class SpoutMessenger {
|
|||||||
// add bg
|
// add bg
|
||||||
GenericGradient gradient = new GenericGradient();
|
GenericGradient gradient = new GenericGradient();
|
||||||
gradient.setAnchor(WidgetAnchor.TOP_LEFT);
|
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.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);
|
player.getMainScreen().attachWidget(War.war, gradient);
|
||||||
|
|
||||||
@ -260,15 +289,17 @@ public class SpoutMessenger {
|
|||||||
teamGradient.setAnchor(WidgetAnchor.TOP_LEFT);
|
teamGradient.setAnchor(WidgetAnchor.TOP_LEFT);
|
||||||
|
|
||||||
Team team = Team.getTeamByPlayerName(playerName);
|
Team team = Team.getTeamByPlayerName(playerName);
|
||||||
|
|
||||||
Color spoutColor = new Color(250.0F, 250.0F, 250.0F, 1.0F);
|
Color spoutColor = new Color(250.0F, 250.0F, 250.0F, 1.0F);
|
||||||
if (team != null) {
|
if (team != null) {
|
||||||
spoutColor = team.getKind().getSpoutColor();
|
spoutColor = team.getKind().getSpoutColor();
|
||||||
}
|
}
|
||||||
spoutColor.setAlpha(0.5F);
|
spoutColor.setAlpha(0.5F);
|
||||||
teamGradient.setY(10);
|
|
||||||
|
teamGradient.setY(2 + LINE_HEIGHT_WITH_MARGIN);
|
||||||
teamGradient.setTopColor(spoutColor);
|
teamGradient.setTopColor(spoutColor);
|
||||||
teamGradient.setBottomColor(new Color(250.0F, 250.0F, 250.0F, 1.0F));
|
teamGradient.setBottomColor(new Color(256, 256, 256, 1.0F));
|
||||||
teamGradient.setHeight(2).setWidth(statsOffset.get(0) - 3);
|
teamGradient.setHeight(2).setWidth((int)(statsOffset.get(0) * 1.15));
|
||||||
|
|
||||||
player.getMainScreen().attachWidget(War.war, teamGradient);
|
player.getMainScreen().attachWidget(War.war, teamGradient);
|
||||||
|
|
||||||
@ -291,7 +322,7 @@ public class SpoutMessenger {
|
|||||||
|
|
||||||
if (horizontalOffset > 160) {
|
if (horizontalOffset > 160) {
|
||||||
horizontalOffset = 2;
|
horizontalOffset = 2;
|
||||||
verticalOffset += 8;
|
verticalOffset += LINE_HEIGHT_WITH_MARGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
word = addMissingColor(word, zone);
|
word = addMissingColor(word, zone);
|
||||||
@ -300,7 +331,7 @@ public class SpoutMessenger {
|
|||||||
int width = GenericLabel.getStringWidth(word);
|
int width = GenericLabel.getStringWidth(word);
|
||||||
label.setAlign(WidgetAnchor.TOP_LEFT);
|
label.setAlign(WidgetAnchor.TOP_LEFT);
|
||||||
label.setWidth(width);
|
label.setWidth(width);
|
||||||
label.setHeight(GenericLabel.getStringHeight(word));
|
label.setHeight(LINE_HEIGHT);
|
||||||
label.setX(horizontalOffset);
|
label.setX(horizontalOffset);
|
||||||
label.setY(verticalOffset);
|
label.setY(verticalOffset);
|
||||||
|
|
||||||
@ -309,7 +340,7 @@ public class SpoutMessenger {
|
|||||||
horizontalOffset += width + 2;
|
horizontalOffset += width + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
verticalOffset += 9;
|
verticalOffset += LINE_HEIGHT_WITH_MARGIN + 1;
|
||||||
|
|
||||||
rank++;
|
rank++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user