mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
spjspj - Add type and search filter to deck editor
This commit is contained in:
parent
383a750f6e
commit
423f1c3fc3
1 changed files with 26 additions and 4 deletions
|
|
@ -896,7 +896,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
selectBySearchOptionsC.fill = GridBagConstraints.VERTICAL;
|
selectBySearchOptionsC.fill = GridBagConstraints.VERTICAL;
|
||||||
|
|
||||||
searchByTextField = new JTextField();
|
searchByTextField = new JTextField();
|
||||||
searchByTextField.setToolTipText("Searches for card names and in the rule text of the card.");
|
searchByTextField.setToolTipText("Searches for card names, types, rarity, casting cost and rules text. NB: Mana symbols are written like {W},{U},{C} etc");
|
||||||
searchByTextField.addKeyListener(new KeyAdapter() {
|
searchByTextField.addKeyListener(new KeyAdapter() {
|
||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
reselectBy();
|
reselectBy();
|
||||||
|
|
@ -1128,7 +1128,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
|
|
||||||
boolean useText = false;
|
boolean useText = false;
|
||||||
String searchStr = "";
|
String searchStr = "";
|
||||||
if (searchByTextField.getText().length() > 3) {
|
if (searchByTextField.getText().length() >= 3) {
|
||||||
useText = true;
|
useText = true;
|
||||||
searchStr = searchByTextField.getText().toLowerCase();
|
searchStr = searchByTextField.getText().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
@ -1140,7 +1140,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
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) {
|
||||||
boolean s = card.getCardTypes().contains(cardType);
|
boolean s = card.isSelected() | card.getCardTypes().contains(cardType);
|
||||||
card.setSelected(s);
|
card.setSelected(s);
|
||||||
cardViews.get(card.getId()).update(card);
|
cardViews.get(card.getId()).update(card);
|
||||||
}
|
}
|
||||||
|
|
@ -1155,10 +1155,11 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
for (ArrayList<CardView> stack : gridRow) {
|
for (ArrayList<CardView> stack : gridRow) {
|
||||||
for (CardView card : stack) {
|
for (CardView card : stack) {
|
||||||
boolean s = card.isSelected();
|
boolean s = card.isSelected();
|
||||||
|
// Name
|
||||||
if (!s) {
|
if (!s) {
|
||||||
s |= card.getName().toLowerCase().contains(searchStr);
|
s |= card.getName().toLowerCase().contains(searchStr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Sub & Super Types
|
||||||
if (!s) {
|
if (!s) {
|
||||||
for (String str : card.getSuperTypes()) {
|
for (String str : card.getSuperTypes()) {
|
||||||
s |= str.toLowerCase().contains(searchStr);
|
s |= str.toLowerCase().contains(searchStr);
|
||||||
|
|
@ -1167,6 +1168,27 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
|
||||||
s |= str.toLowerCase().contains(searchStr);
|
s |= str.toLowerCase().contains(searchStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Rarity
|
||||||
|
if (!s) {
|
||||||
|
s |= card.getRarity().toString().toLowerCase().contains(searchStr);
|
||||||
|
}
|
||||||
|
// Type line
|
||||||
|
if (!s) {
|
||||||
|
String t = "";
|
||||||
|
for (CardType type : card.getCardTypes()) {
|
||||||
|
t += " " + type.toString();
|
||||||
|
}
|
||||||
|
s |= t.toLowerCase().contains(searchStr);
|
||||||
|
}
|
||||||
|
// Casting cost
|
||||||
|
if (!s) {
|
||||||
|
String mc = "";
|
||||||
|
for (String m : card.getManaCost()) {
|
||||||
|
mc += m;
|
||||||
|
}
|
||||||
|
s |= mc.toLowerCase().contains(searchStr);
|
||||||
|
}
|
||||||
|
// Rules
|
||||||
if (!s) {
|
if (!s) {
|
||||||
for (String str : card.getRules()) {
|
for (String str : card.getRules()) {
|
||||||
s |= str.toLowerCase().contains(searchStr);
|
s |= str.toLowerCase().contains(searchStr);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue