mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
Add in Penny Dreadful EDH format (plus filter options for deck editor).
This commit is contained in:
parent
15fd74063c
commit
6435b9950a
14 changed files with 19702 additions and 14 deletions
|
|
@ -206,6 +206,18 @@
|
|||
</Component>
|
||||
<Component class="javax.swing.JToolBar$Separator" name="jSeparator2">
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkPennyDreadful">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Penny Dreadful Only"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Will only allow Penny Dreadful legal cards to be shown."/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="4"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="chkPilesActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnBooster">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Open Booster"/>
|
||||
|
|
@ -528,16 +540,18 @@
|
|||
<Component id="chkRules" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="chkNames" alignment="1" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jButtonRemoveFromMain" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButtonAddToSideboard" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButtonRemoveFromSideboard" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jTextFieldSearch" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButtonSearch" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButtonClean" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cardCount" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButtonAddToMain" alignment="3" max="-2" attributes="0"/>
|
||||
<Component id="cardCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jTextFieldSearch" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButtonSearch" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButtonClean" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="cardCount" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButtonAddToMain" alignment="3" max="-2" attributes="0"/>
|
||||
<Component id="cardCountLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ package mage.client.deckeditor;
|
|||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import mage.MageObject;
|
||||
|
|
@ -74,6 +75,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
private BigCard bigCard;
|
||||
private boolean limited = false;
|
||||
private final SortSetting sortSetting;
|
||||
private static final Map<String, Integer> pdAllowed = new HashMap<>();
|
||||
|
||||
private final ActionListener searchAction = evt -> jButtonSearchActionPerformed(evt);
|
||||
|
||||
|
|
@ -372,6 +374,12 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
try {
|
||||
java.util.List<Card> filteredCards = new ArrayList<>();
|
||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||
|
||||
boolean chkPD = chkPennyDreadful.isSelected();
|
||||
if (chkPD) {
|
||||
generatePennyDreadfulHash();
|
||||
}
|
||||
|
||||
if (limited) {
|
||||
for (Card card : cards) {
|
||||
if (filter.match(card, null)) {
|
||||
|
|
@ -383,6 +391,11 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
for (CardInfo cardInfo : foundCards) {
|
||||
Card card = cardInfo.getMockCard();
|
||||
if (filter.match(card, null)) {
|
||||
if (chkPD) {
|
||||
if (!pdAllowed.containsKey(card.getName())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
filteredCards.add(card);
|
||||
}
|
||||
}
|
||||
|
|
@ -419,6 +432,22 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
}
|
||||
}
|
||||
|
||||
public void generatePennyDreadfulHash() {
|
||||
if (pdAllowed.size() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
properties.load(CardSelector.class.getResourceAsStream("pennydreadful.properties"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (final Entry<Object, Object> entry : properties.entrySet()) {
|
||||
pdAllowed.put((String) entry.getKey(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
|
|
@ -439,6 +468,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
jSeparator1 = new javax.swing.JToolBar.Separator();
|
||||
cbExpansionSet = new javax.swing.JComboBox<>();
|
||||
jSeparator2 = new javax.swing.JToolBar.Separator();
|
||||
chkPennyDreadful = new javax.swing.JCheckBox();
|
||||
btnBooster = new javax.swing.JButton();
|
||||
btnClear = new javax.swing.JButton();
|
||||
tbTypes = new javax.swing.JToolBar();
|
||||
|
|
@ -583,6 +613,27 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
tbColor.add(cbExpansionSet);
|
||||
tbColor.add(jSeparator2);
|
||||
|
||||
|
||||
chkPennyDreadful.setText("Penny Dreadful");
|
||||
chkPennyDreadful.setToolTipText("Will only allow Penny Dreadful legal cards to be shown.");
|
||||
chkPennyDreadful.setFocusable(false);
|
||||
chkPennyDreadful.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
|
||||
chkPennyDreadful.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
chkPennyDreadful.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
chkPilesActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
JPopupMenu filterByFormatPopup = new JPopupMenu();
|
||||
filterByFormatPopup.add(chkPennyDreadful);
|
||||
filterByFormatPopup.setLayout(new GridBagLayout());
|
||||
|
||||
ButtonGroup selectByTypeModeGroup = new ButtonGroup();
|
||||
JButton filterByFormatButton = new JButton ("Filter by Format");
|
||||
makeButtonPopup(filterByFormatButton, filterByFormatPopup);
|
||||
tbColor.add(filterByFormatButton);
|
||||
|
||||
btnBooster.setText("Open Booster");
|
||||
btnBooster.setToolTipText("(CURRENTLY NOT WORKING) Generates a booster of the selected set and adds the cards to the card selector.");
|
||||
btnBooster.setFocusable(false);
|
||||
|
|
@ -939,16 +990,17 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
.addComponent(chkRules, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(chkNames, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(cardSelectorBottomPanelLayout.createSequentialGroup()
|
||||
.addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jButtonRemoveFromMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonAddToSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonRemoveFromSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonSearch)
|
||||
.addComponent(jButtonClean)
|
||||
.addComponent(cardCount)
|
||||
.addComponent(jButtonAddToMain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(cardCountLabel))
|
||||
.addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonSearch)
|
||||
.addComponent(jButtonClean)
|
||||
.addComponent(cardCount)
|
||||
.addComponent(jButtonAddToMain, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(cardCountLabel)))
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
|
@ -1204,6 +1256,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
private javax.swing.JComboBox<String> cbExpansionSet;
|
||||
private javax.swing.JComboBox<SortBy> cbSortBy;
|
||||
private javax.swing.JCheckBox chkNames;
|
||||
private javax.swing.JCheckBox chkPennyDreadful;
|
||||
private javax.swing.JCheckBox chkPiles;
|
||||
private javax.swing.JCheckBox chkRules;
|
||||
private javax.swing.JCheckBox chkTypes;
|
||||
|
|
@ -1287,4 +1340,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
public void dragCardDrop(MouseEvent e, DragCardSource source, Collection<CardView> cards) {
|
||||
// Need to add cards back to tally
|
||||
}
|
||||
|
||||
private static void makeButtonPopup(final AbstractButton button, final JPopupMenu popup) {
|
||||
button.addActionListener(e -> popup.show(button, 0, button.getHeight()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue