mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Merge pull request #6522 from emerald000/oldVersions
UI: Add a button on the deck editor to change your cards to the oldest versions.
This commit is contained in:
commit
0b00ae8b9d
2 changed files with 78 additions and 0 deletions
|
|
@ -562,6 +562,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
JButton selectByButton;
|
||||
JButton analyseButton;
|
||||
JButton blingButton;
|
||||
JButton oldVersionButton;
|
||||
|
||||
// Popup for toolbar
|
||||
final JPopupMenu filterPopup;
|
||||
|
|
@ -716,6 +717,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
selectByButton = new JButton("Select By");
|
||||
analyseButton = new JButton("M"); // "Mana" button
|
||||
blingButton = new JButton("B"); // "Bling" button
|
||||
oldVersionButton = new JButton("O"); // "Old version" button
|
||||
|
||||
// Name and count label
|
||||
deckNameAndCountLabel = new JLabel();
|
||||
|
|
@ -740,6 +742,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
toolbarInner.add(visibilityButton);
|
||||
toolbarInner.add(analyseButton);
|
||||
toolbarInner.add(blingButton);
|
||||
toolbarInner.add(oldVersionButton);
|
||||
toolbar.add(toolbarInner, BorderLayout.WEST);
|
||||
JPanel sliderPanel = new JPanel(new GridBagLayout());
|
||||
sliderPanel.setOpaque(false);
|
||||
|
|
@ -982,6 +985,11 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
|
||||
blingButton.addActionListener(evt -> blingDeck());
|
||||
|
||||
// Old version button - Switch cards to the oldest non-promo printing. In case of multiples in a set, take the lowest card number.
|
||||
oldVersionButton.setToolTipText("Switch cards to the oldest non-promo printing");
|
||||
|
||||
oldVersionButton.addActionListener(evt -> oldVersionDeck());
|
||||
|
||||
// Filter popup
|
||||
filterPopup = new JPopupMenu();
|
||||
filterPopup.setPreferredSize(new Dimension(300, 300));
|
||||
|
|
@ -1567,6 +1575,44 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
|||
}
|
||||
}
|
||||
|
||||
private void oldVersionDeck() {
|
||||
if (this.mode != Constants.DeckEditorMode.FREE_BUILDING) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you want to switch your card versions to the oldest ones?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<List<List<CardView>>> newCardGrid = new ArrayList<>();
|
||||
for (List<List<CardView>> gridRow : cardGrid) {
|
||||
List<List<CardView>> newGridRow = new ArrayList<>();
|
||||
for (List<CardView> stack : gridRow) {
|
||||
List<CardView> newStack = new ArrayList<>();
|
||||
for (CardView card : stack) {
|
||||
CardInfo oldestCardInfo = CardRepository.instance.findOldestNonPromoVersionCard(card.getName());
|
||||
if (oldestCardInfo != null) {
|
||||
CardView oldestCardView = new CardView(oldestCardInfo.getMockCard());
|
||||
this.removeCardView(card);
|
||||
eventSource.fireEvent(card, ClientEventType.REMOVE_SPECIFIC_CARD);
|
||||
this.addCardView(oldestCardView, false);
|
||||
eventSource.fireEvent(oldestCardView, ClientEventType.ADD_SPECIFIC_CARD);
|
||||
newStack.add(oldestCardView);
|
||||
} else {
|
||||
newStack.add(card);
|
||||
}
|
||||
}
|
||||
newGridRow.add(newStack);
|
||||
}
|
||||
newCardGrid.add(newGridRow);
|
||||
}
|
||||
cardGrid = newCardGrid;
|
||||
layoutGrid();
|
||||
cardScroll.revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
// Update the contents of the card grid
|
||||
public void setCards(CardsView cardsView, DeckCardLayout layout, BigCard bigCard) {
|
||||
if (bigCard != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue