Added icon for triggered and activated abilities on the stack to better distinct it from casting a card.

This commit is contained in:
LevelX2 2014-07-23 17:23:49 +02:00
parent bafcff82ec
commit 3a62115c3a
8 changed files with 77 additions and 21 deletions

View file

@ -155,7 +155,7 @@ public class Cards extends javax.swing.JPanel {
} }
// order objects for display // order objects for display
java.util.List<CardView> orderedList = new ArrayList<CardView>(); java.util.List<CardView> orderedList = new ArrayList<>();
for (CardView card: cardsView.values()) { for (CardView card: cardsView.values()) {
orderedList.add(0, card); orderedList.add(0, card);
} }
@ -173,7 +173,10 @@ public class Cards extends javax.swing.JPanel {
tmp.setIsAbility(true); tmp.setIsAbility(true);
tmp.overrideTargets(card.getTargets()); tmp.overrideTargets(card.getTargets());
tmp.overrideId(card.getId()); tmp.overrideId(card.getId());
tmp.setAbilityType(((StackAbilityView)card).getAbilityType());
card = tmp; card = tmp;
} else {
card.setAbilityType(null);
} }
if (!cards.containsKey(card.getId())) { if (!cards.containsKey(card.getId())) {
addCard(card, bigCard, gameId); addCard(card, bigCard, gameId);
@ -302,7 +305,7 @@ public class Cards extends javax.swing.JPanel {
} }
private void layoutCards() { private void layoutCards() {
java.util.List<CardPanel> cards = new ArrayList(); java.util.List<CardPanel> cards = new ArrayList<>();
for (Component component : cardArea.getComponents()) { for (Component component : cardArea.getComponents()) {
if (component instanceof CardPanel) { if (component instanceof CardPanel) {

View file

@ -31,6 +31,8 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.constants.AbilityType;
import mage.constants.MageObjectType;
/** /**
* Main class for drawing Mage card object. * Main class for drawing Mage card object.
@ -104,7 +106,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private boolean animationInProgress = false; private boolean animationInProgress = false;
private JButton dayNightButton; private JButton dayNightButton;
private JButton tokenButton; private JButton typeButton;
private JButton showCopySourceButton; private JButton showCopySourceButton;
private boolean displayTitleAnyway; private boolean displayTitleAnyway;
@ -156,23 +158,16 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
}); });
} }
if (newGameCard.isAbility()) {
if (AbilityType.TRIGGERED.equals(newGameCard.getAbilityType())) {
setTypeIcon(ImageManagerImpl.getInstance().getTriggeredAbilityImage(),"Triggered Ability");
} else if (AbilityType.ACTIVATED.equals(newGameCard.getAbilityType())) {
setTypeIcon(ImageManagerImpl.getInstance().getActivatedAbilityImage(),"Activated Ability");
}
}
if (this.gameCard.isToken()) { if (this.gameCard.isToken()) {
// token icon setTypeIcon(ImageManagerImpl.getInstance().getTokenIconImage(),"Token Permanent");
iconPanel = new JPanel();
iconPanel.setLayout(null);
iconPanel.setOpaque(false);
add(iconPanel);
tokenButton = new JButton("");
tokenButton.setLocation(2, 2);
tokenButton.setSize(25, 25);
iconPanel.setVisible(this.gameCard.isToken());
BufferedImage tokenIconImage = ImageManagerImpl.getInstance().getTokenIconImage();
tokenButton.setIcon(new ImageIcon(tokenIconImage));
iconPanel.add(tokenButton);
} }
// icon to inform about permanent is copying something // icon to inform about permanent is copying something
@ -276,6 +271,24 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
}); });
} }
private void setTypeIcon(BufferedImage bufferedImage, String toolTipText) {
iconPanel = new JPanel();
iconPanel.setLayout(null);
iconPanel.setOpaque(false);
add(iconPanel);
typeButton = new JButton("");
typeButton.setLocation(2, 2);
typeButton.setSize(25, 25);
iconPanel.setVisible(true);
typeButton.setIcon(new ImageIcon(bufferedImage));
if (toolTipText != null) {
typeButton.setToolTipText(toolTipText);
}
iconPanel.add(typeButton);
}
public void cleanUp() { public void cleanUp() {
if (dayNightButton != null) { if (dayNightButton != null) {
for(ActionListener al: dayNightButton.getActionListeners()) { for(ActionListener al: dayNightButton.getActionListeners()) {

View file

@ -13,6 +13,8 @@ public interface ImageManager {
Image getNightImage(); Image getNightImage();
Image getTokenIconImage(); Image getTokenIconImage();
Image getTriggeredAbilityImage();
Image getActivatedAbilityImage();
Image getCopyInformIconImage(); Image getCopyInformIconImage();
Image getDlgAcceptButtonImage(); Image getDlgAcceptButtonImage();

View file

@ -15,7 +15,7 @@ import java.util.Map;
public class ImageManagerImpl implements ImageManager { public class ImageManagerImpl implements ImageManager {
private static ImageManagerImpl fInstance = new ImageManagerImpl(); private static final ImageManagerImpl fInstance = new ImageManagerImpl();
public static ImageManagerImpl getInstance() { public static ImageManagerImpl getInstance() {
return fInstance; return fInstance;
@ -29,7 +29,7 @@ public class ImageManagerImpl implements ImageManager {
String[] phases = {"Untap", "Upkeep", "Draw", "Main1", String[] phases = {"Untap", "Upkeep", "Draw", "Main1",
"Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End", "Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End",
"Main2", "Cleanup", "Next_Turn"}; "Main2", "Cleanup", "Next_Turn"};
phasesImages = new HashMap<String, Image>(); phasesImages = new HashMap<>();
for (String name : phases) { for (String name : phases) {
Image image = getImageFromResource("/phases/phase_" + name.toLowerCase() + ".png", new Rectangle(36, 36)); Image image = getImageFromResource("/phases/phase_" + name.toLowerCase() + ".png", new Rectangle(36, 36));
phasesImages.put(name, image); phasesImages.put(name, image);
@ -106,6 +106,24 @@ public class ImageManagerImpl implements ImageManager {
return imageTokenIcon; return imageTokenIcon;
} }
@Override
public BufferedImage getTriggeredAbilityImage() {
if (triggeredAbilityIcon == null) {
Image image = getImageFromResourceTransparent("/card/triggered_ability.png", Color.WHITE, new Rectangle(20, 20));
triggeredAbilityIcon = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
}
return triggeredAbilityIcon;
}
@Override
public BufferedImage getActivatedAbilityImage() {
if (activatedAbilityIcon == null) {
Image image = getImageFromResourceTransparent("/card/activated_ability.png", Color.WHITE, new Rectangle(20, 20));
activatedAbilityIcon = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
}
return activatedAbilityIcon;
}
@Override @Override
public BufferedImage getCopyInformIconImage() { public BufferedImage getCopyInformIconImage() {
if (imageCopyIcon == null) { if (imageCopyIcon == null) {
@ -235,6 +253,8 @@ public class ImageManagerImpl implements ImageManager {
private static BufferedImage imageNight; private static BufferedImage imageNight;
private static BufferedImage imageTokenIcon; private static BufferedImage imageTokenIcon;
private static BufferedImage triggeredAbilityIcon;
private static BufferedImage activatedAbilityIcon;
private static BufferedImage imageCopyIcon; private static BufferedImage imageCopyIcon;
private static BufferedImage imageDlgAcceptButton; private static BufferedImage imageDlgAcceptButton;

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

View file

@ -53,6 +53,7 @@ import mage.target.Targets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import mage.constants.AbilityType;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -78,6 +79,7 @@ public class CardView extends SimpleCardView {
protected MageObjectType mageObjectType; protected MageObjectType mageObjectType;
protected boolean isAbility; protected boolean isAbility;
protected AbilityType abilityType;
protected boolean isToken; protected boolean isToken;
protected CardView ability; protected CardView ability;
@ -452,6 +454,14 @@ public class CardView extends SimpleCardView {
return isAbility; return isAbility;
} }
public AbilityType getAbilityType() {
return abilityType;
}
public void setAbilityType(AbilityType abilityType) {
this.abilityType = abilityType;
}
public String getPower() { public String getPower() {
return power; return power;
} }

View file

@ -34,6 +34,7 @@ import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Modes; import mage.abilities.Modes;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.constants.AbilityType;
import mage.constants.MageObjectType; import mage.constants.MageObjectType;
import mage.game.Game; import mage.game.Game;
import mage.game.stack.StackAbility; import mage.game.stack.StackAbility;
@ -48,10 +49,12 @@ public class StackAbilityView extends CardView {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final CardView sourceCard; private final CardView sourceCard;
private final AbilityType abilityType;
public StackAbilityView(Game game, StackAbility ability, String sourceName, CardView sourceCard) { public StackAbilityView(Game game, StackAbility ability, String sourceName, CardView sourceCard) {
this.id = ability.getId(); this.id = ability.getId();
this.mageObjectType = MageObjectType.ABILITY_STACK; this.mageObjectType = MageObjectType.ABILITY_STACK;
this.abilityType = ability.getStackAbility().getAbilityType();
this.sourceCard = sourceCard; this.sourceCard = sourceCard;
this.sourceCard.setMageObjectType(mageObjectType); this.sourceCard.setMageObjectType(mageObjectType);
this.name = "Ability"; this.name = "Ability";
@ -113,4 +116,9 @@ public class StackAbilityView extends CardView {
public CardView getSourceCard() { public CardView getSourceCard() {
return this.sourceCard; return this.sourceCard;
} }
public AbilityType getAbilityType() {
return abilityType;
}
} }