Allow multiple icons at the top right of player avatar (#12169)

This commit is contained in:
Alexander Novotny 2024-04-22 23:58:43 -04:00 committed by GitHub
parent 42906f519b
commit 9f52c8946e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 9 deletions

View file

@ -15,6 +15,9 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;
import mage.client.util.Command;
@ -45,7 +48,7 @@ public class HoverButton extends JPanel implements MouseListener {
private String topText;
private Image topTextImage;
private Image topTextImageRight;
private final List<Image> topTextImagesRight = new ArrayList<>();
private String centerText;
private boolean wasHovered = false;
@ -159,8 +162,11 @@ public class HoverButton extends JPanel implements MouseListener {
if (topTextImage != null) {
g.drawImage(topTextImage, 4, 3, this);
}
if (topTextImageRight != null) {
g.drawImage(topTextImageRight, this.getWidth() - 20, 3, this);
int offset = 0;
for (Image img : topTextImagesRight) {
g.drawImage(img, this.getWidth() - 20, 3 + offset, this);
offset += 20;
}
if (centerText != null) {
@ -358,8 +364,12 @@ public class HoverButton extends JPanel implements MouseListener {
this.textOffsetX = -1; // rest for new calculation
}
public void setTopTextImageRight(Image topTextImage) {
this.topTextImageRight = topTextImage;
public void addTopTextImageRight(Image topTextImage) {
this.topTextImagesRight.add(topTextImage);
}
public void clearTopTextImagesRight() {
this.topTextImagesRight.clear();
}
public void setCenterText(String centerText) {

View file

@ -400,20 +400,20 @@ public class PlayerPanelExt extends javax.swing.JPanel {
tooltipText.append("<br/>Match time remaining: ").append(getPriorityTimeLeftString(player));
// designations
this.avatar.setTopTextImageRight(null);
this.avatar.clearTopTextImagesRight();
for (String name : player.getDesignationNames()) {
tooltipText.append("<br/>").append(name);
if (DesignationType.CITYS_BLESSING.toString().equals(name)) {
this.avatar.setTopTextImageRight(ImageHelper.getImageFromResources("/info/city_blessing.png"));
this.avatar.addTopTextImageRight(ImageHelper.getImageFromResources("/info/city_blessing.png"));
}
}
if (player.isMonarch()) {
tooltipText.append("<br/>").append("The Monarch");
this.avatar.setTopTextImageRight(ImageHelper.getImageFromResources("/info/crown.png"));
this.avatar.addTopTextImageRight(ImageHelper.getImageFromResources("/info/crown.png"));
}
if (player.isInitiative()) {
tooltipText.append("<br/>").append("Have the Initiative");
this.avatar.setTopTextImageRight(ImageHelper.getImageFromResources("/info/initiative.png"));
this.avatar.addTopTextImageRight(ImageHelper.getImageFromResources("/info/initiative.png"));
}
// counters