mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Merge pull request #4306 from skeate/feature/rarity-filters
Add rarity filters to deck editor
This commit is contained in:
commit
34c32a7535
2 changed files with 254 additions and 3 deletions
|
@ -500,6 +500,109 @@
|
|||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jToggleCardViewActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JToolBar$Separator" name="jSeparator5">
|
||||
</Component>
|
||||
<Container class="javax.swing.JToolBar" name="tbRarities">
|
||||
<Properties>
|
||||
<Property name="floatable" type="boolean" value="false"/>
|
||||
<Property name="rollover" type="boolean" value="true"/>
|
||||
<Property name="toolTipText" type="java.lang.String" value="Hold the ALT-key while clicking to deselect all other card rarities or hold the CTRL-key to only select all other card rarities."/>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JToggleButton" name="tbCommon">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/rarity_common_20.png"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""<html><strong>Common</strong><br/>" 
+ tbRarities.getToolTipText()" type="code"/>
|
||||
</Property>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Common"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbCommonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JToggleButton" name="tbUncommon">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/rarity_uncommon_20.png"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""<html><strong>Uncommon</strong><br/>" 
+ tbUncommon.getToolTipText()" type="code"/>
|
||||
</Property>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Uncommon"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbUncommonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JToggleButton" name="tbRare">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/rarity_rare_20.png"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""<html><strong>Rare</strong><br/>" 
+ tbRarities.getToolTipText()" type="code"/>
|
||||
</Property>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Rare"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbRareActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JToggleButton" name="tbMythic">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/rarity_mythic_20.png"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""<html><strong>Mythic</strong><br/>" 
+ tbRarities.getToolTipText()" type="code"/>
|
||||
</Property>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Mythic"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbMythicActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JToggleButton" name="tbSpecial">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/buttons/rarity_special_20.png"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""<html><strong>Special</strong><br/>" 
+ tbRarities.getToolTipText()" type="code"/>
|
||||
</Property>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Special"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="tbSpecialActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JScrollPane" name="cardSelectorScrollPane">
|
||||
|
|
|
@ -55,6 +55,7 @@ import mage.client.util.GUISizeHelper;
|
|||
import mage.client.util.gui.FastSearchUtil;
|
||||
import mage.client.util.sets.ConstructedFormats;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Rarity;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.Predicates;
|
||||
|
@ -328,6 +329,24 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
// criteria.types(CardType.TRIBAL);
|
||||
// criteria.types(CardType.CONSPIRACY);
|
||||
|
||||
if (this.tbCommon.isSelected()) {
|
||||
criteria.rarities(Rarity.COMMON);
|
||||
criteria.rarities(Rarity.LAND);
|
||||
}
|
||||
if (this.tbUncommon.isSelected()) {
|
||||
criteria.rarities(Rarity.UNCOMMON);
|
||||
}
|
||||
if (this.tbRare.isSelected()) {
|
||||
criteria.rarities(Rarity.RARE);
|
||||
}
|
||||
if (this.tbMythic.isSelected()) {
|
||||
criteria.rarities(Rarity.MYTHIC);
|
||||
}
|
||||
if (this.tbSpecial.isSelected()) {
|
||||
criteria.rarities(Rarity.SPECIAL);
|
||||
criteria.rarities(Rarity.BONUS);
|
||||
}
|
||||
|
||||
if (this.cbExpansionSet.isVisible()) {
|
||||
String expansionSelection = this.cbExpansionSet.getSelectedItem().toString();
|
||||
if (!expansionSelection.equals("- All Sets")) {
|
||||
|
@ -376,6 +395,19 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
filterCards();
|
||||
}
|
||||
|
||||
private void filterCardsRarity(int modifiers, String actionCommand) {
|
||||
// ALT or CTRL button was pushed
|
||||
if ((modifiers & ActionEvent.ALT_MASK) == ActionEvent.ALT_MASK || (modifiers & ActionEvent.CTRL_MASK) == ActionEvent.CTRL_MASK) {
|
||||
boolean invert = (modifiers & ActionEvent.ALT_MASK) == ActionEvent.ALT_MASK;
|
||||
tbCommon.setSelected(inverter(invert, tbCommon.getActionCommand(), actionCommand));
|
||||
tbUncommon.setSelected(inverter(invert, tbUncommon.getActionCommand(), actionCommand));
|
||||
tbRare.setSelected(inverter(invert, tbRare.getActionCommand(), actionCommand));
|
||||
tbMythic.setSelected(inverter(invert, tbMythic.getActionCommand(), actionCommand));
|
||||
tbSpecial.setSelected(inverter(invert, tbSpecial.getActionCommand(), actionCommand));
|
||||
}
|
||||
filterCards();
|
||||
}
|
||||
|
||||
private void filterCards() {
|
||||
FilterCard filter = buildFilter();
|
||||
try {
|
||||
|
@ -494,6 +526,13 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
jSeparator4 = new javax.swing.JToolBar.Separator();
|
||||
jToggleListView = new javax.swing.JToggleButton();
|
||||
jToggleCardView = new javax.swing.JToggleButton();
|
||||
jSeparator5 = new javax.swing.JToolBar.Separator();
|
||||
tbRarities = new javax.swing.JToolBar();
|
||||
tbCommon = new javax.swing.JToggleButton();
|
||||
tbUncommon = new javax.swing.JToggleButton();
|
||||
tbRare = new javax.swing.JToggleButton();
|
||||
tbMythic = new javax.swing.JToggleButton();
|
||||
tbSpecial = new javax.swing.JToggleButton();
|
||||
cardSelectorScrollPane = new javax.swing.JScrollPane();
|
||||
cardSelectorBottomPanel = new javax.swing.JPanel();
|
||||
jButtonAddToMain = new javax.swing.JButton();
|
||||
|
@ -841,6 +880,88 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
}
|
||||
});
|
||||
tbTypes.add(jToggleCardView);
|
||||
tbTypes.add(jSeparator5);
|
||||
|
||||
tbRarities.setFloatable(false);
|
||||
tbRarities.setRollover(true);
|
||||
tbRarities.setToolTipText("Hold the ALT-key while clicking to deselect all other card rarities or hold the CTRL-key to only select all other card rarities.");
|
||||
|
||||
tbCommon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_common_20.png"))); // NOI18N
|
||||
tbCommon.setSelected(true);
|
||||
tbCommon.setToolTipText("<html><strong>Common</strong><br/>"
|
||||
+ tbRarities.getToolTipText());
|
||||
tbCommon.setActionCommand("Common");
|
||||
tbCommon.setFocusable(false);
|
||||
tbCommon.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
tbCommon.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
tbCommon.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
tbCommonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
tbRarities.add(tbCommon);
|
||||
|
||||
tbUncommon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_uncommon_20.png"))); // NOI18N
|
||||
tbUncommon.setSelected(true);
|
||||
tbUncommon.setToolTipText("<html><strong>Uncommon</strong><br/>"
|
||||
+ tbUncommon.getToolTipText());
|
||||
tbUncommon.setActionCommand("Uncommon");
|
||||
tbUncommon.setFocusable(false);
|
||||
tbUncommon.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
tbUncommon.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
tbUncommon.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
tbUncommonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
tbRarities.add(tbUncommon);
|
||||
|
||||
tbRare.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_rare_20.png"))); // NOI18N
|
||||
tbRare.setSelected(true);
|
||||
tbRare.setToolTipText("<html><strong>Rare</strong><br/>"
|
||||
+ tbRarities.getToolTipText());
|
||||
tbRare.setActionCommand("Rare");
|
||||
tbRare.setFocusable(false);
|
||||
tbRare.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
tbRare.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
tbRare.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
tbRareActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
tbRarities.add(tbRare);
|
||||
|
||||
tbMythic.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_mythic_20.png"))); // NOI18N
|
||||
tbMythic.setSelected(true);
|
||||
tbMythic.setToolTipText("<html><strong>Mythic</strong><br/>"
|
||||
+ tbRarities.getToolTipText());
|
||||
tbMythic.setActionCommand("Mythic");
|
||||
tbMythic.setFocusable(false);
|
||||
tbMythic.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
tbMythic.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
tbMythic.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
tbMythicActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
tbRarities.add(tbMythic);
|
||||
|
||||
tbSpecial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/rarity_special_20.png"))); // NOI18N
|
||||
tbSpecial.setSelected(true);
|
||||
tbSpecial.setToolTipText("<html><strong>Special</strong><br/>"
|
||||
+ tbRarities.getToolTipText());
|
||||
tbSpecial.setActionCommand("Special");
|
||||
tbSpecial.setFocusable(false);
|
||||
tbSpecial.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
tbSpecial.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
tbSpecial.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
tbSpecialActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
tbRarities.add(tbSpecial);
|
||||
|
||||
tbTypes.add(tbRarities);
|
||||
|
||||
cardSelectorScrollPane.setToolTipText("<HTML>Double click to add the card to the main deck.<br/>\nALT + Double click to add the card to the sideboard.");
|
||||
|
||||
|
@ -1224,6 +1345,26 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
FastSearchUtil.showFastSearchForStringComboBox(cbExpansionSet, "Select set or expansion");
|
||||
}//GEN-LAST:event_btnExpansionSearchActionPerformed
|
||||
|
||||
private void tbCommonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbCommonActionPerformed
|
||||
filterCardsRarity(evt.getModifiers(), evt.getActionCommand());
|
||||
}//GEN-LAST:event_tbCommonActionPerformed
|
||||
|
||||
private void tbUncommonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbUncommonActionPerformed
|
||||
filterCardsRarity(evt.getModifiers(), evt.getActionCommand());
|
||||
}//GEN-LAST:event_tbUncommonActionPerformed
|
||||
|
||||
private void tbRareActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbRareActionPerformed
|
||||
filterCardsRarity(evt.getModifiers(), evt.getActionCommand());
|
||||
}//GEN-LAST:event_tbRareActionPerformed
|
||||
|
||||
private void tbMythicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbMythicActionPerformed
|
||||
filterCardsRarity(evt.getModifiers(), evt.getActionCommand());
|
||||
}//GEN-LAST:event_tbMythicActionPerformed
|
||||
|
||||
private void tbSpecialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tbSpecialActionPerformed
|
||||
filterCardsRarity(evt.getModifiers(), evt.getActionCommand());
|
||||
}//GEN-LAST:event_tbSpecialActionPerformed
|
||||
|
||||
private void toggleViewMode() {
|
||||
if (currentView instanceof CardGrid) {
|
||||
jToggleListView.setSelected(true);
|
||||
|
@ -1288,6 +1429,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
private javax.swing.JToolBar.Separator jSeparator2;
|
||||
private javax.swing.JToolBar.Separator jSeparator3;
|
||||
private javax.swing.JToolBar.Separator jSeparator4;
|
||||
private javax.swing.JToolBar.Separator jSeparator5;
|
||||
private javax.swing.JToolBar.Separator jSeparator6;
|
||||
private javax.swing.JTextField jTextFieldSearch;
|
||||
private javax.swing.JToggleButton jToggleCardView;
|
||||
|
@ -1297,15 +1439,21 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
private javax.swing.JToggleButton tbBlue;
|
||||
private javax.swing.JToolBar tbColor;
|
||||
private javax.swing.JToggleButton tbColorless;
|
||||
private javax.swing.JToggleButton tbCommon;
|
||||
private javax.swing.JToggleButton tbCreatures;
|
||||
private javax.swing.JToggleButton tbEnchantments;
|
||||
private javax.swing.JToggleButton tbGreen;
|
||||
private javax.swing.JToggleButton tbInstants;
|
||||
private javax.swing.JToggleButton tbLand;
|
||||
private javax.swing.JToggleButton tbMythic;
|
||||
private javax.swing.JToggleButton tbPlaneswalkers;
|
||||
private javax.swing.JToggleButton tbRare;
|
||||
private javax.swing.JToolBar tbRarities;
|
||||
private javax.swing.JToggleButton tbRed;
|
||||
private javax.swing.JToggleButton tbSorceries;
|
||||
private javax.swing.JToggleButton tbSpecial;
|
||||
private javax.swing.JToolBar tbTypes;
|
||||
private javax.swing.JToggleButton tbUncommon;
|
||||
private javax.swing.JToggleButton tbWhite;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
|
|
Loading…
Reference in a new issue