mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
Allow multiple icons at the top right of player avatar (#12169)
This commit is contained in:
parent
42906f519b
commit
9f52c8946e
2 changed files with 19 additions and 9 deletions
|
|
@ -15,6 +15,9 @@ import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.awt.font.FontRenderContext;
|
import java.awt.font.FontRenderContext;
|
||||||
import java.awt.font.GlyphVector;
|
import java.awt.font.GlyphVector;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
import mage.client.util.Command;
|
import mage.client.util.Command;
|
||||||
|
|
@ -45,7 +48,7 @@ public class HoverButton extends JPanel implements MouseListener {
|
||||||
|
|
||||||
private String topText;
|
private String topText;
|
||||||
private Image topTextImage;
|
private Image topTextImage;
|
||||||
private Image topTextImageRight;
|
private final List<Image> topTextImagesRight = new ArrayList<>();
|
||||||
private String centerText;
|
private String centerText;
|
||||||
|
|
||||||
private boolean wasHovered = false;
|
private boolean wasHovered = false;
|
||||||
|
|
@ -159,8 +162,11 @@ public class HoverButton extends JPanel implements MouseListener {
|
||||||
if (topTextImage != null) {
|
if (topTextImage != null) {
|
||||||
g.drawImage(topTextImage, 4, 3, this);
|
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) {
|
if (centerText != null) {
|
||||||
|
|
@ -358,8 +364,12 @@ public class HoverButton extends JPanel implements MouseListener {
|
||||||
this.textOffsetX = -1; // rest for new calculation
|
this.textOffsetX = -1; // rest for new calculation
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTopTextImageRight(Image topTextImage) {
|
public void addTopTextImageRight(Image topTextImage) {
|
||||||
this.topTextImageRight = topTextImage;
|
this.topTextImagesRight.add(topTextImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearTopTextImagesRight() {
|
||||||
|
this.topTextImagesRight.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCenterText(String centerText) {
|
public void setCenterText(String centerText) {
|
||||||
|
|
|
||||||
|
|
@ -400,20 +400,20 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
tooltipText.append("<br/>Match time remaining: ").append(getPriorityTimeLeftString(player));
|
tooltipText.append("<br/>Match time remaining: ").append(getPriorityTimeLeftString(player));
|
||||||
|
|
||||||
// designations
|
// designations
|
||||||
this.avatar.setTopTextImageRight(null);
|
this.avatar.clearTopTextImagesRight();
|
||||||
for (String name : player.getDesignationNames()) {
|
for (String name : player.getDesignationNames()) {
|
||||||
tooltipText.append("<br/>").append(name);
|
tooltipText.append("<br/>").append(name);
|
||||||
if (DesignationType.CITYS_BLESSING.toString().equals(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()) {
|
if (player.isMonarch()) {
|
||||||
tooltipText.append("<br/>").append("The Monarch");
|
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()) {
|
if (player.isInitiative()) {
|
||||||
tooltipText.append("<br/>").append("Have the Initiative");
|
tooltipText.append("<br/>").append("Have the Initiative");
|
||||||
this.avatar.setTopTextImageRight(ImageHelper.getImageFromResources("/info/initiative.png"));
|
this.avatar.addTopTextImageRight(ImageHelper.getImageFromResources("/info/initiative.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// counters
|
// counters
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue