From 423f1c3fc36c34833d19598d26d13ce6da994b7c Mon Sep 17 00:00:00 2001 From: spjspj Date: Thu, 13 Oct 2016 11:05:49 +1100 Subject: [PATCH] spjspj - Add type and search filter to deck editor --- .../java/mage/client/cards/DragCardGrid.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java index c8ebf88b86..ee285d420d 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java @@ -896,7 +896,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg selectBySearchOptionsC.fill = GridBagConstraints.VERTICAL; searchByTextField = new JTextField(); - searchByTextField.setToolTipText("Searches for card names and in the rule text of the card."); + searchByTextField.setToolTipText("Searches for card names, types, rarity, casting cost and rules text. NB: Mana symbols are written like {W},{U},{C} etc"); searchByTextField.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { reselectBy(); @@ -1128,7 +1128,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg boolean useText = false; String searchStr = ""; - if (searchByTextField.getText().length() > 3) { + if (searchByTextField.getText().length() >= 3) { useText = true; searchStr = searchByTextField.getText().toLowerCase(); } @@ -1140,7 +1140,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg for (ArrayList> gridRow : cardGrid) { for (ArrayList stack : gridRow) { for (CardView card : stack) { - boolean s = card.getCardTypes().contains(cardType); + boolean s = card.isSelected() | card.getCardTypes().contains(cardType); card.setSelected(s); cardViews.get(card.getId()).update(card); } @@ -1155,10 +1155,11 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg for (ArrayList stack : gridRow) { for (CardView card : stack) { boolean s = card.isSelected(); + // Name if (!s) { s |= card.getName().toLowerCase().contains(searchStr); - } + // Sub & Super Types if (!s) { for (String str : card.getSuperTypes()) { s |= str.toLowerCase().contains(searchStr); @@ -1167,6 +1168,27 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg s |= str.toLowerCase().contains(searchStr); } } + // Rarity + if (!s) { + s |= card.getRarity().toString().toLowerCase().contains(searchStr); + } + // Type line + if (!s) { + String t = ""; + for (CardType type : card.getCardTypes()) { + t += " " + type.toString(); + } + s |= t.toLowerCase().contains(searchStr); + } + // Casting cost + if (!s) { + String mc = ""; + for (String m : card.getManaCost()) { + mc += m; + } + s |= mc.toLowerCase().contains(searchStr); + } + // Rules if (!s) { for (String str : card.getRules()) { s |= str.toLowerCase().contains(searchStr);