From ae2787f11954a7cf398ef21cd7d3ba738d1b7982 Mon Sep 17 00:00:00 2001 From: spjspj Date: Fri, 18 Jun 2021 00:36:38 +1000 Subject: [PATCH] Add in color identity as a sortable option in the deck editor and draft editor --- .../src/main/java/mage/client/cards/CardsList.java | 1 + .../main/java/mage/client/deckeditor/CardSelector.java | 1 + .../mage/client/deckeditor/table/MageCardComparator.java | 4 ++++ .../java/mage/client/deckeditor/table/TableModel.java | 6 +++++- Mage.Common/src/main/java/mage/view/CardView.java | 9 +++++++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Mage.Client/src/main/java/mage/client/cards/CardsList.java b/Mage.Client/src/main/java/mage/client/cards/CardsList.java index ae05372830..b738a7a02a 100644 --- a/Mage.Client/src/main/java/mage/client/cards/CardsList.java +++ b/Mage.Client/src/main/java/mage/client/cards/CardsList.java @@ -141,6 +141,7 @@ // new mana render (svg support) mainTable.getColumnModel().getColumn(mainModel.COLUMN_INDEX_COST).setCellRenderer(new ManaSymbolsCellRenderer()); + mainTable.getColumnModel().getColumn(mainModel.COLUMN_INDEX_COLOR_IDENTITY).setCellRenderer(new ManaSymbolsCellRenderer()); if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_DRAFT_VIEW, "cardView").equals("listView")) { jToggleListView.setSelected(true); diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java index cb83a88c32..5e706e36a6 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/CardSelector.java @@ -127,6 +127,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene // new mana render (svg support) mainTable.getColumnModel().getColumn(mainModel.COLUMN_INDEX_COST).setCellRenderer(new ManaSymbolsCellRenderer()); + mainTable.getColumnModel().getColumn(mainModel.COLUMN_INDEX_COLOR_IDENTITY).setCellRenderer(new ManaSymbolsCellRenderer()); // mainTable.setToolTipText(cardSelectorScrollPane.getToolTipText()); cardSelectorScrollPane.setViewportView(mainTable); diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/table/MageCardComparator.java b/Mage.Client/src/main/java/mage/client/deckeditor/table/MageCardComparator.java index 1775689bfd..d14d236c14 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/table/MageCardComparator.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/table/MageCardComparator.java @@ -86,6 +86,10 @@ public class MageCardComparator implements CardViewComparator { aCom = RateCard.rateCard(a.getOriginalCard(), null); bCom = RateCard.rateCard(b.getOriginalCard(), null); break; + case 10: + aCom = a.getColorIdentityStr(); + bCom = b.getColorIdentityStr(); + break; default: break; } diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java b/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java index 93e251641b..5ddee21ab5 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java @@ -51,9 +51,10 @@ public class TableModel extends AbstractTableModel implements ICardGrid { private boolean displayNoCopies = false; private UpdateCountsCallback updateCountsCallback; - private final String[] column = {"Qty", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set", "Card number", "Draft Rating"}; + private final String[] column = {"Qty", "Name", "Cost", "Color", "Type", "Stats", "Rarity", "Set", "Card number", "Draft Rating", "Color Identity"}; public final int COLUMN_INDEX_COST = 2; public final int COLUMN_INDEX_RATING = 9; + public final int COLUMN_INDEX_COLOR_IDENTITY = 10; private SortSetting sortSetting; private int recentSortedColumn; @@ -227,6 +228,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid { case 2: // new svg images version return ManaSymbols.getClearManaCost(c.getManaCostStr()); + /* // old html images version String manaCost = ""; @@ -253,6 +255,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid { return c.getCardNumber(); case 9: return RateCard.rateCard(c.getOriginalCard(), null); + case 10: + return ManaSymbols.getClearManaCost(c.getColorIdentityStr()); default: return "error"; } diff --git a/Mage.Common/src/main/java/mage/view/CardView.java b/Mage.Common/src/main/java/mage/view/CardView.java index f648dfa0d6..3e2646a596 100644 --- a/Mage.Common/src/main/java/mage/view/CardView.java +++ b/Mage.Common/src/main/java/mage/view/CardView.java @@ -18,6 +18,7 @@ import mage.constants.*; import mage.counters.Counter; import mage.counters.CounterType; import mage.designations.Designation; +import mage.filter.FilterMana; import mage.game.Game; import mage.game.command.Emblem; import mage.game.command.Plane; @@ -856,6 +857,14 @@ public class CardView extends SimpleCardView { return rarity; } + public String getColorIdentityStr() { + FilterMana filterMana = originalCard.getColorIdentity(); + if (filterMana.getColorCount() == 0) { + return CardUtil.concatManaSymbols(CardInfo.SPLIT_MANA_SEPARATOR_FULL, "{C}", ""); + } + return CardUtil.concatManaSymbols(CardInfo.SPLIT_MANA_SEPARATOR_FULL, filterMana.toString(), ""); + } + @Override public String getExpansionSetCode() { if (expansionSetCode == null) {