mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Merge pull request #2609 from spjspj/master
spjspj - Add concept of 'Multiples' (work out in new edh decks which …
This commit is contained in:
commit
b29e25cb87
1 changed files with 41 additions and 1 deletions
|
@ -613,6 +613,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
JPopupMenu selectByPopup;
|
JPopupMenu selectByPopup;
|
||||||
JCheckBox separateCreaturesCb;
|
JCheckBox separateCreaturesCb;
|
||||||
JTextField searchByTextField;
|
JTextField searchByTextField;
|
||||||
|
JToggleButton multiplesButton;
|
||||||
|
|
||||||
JSlider cardSizeSlider;
|
JSlider cardSizeSlider;
|
||||||
JLabel cardSizeSliderLabel;
|
JLabel cardSizeSliderLabel;
|
||||||
|
@ -952,8 +953,20 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
|
|
||||||
ButtonGroup selectByTypeModeGroup = new ButtonGroup();
|
ButtonGroup selectByTypeModeGroup = new ButtonGroup();
|
||||||
for (final CardType cardType : CardType.values()) {
|
for (final CardType cardType : CardType.values()) {
|
||||||
JToggleButton button = new JToggleButton(cardType.toString());
|
|
||||||
|
|
||||||
|
if (cardType == cardType.CONSPIRACY) {
|
||||||
|
multiplesButton = new JToggleButton("Multiples");
|
||||||
|
selectByTypeButtons.put(cardType, multiplesButton);
|
||||||
|
selectByTypeMode.add(multiplesButton);
|
||||||
|
selectByTypeModeGroup.add(multiplesButton);
|
||||||
|
multiplesButton.addActionListener(e -> {
|
||||||
|
multiplesButton.setSelected(!multiplesButton.isSelected());
|
||||||
|
reselectBy();
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
JToggleButton button = new JToggleButton(cardType.toString());
|
||||||
selectByTypeButtons.put(cardType, button);
|
selectByTypeButtons.put(cardType, button);
|
||||||
selectByTypeMode.add(button);
|
selectByTypeMode.add(button);
|
||||||
selectByTypeModeGroup.add(button);
|
selectByTypeModeGroup.add(button);
|
||||||
|
@ -1232,6 +1245,29 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
AbstractButton button = selectByTypeButtons.get(cardType);
|
AbstractButton button = selectByTypeButtons.get(cardType);
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
if (button.isSelected()) {
|
if (button.isSelected()) {
|
||||||
|
// Special case - "Multiples" (CONSPIRACY type)
|
||||||
|
if (cardType == CardType.CONSPIRACY) {
|
||||||
|
HashMap<String, CardView> cardNames = new HashMap<>();
|
||||||
|
|
||||||
|
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||||
|
for (ArrayList<CardView> stack : gridRow) {
|
||||||
|
for (CardView card : stack) {
|
||||||
|
if (cardNames.get(card.getName()) == null) {
|
||||||
|
cardNames.put(card.getName(), card);
|
||||||
|
} else {
|
||||||
|
card.setSelected(true);
|
||||||
|
cardViews.get(card.getId()).update(card);
|
||||||
|
|
||||||
|
CardView origCard = cardNames.get(card.getName());
|
||||||
|
origCard.setSelected(true);
|
||||||
|
cardViews.get(origCard.getId()).update(origCard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
for (ArrayList<ArrayList<CardView>> gridRow : cardGrid) {
|
||||||
for (ArrayList<CardView> stack : gridRow) {
|
for (ArrayList<CardView> stack : gridRow) {
|
||||||
for (CardView card : stack) {
|
for (CardView card : stack) {
|
||||||
|
@ -1590,6 +1626,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
AbstractButton button = selectByTypeButtons.get(cardType);
|
AbstractButton button = selectByTypeButtons.get(cardType);
|
||||||
String text = cardType.toString();
|
String text = cardType.toString();
|
||||||
int numCards = getCount(cardType);
|
int numCards = getCount(cardType);
|
||||||
|
if (cardType == cardType.CONSPIRACY) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (numCards > 0) {
|
if (numCards > 0) {
|
||||||
button.setForeground(Color.BLACK);
|
button.setForeground(Color.BLACK);
|
||||||
text = text + " - " + numCards;
|
text = text + " - " + numCards;
|
||||||
|
|
Loading…
Reference in a new issue