mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
just tried to test issue 148, but could not find a card to quest deck, added it. and it didn't appear in list, so I moved the name, type and set filter to quest Deckeditor. Draft users also get an update of colored mana costs.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -9806,6 +9806,7 @@ src/main/java/forge/gui/deckeditor/DeckEditorQuest.java svneol=native#text/plain
|
|||||||
src/main/java/forge/gui/deckeditor/DeckEditorQuestMenu.java svneol=native#text/plain
|
src/main/java/forge/gui/deckeditor/DeckEditorQuestMenu.java svneol=native#text/plain
|
||||||
src/main/java/forge/gui/deckeditor/DeckEditorShop.java svneol=native#text/plain
|
src/main/java/forge/gui/deckeditor/DeckEditorShop.java svneol=native#text/plain
|
||||||
src/main/java/forge/gui/deckeditor/FilterCheckBoxes.java -text
|
src/main/java/forge/gui/deckeditor/FilterCheckBoxes.java -text
|
||||||
|
src/main/java/forge/gui/deckeditor/FilterNameTypeSetPanel.java -text
|
||||||
src/main/java/forge/gui/deckeditor/GuiFilterCheckBox.java svneol=native#text/plain
|
src/main/java/forge/gui/deckeditor/GuiFilterCheckBox.java svneol=native#text/plain
|
||||||
src/main/java/forge/gui/deckeditor/ManaCostRenderer.java -text
|
src/main/java/forge/gui/deckeditor/ManaCostRenderer.java -text
|
||||||
src/main/java/forge/gui/deckeditor/PresetColumns.java -text
|
src/main/java/forge/gui/deckeditor/PresetColumns.java -text
|
||||||
|
|||||||
@@ -219,6 +219,7 @@ public final class CardPrinted implements Comparable<CardPrinted> {
|
|||||||
public static final Predicate<CardPrinted> isStandard = printedInSets(
|
public static final Predicate<CardPrinted> isStandard = printedInSets(
|
||||||
Arrays.asList(new String[] {"M12", "NPH", "MBS", "SOM", "M11", "ROE", "WWK", "ZEN"}), true);
|
Arrays.asList(new String[] {"M12", "NPH", "MBS", "SOM", "M11", "ROE", "WWK", "ZEN"}), true);
|
||||||
|
|
||||||
|
public static final Predicate<CardPrinted> isTrue = Predicate.getTrue(CardPrinted.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import java.awt.Container;
|
|||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ItemEvent;
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
@@ -54,19 +56,10 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
|||||||
private JButton removeButton = new JButton();
|
private JButton removeButton = new JButton();
|
||||||
private JButton addButton = new JButton();
|
private JButton addButton = new JButton();
|
||||||
private JButton analysisButton = new JButton();
|
private JButton analysisButton = new JButton();
|
||||||
|
|
||||||
private JLabel labelFilterName = new JLabel();
|
|
||||||
private JLabel labelFilterType = new JLabel();
|
|
||||||
private JLabel labelFilterRules = new JLabel();
|
|
||||||
private JLabel jLabel4 = new JLabel();
|
|
||||||
|
|
||||||
//public JButton filterButton = new JButton();
|
|
||||||
private JTextField txtCardName = new JTextField();
|
|
||||||
|
|
||||||
private JTextField txtCardType = new JTextField();
|
|
||||||
private JTextField txtCardRules = new JTextField();
|
|
||||||
private JComboBox searchSetCombo = new JComboBox();
|
|
||||||
private JButton clearFilterButton = new JButton();
|
private JButton clearFilterButton = new JButton();
|
||||||
|
|
||||||
|
private JLabel jLabelAnalysisGap = new JLabel();
|
||||||
|
private FilterNameTypeSetPanel filterNameTypeSet;
|
||||||
|
|
||||||
private boolean isConstructed = false;
|
private boolean isConstructed = false;
|
||||||
|
|
||||||
@@ -127,25 +120,13 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
|||||||
|
|
||||||
top.setup(columns, cardView);
|
top.setup(columns, cardView);
|
||||||
bottom.setup(columns, cardView);
|
bottom.setup(columns, cardView);
|
||||||
|
|
||||||
|
filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), itemListenerUpdatesDisplay);
|
||||||
|
|
||||||
// TODO use this as soon the deck editor has resizable GUI
|
|
||||||
// Use both so that when "un"maximizing, the frame isn't tiny
|
|
||||||
setSize(1024, 740);
|
setSize(1024, 740);
|
||||||
setExtendedState(Frame.MAXIMIZED_BOTH);
|
setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||||
|
|
||||||
// This was an attempt to limit the width of the deck editor to 1400
|
}
|
||||||
// pixels.
|
|
||||||
/*
|
|
||||||
* setSize(1024, 740); Rectangle bounds = getBounds(); Dimension screen
|
|
||||||
* = getToolkit().getScreenSize(); int maxWidth;
|
|
||||||
*
|
|
||||||
* if (screen.width >= 1400) { maxWidth = 1400; } else { maxWidth =
|
|
||||||
* screen.width; } bounds.width = maxWidth; bounds.height =
|
|
||||||
* screen.height;
|
|
||||||
*
|
|
||||||
* setMaximizedBounds(bounds);
|
|
||||||
*/
|
|
||||||
}// setupAndDisplay()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,6 +140,7 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
|||||||
top = new TableWithCards("Avaliable Cards", true, true);
|
top = new TableWithCards("Avaliable Cards", true, true);
|
||||||
bottom = new TableWithCards("Deck", true);
|
bottom = new TableWithCards("Deck", true);
|
||||||
cardView = new CardPanelHeavy();
|
cardView = new CardPanelHeavy();
|
||||||
|
filterNameTypeSet = new FilterNameTypeSetPanel();
|
||||||
|
|
||||||
jbInit();
|
jbInit();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@@ -249,42 +231,13 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
|||||||
//this.getContentPane().add(filterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow");
|
//this.getContentPane().add(filterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow");
|
||||||
this.getContentPane().add(clearFilterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow");
|
this.getContentPane().add(clearFilterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow");
|
||||||
|
|
||||||
|
this.getContentPane().add(filterNameTypeSet, "cell 0 1, grow");
|
||||||
this.getContentPane().add(top.getTableDecorated(), "cell 0 2 1 2, pushy, grow");
|
this.getContentPane().add(top.getTableDecorated(), "cell 0 2 1 2, pushy, grow");
|
||||||
|
|
||||||
this.getContentPane().add(cardView, "cell 1 0 1 8, flowy, grow");
|
this.getContentPane().add(cardView, "cell 1 0 1 8, flowy, grow");
|
||||||
|
|
||||||
labelFilterName.setText("Name:");
|
|
||||||
labelFilterName.setToolTipText("Card names must include the text in this field");
|
|
||||||
this.getContentPane().add(labelFilterName, "cell 0 1, split 7");
|
|
||||||
this.getContentPane().add(txtCardName, "wmin 100, grow");
|
|
||||||
txtCardName.getDocument().addDocumentListener(new OnChangeTextUpdateDisplay());
|
|
||||||
|
|
||||||
/* txtCardName.getDocument().addDocumentListener(new DocumentListener() {
|
|
||||||
@Override public void removeUpdate(final DocumentEvent e) { }
|
|
||||||
@Override public void insertUpdate(final DocumentEvent e) { }
|
|
||||||
@Override public void changedUpdate(final DocumentEvent e) { updateDisplay(); }
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
labelFilterType.setText("Type:");
|
|
||||||
labelFilterType.setToolTipText("Card types must include the text in this field");
|
|
||||||
this.getContentPane().add(labelFilterType, "");
|
|
||||||
this.getContentPane().add(txtCardType, "wmin 100, grow");
|
|
||||||
txtCardType.getDocument().addDocumentListener(new OnChangeTextUpdateDisplay());
|
|
||||||
labelFilterRules.setText("Text:");
|
|
||||||
labelFilterRules.setToolTipText("Card descriptions must include the text in this field");
|
|
||||||
this.getContentPane().add(labelFilterRules, "");
|
|
||||||
this.getContentPane().add(txtCardRules, "wmin 200, grow");
|
|
||||||
txtCardRules.getDocument().addDocumentListener(new OnChangeTextUpdateDisplay());
|
|
||||||
|
|
||||||
searchSetCombo.removeAllItems();
|
|
||||||
searchSetCombo.addItem("");
|
|
||||||
for (int i = 0; i < SetUtils.getNameList().size(); i++)
|
|
||||||
searchSetCombo.addItem(SetUtils.getNameList().get(i));
|
|
||||||
searchSetCombo.addItemListener(itemListenerUpdatesDisplay);
|
|
||||||
|
|
||||||
this.getContentPane().add(searchSetCombo, "wmin 150, grow");
|
|
||||||
|
|
||||||
this.getContentPane().add(top.getLabel(), "cell 0 4");
|
this.getContentPane().add(top.getLabel(), "cell 0 4");
|
||||||
|
|
||||||
this.getContentPane().add(addButton, "w 100, h 49, sg button, cell 0 5, split 4");
|
this.getContentPane().add(addButton, "w 100, h 49, sg button, cell 0 5, split 4");
|
||||||
@@ -292,8 +245,8 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
|||||||
|
|
||||||
// jLabel4 is used to push the analysis button to the right
|
// jLabel4 is used to push the analysis button to the right
|
||||||
// This will separate this button from the add and remove card buttons
|
// This will separate this button from the add and remove card buttons
|
||||||
jLabel4.setText("");
|
jLabelAnalysisGap.setText("");
|
||||||
this.getContentPane().add(jLabel4, "wmin 100, grow");
|
this.getContentPane().add(jLabelAnalysisGap, "wmin 100, grow");
|
||||||
|
|
||||||
this.getContentPane().add(analysisButton, "w 100, h 49, wrap");
|
this.getContentPane().add(analysisButton, "w 100, h 49, wrap");
|
||||||
|
|
||||||
@@ -312,26 +265,7 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Predicate<CardPrinted> buildFilter() {
|
protected Predicate<CardPrinted> buildFilter() {
|
||||||
List<Predicate<CardPrinted>> rules = new ArrayList<Predicate<CardPrinted>>(5);
|
return Predicate.and(filterBoxes.buildFilter(), filterNameTypeSet.buildFilter());
|
||||||
rules.add(super.buildFilter());
|
|
||||||
if (StringUtils.isNotBlank(txtCardName.getText())) {
|
|
||||||
rules.add(CardPrinted.Predicates.name(StringOp.CONTAINS, txtCardName.getText()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(txtCardType.getText())) {
|
|
||||||
rules.add(Predicate.brigde(CardRules.Predicates.joinedType(StringOp.CONTAINS, txtCardType.getText()), CardPrinted.fnGetRules));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(txtCardRules.getText())) {
|
|
||||||
rules.add(Predicate.brigde(CardRules.Predicates.rules(StringOp.CONTAINS, txtCardRules.getText()), CardPrinted.fnGetRules));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (searchSetCombo.getSelectedIndex() != 0) {
|
|
||||||
String setCode = SetUtils.getCode3ByName(searchSetCombo.getSelectedItem().toString());
|
|
||||||
rules.add(CardPrinted.Predicates.printedInSets(setCode));
|
|
||||||
}
|
|
||||||
|
|
||||||
return rules.size() == 1 ? rules.get(0) : Predicate.and(rules);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearFilterButton_actionPerformed(ActionEvent e) {
|
void clearFilterButton_actionPerformed(ActionEvent e) {
|
||||||
@@ -341,24 +275,13 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
|||||||
for (JCheckBox box : filterBoxes.allTypes) { if (!box.isSelected()) { box.doClick(); } }
|
for (JCheckBox box : filterBoxes.allTypes) { if (!box.isSelected()) { box.doClick(); } }
|
||||||
for (JCheckBox box : filterBoxes.allColors) { if (!box.isSelected()) { box.doClick(); } }
|
for (JCheckBox box : filterBoxes.allColors) { if (!box.isSelected()) { box.doClick(); } }
|
||||||
|
|
||||||
txtCardName.setText("");
|
filterNameTypeSet.clearFilters();
|
||||||
txtCardType.setText("");
|
|
||||||
txtCardRules.setText("");
|
|
||||||
searchSetCombo.setSelectedIndex(0);
|
|
||||||
|
|
||||||
isFiltersChangeFiringUpdate = true;
|
isFiltersChangeFiringUpdate = true;
|
||||||
|
|
||||||
top.setFilter(null);
|
top.setFilter(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* addButton_actionPerformed.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param e
|
|
||||||
* a {@link java.awt.event.ActionEvent} object.
|
|
||||||
*/
|
|
||||||
void addButton_actionPerformed(ActionEvent e) {
|
void addButton_actionPerformed(ActionEvent e) {
|
||||||
addCardToDeck();
|
addCardToDeck();
|
||||||
}
|
}
|
||||||
@@ -375,14 +298,6 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* removeButton_actionPerformed.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param e
|
|
||||||
* a {@link java.awt.event.ActionEvent} object.
|
|
||||||
*/
|
|
||||||
void removeButtonClicked(ActionEvent e) {
|
void removeButtonClicked(ActionEvent e) {
|
||||||
CardPrinted card = bottom.getSelectedCard();
|
CardPrinted card = bottom.getSelectedCard();
|
||||||
if (card == null) { return; }
|
if (card == null) { return; }
|
||||||
@@ -417,30 +332,4 @@ public final class DeckEditor extends DeckEditorBase implements NewConstants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class OnChangeTextUpdateDisplay implements DocumentListener {
|
|
||||||
//private String lastText = "";
|
|
||||||
private void onChange() {
|
|
||||||
//String newValue = getTextFromDocument(e.getDocument();
|
|
||||||
//System.out.println(String.format("%s --> %s", lastText, nowText));
|
|
||||||
if (isFiltersChangeFiringUpdate) { updateDisplay(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
private String getTextFromDocument(final Document doc) {
|
|
||||||
try {
|
|
||||||
return doc.getText(0, doc.getLength());
|
|
||||||
} catch (BadLocationException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override public void insertUpdate(DocumentEvent e) { onChange(); }
|
|
||||||
@Override public void removeUpdate(DocumentEvent e) { onChange(); }
|
|
||||||
|
|
||||||
// Happend only on ENTER pressed
|
|
||||||
@Override public void changedUpdate(DocumentEvent e) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import java.awt.event.ItemListener;
|
|||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.event.DocumentEvent;
|
||||||
|
import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
@@ -38,12 +40,7 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay {
|
|||||||
|
|
||||||
// THIS IS HERE FOR OVERLOADING!!!1
|
// THIS IS HERE FOR OVERLOADING!!!1
|
||||||
// or may be return abstract getFilter from derived class + this filter ... virtual protected member, but later
|
// or may be return abstract getFilter from derived class + this filter ... virtual protected member, but later
|
||||||
protected Predicate<CardPrinted> buildFilter() {
|
protected abstract Predicate<CardPrinted> buildFilter();
|
||||||
if (null == filterBoxes) {
|
|
||||||
return Predicate.getTrue(CardPrinted.class);
|
|
||||||
}
|
|
||||||
return filterBoxes.buildFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
void analysisButton_actionPerformed(ActionEvent e) {
|
void analysisButton_actionPerformed(ActionEvent e) {
|
||||||
CardPoolView deck = bottom.getCards();
|
CardPoolView deck = bottom.getCards();
|
||||||
@@ -57,12 +54,6 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay {
|
|||||||
g.setEnabled(false);
|
g.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemListener itemListenerUpdatesDisplay = new ItemListener() {
|
|
||||||
public void itemStateChanged(ItemEvent e) {
|
|
||||||
if (isFiltersChangeFiringUpdate) { updateDisplay(); }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public void setDecks(CardPoolView topParam, CardPoolView bottomParam) {
|
public void setDecks(CardPoolView topParam, CardPoolView bottomParam) {
|
||||||
top.setDeck(topParam);
|
top.setDeck(topParam);
|
||||||
@@ -73,4 +64,16 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay {
|
|||||||
top.setFilter(buildFilter());
|
top.setFilter(buildFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ItemListener itemListenerUpdatesDisplay = new ItemListener() {
|
||||||
|
public void itemStateChanged(ItemEvent e) {
|
||||||
|
if (isFiltersChangeFiringUpdate) { updateDisplay(); }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
protected class OnChangeTextUpdateDisplay implements DocumentListener {
|
||||||
|
private void onChange() { if (isFiltersChangeFiringUpdate) { updateDisplay(); } }
|
||||||
|
@Override public void insertUpdate(DocumentEvent e) { onChange(); }
|
||||||
|
@Override public void removeUpdate(DocumentEvent e) { onChange(); }
|
||||||
|
@Override public void changedUpdate(DocumentEvent e) { } // Happend only on ENTER pressed
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ import forge.properties.NewConstants;
|
|||||||
import forge.view.swing.OldGuiNewGame;
|
import forge.view.swing.OldGuiNewGame;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -93,6 +96,7 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
columns.add(new TableColumnInfo<CardPrinted>("R", 35, PresetColumns.fnRarityCompare, PresetColumns.fnRarityGet));
|
columns.add(new TableColumnInfo<CardPrinted>("R", 35, PresetColumns.fnRarityCompare, PresetColumns.fnRarityGet));
|
||||||
columns.add(new TableColumnInfo<CardPrinted>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
columns.add(new TableColumnInfo<CardPrinted>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
||||||
columns.add(new TableColumnInfo<CardPrinted>("AI", 30, PresetColumns.fnAiStatusCompare, PresetColumns.fnAiStatusGet));
|
columns.add(new TableColumnInfo<CardPrinted>("AI", 30, PresetColumns.fnAiStatusCompare, PresetColumns.fnAiStatusGet));
|
||||||
|
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
||||||
|
|
||||||
top.setup(columns, cardView);
|
top.setup(columns, cardView);
|
||||||
bottom.setup(columns, cardView);
|
bottom.setup(columns, cardView);
|
||||||
@@ -267,4 +271,10 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
dispose();
|
dispose();
|
||||||
new OldGuiNewGame();
|
new OldGuiNewGame();
|
||||||
}/*saveDraft()*/
|
}/*saveDraft()*/
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Predicate<CardPrinted> buildFilter() {
|
||||||
|
return CardPrinted.Predicates.Presets.isTrue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
//import forge.quest.data.QuestBoosterPack;
|
//import forge.quest.data.QuestBoosterPack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,11 +49,14 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
// private ImageIcon upIcon = Constant.IO.upIcon;
|
// private ImageIcon upIcon = Constant.IO.upIcon;
|
||||||
// private ImageIcon downIcon = Constant.IO.downIcon;
|
// private ImageIcon downIcon = Constant.IO.downIcon;
|
||||||
|
|
||||||
|
//private JLabel labelSortHint = new JLabel();
|
||||||
private JButton addButton = new JButton();
|
private JButton addButton = new JButton();
|
||||||
private JButton removeButton = new JButton();
|
private JButton removeButton = new JButton();
|
||||||
private JButton analysisButton = new JButton();
|
private JButton analysisButton = new JButton();
|
||||||
private JLabel labelSortHint = new JLabel();
|
|
||||||
|
|
||||||
|
private FilterNameTypeSetPanel filterNameTypeSet;
|
||||||
|
|
||||||
private QuestData questData;
|
private QuestData questData;
|
||||||
|
|
||||||
|
|
||||||
@@ -116,6 +121,8 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
this.setLayout(null);
|
||||||
|
|
||||||
List<TableColumnInfo<CardPrinted>> columns = new ArrayList<TableColumnInfo<CardPrinted>>();
|
List<TableColumnInfo<CardPrinted>> columns = new ArrayList<TableColumnInfo<CardPrinted>>();
|
||||||
columns.add(new TableColumnInfo<CardPrinted>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
columns.add(new TableColumnInfo<CardPrinted>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
||||||
columns.add(new TableColumnInfo<CardPrinted>("Name", 180, PresetColumns.fnNameCompare, PresetColumns.fnNameGet));
|
columns.add(new TableColumnInfo<CardPrinted>("Name", 180, PresetColumns.fnNameCompare, PresetColumns.fnNameGet));
|
||||||
@@ -131,6 +138,8 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
|
|
||||||
top.setup(columns, cardView);
|
top.setup(columns, cardView);
|
||||||
bottom.setup(columns, cardView);
|
bottom.setup(columns, cardView);
|
||||||
|
|
||||||
|
filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), itemListenerUpdatesDisplay);
|
||||||
|
|
||||||
this.setSize(1024, 768);
|
this.setSize(1024, 768);
|
||||||
GuiUtils.centerFrame(this);
|
GuiUtils.centerFrame(this);
|
||||||
@@ -149,6 +158,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
top = new TableWithCards("All Cards", true);
|
top = new TableWithCards("All Cards", true);
|
||||||
bottom = new TableWithCards("Your deck", true);
|
bottom = new TableWithCards("Your deck", true);
|
||||||
cardView = new CardPanelHeavy();
|
cardView = new CardPanelHeavy();
|
||||||
|
filterNameTypeSet = new FilterNameTypeSetPanel();
|
||||||
jbInit();
|
jbInit();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ErrorViewer.showError(ex);
|
ErrorViewer.showError(ex);
|
||||||
@@ -157,10 +167,15 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
|
|
||||||
|
|
||||||
private void jbInit() throws Exception {
|
private void jbInit() throws Exception {
|
||||||
this.setLayout(null);
|
this.getContentPane().setLayout(null);
|
||||||
|
|
||||||
top.getTableDecorated().setBounds(new Rectangle(19, 20, 726, 346));
|
//labelSortHint.setText("Click on the column name (like name or color) to sort the cards");
|
||||||
|
//labelSortHint.setBounds(new Rectangle(20, 27, 400, 19));
|
||||||
|
|
||||||
|
filterNameTypeSet.setBounds(new Rectangle(19, 10, 726, 25));
|
||||||
|
top.getTableDecorated().setBounds(new Rectangle(19, 40, 726, 316));
|
||||||
bottom.getTableDecorated().setBounds(new Rectangle(19, 458, 726, 218));
|
bottom.getTableDecorated().setBounds(new Rectangle(19, 458, 726, 218));
|
||||||
|
|
||||||
|
|
||||||
removeButton.setBounds(new Rectangle(180, 403, 146, 49));
|
removeButton.setBounds(new Rectangle(180, 403, 146, 49));
|
||||||
// removeButton.setIcon(upIcon);
|
// removeButton.setIcon(upIcon);
|
||||||
@@ -236,9 +251,8 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
// x 768 screen size
|
// x 768 screen size
|
||||||
this.setTitle("Deck Editor");
|
this.setTitle("Deck Editor");
|
||||||
|
|
||||||
labelSortHint.setText("Click on the column name (like name or color) to sort the cards");
|
|
||||||
labelSortHint.setBounds(new Rectangle(20, 1, 400, 19));
|
|
||||||
|
|
||||||
|
this.getContentPane().add(filterNameTypeSet, null);
|
||||||
this.getContentPane().add(top.getTableDecorated(), null);
|
this.getContentPane().add(top.getTableDecorated(), null);
|
||||||
this.getContentPane().add(bottom.getTableDecorated(), null);
|
this.getContentPane().add(bottom.getTableDecorated(), null);
|
||||||
this.getContentPane().add(addButton, null);
|
this.getContentPane().add(addButton, null);
|
||||||
@@ -246,7 +260,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
this.getContentPane().add(analysisButton, null);
|
this.getContentPane().add(analysisButton, null);
|
||||||
this.getContentPane().add(bottom.getLabel(), null);
|
this.getContentPane().add(bottom.getLabel(), null);
|
||||||
this.getContentPane().add(top.getLabel(), null);
|
this.getContentPane().add(top.getLabel(), null);
|
||||||
this.getContentPane().add(labelSortHint, null);
|
//this.getContentPane().add(labelSortHint, null);
|
||||||
this.getContentPane().add(cardView, null);
|
this.getContentPane().add(cardView, null);
|
||||||
|
|
||||||
for (JCheckBox box : filterBoxes.allTypes) {
|
for (JCheckBox box : filterBoxes.allTypes) {
|
||||||
@@ -266,6 +280,11 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Predicate<CardPrinted> buildFilter() {
|
||||||
|
return Predicate.and(filterBoxes.buildFilter(), filterNameTypeSet.buildFilter());
|
||||||
|
}
|
||||||
|
|
||||||
private void addButtonActionPerformed(final ActionEvent e) {
|
private void addButtonActionPerformed(final ActionEvent e) {
|
||||||
CardPrinted card = top.getSelectedCard();
|
CardPrinted card = top.getSelectedCard();
|
||||||
if (card == null) { return; }
|
if (card == null) { return; }
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import javax.swing.JLabel;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.ReadPriceList;
|
import forge.ReadPriceList;
|
||||||
@@ -269,8 +270,12 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Predicate<CardPrinted> buildFilter() {
|
||||||
|
return CardPrinted.Predicates.Presets.isTrue;
|
||||||
|
}
|
||||||
|
|
||||||
void sellButton_actionPerformed(ActionEvent e) {
|
private void sellButton_actionPerformed(ActionEvent e) {
|
||||||
CardPrinted c = bottom.getSelectedCard();
|
CardPrinted c = bottom.getSelectedCard();
|
||||||
if (c == null) { return; }
|
if (c == null) { return; }
|
||||||
|
|
||||||
|
|||||||
112
src/main/java/forge/gui/deckeditor/FilterNameTypeSetPanel.java
Normal file
112
src/main/java/forge/gui/deckeditor/FilterNameTypeSetPanel.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package forge.gui.deckeditor;
|
||||||
|
|
||||||
|
import java.awt.event.ItemListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
import net.slightlymagic.maxmtg.Predicate.StringOp;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import forge.SetUtils;
|
||||||
|
import forge.card.CardPrinted;
|
||||||
|
import forge.card.CardRules;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A panel that holds Name, Type, Rules text fields aligned horizontally together with set filter
|
||||||
|
*/
|
||||||
|
public class FilterNameTypeSetPanel extends JComponent{
|
||||||
|
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -6409564625432765430L;
|
||||||
|
public final JLabel labelFilterName = new JLabel();
|
||||||
|
public final JLabel labelFilterType = new JLabel();
|
||||||
|
public final JLabel labelFilterRules = new JLabel();
|
||||||
|
|
||||||
|
public final JTextField txtCardName = new JTextField();
|
||||||
|
public final JTextField txtCardType = new JTextField();
|
||||||
|
public final JTextField txtCardRules = new JTextField();
|
||||||
|
public final JComboBox searchSetCombo = new JComboBox();
|
||||||
|
|
||||||
|
|
||||||
|
public FilterNameTypeSetPanel()
|
||||||
|
{
|
||||||
|
this.setLayout(new MigLayout("fill, ins 0"));
|
||||||
|
|
||||||
|
labelFilterName.setText("Name:");
|
||||||
|
labelFilterName.setToolTipText("Card names must include the text in this field");
|
||||||
|
this.add(labelFilterName, "cell 0 1, split 7");
|
||||||
|
this.add(txtCardName, "wmin 100, grow");
|
||||||
|
|
||||||
|
labelFilterType.setText("Type:");
|
||||||
|
labelFilterType.setToolTipText("Card types must include the text in this field");
|
||||||
|
this.add(labelFilterType, "");
|
||||||
|
this.add(txtCardType, "wmin 100, grow");
|
||||||
|
|
||||||
|
labelFilterRules.setText("Text:");
|
||||||
|
labelFilterRules.setToolTipText("Card descriptions must include the text in this field");
|
||||||
|
this.add(labelFilterRules, "");
|
||||||
|
this.add(txtCardRules, "wmin 200, grow");
|
||||||
|
|
||||||
|
|
||||||
|
searchSetCombo.removeAllItems();
|
||||||
|
searchSetCombo.addItem("");
|
||||||
|
for (int i = 0; i < SetUtils.getNameList().size(); i++)
|
||||||
|
searchSetCombo.addItem(SetUtils.getNameList().get(i));
|
||||||
|
|
||||||
|
this.add(searchSetCombo, "wmin 150, grow");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListeners(DocumentListener onTextChange, ItemListener onComboChange)
|
||||||
|
{
|
||||||
|
txtCardType.getDocument().addDocumentListener(onTextChange);
|
||||||
|
txtCardRules.getDocument().addDocumentListener(onTextChange);
|
||||||
|
txtCardName.getDocument().addDocumentListener(onTextChange);
|
||||||
|
searchSetCombo.addItemListener(onComboChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Predicate<CardPrinted> buildFilter() {
|
||||||
|
List<Predicate<CardPrinted>> rules = new ArrayList<Predicate<CardPrinted>>(4);
|
||||||
|
if (StringUtils.isNotBlank(txtCardName.getText())) {
|
||||||
|
rules.add(CardPrinted.Predicates.name(StringOp.CONTAINS, txtCardName.getText()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(txtCardType.getText())) {
|
||||||
|
rules.add(Predicate.brigde(CardRules.Predicates.joinedType(StringOp.CONTAINS, txtCardType.getText()), CardPrinted.fnGetRules));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(txtCardRules.getText())) {
|
||||||
|
rules.add(Predicate.brigde(CardRules.Predicates.rules(StringOp.CONTAINS, txtCardRules.getText()), CardPrinted.fnGetRules));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchSetCombo.getSelectedIndex() != 0) {
|
||||||
|
String setCode = SetUtils.getCode3ByName(searchSetCombo.getSelectedItem().toString());
|
||||||
|
rules.add(CardPrinted.Predicates.printedInSets(setCode));
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (rules.size()){
|
||||||
|
case 0: return Predicate.getTrue(CardPrinted.class);
|
||||||
|
case 1: return rules.get(0);
|
||||||
|
case 2: return Predicate.and(rules.get(0), rules.get(1));
|
||||||
|
default: return Predicate.and(rules);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
*/
|
||||||
|
public void clearFilters() {
|
||||||
|
txtCardName.setText("");
|
||||||
|
txtCardType.setText("");
|
||||||
|
txtCardRules.setText("");
|
||||||
|
searchSetCombo.setSelectedIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -121,17 +121,19 @@ public final class TableWithCards {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDeck(final Iterable<CardPrinted> cards) {
|
public void setDeck(final Iterable<CardPrinted> cards) {
|
||||||
model.clear();
|
setDeckImpl(new CardPool(cards));
|
||||||
pool = new CardPool(cards);
|
|
||||||
model.addCards(pool);
|
|
||||||
updateView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeck(final CardPoolView poolView) {
|
public void setDeck(final CardPoolView poolView) {
|
||||||
|
setDeckImpl(new CardPool(poolView));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDeckImpl(CardPool thePool)
|
||||||
|
{
|
||||||
model.clear();
|
model.clear();
|
||||||
pool = new CardPool(poolView);
|
pool = thePool;
|
||||||
model.addCards(pool);
|
model.addCards(pool);
|
||||||
updateView();
|
updateView(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CardPrinted getSelectedCard() {
|
public CardPrinted getSelectedCard() {
|
||||||
@@ -140,36 +142,37 @@ public final class TableWithCards {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUnfiltered() { return filter == null || filter.is1(); }
|
private boolean isUnfiltered() { return filter == null || filter.is1(); }
|
||||||
private boolean isFiltered() { return filter != null && !filter.is1(); }
|
|
||||||
|
|
||||||
public void setFilter(final Predicate<CardPrinted> filterToSet) {
|
public void setFilter(final Predicate<CardPrinted> filterToSet) {
|
||||||
filter = filterToSet;
|
filter = filterToSet;
|
||||||
updateView();
|
updateView(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCard(final CardPrinted card) {
|
public void addCard(final CardPrinted card) {
|
||||||
//int n = table.getSelectedRow();
|
//int n = table.getSelectedRow();
|
||||||
pool.add(card);
|
pool.add(card);
|
||||||
if (isUnfiltered()) { model.addCard(card); }
|
if (isUnfiltered()) { model.addCard(card); }
|
||||||
updateView();
|
updateView(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCard(final CardPrinted card) {
|
public void removeCard(final CardPrinted card) {
|
||||||
int n = table.getSelectedRow();
|
int n = table.getSelectedRow();
|
||||||
pool.remove(card);
|
pool.remove(card);
|
||||||
if (isUnfiltered()) { model.removeCard(card); }
|
if (isUnfiltered()) { model.removeCard(card); }
|
||||||
updateView();
|
updateView(false);
|
||||||
fixSelection(n);
|
fixSelection(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateView() {
|
public void updateView(boolean bForceFilter) {
|
||||||
if (isFiltered() || wantUnique) {
|
boolean useFilter = ( bForceFilter && filter != null ) || !isUnfiltered();
|
||||||
|
|
||||||
|
if (useFilter || wantUnique) {
|
||||||
model.clear();
|
model.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFiltered() && wantUnique) {
|
if (useFilter && wantUnique) {
|
||||||
model.addCards(filter.uniqueByLast(pool, CardPoolView.fnToCardName, CardPoolView.fnToPrinted));
|
model.addCards(filter.uniqueByLast(pool, CardPoolView.fnToCardName, CardPoolView.fnToPrinted));
|
||||||
} else if (isFiltered()) {
|
} else if (useFilter) {
|
||||||
model.addCards(filter.select(pool, CardPoolView.fnToPrinted));
|
model.addCards(filter.select(pool, CardPoolView.fnToPrinted));
|
||||||
} else if (wantUnique) {
|
} else if (wantUnique) {
|
||||||
model.addCards(CardRules.Predicates.Presets.constantTrue.uniqueByLast(pool, CardPoolView.fnToCardName, CardPoolView.fnToCard));
|
model.addCards(CardRules.Predicates.Presets.constantTrue.uniqueByLast(pool, CardPoolView.fnToCardName, CardPoolView.fnToCard));
|
||||||
|
|||||||
Reference in New Issue
Block a user