From b69f2c4fd820ddd9a2c61123b674944ecd385ec9 Mon Sep 17 00:00:00 2001 From: spjspj Date: Sat, 31 Mar 2018 17:55:55 +1100 Subject: [PATCH] Add 'Choose Matching' to deck editor --- .../java/mage/client/cards/DragCardGrid.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 c2435410ac..258892ee88 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java @@ -1083,6 +1083,22 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg } repaint(); } + + private void chooseMatching() { + Collection toMatch = dragCardList(); + + for (DragCardGridListener l : listeners) { + for (CardView card : allCards) { + for (CardView aMatch : toMatch) { + if (card.getName().equals(aMatch.getName())) { + card.setSelected(true); + cardViews.get(card.getId()).update(card); + } + } + } + } + repaint(); + } private void showAll() { for (DragCardGridListener l : listeners) { @@ -1704,6 +1720,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg JMenuItem invertSelection = new JMenuItem("Invert Selection"); invertSelection.addActionListener(e2 -> invertSelection()); menu.add(invertSelection); + + JMenuItem chooseMatching = new JMenuItem("Choose Matching"); + chooseMatching.addActionListener(e2 -> chooseMatching()); + menu.add(chooseMatching); // Show 'Duplicate Selection' for FREE_BUILDING if (this.mode == Constants.DeckEditorMode.FREE_BUILDING) {