From 3a62115c3a60bd4762f58a3f534f9fdf2a5b4f84 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 23 Jul 2014 17:23:49 +0200 Subject: [PATCH] Added icon for triggered and activated abilities on the stack to better distinct it from casting a card. --- .../main/java/mage/client/cards/Cards.java | 7 ++- .../java/org/mage/card/arcane/CardPanel.java | 47 +++++++++++------- .../mage/plugins/card/utils/ImageManager.java | 2 + .../card/utils/impl/ImageManagerImpl.java | 24 ++++++++- .../main/resources/card/activated_ability.png | Bin 0 -> 644 bytes .../main/resources/card/triggered_ability.png | Bin 0 -> 733 bytes Mage.Common/src/mage/view/CardView.java | 10 ++++ .../src/mage/view/StackAbilityView.java | 8 +++ 8 files changed, 77 insertions(+), 21 deletions(-) create mode 100644 Mage.Client/src/main/resources/card/activated_ability.png create mode 100644 Mage.Client/src/main/resources/card/triggered_ability.png diff --git a/Mage.Client/src/main/java/mage/client/cards/Cards.java b/Mage.Client/src/main/java/mage/client/cards/Cards.java index 9d4c70758b..3360df1160 100644 --- a/Mage.Client/src/main/java/mage/client/cards/Cards.java +++ b/Mage.Client/src/main/java/mage/client/cards/Cards.java @@ -155,7 +155,7 @@ public class Cards extends javax.swing.JPanel { } // order objects for display - java.util.List orderedList = new ArrayList(); + java.util.List orderedList = new ArrayList<>(); for (CardView card: cardsView.values()) { orderedList.add(0, card); } @@ -173,7 +173,10 @@ public class Cards extends javax.swing.JPanel { tmp.setIsAbility(true); tmp.overrideTargets(card.getTargets()); tmp.overrideId(card.getId()); + tmp.setAbilityType(((StackAbilityView)card).getAbilityType()); card = tmp; + } else { + card.setAbilityType(null); } if (!cards.containsKey(card.getId())) { addCard(card, bigCard, gameId); @@ -302,7 +305,7 @@ public class Cards extends javax.swing.JPanel { } private void layoutCards() { - java.util.List cards = new ArrayList(); + java.util.List cards = new ArrayList<>(); for (Component component : cardArea.getComponents()) { if (component instanceof CardPanel) { diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java index 29b7bbf204..9f58408671 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java @@ -31,6 +31,8 @@ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import mage.constants.AbilityType; +import mage.constants.MageObjectType; /** * Main class for drawing Mage card object. @@ -104,7 +106,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti private boolean animationInProgress = false; private JButton dayNightButton; - private JButton tokenButton; + private JButton typeButton; private JButton showCopySourceButton; 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()) { - // token icon - 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); + setTypeIcon(ImageManagerImpl.getInstance().getTokenIconImage(),"Token Permanent"); } // 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() { if (dayNightButton != null) { for(ActionListener al: dayNightButton.getActionListeners()) { diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/utils/ImageManager.java b/Mage.Client/src/main/java/org/mage/plugins/card/utils/ImageManager.java index 30ad68bb0e..42b256f4c5 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/utils/ImageManager.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/utils/ImageManager.java @@ -13,6 +13,8 @@ public interface ImageManager { Image getNightImage(); Image getTokenIconImage(); + Image getTriggeredAbilityImage(); + Image getActivatedAbilityImage(); Image getCopyInformIconImage(); Image getDlgAcceptButtonImage(); diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java b/Mage.Client/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java index 7192d912f7..d08a09f6cc 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java @@ -15,7 +15,7 @@ import java.util.Map; public class ImageManagerImpl implements ImageManager { - private static ImageManagerImpl fInstance = new ImageManagerImpl(); + private static final ImageManagerImpl fInstance = new ImageManagerImpl(); public static ImageManagerImpl getInstance() { return fInstance; @@ -29,7 +29,7 @@ public class ImageManagerImpl implements ImageManager { String[] phases = {"Untap", "Upkeep", "Draw", "Main1", "Combat_Start", "Combat_Attack", "Combat_Block", "Combat_Damage", "Combat_End", "Main2", "Cleanup", "Next_Turn"}; - phasesImages = new HashMap(); + phasesImages = new HashMap<>(); for (String name : phases) { Image image = getImageFromResource("/phases/phase_" + name.toLowerCase() + ".png", new Rectangle(36, 36)); phasesImages.put(name, image); @@ -106,6 +106,24 @@ public class ImageManagerImpl implements ImageManager { 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 public BufferedImage getCopyInformIconImage() { if (imageCopyIcon == null) { @@ -235,6 +253,8 @@ public class ImageManagerImpl implements ImageManager { private static BufferedImage imageNight; private static BufferedImage imageTokenIcon; + private static BufferedImage triggeredAbilityIcon; + private static BufferedImage activatedAbilityIcon; private static BufferedImage imageCopyIcon; private static BufferedImage imageDlgAcceptButton; diff --git a/Mage.Client/src/main/resources/card/activated_ability.png b/Mage.Client/src/main/resources/card/activated_ability.png new file mode 100644 index 0000000000000000000000000000000000000000..310ccabf11f83cdaf8119fbcff2215fb9a7a3732 GIT binary patch literal 644 zcmV-~0(_XcesuRkTR3RYXApA}%Yq=%T3T@l1ThVR#b* zjp&2lBAI*7dH3G;hEeK2TwSC>UXg>%7LSu90w1TEX|O&ZzD#Gc3^s=t%#lbl3GPo6H$e3(PChY&(y6G%R>8Mj3parrqbYPL3mU-mmDh_jZc^StUd5%l!OD*Oxc|!aK_sId7L^2W& zyKL>~muZYK@HUww_jKYEc}U7+#$a%VWaSEyE%oPtU5<@ClHqPY;+oIkfzQAbE2-}& zNCju*b!`qAIgXw-Y52_sw>47hb)PkWoOKz4Y83re5m{@HJ>G$|v*y?Ato;=4`)gkS eNVVJQU#_2)Ep8{`Z{e>10000H&0@$uC>$K7nx4{IuIJgOph?6jWxocpEe+Eg+8 zV1#$THYw33TbLRC?*QUGKzsm*kMnbXy&d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