From 8675e47c88b9c102c9231eec33b2bcf80f1f415d Mon Sep 17 00:00:00 2001 From: Liam Speirs Date: Thu, 28 Apr 2016 00:13:32 -0400 Subject: [PATCH] Add Card-type counter for graveyard label hover and in graveyard Dialog window. (To mirror magic online and to make delirium easier to check) --- .../client/dialog/CardInfoWindowDialog.java | 19 ++++++++++++++- .../java/mage/client/game/PlayerPanelExt.java | 23 +++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/dialog/CardInfoWindowDialog.java b/Mage.Client/src/main/java/mage/client/dialog/CardInfoWindowDialog.java index ab484eb8055..92884966252 100644 --- a/Mage.Client/src/main/java/mage/client/dialog/CardInfoWindowDialog.java +++ b/Mage.Client/src/main/java/mage/client/dialog/CardInfoWindowDialog.java @@ -36,6 +36,9 @@ package mage.client.dialog; import java.awt.Dimension; import java.awt.Point; import java.beans.PropertyVetoException; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; import java.util.UUID; import javax.swing.ImageIcon; import javax.swing.SwingUtilities; @@ -46,6 +49,8 @@ import mage.client.util.GUISizeHelper; import mage.client.util.ImageHelper; import mage.client.util.SettingsManager; import mage.client.util.gui.GuiDisplayUtil; +import mage.constants.CardType; +import mage.view.CardView; import mage.view.CardsView; import mage.view.ExileView; import mage.view.SimpleCardsView; @@ -158,7 +163,8 @@ public class CardInfoWindowDialog extends MageDialog { public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId, boolean revertOrder) { cards.loadCards(showCards, bigCard, gameId, revertOrder); if (showType.equals(ShowType.GRAVEYARD)) { - String titel = name + "'s Graveyard (" + showCards.size() + ")"; + int qty = qtyCardTypes(showCards); + String titel = name + "'s Graveyard (" + showCards.size() + ") - " + qty + ((qty == 1) ? " Card Type" : " Card Types"); setTitle(titel); this.setTitelBarToolTip(titel); } @@ -199,6 +205,17 @@ public class CardInfoWindowDialog extends MageDialog { }); } + private int qtyCardTypes(mage.view.CardsView cardsView){ + Set cardTypesPresent = new LinkedHashSet() {}; + for (CardView card : cardsView.values()){ + List cardTypes = card.getCardTypes(); + for (CardType cardType : cardTypes){ + cardTypesPresent.add(cardType.toString()); + } + } + if (cardTypesPresent.isEmpty()) return 0; + else return cardTypesPresent.size(); + } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index f2a85347d52..5c3bad66f13 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -42,7 +42,10 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import javax.swing.BorderFactory; import javax.swing.GroupLayout; @@ -69,6 +72,7 @@ import mage.client.util.ImageHelper; import mage.client.util.gui.BufferedImageBuilder; import mage.client.util.gui.countryBox.CountryUtil; import mage.components.ImagePanel; +import mage.constants.CardType; import static mage.constants.Constants.DEFAULT_AVATAR_ID; import static mage.constants.Constants.MAX_AVATAR_ID; import static mage.constants.Constants.MIN_AVATAR_ID; @@ -78,6 +82,8 @@ import mage.utils.timer.PriorityTimer; import mage.view.ManaPoolView; import mage.view.PlayerView; import org.mage.card.arcane.ManaSymbols; +import mage.players.Player; +import mage.view.CardView; /** * Enhanced player pane. @@ -215,7 +221,8 @@ public class PlayerPanelExt extends javax.swing.JPanel { changedFontGrave = false; } graveLabel.setText(Integer.toString(graveCards)); - + graveLabel.setToolTipText("Card Types: " + qtyCardTypes(player.getGraveyard())); + int exileCards = player.getExile().size(); if (exileCards > 99) { if (!changedFontExile) { @@ -439,7 +446,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { // Grave count and open graveyard button r = new Rectangle(21, 21); - graveLabel.setToolTipText("Graveyard"); + graveLabel.setToolTipText("Card Types: 0"); Image imageGrave = ImageHelper.getImageFromResources("/info/grave.png"); BufferedImage resizedGrave = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageGrave, BufferedImage.TYPE_INT_ARGB), r); @@ -858,6 +865,18 @@ public class PlayerPanelExt extends javax.swing.JPanel { return player; } + private int qtyCardTypes(mage.view.CardsView cardsView){ + Set cardTypesPresent = new LinkedHashSet() {}; + for (CardView card : cardsView.values()){ + List cardTypes = card.getCardTypes(); + for (CardType cardType : cardTypes){ + cardTypesPresent.add(cardType.toString()); + } + } + if (cardTypesPresent.isEmpty()) return 0; + else return cardTypesPresent.size(); + } + private HoverButton avatar; private JLabel avatarFlag; private JButton btnPlayer;