mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
- Support showing Energy counters in the desktop version of Forge (poison counters take priority over energy counters).
This commit is contained in:
@@ -76,6 +76,7 @@ public class VField implements IVDoc<CField> {
|
||||
private final FLabel lblAvatar = new FLabel.Builder().fontAlign(SwingConstants.CENTER).iconScaleFactor(1.0f).build();
|
||||
private final FLabel lblLife = new FLabel.Builder().fontAlign(SwingConstants.CENTER).fontStyle(Font.BOLD).build();
|
||||
private final FLabel lblPoison = new FLabel.Builder().fontAlign(SwingConstants.CENTER).fontStyle(Font.BOLD).icon(FSkin.getImage(FSkinProp.IMG_ZONE_POISON)).iconInBackground().build();
|
||||
private final FLabel lblEnergy = new FLabel.Builder().fontAlign(SwingConstants.CENTER).fontStyle(Font.BOLD).icon(FSkin.getImage(FSkinProp.IMG_ENERGY)).iconInBackground().build();
|
||||
|
||||
private final PhaseIndicator phaseIndicator = new PhaseIndicator();
|
||||
|
||||
@@ -108,6 +109,7 @@ public class VField implements IVDoc<CField> {
|
||||
lblAvatar.setFocusable(false);
|
||||
lblLife.setFocusable(false);
|
||||
lblPoison.setFocusable(false);
|
||||
lblEnergy.setFocusable(false);
|
||||
|
||||
avatarArea.setOpaque(false);
|
||||
avatarArea.setBackground(FSkin.getColor(FSkin.Colors.CLR_HOVER));
|
||||
@@ -210,6 +212,25 @@ public class VField implements IVDoc<CField> {
|
||||
detailsPanel.updateZones();
|
||||
}
|
||||
|
||||
private void addLblEnergy() {
|
||||
if (lblEnergy.isShowing() || lblPoison.isShowing()) {
|
||||
return; // poison takes precedence
|
||||
}
|
||||
avatarArea.remove(lblLife);
|
||||
lblLife.setIcon(FSkin.getImage(FSkinProp.ICO_QUEST_LIFE));
|
||||
avatarArea.add(lblLife, "w 50%!, h 20px!, split 2");
|
||||
avatarArea.add(lblEnergy, "w 50%!, h 20px!, wrap");
|
||||
}
|
||||
|
||||
private void removeLblEnergy() {
|
||||
if (!lblEnergy.isShowing()) {
|
||||
return;
|
||||
}
|
||||
avatarArea.remove(lblEnergy);
|
||||
avatarArea.remove(lblLife);
|
||||
avatarArea.add(lblLife, "w 100%!, h 20px!, wrap");
|
||||
}
|
||||
|
||||
private void addLblPoison() {
|
||||
if (lblPoison.isShowing()) {
|
||||
return;
|
||||
@@ -238,9 +259,12 @@ public class VField implements IVDoc<CField> {
|
||||
lblLife.setForeground(Color.RED);
|
||||
}
|
||||
|
||||
// Update poison counters
|
||||
// Update poison and/or energy counters, poison counters take precedence
|
||||
final int poison = player.getCounters(CounterType.POISON);
|
||||
final int energy = player.getCounters(CounterType.ENERGY);
|
||||
|
||||
if (poison > 0) {
|
||||
removeLblEnergy();
|
||||
addLblPoison();
|
||||
lblPoison.setText(String.valueOf(poison));
|
||||
if (poison < POISON_CRITICAL) {
|
||||
@@ -252,6 +276,15 @@ public class VField implements IVDoc<CField> {
|
||||
removeLblPoison();
|
||||
}
|
||||
|
||||
if (energy > 0) {
|
||||
if (poison == 0) {
|
||||
addLblEnergy();
|
||||
lblEnergy.setText(String.valueOf(energy));
|
||||
}
|
||||
} else {
|
||||
removeLblEnergy();
|
||||
}
|
||||
|
||||
final boolean highlighted = isHighlighted();
|
||||
this.avatarArea.setBorder(highlighted ? borderAvatarHighlighted : borderAvatarSimple );
|
||||
this.avatarArea.setOpaque(highlighted);
|
||||
|
||||
Reference in New Issue
Block a user