diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index 034d607f6e0..24e95333b4d 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -105,12 +105,20 @@ public class PlayerPanelExt extends javax.swing.JPanel { timer.setTaskOnTick(() -> { int priorityTimeValue = pt.getCount() + pt.getBufferCount(); String text = getPriorityTimeLeftString(priorityTimeValue); - + // Set timer text colors (note, if you change it here, change it in update() as well) + Color textColor = null; // use default in HoverButton + Color foregroundColor = Color.BLACK; + if (pt.getBufferCount() > 0) { + textColor = Color.GREEN; + foregroundColor = Color.GREEN.darker().darker(); + } else if (pt.getCount() < 300) { // visual indication for under 5 minutes + textColor = Color.RED; + foregroundColor = Color.RED.darker().darker(); + } PlayerPanelExt.this.avatar.setTopText(text); - PlayerPanelExt.this.avatar.setTopTextColor(pt.getBufferCount() > 0 ? Color.GREEN : null); + PlayerPanelExt.this.avatar.setTopTextColor(textColor); PlayerPanelExt.this.timerLabel.setText(text); - PlayerPanelExt.this.timerLabel - .setForeground(pt.getBufferCount() > 0 ? Color.GREEN.darker().darker() : Color.BLACK); + PlayerPanelExt.this.timerLabel.setForeground(foregroundColor); PlayerPanelExt.this.avatar.repaint(); }); timer.init(gameId); @@ -195,10 +203,10 @@ public class PlayerPanelExt extends javax.swing.JPanel { if (playerLife != pastLife) { if (playerLife > pastLife) { avatar.gainLifeDisplay(); - } else if (playerLife < pastLife) { + } else { avatar.loseLifeDisplay(); } - } else if (playerLife == pastLife) { + } else { avatar.stopLifeDisplay(); } } @@ -311,10 +319,18 @@ public class PlayerPanelExt extends javax.swing.JPanel { this.timer.setBufferCount(player.getBufferTimeLeft()); this.avatar.setTopText(priorityTimeValue); this.timerLabel.setText(priorityTimeValue); - - this.avatar.setTopTextColor(player.getBufferTimeLeft() > 0 ? Color.GREEN : null); - this.timerLabel - .setForeground(player.getBufferTimeLeft() > 0 ? Color.GREEN.darker().darker() : Color.BLACK); + // Set timer text colors (note, if you change it here, change it in init()::timer.setTaskOnTick() as well) + Color textColor = null; // use default in HoverButton + Color foregroundColor = Color.BLACK; + if (player.getBufferTimeLeft() > 0) { + textColor = Color.GREEN; + foregroundColor = Color.GREEN.darker().darker(); + } else if (player.getPriorityTimeLeft() < 300) { // visual indication for under 5 minutes + textColor = Color.RED; + foregroundColor = Color.RED.darker().darker(); + } + this.avatar.setTopTextColor(textColor); + this.timerLabel.setForeground(foregroundColor); } if (player.isTimerActive()) { this.timer.resume(); @@ -360,25 +376,17 @@ public class PlayerPanelExt extends javax.swing.JPanel { private void updateAvatar() { if (flagName == null) { // do only once avatar.setText(this.player.getName()); - if (!player.getUserData().getFlagName().equals(flagName)) { - flagName = player.getUserData().getFlagName(); - this.avatar.setTopTextImage(CountryUtil.getCountryFlagIconSize(flagName, 11).getImage()); - } - // TODO: Add the wins to the tooltiptext of the avatar - String countryname = CountryUtil.getCountryName(flagName); - if (countryname == null) { - countryname = "Unknown"; - } + flagName = player.getUserData().getFlagName(); + this.avatar.setTopTextImage(CountryUtil.getCountryFlagIconSize(flagName, 11).getImage()); + String countryName = CountryUtil.getCountryName(flagName); basicTooltipText = "Name: " + player.getName() - + "
Flag: " + countryname - + "
Constructed rating: " + player.getUserData().getConstructedRating() - + "
Limited rating: " + player.getUserData().getLimitedRating() + + "
Flag: " + (countryName == null ? "Unknown" : countryName) + "
Deck hash code: " + player.getDeckHashCode() - + "
This match wins: " + player.getWins() + " of " + player.getWinsNeeded() + " (to win the match)" - + (player.getUserData() == null ? "" : "
History: " + player.getUserData().getHistory()); + + "
This match wins: " + player.getWins() + " of " + player.getWinsNeeded() + " (to win the match)"; } // Extend tooltip StringBuilder tooltipText = new StringBuilder(basicTooltipText); + tooltipText.append("
Match time remaining: ").append(getPriorityTimeLeftString(player)); this.avatar.setTopTextImageRight(null); for (String name : player.getDesignationNames()) { tooltipText.append("
").append(name);