mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
checkstyle
This commit is contained in:
@@ -14,7 +14,9 @@ public abstract class CardPanelBase extends JPanel {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* showCard.
|
* showCard.
|
||||||
* @param card an InventoryItem
|
*
|
||||||
|
* @param card
|
||||||
|
* an InventoryItem
|
||||||
*/
|
*/
|
||||||
public abstract void showCard(InventoryItem card);
|
public abstract void showCard(InventoryItem card);
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,8 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import arcane.ui.CardPanel;
|
import arcane.ui.CardPanel;
|
||||||
import arcane.ui.ViewPanel;
|
import arcane.ui.ViewPanel;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.GuiDisplayUtil;
|
import forge.GuiDisplayUtil;
|
||||||
import forge.ImagePreviewPanel;
|
import forge.ImagePreviewPanel;
|
||||||
@@ -24,10 +22,8 @@ import forge.item.InventoryItem;
|
|||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This panel is to be placed in the right part of a deck editor
|
* This panel is to be placed in the right part of a deck editor.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CardPanelHeavy extends CardPanelBase {
|
public class CardPanelHeavy extends CardPanelBase {
|
||||||
|
|
||||||
@@ -36,50 +32,58 @@ public class CardPanelHeavy extends CardPanelBase {
|
|||||||
private JButton changeStateButton = new JButton();
|
private JButton changeStateButton = new JButton();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Removed Oct 25 2011 - Hellfish
|
* Removed Oct 25 2011 - Hellfish private JButton changePictureButton = new
|
||||||
private JButton changePictureButton = new JButton();
|
* JButton(); private JButton removePictureButton = new JButton();
|
||||||
private JButton removePictureButton = new JButton();
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Controls to show card details
|
// Controls to show card details
|
||||||
|
/** The detail. */
|
||||||
protected CardDetailPanel detail = new CardDetailPanel(null);
|
protected CardDetailPanel detail = new CardDetailPanel(null);
|
||||||
|
|
||||||
|
/** The picture. */
|
||||||
protected CardPanel picture = new CardPanel(null);
|
protected CardPanel picture = new CardPanel(null);
|
||||||
|
|
||||||
|
/** The picture view panel. */
|
||||||
protected ViewPanel pictureViewPanel = new ViewPanel();
|
protected ViewPanel pictureViewPanel = new ViewPanel();
|
||||||
|
|
||||||
// fake card to allow picture changes
|
// fake card to allow picture changes
|
||||||
|
/** The c card hq. */
|
||||||
public Card cCardHQ;
|
public Card cCardHQ;
|
||||||
/** Constant <code>previousDirectory</code> */
|
|
||||||
|
/** Constant <code>previousDirectory</code>. */
|
||||||
protected static File previousDirectory = null;
|
protected static File previousDirectory = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new card panel heavy.
|
||||||
|
*/
|
||||||
public CardPanelHeavy() {
|
public CardPanelHeavy() {
|
||||||
changeStateButton.setVisible(false);
|
changeStateButton.setVisible(false);
|
||||||
changeStateButton.addActionListener(new java.awt.event.ActionListener() {
|
changeStateButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
changeStateButton_actionPerformed(e);
|
changeStateButton_actionPerformed(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
changeStateButton.setFont(new java.awt.Font("Dialog", 0, 10));
|
changeStateButton.setFont(new java.awt.Font("Dialog", 0, 10));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Removed Oct 25 2011 - Hellfish
|
* Removed Oct 25 2011 - Hellfish
|
||||||
changePictureButton.setText("Change picture...");
|
* changePictureButton.setText("Change picture...");
|
||||||
changePictureButton.addActionListener(new java.awt.event.ActionListener() {
|
* changePictureButton.addActionListener(new
|
||||||
public void actionPerformed(ActionEvent e) {
|
* java.awt.event.ActionListener() { public void
|
||||||
changePictureButton_actionPerformed(e);
|
* actionPerformed(ActionEvent e) {
|
||||||
}
|
* changePictureButton_actionPerformed(e); } }); if
|
||||||
});
|
* (!Singletons.getModel().getPreferences().lafFonts)
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
* changePictureButton.setFont(new java.awt.Font("Dialog", 0, 10));
|
||||||
changePictureButton.setFont(new java.awt.Font("Dialog", 0, 10));
|
*
|
||||||
|
* removePictureButton.setText("Remove picture...");
|
||||||
removePictureButton.setText("Remove picture...");
|
* removePictureButton.addActionListener(new
|
||||||
removePictureButton.addActionListener(new java.awt.event.ActionListener() {
|
* java.awt.event.ActionListener() { public void
|
||||||
public void actionPerformed(ActionEvent e) {
|
* actionPerformed(ActionEvent e) {
|
||||||
removePictureButton_actionPerformed(e);
|
* removePictureButton_actionPerformed(e); } }); if
|
||||||
}
|
* (!Singletons.getModel().getPreferences().lafFonts)
|
||||||
});
|
* removePictureButton.setFont(new java.awt.Font("Dialog", 0, 10));
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
|
||||||
removePictureButton.setFont(new java.awt.Font("Dialog", 0, 10));
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pictureViewPanel.setCardPanel(picture);
|
pictureViewPanel.setCardPanel(picture);
|
||||||
@@ -87,21 +91,33 @@ public class CardPanelHeavy extends CardPanelBase {
|
|||||||
this.setLayout(new MigLayout("fill, ins 0"));
|
this.setLayout(new MigLayout("fill, ins 0"));
|
||||||
this.add(detail, "w 239, h 323, grow, flowy, wrap");
|
this.add(detail, "w 239, h 323, grow, flowy, wrap");
|
||||||
/*
|
/*
|
||||||
* Removed Oct 25 2011 - Hellfish
|
* Removed Oct 25 2011 - Hellfish this.add(changeStateButton,
|
||||||
this.add(changeStateButton, "align 50% 0%, split 3, flowx");
|
* "align 50% 0%, split 3, flowx"); this.add(changePictureButton,
|
||||||
this.add(changePictureButton, "align 50% 0%");
|
* "align 50% 0%"); this.add(removePictureButton, "align 50% 0%, wrap");
|
||||||
this.add(removePictureButton, "align 50% 0%, wrap");
|
|
||||||
*/
|
*/
|
||||||
this.add(changeStateButton, "align 50% 0%, flowx, wrap");
|
this.add(changeStateButton, "align 50% 0%, flowx, wrap");
|
||||||
this.add(pictureViewPanel, "wmin 239, hmin 323, grow");
|
this.add(pictureViewPanel, "wmin 239, hmin 323, grow");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showCard(InventoryItem card) {
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* forge.gui.deckeditor.CardPanelBase#showCard(forge.item.InventoryItem)
|
||||||
|
*/
|
||||||
|
public final void showCard(final InventoryItem card) {
|
||||||
Card card2 = card instanceof CardPrinted ? ((CardPrinted) card).toForgeCard() : null;
|
Card card2 = card instanceof CardPrinted ? ((CardPrinted) card).toForgeCard() : null;
|
||||||
detail.setCard(card2);
|
detail.setCard(card2);
|
||||||
setCard(card2);
|
setCard(card2);
|
||||||
}
|
}
|
||||||
public void setCard(Card c) {
|
|
||||||
|
/**
|
||||||
|
* Sets the card.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* the new card
|
||||||
|
*/
|
||||||
|
public final void setCard(final Card c) {
|
||||||
if (picture.getCard() != null) {
|
if (picture.getCard() != null) {
|
||||||
if (picture.getCard().isInAlternateState()) {
|
if (picture.getCard().isInAlternateState()) {
|
||||||
picture.getCard().changeState();
|
picture.getCard().changeState();
|
||||||
@@ -113,12 +129,10 @@ public class CardPanelHeavy extends CardPanelBase {
|
|||||||
changeStateButton.setVisible(true);
|
changeStateButton.setVisible(true);
|
||||||
if (c.isFlip()) {
|
if (c.isFlip()) {
|
||||||
changeStateButton.setText("Flip");
|
changeStateButton.setText("Flip");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
changeStateButton.setText("Transform");
|
changeStateButton.setText("Transform");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
changeStateButton.setVisible(false);
|
changeStateButton.setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,7 +145,7 @@ public class CardPanelHeavy extends CardPanelBase {
|
|||||||
* @param e
|
* @param e
|
||||||
* a {@link java.awt.event.ActionEvent} object.
|
* a {@link java.awt.event.ActionEvent} object.
|
||||||
*/
|
*/
|
||||||
void changeStateButton_actionPerformed(ActionEvent e) {
|
final void changeStateButton_actionPerformed(final ActionEvent e) {
|
||||||
Card cur = picture.getCard();
|
Card cur = picture.getCard();
|
||||||
cur.changeState();
|
cur.changeState();
|
||||||
|
|
||||||
@@ -147,7 +161,7 @@ public class CardPanelHeavy extends CardPanelBase {
|
|||||||
* @param e
|
* @param e
|
||||||
* a {@link java.awt.event.ActionEvent} object.
|
* a {@link java.awt.event.ActionEvent} object.
|
||||||
*/
|
*/
|
||||||
void changePictureButton_actionPerformed(ActionEvent e) {
|
final void changePictureButton_actionPerformed(final ActionEvent e) {
|
||||||
if (cCardHQ != null) {
|
if (cCardHQ != null) {
|
||||||
File file = getImportFilename();
|
File file = getImportFilename();
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
@@ -159,7 +173,8 @@ public class CardPanelHeavy extends CardPanelBase {
|
|||||||
try {
|
try {
|
||||||
org.apache.commons.io.FileUtils.copyFile(file, f);
|
org.apache.commons.io.FileUtils.copyFile(file, f);
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
// TODO Auto-generated catch block ignores the exception, but sends it to System.err and probably forge.log.
|
// TODO Auto-generated catch block ignores the exception,
|
||||||
|
// but sends it to System.err and probably forge.log.
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
setCard(cCardHQ);
|
setCard(cCardHQ);
|
||||||
@@ -192,10 +207,11 @@ public class CardPanelHeavy extends CardPanelBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The dck filter. */
|
||||||
protected FileFilter dckFilter = new FileFilter() {
|
protected FileFilter dckFilter = new FileFilter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File f) {
|
public boolean accept(final File f) {
|
||||||
return f.getName().endsWith(".jpg") || f.isDirectory();
|
return f.getName().endsWith(".jpg") || f.isDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,11 +223,15 @@ public class CardPanelHeavy extends CardPanelBase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <p>
|
||||||
|
* removePictureButton_actionPerformed
|
||||||
|
* </p>
|
||||||
|
* . Removed Oct 25 2011 - Hellfish
|
||||||
*
|
*
|
||||||
* <p>removePictureButton_actionPerformed</p>. Removed Oct 25 2011 - Hellfish
|
|
||||||
* @param e
|
* @param e
|
||||||
|
* the e
|
||||||
*/
|
*/
|
||||||
void removePictureButton_actionPerformed(ActionEvent e) {
|
final void removePictureButton_actionPerformed(final ActionEvent e) {
|
||||||
if (cCardHQ != null) {
|
if (cCardHQ != null) {
|
||||||
String options[] = { "Yes", "No" };
|
String options[] = { "Yes", "No" };
|
||||||
int value = JOptionPane.showOptionDialog(null, "Do you want delete " + cCardHQ.getName() + " picture?",
|
int value = JOptionPane.showOptionDialog(null, "Do you want delete " + cCardHQ.getName() + " picture?",
|
||||||
@@ -229,6 +249,13 @@ public class CardPanelHeavy extends CardPanelBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Card getCard() { return detail.getCard(); }
|
/**
|
||||||
|
* Gets the card.
|
||||||
|
*
|
||||||
|
* @return the card
|
||||||
|
*/
|
||||||
|
public final Card getCard() {
|
||||||
|
return detail.getCard();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.awt.event.ActionListener;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.gui.game.CardDetailPanel;
|
import forge.gui.game.CardDetailPanel;
|
||||||
@@ -23,6 +22,7 @@ public class CardPanelLite extends CardPanelBase {
|
|||||||
private static final long serialVersionUID = -7134546689397508597L;
|
private static final long serialVersionUID = -7134546689397508597L;
|
||||||
|
|
||||||
// Controls to show card details
|
// Controls to show card details
|
||||||
|
/** The detail. */
|
||||||
protected CardDetailPanel detail = new CardDetailPanel(null);
|
protected CardDetailPanel detail = new CardDetailPanel(null);
|
||||||
private CardPicturePanel picture = new CardPicturePanel(null);
|
private CardPicturePanel picture = new CardPicturePanel(null);
|
||||||
private JButton bChangeState = new JButton();
|
private JButton bChangeState = new JButton();
|
||||||
@@ -34,12 +34,13 @@ public class CardPanelLite extends CardPanelBase {
|
|||||||
public CardPanelLite() {
|
public CardPanelLite() {
|
||||||
bChangeState.setVisible(false);
|
bChangeState.setVisible(false);
|
||||||
bChangeState.addActionListener(new ActionListener() {
|
bChangeState.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
bChangeState_actionPerformed(e);
|
bChangeState_actionPerformed(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
bChangeState.setFont(new java.awt.Font("Dialog", 0, 10));
|
bChangeState.setFont(new java.awt.Font("Dialog", 0, 10));
|
||||||
|
}
|
||||||
|
|
||||||
this.setLayout(new MigLayout("fill, ins 0"));
|
this.setLayout(new MigLayout("fill, ins 0"));
|
||||||
this.add(detail, "w 239, h 303, grow, flowy, wrap");
|
this.add(detail, "w 239, h 303, grow, flowy, wrap");
|
||||||
@@ -66,15 +67,20 @@ public class CardPanelLite extends CardPanelBase {
|
|||||||
bChangeState.setVisible(true);
|
bChangeState.setVisible(true);
|
||||||
if (toSet.isFlip()) {
|
if (toSet.isFlip()) {
|
||||||
bChangeState.setText("Flip");
|
bChangeState.setText("Flip");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
bChangeState.setText("Transform");
|
bChangeState.setText("Transform");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCard(Card c) {
|
/**
|
||||||
|
* Sets the card.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* the new card
|
||||||
|
*/
|
||||||
|
public final void setCard(final Card c) {
|
||||||
picture.setCard(c);
|
picture.setCard(c);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
detail.setCard(c);
|
detail.setCard(c);
|
||||||
@@ -82,8 +88,7 @@ public class CardPanelLite extends CardPanelBase {
|
|||||||
bChangeState.setVisible(true);
|
bChangeState.setVisible(true);
|
||||||
if (c.isFlip()) {
|
if (c.isFlip()) {
|
||||||
bChangeState.setText("Flip");
|
bChangeState.setText("Flip");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
bChangeState.setText("Transform");
|
bChangeState.setText("Transform");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +105,7 @@ public class CardPanelLite extends CardPanelBase {
|
|||||||
return detail.getCard();
|
return detail.getCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bChangeState_actionPerformed(ActionEvent e) {
|
private void bChangeState_actionPerformed(final ActionEvent e) {
|
||||||
Card cur = detail.getCard();
|
Card cur = detail.getCard();
|
||||||
if (cur != null) {
|
if (cur != null) {
|
||||||
cur.changeState();
|
cur.changeState();
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import javax.swing.ImageIcon;
|
|||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom check box class for filter icon
|
* Custom check box class for filter icon.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class CheckBoxWithIcon extends JCheckBox {
|
public class CheckBoxWithIcon extends JCheckBox {
|
||||||
/* CHOPPIC */
|
/* CHOPPIC */
|
||||||
@@ -20,7 +19,15 @@ public class CheckBoxWithIcon extends JCheckBox {
|
|||||||
private String iconNo;
|
private String iconNo;
|
||||||
private CheckBoxWithIcon cb;
|
private CheckBoxWithIcon cb;
|
||||||
|
|
||||||
CheckBoxWithIcon(String filterName, String toolTip) {
|
/**
|
||||||
|
* Instantiates a new check box with icon.
|
||||||
|
*
|
||||||
|
* @param filterName
|
||||||
|
* the filter name
|
||||||
|
* @param toolTip
|
||||||
|
* the tool tip
|
||||||
|
*/
|
||||||
|
CheckBoxWithIcon(final String filterName, final String toolTip) {
|
||||||
super("", true);
|
super("", true);
|
||||||
cb = this;
|
cb = this;
|
||||||
iconYes = imagePath + "filter_" + filterName + "_y.png";
|
iconYes = imagePath + "filter_" + filterName + "_y.png";
|
||||||
@@ -28,7 +35,7 @@ public class CheckBoxWithIcon extends JCheckBox {
|
|||||||
this.setIcon(new ImageIcon(iconYes));
|
this.setIcon(new ImageIcon(iconYes));
|
||||||
this.setToolTipText(toolTip);
|
this.setToolTipText(toolTip);
|
||||||
this.addActionListener(new ActionListener() {
|
this.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(final ActionEvent actionEvent) {
|
||||||
if (cb.isSelected()) {
|
if (cb.isSelected()) {
|
||||||
cb.setIcon(new ImageIcon(iconYes));
|
cb.setIcon(new ImageIcon(iconYes));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import javax.swing.border.BevelBorder;
|
|||||||
import javax.swing.event.MouseInputAdapter;
|
import javax.swing.event.MouseInputAdapter;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
import forge.CardList;
|
import forge.CardList;
|
||||||
import forge.MyRandom;
|
import forge.MyRandom;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
@@ -35,8 +36,6 @@ import forge.card.CardType;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
|
* This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
|
||||||
* Builder, which is free for non-commercial use. If Jigloo is being used
|
* Builder, which is free for non-commercial use. If Jigloo is being used
|
||||||
@@ -99,7 +98,10 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
private JFrame jF;
|
private JFrame jF;
|
||||||
// private ButtonGroup buttonGroup1;
|
// private ButtonGroup buttonGroup1;
|
||||||
|
|
||||||
|
/** The filter card list. */
|
||||||
public CardList filterCardList;
|
public CardList filterCardList;
|
||||||
|
|
||||||
|
/** The deck. */
|
||||||
public ItemPoolView<CardPrinted> deck;
|
public ItemPoolView<CardPrinted> deck;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,10 +111,10 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
*
|
*
|
||||||
* @param g
|
* @param g
|
||||||
* a {@link javax.swing.JFrame} object.
|
* a {@link javax.swing.JFrame} object.
|
||||||
* @param tb
|
* @param deckView
|
||||||
* a {@link forge.gui.deckeditor.TableModel} object.
|
* the deck view
|
||||||
*/
|
*/
|
||||||
public DeckAnalysis(JFrame g, ItemPoolView<CardPrinted> deckView) {
|
public DeckAnalysis(final JFrame g, final ItemPoolView<CardPrinted> deckView) {
|
||||||
super(g);
|
super(g);
|
||||||
deck = deckView;
|
deck = deckView;
|
||||||
|
|
||||||
@@ -145,12 +147,12 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
|
|
||||||
this.addWindowListener(new WindowAdapter() {
|
this.addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent arg0) {
|
public void windowClosing(final WindowEvent arg0) {
|
||||||
jF.setEnabled(true);
|
jF.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowOpened(WindowEvent arg0) {
|
public void windowOpened(final WindowEvent arg0) {
|
||||||
|
|
||||||
int cBlack, cBlue, cGreen, cRed, cWhite, cMulticolor, cColorless, cLand;
|
int cBlack, cBlue, cGreen, cRed, cWhite, cMulticolor, cColorless, cLand;
|
||||||
int cArtifact, cCreature, cEnchant, cInstant, cLandType, cPlaneswalker, cSorcery;
|
int cArtifact, cCreature, cEnchant, cInstant, cLandType, cPlaneswalker, cSorcery;
|
||||||
@@ -188,36 +190,69 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
if (c.getColor().isMulticolor()) {
|
if (c.getColor().isMulticolor()) {
|
||||||
cMulticolor = cMulticolor + cnt;
|
cMulticolor = cMulticolor + cnt;
|
||||||
} else {
|
} else {
|
||||||
if (c.getColor().isBlack()) { cBlack = cBlack + cnt; }
|
if (c.getColor().isBlack()) {
|
||||||
if (c.getColor().isBlue()) { cBlue = cBlue + cnt; }
|
cBlack = cBlack + cnt;
|
||||||
if (c.getColor().isGreen()) { cGreen = cGreen + cnt; }
|
}
|
||||||
if (c.getColor().isRed()) { cRed = cRed + cnt; }
|
if (c.getColor().isBlue()) {
|
||||||
if (c.getColor().isWhite()) { cWhite = cWhite + cnt; }
|
cBlue = cBlue + cnt;
|
||||||
|
}
|
||||||
|
if (c.getColor().isGreen()) {
|
||||||
|
cGreen = cGreen + cnt;
|
||||||
|
}
|
||||||
|
if (c.getColor().isRed()) {
|
||||||
|
cRed = cRed + cnt;
|
||||||
|
}
|
||||||
|
if (c.getColor().isWhite()) {
|
||||||
|
cWhite = cWhite + cnt;
|
||||||
|
}
|
||||||
if (c.getColor().isColorless()) {
|
if (c.getColor().isColorless()) {
|
||||||
if (c.getType().isLand()) { cLand = cLand + cnt; }
|
if (c.getType().isLand()) {
|
||||||
else { cColorless = cColorless + cnt; }
|
cLand = cLand + cnt;
|
||||||
|
} else {
|
||||||
|
cColorless = cColorless + cnt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// count card types
|
// count card types
|
||||||
CardType cType = c.getType();
|
CardType cType = c.getType();
|
||||||
if (cType.isArtifact()) { cArtifact = cArtifact + cnt; }
|
if (cType.isArtifact()) {
|
||||||
if (cType.isCreature()) { cCreature = cCreature + cnt; }
|
cArtifact = cArtifact + cnt;
|
||||||
if (cType.isEnchantment()) { cEnchant = cEnchant + cnt; }
|
}
|
||||||
if (cType.isInstant()) { cInstant = cInstant + cnt; }
|
if (cType.isCreature()) {
|
||||||
if (cType.isLand()) { cLandType = cLandType + cnt; }
|
cCreature = cCreature + cnt;
|
||||||
if (cType.isPlaneswalker()) { cPlaneswalker = cPlaneswalker + cnt; }
|
}
|
||||||
if (cType.isSorcery()) { cSorcery = cSorcery + cnt; }
|
if (cType.isEnchantment()) {
|
||||||
|
cEnchant = cEnchant + cnt;
|
||||||
|
}
|
||||||
|
if (cType.isInstant()) {
|
||||||
|
cInstant = cInstant + cnt;
|
||||||
|
}
|
||||||
|
if (cType.isLand()) {
|
||||||
|
cLandType = cLandType + cnt;
|
||||||
|
}
|
||||||
|
if (cType.isPlaneswalker()) {
|
||||||
|
cPlaneswalker = cPlaneswalker + cnt;
|
||||||
|
}
|
||||||
|
if (cType.isSorcery()) {
|
||||||
|
cSorcery = cSorcery + cnt;
|
||||||
|
}
|
||||||
|
|
||||||
int cmc = c.getManaCost().getCMC();
|
int cmc = c.getManaCost().getCMC();
|
||||||
if (cmc == 0) { mZero = mZero + cnt;
|
if (cmc == 0) {
|
||||||
} else if (cmc == 1) { mOne = mOne + cnt;
|
mZero = mZero + cnt;
|
||||||
} else if (cmc == 2) { mTwo = mTwo + cnt;
|
} else if (cmc == 1) {
|
||||||
} else if (cmc == 3) { mThree = mThree + cnt;
|
mOne = mOne + cnt;
|
||||||
} else if (cmc == 4) { mFour = mFour + cnt;
|
} else if (cmc == 2) {
|
||||||
} else if (cmc == 5) { mFive = mFive + 1;
|
mTwo = mTwo + cnt;
|
||||||
} else if (cmc >= 6) { mSixMore = mSixMore + 1;
|
} else if (cmc == 3) {
|
||||||
|
mThree = mThree + cnt;
|
||||||
|
} else if (cmc == 4) {
|
||||||
|
mFour = mFour + cnt;
|
||||||
|
} else if (cmc == 5) {
|
||||||
|
mFive = mFive + 1;
|
||||||
|
} else if (cmc >= 6) {
|
||||||
|
mSixMore = mSixMore + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tManaCost = tManaCost + cmc * cnt;
|
tManaCost = tManaCost + cmc * cnt;
|
||||||
@@ -230,51 +265,95 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
jLabelManaCost.setText("Mana cost (ACC:" + aManaCost + ")");
|
jLabelManaCost.setText("Mana cost (ACC:" + aManaCost + ")");
|
||||||
Color cr = new Color(100, 100, 100);
|
Color cr = new Color(100, 100, 100);
|
||||||
|
|
||||||
if (cBlack == 0) { jLabelBlack.setForeground(cr); }
|
if (cBlack == 0) {
|
||||||
|
jLabelBlack.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelBlack.setText(formatStat("Black", cBlack, total));
|
jLabelBlack.setText(formatStat("Black", cBlack, total));
|
||||||
if (cBlue == 0) { jLabelBlue.setForeground(cr); }
|
if (cBlue == 0) {
|
||||||
|
jLabelBlue.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelBlue.setText(formatStat("Blue", cBlue, total));
|
jLabelBlue.setText(formatStat("Blue", cBlue, total));
|
||||||
if (cGreen == 0) { jLabelGreen.setForeground(cr); }
|
if (cGreen == 0) {
|
||||||
|
jLabelGreen.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelGreen.setText(formatStat("Green", cGreen, total));
|
jLabelGreen.setText(formatStat("Green", cGreen, total));
|
||||||
if (cRed == 0) { jLabelRed.setForeground(cr); }
|
if (cRed == 0) {
|
||||||
|
jLabelRed.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelRed.setText(formatStat("Red", cRed, total));
|
jLabelRed.setText(formatStat("Red", cRed, total));
|
||||||
if (cWhite == 0) { jLabelWhite.setForeground(cr); }
|
if (cWhite == 0) {
|
||||||
|
jLabelWhite.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelWhite.setText(formatStat("White", cWhite, total));
|
jLabelWhite.setText(formatStat("White", cWhite, total));
|
||||||
if (cMulticolor == 0) { jLabelMultiColor.setForeground(cr); }
|
if (cMulticolor == 0) {
|
||||||
|
jLabelMultiColor.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelMultiColor.setText(formatStat("Multicolor", cMulticolor, total));
|
jLabelMultiColor.setText(formatStat("Multicolor", cMulticolor, total));
|
||||||
if (cColorless == 0) { jLabelColorless.setForeground(cr); }
|
if (cColorless == 0) {
|
||||||
|
jLabelColorless.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelColorless.setText(formatStat("Colorless", cColorless, total));
|
jLabelColorless.setText(formatStat("Colorless", cColorless, total));
|
||||||
|
|
||||||
if (cLand == 0) { jLabelLand.setForeground(cr); }
|
if (cLand == 0) {
|
||||||
|
jLabelLand.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelLand.setText(formatStat("Land", cLand, total));
|
jLabelLand.setText(formatStat("Land", cLand, total));
|
||||||
if (cArtifact == 0) { jLabelArtifact.setForeground(cr); }
|
if (cArtifact == 0) {
|
||||||
|
jLabelArtifact.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelArtifact.setText(formatStat("Artifact", cArtifact, total));
|
jLabelArtifact.setText(formatStat("Artifact", cArtifact, total));
|
||||||
if (cCreature == 0) { jLabelCreature.setForeground(cr); }
|
if (cCreature == 0) {
|
||||||
|
jLabelCreature.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelCreature.setText(formatStat("Creature", cCreature, total));
|
jLabelCreature.setText(formatStat("Creature", cCreature, total));
|
||||||
if (cEnchant == 0) { jLabelEnchant.setForeground(cr); }
|
if (cEnchant == 0) {
|
||||||
|
jLabelEnchant.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelEnchant.setText(formatStat("Enchant", cEnchant, total));
|
jLabelEnchant.setText(formatStat("Enchant", cEnchant, total));
|
||||||
if (cInstant == 0) { jLabelInstant.setForeground(cr); }
|
if (cInstant == 0) {
|
||||||
|
jLabelInstant.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelInstant.setText(formatStat("Instant", cInstant, total));
|
jLabelInstant.setText(formatStat("Instant", cInstant, total));
|
||||||
if (cLandType == 0) { jLabelLandType.setForeground(cr); }
|
if (cLandType == 0) {
|
||||||
|
jLabelLandType.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelLandType.setText(formatStat("Land", cLandType, total));
|
jLabelLandType.setText(formatStat("Land", cLandType, total));
|
||||||
if (cPlaneswalker == 0) { jLabelPlaneswalker.setForeground(cr); }
|
if (cPlaneswalker == 0) {
|
||||||
|
jLabelPlaneswalker.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelPlaneswalker.setText(formatStat("Planeswalker", cPlaneswalker, total));
|
jLabelPlaneswalker.setText(formatStat("Planeswalker", cPlaneswalker, total));
|
||||||
|
|
||||||
if (cSorcery == 0) { jLabelSorcery.setForeground(cr); }
|
if (cSorcery == 0) {
|
||||||
|
jLabelSorcery.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelSorcery.setText(formatStat("Sorcery", cSorcery, total));
|
jLabelSorcery.setText(formatStat("Sorcery", cSorcery, total));
|
||||||
if (mZero == 0) { jLabelZeroMana.setForeground(cr); }
|
if (mZero == 0) {
|
||||||
|
jLabelZeroMana.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelZeroMana.setText(formatStat("Zero mana", mZero, total));
|
jLabelZeroMana.setText(formatStat("Zero mana", mZero, total));
|
||||||
if (mOne == 0) { jLabelOneMana.setForeground(cr); }
|
if (mOne == 0) {
|
||||||
|
jLabelOneMana.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelOneMana.setText(formatStat("One mana", mOne, total));
|
jLabelOneMana.setText(formatStat("One mana", mOne, total));
|
||||||
if (mTwo == 0) { jLabelTwoMana.setForeground(cr); }
|
if (mTwo == 0) {
|
||||||
|
jLabelTwoMana.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelTwoMana.setText(formatStat("Two mana", mTwo, total));
|
jLabelTwoMana.setText(formatStat("Two mana", mTwo, total));
|
||||||
if (mThree == 0) { jLabelThreeMana.setForeground(cr); }
|
if (mThree == 0) {
|
||||||
|
jLabelThreeMana.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelThreeMana.setText(formatStat("Three mana", mThree, total));
|
jLabelThreeMana.setText(formatStat("Three mana", mThree, total));
|
||||||
if (mFour == 0) { jLabelFourMana.setForeground(cr); }
|
if (mFour == 0) {
|
||||||
|
jLabelFourMana.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelFourMana.setText(formatStat("Four mana", mFour, total));
|
jLabelFourMana.setText(formatStat("Four mana", mFour, total));
|
||||||
if (mFive == 0) { jLabelFiveMana.setForeground(cr); }
|
if (mFive == 0) {
|
||||||
|
jLabelFiveMana.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelFiveMana.setText(formatStat("Five mana", mFive, total));
|
jLabelFiveMana.setText(formatStat("Five mana", mFive, total));
|
||||||
if (mSixMore == 0) { jLabelSixMana.setForeground(cr); }
|
if (mSixMore == 0) {
|
||||||
|
jLabelSixMana.setForeground(cr);
|
||||||
|
}
|
||||||
jLabelSixMana.setText(formatStat("Six and more", mSixMore, total));
|
jLabelSixMana.setText(formatStat("Six and more", mSixMore, total));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -294,8 +373,7 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatStat(String statName, int value, int deckSize )
|
private String formatStat(final String statName, final int value, final int deckSize) {
|
||||||
{
|
|
||||||
return String.format("%s: %d (%f%%)", statName, value, 100f * value / deckSize);
|
return String.format("%s: %d (%f%%)", statName, value, 100f * value / deckSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,7 +458,7 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
jButtonOk.setBounds(206, 536, 168, 31);
|
jButtonOk.setBounds(206, 536, 168, 31);
|
||||||
jButtonOk.addMouseListener(new MouseInputAdapter() {
|
jButtonOk.addMouseListener(new MouseInputAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(final MouseEvent e) {
|
||||||
jF.setEnabled(true);
|
jF.setEnabled(true);
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
@@ -931,9 +1009,9 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rList.size() >= 40) {
|
if (rList.size() >= 40) {
|
||||||
jList1Model = new DefaultComboBoxModel(new String[] { rList.get(0).getName(),
|
jList1Model = new DefaultComboBoxModel(new String[] { rList.get(0).getName(), rList.get(1).getName(),
|
||||||
rList.get(1).getName(), rList.get(2).getName(), rList.get(3).getName(),
|
rList.get(2).getName(), rList.get(3).getName(), rList.get(4).getName(), rList.get(5).getName(),
|
||||||
rList.get(4).getName(), rList.get(5).getName(), rList.get(6).getName() });
|
rList.get(6).getName() });
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
jList1Model = new DefaultComboBoxModel(new String[] { "Few cards." });
|
jList1Model = new DefaultComboBoxModel(new String[] { "Few cards." });
|
||||||
@@ -1038,7 +1116,7 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
jButtonRegenerate.setPreferredSize(new java.awt.Dimension(139, 21));
|
jButtonRegenerate.setPreferredSize(new java.awt.Dimension(139, 21));
|
||||||
jButtonRegenerate.setBounds(2, 189, 133, 13);
|
jButtonRegenerate.setBounds(2, 189, 133, 13);
|
||||||
jButtonRegenerate.addActionListener(new java.awt.event.ActionListener() {
|
jButtonRegenerate.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
jButtonRegenerate_actionPerformed(e);
|
jButtonRegenerate_actionPerformed(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1059,7 +1137,7 @@ public class DeckAnalysis extends javax.swing.JDialog {
|
|||||||
* @param e
|
* @param e
|
||||||
* a {@link java.awt.event.ActionEvent} object.
|
* a {@link java.awt.event.ActionEvent} object.
|
||||||
*/
|
*/
|
||||||
void jButtonRegenerate_actionPerformed(ActionEvent e) {
|
final void jButtonRegenerate_actionPerformed(final ActionEvent e) {
|
||||||
getContentPane().removeAll();
|
getContentPane().removeAll();
|
||||||
getContentPane().add(getJPanel5());
|
getContentPane().add(getJPanel5());
|
||||||
getContentPane().add(getJLabel1xx());
|
getContentPane().add(getJLabel1xx());
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ import forge.item.InventoryItem;
|
|||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by IntelliJ IDEA.
|
* Created by IntelliJ IDEA. User: dhudson Date: 6/24/11
|
||||||
* User: dhudson
|
|
||||||
* Date: 6/24/11
|
|
||||||
*
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
@@ -18,27 +16,37 @@ public interface DeckDisplay {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* setDeck.
|
* setDeck.
|
||||||
* @param top ItemPoolView<CardPrinted>
|
*
|
||||||
* @param bottom ItemPoolView<CardPrinted>
|
* @param top
|
||||||
* @param gameType GameType
|
* ItemPoolView<CardPrinted>
|
||||||
|
* @param bottom
|
||||||
|
* ItemPoolView<CardPrinted>
|
||||||
|
* @param gameType
|
||||||
|
* GameType
|
||||||
*/
|
*/
|
||||||
void setDeck(ItemPoolView<CardPrinted> top, ItemPoolView<CardPrinted> bottom, GameType gameType);
|
void setDeck(ItemPoolView<CardPrinted> top, ItemPoolView<CardPrinted> bottom, GameType gameType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* setItems.
|
* setItems.
|
||||||
* @param <T> InventoryItem
|
*
|
||||||
* @param topParam ItemPoolView<T>
|
* @param <T>
|
||||||
* @param bottomParam ItemPoolView<T>
|
* InventoryItem
|
||||||
* @param gt GameType
|
* @param topParam
|
||||||
|
* ItemPoolView<T>
|
||||||
|
* @param bottomParam
|
||||||
|
* ItemPoolView<T>
|
||||||
|
* @param gt
|
||||||
|
* GameType
|
||||||
*/
|
*/
|
||||||
<T extends InventoryItem> void setItems(ItemPoolView<T> topParam, ItemPoolView<T> bottomParam, GameType gt);
|
<T extends InventoryItem> void setItems(ItemPoolView<T> topParam, ItemPoolView<T> bottomParam, GameType gt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Top shows available card pool.
|
* Top shows available card pool. if constructed, top shows all cards if
|
||||||
* if constructed, top shows all cards
|
* sealed, top shows 5 booster packs if draft, top shows cards that were
|
||||||
* if sealed, top shows 5 booster packs
|
* chosen
|
||||||
* if draft, top shows cards that were chosen
|
*
|
||||||
* @return ItemPoolView<InventoryItem>
|
* @return ItemPoolView<InventoryItem>
|
||||||
*/
|
*/
|
||||||
ItemPoolView<InventoryItem> getTop();
|
ItemPoolView<InventoryItem> getTop();
|
||||||
@@ -47,6 +55,7 @@ public interface DeckDisplay {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Bottom shows cards that the user has chosen for his library.
|
* Bottom shows cards that the user has chosen for his library.
|
||||||
|
*
|
||||||
* @return ItemPoolView<InventoryItem>
|
* @return ItemPoolView<InventoryItem>
|
||||||
*/
|
*/
|
||||||
ItemPoolView<InventoryItem> getBottom();
|
ItemPoolView<InventoryItem> getBottom();
|
||||||
@@ -54,19 +63,24 @@ public interface DeckDisplay {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Set title.
|
* Set title.
|
||||||
* @param message String
|
*
|
||||||
|
* @param message
|
||||||
|
* String
|
||||||
*/
|
*/
|
||||||
void setTitle(String message);
|
void setTitle(String message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Get deck.
|
* Get deck.
|
||||||
|
*
|
||||||
* @return Deck
|
* @return Deck
|
||||||
*/
|
*/
|
||||||
Deck getDeck();
|
Deck getDeck();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Get game type.
|
* Get game type.
|
||||||
|
*
|
||||||
* @return GameType
|
* @return GameType
|
||||||
*/
|
*/
|
||||||
GameType getGameType();
|
GameType getGameType();
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import javax.swing.event.DocumentEvent;
|
|||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.game.GameType;
|
import forge.game.GameType;
|
||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
@@ -18,38 +17,89 @@ import forge.item.InventoryItem;
|
|||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class DeckEditorBase.
|
||||||
|
*/
|
||||||
public abstract class DeckEditorBase extends JFrame implements DeckDisplay {
|
public abstract class DeckEditorBase extends JFrame implements DeckDisplay {
|
||||||
private static final long serialVersionUID = -401223933343539977L;
|
private static final long serialVersionUID = -401223933343539977L;
|
||||||
|
|
||||||
|
/** The filter boxes. */
|
||||||
protected FilterCheckBoxes filterBoxes;
|
protected FilterCheckBoxes filterBoxes;
|
||||||
// set this to false when resetting filter from code (like "clearFiltersPressed"), reset when done.
|
// set this to false when resetting filter from code (like
|
||||||
|
// "clearFiltersPressed"), reset when done.
|
||||||
|
/** The is filters change firing update. */
|
||||||
protected boolean isFiltersChangeFiringUpdate = true;
|
protected boolean isFiltersChangeFiringUpdate = true;
|
||||||
|
|
||||||
|
/** The card view. */
|
||||||
protected CardPanelBase cardView;
|
protected CardPanelBase cardView;
|
||||||
|
|
||||||
// CardPools and Table data for top and bottom lists
|
// CardPools and Table data for top and bottom lists
|
||||||
|
/** The top. */
|
||||||
protected TableWithCards top;
|
protected TableWithCards top;
|
||||||
|
|
||||||
|
/** The bottom. */
|
||||||
protected TableWithCards bottom;
|
protected TableWithCards bottom;
|
||||||
|
|
||||||
|
|
||||||
private GameType gameType;
|
private GameType gameType;
|
||||||
public GameType getGameType() { return gameType; }
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckDisplay#getGameType()
|
||||||
|
*/
|
||||||
|
public final GameType getGameType() {
|
||||||
|
return gameType;
|
||||||
|
}
|
||||||
|
|
||||||
// top shows available card pool
|
// top shows available card pool
|
||||||
// if constructed, top shows all cards
|
// if constructed, top shows all cards
|
||||||
// if sealed, top shows N booster packs
|
// if sealed, top shows N booster packs
|
||||||
// if draft, top shows cards that were chosen
|
// if draft, top shows cards that were chosen
|
||||||
public final TableWithCards getTopTableModel() { return top; }
|
/**
|
||||||
public final ItemPoolView<InventoryItem> getTop() { return top.getCards(); }
|
* Gets the top table model.
|
||||||
|
*
|
||||||
|
* @return the top table model
|
||||||
|
*/
|
||||||
|
public final TableWithCards getTopTableModel() {
|
||||||
|
return top;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckDisplay#getTop()
|
||||||
|
*/
|
||||||
|
public final ItemPoolView<InventoryItem> getTop() {
|
||||||
|
return top.getCards();
|
||||||
|
}
|
||||||
|
|
||||||
// bottom shows player's choice - be it deck or draft
|
// bottom shows player's choice - be it deck or draft
|
||||||
public final ItemPoolView<InventoryItem> getBottom() { return bottom.getCards(); }
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckDisplay#getBottom()
|
||||||
|
*/
|
||||||
|
public final ItemPoolView<InventoryItem> getBottom() {
|
||||||
|
return bottom.getCards();
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
/**
|
||||||
|
* Builds the filter.
|
||||||
|
*
|
||||||
|
* @return the predicate
|
||||||
|
*/
|
||||||
protected abstract Predicate<InventoryItem> buildFilter();
|
protected abstract Predicate<InventoryItem> buildFilter();
|
||||||
|
|
||||||
void analysisButton_actionPerformed(ActionEvent e) {
|
/**
|
||||||
|
* Analysis button_action performed.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
* the e
|
||||||
|
*/
|
||||||
|
final void analysisButton_actionPerformed(final ActionEvent e) {
|
||||||
ItemPoolView<CardPrinted> deck = ItemPool.createFrom(bottom.getCards(), CardPrinted.class);
|
ItemPoolView<CardPrinted> deck = ItemPool.createFrom(bottom.getCards(), CardPrinted.class);
|
||||||
if (deck.isEmpty()) {
|
if (deck.isEmpty()) {
|
||||||
JOptionPane.showMessageDialog(null, "Cards in deck not found.", "Analysis Deck",
|
JOptionPane.showMessageDialog(null, "Cards in deck not found.", "Analysis Deck",
|
||||||
@@ -62,42 +112,111 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeckEditorBase(GameType gametype)
|
/**
|
||||||
{
|
* Instantiates a new deck editor base.
|
||||||
|
*
|
||||||
|
* @param gametype
|
||||||
|
* the gametype
|
||||||
|
*/
|
||||||
|
public DeckEditorBase(final GameType gametype) {
|
||||||
gameType = gametype;
|
gameType = gametype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeck(ItemPoolView<CardPrinted> topParam, ItemPoolView<CardPrinted> bottomParam, GameType gt) {
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckDisplay#setDeck(forge.item.ItemPoolView,
|
||||||
|
* forge.item.ItemPoolView, forge.game.GameType)
|
||||||
|
*/
|
||||||
|
public void setDeck(final ItemPoolView<CardPrinted> topParam, final ItemPoolView<CardPrinted> bottomParam,
|
||||||
|
final GameType gt) {
|
||||||
gameType = gt;
|
gameType = gt;
|
||||||
top.setDeck(topParam);
|
top.setDeck(topParam);
|
||||||
bottom.setDeck(bottomParam);
|
bottom.setDeck(bottomParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends InventoryItem> void setItems(ItemPoolView<T> topParam, ItemPoolView<T> bottomParam, GameType gt) {
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckDisplay#setItems(forge.item.ItemPoolView,
|
||||||
|
* forge.item.ItemPoolView, forge.game.GameType)
|
||||||
|
*/
|
||||||
|
public final <T extends InventoryItem> void setItems(final ItemPoolView<T> topParam,
|
||||||
|
final ItemPoolView<T> bottomParam, final GameType gt) {
|
||||||
gameType = gt;
|
gameType = gt;
|
||||||
top.setDeck(topParam);
|
top.setDeck(topParam);
|
||||||
bottom.setDeck(bottomParam);
|
bottom.setDeck(bottomParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDisplay() {
|
/**
|
||||||
|
* Update display.
|
||||||
|
*/
|
||||||
|
public final void updateDisplay() {
|
||||||
top.setFilter(buildFilter());
|
top.setFilter(buildFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The item listener updates display. */
|
||||||
protected ItemListener itemListenerUpdatesDisplay = new ItemListener() {
|
protected ItemListener itemListenerUpdatesDisplay = new ItemListener() {
|
||||||
public void itemStateChanged(ItemEvent e) {
|
public void itemStateChanged(final ItemEvent e) {
|
||||||
if (isFiltersChangeFiringUpdate) { updateDisplay(); }
|
if (isFiltersChangeFiringUpdate) {
|
||||||
|
updateDisplay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This class is used for a feature: when you start typing card name, the list gets auto-filtered. */
|
/**
|
||||||
|
* This class is used for a feature: when you start typing card name, the
|
||||||
|
* list gets auto-filtered.
|
||||||
|
*/
|
||||||
protected class OnChangeTextUpdateDisplay implements DocumentListener {
|
protected class OnChangeTextUpdateDisplay implements DocumentListener {
|
||||||
private void onChange() { if (isFiltersChangeFiringUpdate) { updateDisplay(); } }
|
private void onChange() {
|
||||||
@Override public void insertUpdate(DocumentEvent e) { onChange(); }
|
if (isFiltersChangeFiringUpdate) {
|
||||||
@Override public void removeUpdate(DocumentEvent e) { onChange(); }
|
updateDisplay();
|
||||||
@Override public void changedUpdate(DocumentEvent e) { } // Happend only on ENTER pressed
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Deck getDeck() {
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* javax.swing.event.DocumentListener#insertUpdate(javax.swing.event
|
||||||
|
* .DocumentEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final void insertUpdate(final DocumentEvent e) {
|
||||||
|
onChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* javax.swing.event.DocumentListener#removeUpdate(javax.swing.event
|
||||||
|
* .DocumentEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final void removeUpdate(final DocumentEvent e) {
|
||||||
|
onChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* javax.swing.event.DocumentListener#changedUpdate(javax.swing.event
|
||||||
|
* .DocumentEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void changedUpdate(final DocumentEvent e) {
|
||||||
|
} // Happend only on ENTER pressed
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckDisplay#getDeck()
|
||||||
|
*/
|
||||||
|
public final Deck getDeck() {
|
||||||
Deck deck = new Deck(gameType);
|
Deck deck = new Deck(gameType);
|
||||||
deck.addMain(ItemPool.createFrom(getBottom(), CardPrinted.class));
|
deck.addMain(ItemPool.createFrom(getBottom(), CardPrinted.class));
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package forge.gui.deckeditor;
|
package forge.gui.deckeditor;
|
||||||
|
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
|
import java.awt.Dialog.ModalityType;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.Dialog.ModalityType;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
@@ -17,6 +17,7 @@ import java.util.List;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
@@ -42,6 +43,7 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
/** Constant <code>serialVersionUID=130339644136746796L</code> */
|
/** Constant <code>serialVersionUID=130339644136746796L</code> */
|
||||||
private static final long serialVersionUID = 130339644136746796L;
|
private static final long serialVersionUID = 130339644136746796L;
|
||||||
|
|
||||||
|
/** The custom menu. */
|
||||||
public DeckEditorCommonMenu customMenu;
|
public DeckEditorCommonMenu customMenu;
|
||||||
|
|
||||||
private JButton removeButton = new JButton();
|
private JButton removeButton = new JButton();
|
||||||
@@ -54,6 +56,12 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
private JLabel jLabelAnalysisGap = new JLabel("");
|
private JLabel jLabelAnalysisGap = new JLabel("");
|
||||||
private FilterNameTypeSetPanel filterNameTypeSet;
|
private FilterNameTypeSetPanel filterNameTypeSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show.
|
||||||
|
*
|
||||||
|
* @param exitCommand
|
||||||
|
* the exit command
|
||||||
|
*/
|
||||||
public void show(final Command exitCommand) {
|
public void show(final Command exitCommand) {
|
||||||
final Command exit = new Command() {
|
final Command exit = new Command() {
|
||||||
private static final long serialVersionUID = 5210924838133689758L;
|
private static final long serialVersionUID = 5210924838133689758L;
|
||||||
@@ -77,8 +85,6 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// show cards, makes this user friendly
|
// show cards, makes this user friendly
|
||||||
if (!getGameType().isLimited()) {
|
if (!getGameType().isLimited()) {
|
||||||
customMenu.newConstructed(false);
|
customMenu.newConstructed(false);
|
||||||
@@ -89,18 +95,23 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
|
|
||||||
} // show(Command)
|
} // show(Command)
|
||||||
|
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Name", 175, PresetColumns.fnNameCompare, PresetColumns.fnNameGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Name", 175, PresetColumns.fnNameCompare,
|
||||||
|
PresetColumns.fnNameGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Cost", 75, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Cost", 75, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare, PresetColumns.fnColorGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare,
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare, PresetColumns.fnTypeGet));
|
PresetColumns.fnColorGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare, PresetColumns.fnStatsGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare,
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.fnRarityCompare, PresetColumns.fnRarityGet));
|
PresetColumns.fnTypeGet));
|
||||||
|
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare,
|
||||||
|
PresetColumns.fnStatsGet));
|
||||||
|
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.fnRarityCompare,
|
||||||
|
PresetColumns.fnRarityGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.fnAiStatusCompare, PresetColumns.fnAiStatusGet));
|
columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.fnAiStatusCompare,
|
||||||
|
PresetColumns.fnAiStatusGet));
|
||||||
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
||||||
|
|
||||||
top.setup(columns, cardView);
|
top.setup(columns, cardView);
|
||||||
@@ -113,8 +124,13 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public DeckEditorCommon(GameType gameType) {
|
* Instantiates a new deck editor common.
|
||||||
|
*
|
||||||
|
* @param gameType
|
||||||
|
* the game type
|
||||||
|
*/
|
||||||
|
public DeckEditorCommon(final GameType gameType) {
|
||||||
super(gameType);
|
super(gameType);
|
||||||
try {
|
try {
|
||||||
filterBoxes = new FilterCheckBoxes(true);
|
filterBoxes = new FilterCheckBoxes(true);
|
||||||
@@ -129,7 +145,6 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void jbInit() {
|
private void jbInit() {
|
||||||
|
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts) {
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
@@ -148,20 +163,37 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
analysisButton.setText("Deck Analysis");
|
analysisButton.setText("Deck Analysis");
|
||||||
|
|
||||||
removeButton.addActionListener(new java.awt.event.ActionListener() {
|
removeButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent e) { removeButtonClicked(e); } });
|
public void actionPerformed(final ActionEvent e) {
|
||||||
|
removeButtonClicked(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
addButton.addActionListener(new java.awt.event.ActionListener() {
|
addButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent e) { addButton_actionPerformed(e); } });
|
public void actionPerformed(final ActionEvent e) {
|
||||||
|
addButton_actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
importButton.addActionListener(new java.awt.event.ActionListener() {
|
importButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent e) { importButton_actionPerformed(e); } });
|
public void actionPerformed(final ActionEvent e) {
|
||||||
|
importButton_actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
clearFilterButton.addActionListener(new java.awt.event.ActionListener() {
|
clearFilterButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent e) { clearFilterButton_actionPerformed(e); } });
|
public void actionPerformed(final ActionEvent e) {
|
||||||
|
clearFilterButton_actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
analysisButton.addActionListener(new java.awt.event.ActionListener() {
|
analysisButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent e) { analysisButton_actionPerformed(e); } });
|
public void actionPerformed(final ActionEvent e) {
|
||||||
|
analysisButton_actionPerformed(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Type filtering
|
// Type filtering
|
||||||
Font f = new Font("Tahoma", Font.PLAIN, 10);
|
Font f = new Font("Tahoma", Font.PLAIN, 10);
|
||||||
for (JCheckBox box : filterBoxes.allTypes) {
|
for (JCheckBox box : filterBoxes.allTypes) {
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts) { box.setFont(f); }
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
|
box.setFont(f);
|
||||||
|
}
|
||||||
box.setOpaque(false);
|
box.setOpaque(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +235,8 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
content.add(addButton, "w 100, h 49, sg button, cell 0 5, split 5");
|
content.add(addButton, "w 100, h 49, sg button, cell 0 5, split 5");
|
||||||
content.add(removeButton, "w 100, h 49, sg button");
|
content.add(removeButton, "w 100, h 49, sg button");
|
||||||
content.add(importButton, "w 100, h 49, sg button, gapleft 40px");
|
content.add(importButton, "w 100, h 49, sg button, gapleft 40px");
|
||||||
// Label is used to push the analysis button to the right to separate analysis button from add/remove card ones
|
// Label is used to push the analysis button to the right to separate
|
||||||
|
// analysis button from add/remove card ones
|
||||||
content.add(jLabelAnalysisGap, "wmin 75, growx");
|
content.add(jLabelAnalysisGap, "wmin 75, growx");
|
||||||
content.add(analysisButton, "w 100, h 49, wrap");
|
content.add(analysisButton, "w 100, h 49, wrap");
|
||||||
|
|
||||||
@@ -213,36 +246,76 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
content.add(cardView, "cell 1 0 1 8, flowy, grow");
|
content.add(cardView, "cell 1 0 1 8, flowy, grow");
|
||||||
|
|
||||||
top.getTable().addMouseListener(new MouseAdapter() {
|
top.getTable().addMouseListener(new MouseAdapter() {
|
||||||
@Override public void mouseClicked(final MouseEvent e) { if (e.getClickCount() == 2) { addCardToDeck(); } } });
|
@Override
|
||||||
|
public void mouseClicked(final MouseEvent e) {
|
||||||
|
if (e.getClickCount() == 2) {
|
||||||
|
addCardToDeck();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
top.getTable().addKeyListener(new KeyAdapter() {
|
top.getTable().addKeyListener(new KeyAdapter() {
|
||||||
@Override public void keyPressed(final KeyEvent e) { if (e.getKeyChar() == ' ') { addCardToDeck(); } } });
|
@Override
|
||||||
|
public void keyPressed(final KeyEvent e) {
|
||||||
|
if (e.getKeyChar() == ' ') {
|
||||||
|
addCardToDeck();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// javax.swing.JRootPane rootPane = this.getRootPane();
|
// javax.swing.JRootPane rootPane = this.getRootPane();
|
||||||
// rootPane.setDefaultButton(filterButton);
|
// rootPane.setDefaultButton(filterButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckEditorBase#buildFilter()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Predicate<InventoryItem> buildFilter() {
|
protected Predicate<InventoryItem> buildFilter() {
|
||||||
Predicate<CardPrinted> cardFilter = Predicate.and(Predicate.and(filterBoxes.buildFilter(), filterNameTypeSet.buildFilter()),CardPrinted.Predicates.Presets.nonAlternate);
|
Predicate<CardPrinted> cardFilter = Predicate.and(
|
||||||
|
Predicate.and(filterBoxes.buildFilter(), filterNameTypeSet.buildFilter()),
|
||||||
|
CardPrinted.Predicates.Presets.nonAlternate);
|
||||||
return Predicate.instanceOf(cardFilter, CardPrinted.class);
|
return Predicate.instanceOf(cardFilter, CardPrinted.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckEditorBase#setDeck(forge.item.ItemPoolView,
|
||||||
|
* forge.item.ItemPoolView, forge.game.GameType)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDeck(ItemPoolView<CardPrinted> topParam, ItemPoolView<CardPrinted> bottomParam, GameType gt)
|
public void setDeck(final ItemPoolView<CardPrinted> topParam, final ItemPoolView<CardPrinted> bottomParam,
|
||||||
{
|
final GameType gt) {
|
||||||
boolean keepRecievedCards = gt.isLimited() || topParam != null;
|
boolean keepRecievedCards = gt.isLimited() || topParam != null;
|
||||||
// if constructed, can add the all cards above
|
// if constructed, can add the all cards above
|
||||||
ItemPoolView<CardPrinted> top = keepRecievedCards ? topParam : ItemPool.createFrom(CardDb.instance().getAllCards(), CardPrinted.class);
|
ItemPoolView<CardPrinted> top = keepRecievedCards ? topParam : ItemPool.createFrom(CardDb.instance()
|
||||||
|
.getAllCards(), CardPrinted.class);
|
||||||
importButton.setVisible(!gt.isLimited());
|
importButton.setVisible(!gt.isLimited());
|
||||||
super.setDeck(top, bottomParam, gt);
|
super.setDeck(top, bottomParam, gt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearFilterButton_actionPerformed(ActionEvent e) {
|
/**
|
||||||
|
* Clear filter button_action performed.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
* the e
|
||||||
|
*/
|
||||||
|
void clearFilterButton_actionPerformed(final ActionEvent e) {
|
||||||
// disable automatic update triggered by listeners
|
// disable automatic update triggered by listeners
|
||||||
isFiltersChangeFiringUpdate = false;
|
isFiltersChangeFiringUpdate = false;
|
||||||
|
|
||||||
for (JCheckBox box : filterBoxes.allTypes) { if (!box.isSelected()) { box.doClick(); } }
|
for (JCheckBox box : filterBoxes.allTypes) {
|
||||||
for (JCheckBox box : filterBoxes.allColors) { if (!box.isSelected()) { box.doClick(); } }
|
if (!box.isSelected()) {
|
||||||
|
box.doClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (JCheckBox box : filterBoxes.allColors) {
|
||||||
|
if (!box.isSelected()) {
|
||||||
|
box.doClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
filterNameTypeSet.clearFilters();
|
filterNameTypeSet.clearFilters();
|
||||||
|
|
||||||
@@ -251,13 +324,24 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
top.setFilter(null);
|
top.setFilter(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addButton_actionPerformed(ActionEvent e) {
|
/**
|
||||||
|
* Adds the button_action performed.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
* the e
|
||||||
|
*/
|
||||||
|
void addButton_actionPerformed(final ActionEvent e) {
|
||||||
addCardToDeck();
|
addCardToDeck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the card to deck.
|
||||||
|
*/
|
||||||
void addCardToDeck() {
|
void addCardToDeck() {
|
||||||
InventoryItem item = top.getSelectedCard();
|
InventoryItem item = top.getSelectedCard();
|
||||||
if (item == null || !( item instanceof CardPrinted )) { return; }
|
if (item == null || !(item instanceof CardPrinted)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CardPrinted card = (CardPrinted) item;
|
CardPrinted card = (CardPrinted) item;
|
||||||
setTitle("Deck Editor : " + customMenu.getDeckName() + " : unsaved");
|
setTitle("Deck Editor : " + customMenu.getDeckName() + " : unsaved");
|
||||||
@@ -270,9 +354,17 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
customMenu.notifyDeckChange();
|
customMenu.notifyDeckChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeButtonClicked(ActionEvent e) {
|
/**
|
||||||
|
* Removes the button clicked.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
* the e
|
||||||
|
*/
|
||||||
|
void removeButtonClicked(final ActionEvent e) {
|
||||||
InventoryItem item = bottom.getSelectedCard();
|
InventoryItem item = bottom.getSelectedCard();
|
||||||
if (item == null || !( item instanceof CardPrinted )) { return; }
|
if (item == null || !(item instanceof CardPrinted)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CardPrinted card = (CardPrinted) item;
|
CardPrinted card = (CardPrinted) item;
|
||||||
|
|
||||||
@@ -286,7 +378,13 @@ public final class DeckEditorCommon extends DeckEditorBase {
|
|||||||
customMenu.notifyDeckChange();
|
customMenu.notifyDeckChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
void importButton_actionPerformed(ActionEvent e) {
|
/**
|
||||||
|
* Import button_action performed.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
* the e
|
||||||
|
*/
|
||||||
|
void importButton_actionPerformed(final ActionEvent e) {
|
||||||
DeckEditorBase g = this;
|
DeckEditorBase g = this;
|
||||||
DeckImport dImport = new DeckImport(g);
|
DeckImport dImport = new DeckImport(g);
|
||||||
dImport.setModalityType(ModalityType.APPLICATION_MODAL);
|
dImport.setModalityType(ModalityType.APPLICATION_MODAL);
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants
|
|||||||
} // setupSortMenu()
|
} // setupSortMenu()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* New constructed.
|
||||||
*
|
*
|
||||||
* @param careAboutOldDeck
|
* @param careAboutOldDeck
|
||||||
* a boolean
|
* a boolean
|
||||||
|
|||||||
@@ -1,25 +1,5 @@
|
|||||||
package forge.gui.deckeditor;
|
package forge.gui.deckeditor;
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Constant;
|
|
||||||
import forge.deck.Deck;
|
|
||||||
import forge.deck.DeckManager;
|
|
||||||
import forge.error.ErrorViewer;
|
|
||||||
import forge.game.GameType;
|
|
||||||
import forge.game.limited.BoosterDraft;
|
|
||||||
import forge.gui.GuiUtils;
|
|
||||||
import forge.item.CardDb;
|
|
||||||
import forge.item.CardPrinted;
|
|
||||||
import forge.item.InventoryItem;
|
|
||||||
import forge.item.ItemPool;
|
|
||||||
import forge.item.ItemPoolView;
|
|
||||||
import forge.properties.ForgeProps;
|
|
||||||
import forge.properties.NewConstants;
|
|
||||||
import forge.view.swing.Gui_HomeScreen;
|
|
||||||
import forge.view.swing.OldGuiNewGame;
|
|
||||||
|
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -38,9 +18,29 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
|
||||||
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
import forge.AllZone;
|
||||||
|
import forge.Constant;
|
||||||
|
import forge.deck.Deck;
|
||||||
|
import forge.deck.DeckManager;
|
||||||
|
import forge.error.ErrorViewer;
|
||||||
|
import forge.game.GameType;
|
||||||
|
import forge.game.limited.BoosterDraft;
|
||||||
|
import forge.gui.GuiUtils;
|
||||||
|
import forge.item.CardDb;
|
||||||
|
import forge.item.CardPrinted;
|
||||||
|
import forge.item.InventoryItem;
|
||||||
|
import forge.item.ItemPool;
|
||||||
|
import forge.item.ItemPoolView;
|
||||||
|
import forge.properties.ForgeProps;
|
||||||
|
import forge.properties.NewConstants;
|
||||||
|
import forge.view.swing.Gui_HomeScreen;
|
||||||
|
import forge.view.swing.OldGuiNewGame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Gui_BoosterDraft class.</p>
|
* <p>
|
||||||
|
* Gui_BoosterDraft class.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
@@ -57,18 +57,23 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
|
|
||||||
private CardPanelLite cardView = new CardPanelLite();
|
private CardPanelLite cardView = new CardPanelLite();
|
||||||
|
|
||||||
|
|
||||||
private MouseListener pickWithMouse = new MouseAdapter() {
|
private MouseListener pickWithMouse = new MouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(final MouseEvent e) {
|
public void mouseClicked(final MouseEvent e) {
|
||||||
// Pick on left-button double click
|
// Pick on left-button double click
|
||||||
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.getClickCount() == 2) {
|
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.getClickCount() == 2) {
|
||||||
jButtonPickClicked(null);
|
jButtonPickClicked(null);
|
||||||
} else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { // pick on right click
|
} else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { // pick
|
||||||
|
// on
|
||||||
|
// right
|
||||||
|
// click
|
||||||
JTable table = top.getTable();
|
JTable table = top.getTable();
|
||||||
int rowNumber = table.rowAtPoint(e.getPoint());
|
int rowNumber = table.rowAtPoint(e.getPoint());
|
||||||
// after hittest - if it was outside of rows - discard this click
|
// after hittest - if it was outside of rows - discard this
|
||||||
if (rowNumber == -1) { return; }
|
// click
|
||||||
|
if (rowNumber == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if row was not selected, select it. If it was, pick a card
|
// if row was not selected, select it. If it was, pick a card
|
||||||
if (rowNumber != table.getSelectedRow()) {
|
if (rowNumber != table.getSelectedRow()) {
|
||||||
@@ -80,7 +85,13 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public void showGui(BoosterDraft in_boosterDraft) {
|
/**
|
||||||
|
* Show gui.
|
||||||
|
*
|
||||||
|
* @param in_boosterDraft
|
||||||
|
* the in_booster draft
|
||||||
|
*/
|
||||||
|
public final void showGui(final BoosterDraft in_boosterDraft) {
|
||||||
boosterDraft = in_boosterDraft;
|
boosterDraft = in_boosterDraft;
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
@@ -94,12 +105,14 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>addListeners.</p>
|
* <p>
|
||||||
|
* addListeners.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
private void addListeners() {
|
private void addListeners() {
|
||||||
this.addWindowListener(new WindowAdapter() {
|
this.addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent ev) {
|
public void windowClosing(final WindowEvent ev) {
|
||||||
int n = JOptionPane.showConfirmDialog(null, ForgeProps.getLocalized(CLOSE_MESSAGE), "",
|
int n = JOptionPane.showConfirmDialog(null, ForgeProps.getLocalized(CLOSE_MESSAGE), "",
|
||||||
JOptionPane.YES_NO_OPTION);
|
JOptionPane.YES_NO_OPTION);
|
||||||
if (n == JOptionPane.YES_OPTION) {
|
if (n == JOptionPane.YES_OPTION) {
|
||||||
@@ -107,7 +120,7 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
|
|
||||||
if (System.getenv("NG2") != null) {
|
if (System.getenv("NG2") != null) {
|
||||||
if (System.getenv("NG2").equalsIgnoreCase("true")) {
|
if (System.getenv("NG2").equalsIgnoreCase("true")) {
|
||||||
String argz[] = {};
|
String[] argz = {};
|
||||||
Gui_HomeScreen.main(argz);
|
Gui_HomeScreen.main(argz);
|
||||||
} else {
|
} else {
|
||||||
new OldGuiNewGame();
|
new OldGuiNewGame();
|
||||||
@@ -122,7 +135,9 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
}// addListeners()
|
}// addListeners()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>setup.</p>
|
* <p>
|
||||||
|
* setup.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
private void setup() {
|
private void setup() {
|
||||||
addListeners();
|
addListeners();
|
||||||
@@ -130,14 +145,20 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
|
|
||||||
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.fnNameCompare, PresetColumns.fnNameGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.fnNameCompare,
|
||||||
|
PresetColumns.fnNameGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare, PresetColumns.fnColorGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare,
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare, PresetColumns.fnTypeGet));
|
PresetColumns.fnColorGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare, PresetColumns.fnStatsGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare,
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.fnRarityCompare, PresetColumns.fnRarityGet));
|
PresetColumns.fnTypeGet));
|
||||||
|
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare,
|
||||||
|
PresetColumns.fnStatsGet));
|
||||||
|
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.fnRarityCompare,
|
||||||
|
PresetColumns.fnRarityGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.fnAiStatusCompare, PresetColumns.fnAiStatusGet));
|
columns.add(new TableColumnInfo<InventoryItem>("AI", 30, PresetColumns.fnAiStatusCompare,
|
||||||
|
PresetColumns.fnAiStatusGet));
|
||||||
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
||||||
|
|
||||||
top.setup(columns, cardView);
|
top.setup(columns, cardView);
|
||||||
@@ -149,11 +170,19 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
|
|
||||||
top.getTable().addMouseListener(pickWithMouse);
|
top.getTable().addMouseListener(pickWithMouse);
|
||||||
top.getTable().addKeyListener(new KeyAdapter() {
|
top.getTable().addKeyListener(new KeyAdapter() {
|
||||||
@Override public void keyPressed(final KeyEvent e) {
|
@Override
|
||||||
if (e.getKeyChar() == ' ') { jButtonPickClicked(null); } } });
|
public void keyPressed(final KeyEvent e) {
|
||||||
|
if (e.getKeyChar() == ' ') {
|
||||||
|
jButtonPickClicked(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new deck editor draft.
|
||||||
|
*/
|
||||||
public DeckEditorDraft() {
|
public DeckEditorDraft() {
|
||||||
super(GameType.Draft);
|
super(GameType.Draft);
|
||||||
try {
|
try {
|
||||||
@@ -167,11 +196,13 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>jbInit.</p>
|
* <p>
|
||||||
|
* jbInit.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @throws java.lang.Exception if any.
|
* @throws java.lang.Exception
|
||||||
|
* if any.
|
||||||
*/
|
*/
|
||||||
private void jbInit() throws Exception {
|
private void jbInit() throws Exception {
|
||||||
this.getContentPane().setLayout(null);
|
this.getContentPane().setLayout(null);
|
||||||
@@ -189,7 +220,7 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
jButtonPick.setFont(new java.awt.Font("Dialog", 0, 16));
|
jButtonPick.setFont(new java.awt.Font("Dialog", 0, 16));
|
||||||
jButtonPick.setText("Choose Card");
|
jButtonPick.setText("Choose Card");
|
||||||
jButtonPick.addActionListener(new ActionListener() {
|
jButtonPick.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
jButtonPickClicked(e);
|
jButtonPickClicked(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -202,13 +233,18 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>jButton1_actionPerformed.</p>
|
* <p>
|
||||||
|
* jButton1_actionPerformed.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param e a {@link java.awt.event.ActionEvent} object.
|
* @param e
|
||||||
|
* a {@link java.awt.event.ActionEvent} object.
|
||||||
*/
|
*/
|
||||||
void jButtonPickClicked(final ActionEvent e) {
|
final void jButtonPickClicked(final ActionEvent e) {
|
||||||
InventoryItem item = top.getSelectedCard();
|
InventoryItem item = top.getSelectedCard();
|
||||||
if (item == null || !( item instanceof CardPrinted )) { return; }
|
if (item == null || !(item instanceof CardPrinted)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CardPrinted card = (CardPrinted) item;
|
CardPrinted card = (CardPrinted) item;
|
||||||
|
|
||||||
@@ -228,18 +264,23 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
}/* OK Button */
|
}/* OK Button */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>showChoices.</p>
|
* <p>
|
||||||
|
* showChoices.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param list a {@link forge.CardList} object.
|
* @param list
|
||||||
|
* a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
private void showChoices(ItemPoolView<CardPrinted> list) {
|
private void showChoices(final ItemPoolView<CardPrinted> list) {
|
||||||
top.setDeck(list);
|
top.setDeck(list);
|
||||||
cardView.showCard(null);
|
cardView.showCard(null);
|
||||||
top.fixSelection(0);
|
top.fixSelection(0);
|
||||||
}// showChoices()
|
}// showChoices()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getPlayersDeck.</p>
|
* <p>
|
||||||
|
* getPlayersDeck.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return a {@link forge.deck.Deck} object.
|
* @return a {@link forge.deck.Deck} object.
|
||||||
*/
|
*/
|
||||||
@@ -263,7 +304,9 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
}// getPlayersDeck()
|
}// getPlayersDeck()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>saveDraft.</p>
|
* <p>
|
||||||
|
* saveDraft.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
private void saveDraft() {
|
private void saveDraft() {
|
||||||
String s = "";
|
String s = "";
|
||||||
@@ -271,7 +314,8 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
s = JOptionPane.showInputDialog(null, ForgeProps.getLocalized(SAVE_DRAFT_MESSAGE),
|
s = JOptionPane.showInputDialog(null, ForgeProps.getLocalized(SAVE_DRAFT_MESSAGE),
|
||||||
ForgeProps.getLocalized(SAVE_DRAFT_TITLE), JOptionPane.QUESTION_MESSAGE);
|
ForgeProps.getLocalized(SAVE_DRAFT_TITLE), JOptionPane.QUESTION_MESSAGE);
|
||||||
}
|
}
|
||||||
//TODO: check if overwriting the same name, and let the user delete old drafts
|
// TODO: check if overwriting the same name, and let the user delete old
|
||||||
|
// drafts
|
||||||
|
|
||||||
// construct computer's decks
|
// construct computer's decks
|
||||||
// save draft
|
// save draft
|
||||||
@@ -280,14 +324,14 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
Deck human = getPlayersDeck();
|
Deck human = getPlayersDeck();
|
||||||
human.setName(s);
|
human.setName(s);
|
||||||
|
|
||||||
Deck[] all = {
|
Deck[] all = { human, computer[0], computer[1], computer[2], computer[3], computer[4], computer[5], computer[6] };
|
||||||
human, computer[0], computer[1], computer[2], computer[3], computer[4], computer[5], computer[6]};
|
|
||||||
|
|
||||||
for (int i = 1; i < all.length; i++) {
|
for (int i = 1; i < all.length; i++) {
|
||||||
all[i].setName(String.format("Draft %s - Computer %d", s, i));
|
all[i].setName(String.format("Draft %s - Computer %d", s, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
//DeckManager deckManager = new DeckManager(ForgeProps.getFile(NEW_DECKS));
|
// DeckManager deckManager = new
|
||||||
|
// DeckManager(ForgeProps.getFile(NEW_DECKS));
|
||||||
DeckManager deckManager = AllZone.getDeckManager();
|
DeckManager deckManager = AllZone.getDeckManager();
|
||||||
deckManager.addDraftDeck(all);
|
deckManager.addDraftDeck(all);
|
||||||
|
|
||||||
@@ -299,7 +343,7 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
|
|
||||||
if (System.getenv("NG2") != null) {
|
if (System.getenv("NG2") != null) {
|
||||||
if (System.getenv("NG2").equalsIgnoreCase("true")) {
|
if (System.getenv("NG2").equalsIgnoreCase("true")) {
|
||||||
String argz[] = {};
|
String[] argz = {};
|
||||||
Gui_HomeScreen.main(argz);
|
Gui_HomeScreen.main(argz);
|
||||||
} else {
|
} else {
|
||||||
new OldGuiNewGame();
|
new OldGuiNewGame();
|
||||||
@@ -310,9 +354,13 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New
|
|||||||
|
|
||||||
}/* saveDraft() */
|
}/* saveDraft() */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckEditorBase#buildFilter()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Predicate<InventoryItem> buildFilter() {
|
protected final Predicate<InventoryItem> buildFilter() {
|
||||||
return Predicate.getTrue(InventoryItem.class);
|
return Predicate.getTrue(InventoryItem.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
package forge.gui.deckeditor;
|
package forge.gui.deckeditor;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
|
||||||
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
@@ -14,22 +29,6 @@ import forge.item.ItemPoolView;
|
|||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestData;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.KeyAdapter;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
|
||||||
|
|
||||||
//import forge.quest.data.QuestBoosterPack;
|
//import forge.quest.data.QuestBoosterPack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,6 +43,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
/** Constant <code>serialVersionUID=152061168634545L</code> */
|
/** Constant <code>serialVersionUID=152061168634545L</code> */
|
||||||
private static final long serialVersionUID = 152061168634545L;
|
private static final long serialVersionUID = 152061168634545L;
|
||||||
|
|
||||||
|
/** The custom menu. */
|
||||||
DeckEditorQuestMenu customMenu;
|
DeckEditorQuestMenu customMenu;
|
||||||
|
|
||||||
// private ImageIcon upIcon = Constant.IO.upIcon;
|
// private ImageIcon upIcon = Constant.IO.upIcon;
|
||||||
@@ -54,12 +54,16 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
private JButton removeButton = new JButton();
|
private JButton removeButton = new JButton();
|
||||||
private JButton analysisButton = new JButton();
|
private JButton analysisButton = new JButton();
|
||||||
|
|
||||||
|
|
||||||
private FilterNameTypeSetPanel filterNameTypeSet;
|
private FilterNameTypeSetPanel filterNameTypeSet;
|
||||||
|
|
||||||
private QuestData questData;
|
private QuestData questData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show.
|
||||||
|
*
|
||||||
|
* @param exitCommand
|
||||||
|
* the exit command
|
||||||
|
*/
|
||||||
public void show(final Command exitCommand) {
|
public void show(final Command exitCommand) {
|
||||||
final Command exit = new Command() {
|
final Command exit = new Command() {
|
||||||
private static final long serialVersionUID = -7428793574300520612L;
|
private static final long serialVersionUID = -7428793574300520612L;
|
||||||
@@ -114,7 +118,6 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
bottom.sort(1, true);
|
bottom.sort(1, true);
|
||||||
} // show(Command)
|
} // show(Command)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* setup.
|
* setup.
|
||||||
@@ -125,14 +128,20 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
|
|
||||||
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.fnNameCompare, PresetColumns.fnNameGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.fnNameCompare,
|
||||||
|
PresetColumns.fnNameGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare, PresetColumns.fnColorGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare,
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare, PresetColumns.fnTypeGet));
|
PresetColumns.fnColorGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare, PresetColumns.fnStatsGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare,
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.fnRarityCompare, PresetColumns.fnRarityGet));
|
PresetColumns.fnTypeGet));
|
||||||
|
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare,
|
||||||
|
PresetColumns.fnStatsGet));
|
||||||
|
columns.add(new TableColumnInfo<InventoryItem>("R", 35, PresetColumns.fnRarityCompare,
|
||||||
|
PresetColumns.fnRarityGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Set", 40, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("New", 30, questData.getCards().fnNewCompare, questData.getCards().fnNewGet));
|
columns.add(new TableColumnInfo<InventoryItem>("New", 30, questData.getCards().fnNewCompare, questData
|
||||||
|
.getCards().fnNewGet));
|
||||||
|
|
||||||
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
||||||
|
|
||||||
@@ -151,7 +160,13 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
// setExtendedState(Frame.MAXIMIZED_BOTH);
|
// setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||||
} // setupAndDisplay()
|
} // setupAndDisplay()
|
||||||
|
|
||||||
public DeckEditorQuest(QuestData questData2) {
|
/**
|
||||||
|
* Instantiates a new deck editor quest.
|
||||||
|
*
|
||||||
|
* @param questData2
|
||||||
|
* the quest data2
|
||||||
|
*/
|
||||||
|
public DeckEditorQuest(final QuestData questData2) {
|
||||||
super(GameType.Quest);
|
super(GameType.Quest);
|
||||||
questData = questData2;
|
questData = questData2;
|
||||||
try {
|
try {
|
||||||
@@ -166,7 +181,6 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void jbInit() throws Exception {
|
private void jbInit() throws Exception {
|
||||||
this.getContentPane().setLayout(null);
|
this.getContentPane().setLayout(null);
|
||||||
|
|
||||||
@@ -177,11 +191,11 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
top.getTableDecorated().setBounds(new Rectangle(19, 40, 726, 316));
|
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);
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
removeButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
removeButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
||||||
|
}
|
||||||
removeButton.setText("Remove Card");
|
removeButton.setText("Remove Card");
|
||||||
removeButton.addActionListener(new ActionListener() {
|
removeButton.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
@@ -195,8 +209,9 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// addButton.setIcon(downIcon);
|
// addButton.setIcon(downIcon);
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
addButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
addButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
||||||
|
}
|
||||||
addButton.setBounds(new Rectangle(23, 403, 146, 49));
|
addButton.setBounds(new Rectangle(23, 403, 146, 49));
|
||||||
|
|
||||||
analysisButton.setText("Deck Analysis");
|
analysisButton.setText("Deck Analysis");
|
||||||
@@ -205,8 +220,9 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
analysisButton_actionPerformed(e);
|
analysisButton_actionPerformed(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
analysisButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
analysisButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
||||||
|
}
|
||||||
analysisButton.setBounds(new Rectangle(578, 426, 166, 25));
|
analysisButton.setBounds(new Rectangle(578, 426, 166, 25));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -222,7 +238,9 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
|
|
||||||
Font f = new Font("Tahoma", Font.PLAIN, 10);
|
Font f = new Font("Tahoma", Font.PLAIN, 10);
|
||||||
for (JCheckBox box : filterBoxes.allTypes) {
|
for (JCheckBox box : filterBoxes.allTypes) {
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts) { box.setFont(f); }
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
|
box.setFont(f);
|
||||||
|
}
|
||||||
box.setOpaque(false);
|
box.setOpaque(false);
|
||||||
box.addItemListener(itemListenerUpdatesDisplay);
|
box.addItemListener(itemListenerUpdatesDisplay);
|
||||||
}
|
}
|
||||||
@@ -252,7 +270,6 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
// x 768 screen size
|
// x 768 screen size
|
||||||
this.setTitle("Deck Editor");
|
this.setTitle("Deck Editor");
|
||||||
|
|
||||||
|
|
||||||
this.getContentPane().add(filterNameTypeSet, null);
|
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);
|
||||||
@@ -275,12 +292,18 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
top.getTable().addKeyListener(new KeyAdapter() {
|
top.getTable().addKeyListener(new KeyAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(final KeyEvent e) {
|
public void keyPressed(final KeyEvent e) {
|
||||||
if (e.getKeyChar() == ' ') { addButtonActionPerformed(null); }
|
if (e.getKeyChar() == ' ') {
|
||||||
|
addButtonActionPerformed(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckEditorBase#buildFilter()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Predicate<InventoryItem> buildFilter() {
|
protected Predicate<InventoryItem> buildFilter() {
|
||||||
Predicate<CardPrinted> cardFilter = Predicate.and(filterBoxes.buildFilter(), filterNameTypeSet.buildFilter());
|
Predicate<CardPrinted> cardFilter = Predicate.and(filterBoxes.buildFilter(), filterNameTypeSet.buildFilter());
|
||||||
@@ -289,7 +312,9 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
|
|
||||||
private void addButtonActionPerformed(final ActionEvent e) {
|
private void addButtonActionPerformed(final ActionEvent e) {
|
||||||
InventoryItem item = top.getSelectedCard();
|
InventoryItem item = top.getSelectedCard();
|
||||||
if (item == null || !( item instanceof CardPrinted )) { return; }
|
if (item == null || !(item instanceof CardPrinted)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CardPrinted card = (CardPrinted) item;
|
CardPrinted card = (CardPrinted) item;
|
||||||
|
|
||||||
@@ -299,10 +324,11 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
bottom.addCard(card);
|
bottom.addCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void removeButtonActionPerformed(final ActionEvent e) {
|
private void removeButtonActionPerformed(final ActionEvent e) {
|
||||||
InventoryItem item = bottom.getSelectedCard();
|
InventoryItem item = bottom.getSelectedCard();
|
||||||
if (item == null || !( item instanceof CardPrinted )) { return; }
|
if (item == null || !(item instanceof CardPrinted)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CardPrinted card = (CardPrinted) item;
|
CardPrinted card = (CardPrinted) item;
|
||||||
|
|
||||||
@@ -312,7 +338,12 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
|
|||||||
bottom.removeCard(card);
|
bottom.removeCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the cheat card.
|
||||||
|
*
|
||||||
|
* @param card
|
||||||
|
* the card
|
||||||
|
*/
|
||||||
public void addCheatCard(final CardPrinted card) {
|
public void addCheatCard(final CardPrinted card) {
|
||||||
top.addCard(card);
|
top.addCard(card);
|
||||||
questData.getCards().getCardpool().add(card);
|
questData.getCards().getCardpool().add(card);
|
||||||
|
|||||||
@@ -1,5 +1,25 @@
|
|||||||
package forge.gui.deckeditor;
|
package forge.gui.deckeditor;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JMenu;
|
||||||
|
import javax.swing.JMenuBar;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
@@ -17,27 +37,11 @@ import forge.item.ItemPool;
|
|||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestData;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import javax.swing.filechooser.FileFilter;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
|
|
||||||
//presumes AllZone.getQuestData() is not null
|
//presumes AllZone.getQuestData() is not null
|
||||||
/**
|
/**
|
||||||
* <p>Gui_Quest_DeckEditor_Menu class.</p>
|
* <p>
|
||||||
|
* Gui_Quest_DeckEditor_Menu class.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
@@ -60,14 +64,19 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
// the class DeckDisplay is in the file "Gui_DeckEditor_Menu.java"
|
// the class DeckDisplay is in the file "Gui_DeckEditor_Menu.java"
|
||||||
private DeckDisplay deckDisplay;
|
private DeckDisplay deckDisplay;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for Gui_Quest_DeckEditor_Menu.</p>
|
* <p>
|
||||||
|
* Constructor for Gui_Quest_DeckEditor_Menu.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param d a {@link forge.gui.deckeditor.DeckDisplay} object.
|
* @param q
|
||||||
* @param exit a {@link forge.Command} object.
|
* the q
|
||||||
|
* @param d
|
||||||
|
* a {@link forge.gui.deckeditor.DeckDisplay} object.
|
||||||
|
* @param exit
|
||||||
|
* a {@link forge.Command} object.
|
||||||
*/
|
*/
|
||||||
public DeckEditorQuestMenu(QuestData q, final DeckDisplay d, final Command exit) {
|
public DeckEditorQuestMenu(final QuestData q, final DeckDisplay d, final Command exit) {
|
||||||
|
|
||||||
deckDisplay = d;
|
deckDisplay = d;
|
||||||
questData = q;
|
questData = q;
|
||||||
@@ -79,13 +88,15 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
setupMenu();
|
setupMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>addImportExport.</p>
|
* <p>
|
||||||
|
* addImportExport.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param menu a {@link javax.swing.JMenu} object.
|
* @param menu
|
||||||
* @param isHumanMenu a boolean.
|
* a {@link javax.swing.JMenu} object.
|
||||||
|
* @param isHumanMenu
|
||||||
|
* a boolean.
|
||||||
*/
|
*/
|
||||||
private void addImportExport(final JMenu menu, final boolean isHumanMenu) {
|
private void addImportExport(final JMenu menu, final boolean isHumanMenu) {
|
||||||
JMenuItem import2 = new JMenuItem("Import");
|
JMenuItem import2 = new JMenuItem("Import");
|
||||||
@@ -109,7 +120,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
} // addImportExport()
|
} // addImportExport()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>exportDeck.</p>
|
* <p>
|
||||||
|
* exportDeck.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
private void exportDeck() {
|
private void exportDeck() {
|
||||||
File filename = getExportFilename();
|
File filename = getExportFilename();
|
||||||
@@ -139,10 +152,14 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
} // exportDeck()
|
} // exportDeck()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>exportDeckText.</p>
|
* <p>
|
||||||
|
* exportDeckText.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param deckText a {@link java.lang.String} object.
|
* @param deckText
|
||||||
* @param filename a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
|
* @param filename
|
||||||
|
* a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private void exportDeckText(final String deckText, String filename) {
|
private void exportDeckText(final String deckText, String filename) {
|
||||||
|
|
||||||
@@ -158,15 +175,18 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
writer.close();
|
writer.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ErrorViewer.showError(ex);
|
ErrorViewer.showError(ex);
|
||||||
throw new RuntimeException("Gui_Quest_DeckEditor_Menu : exportDeckText() error, " + ex.getMessage()
|
throw new RuntimeException("Gui_Quest_DeckEditor_Menu : exportDeckText() error, " + ex.getMessage() + " : "
|
||||||
+ " : " + Arrays.toString(ex.getStackTrace()));
|
+ Arrays.toString(ex.getStackTrace()));
|
||||||
}
|
}
|
||||||
} // exportDeckText()
|
} // exportDeckText()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getExportDeckText.</p>
|
* <p>
|
||||||
|
* getExportDeckText.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param aDeck a {@link forge.deck.Deck} object.
|
* @param aDeck
|
||||||
|
* a {@link forge.deck.Deck} object.
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private String getExportDeckText(final Deck aDeck) {
|
private String getExportDeckText(final Deck aDeck) {
|
||||||
@@ -182,19 +202,22 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
|
|
||||||
// creatures
|
// creatures
|
||||||
|
|
||||||
sb.append(String.format("%d Creatures%n-------------%n", CardRules.Predicates.Presets.isCreature.aggregate(all, all.fnToCard, all.fnToCount)));
|
sb.append(String.format("%d Creatures%n-------------%n",
|
||||||
|
CardRules.Predicates.Presets.isCreature.aggregate(all, all.fnToCard, all.fnToCount)));
|
||||||
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.isCreature.select(all, all.fnToCard)) {
|
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.isCreature.select(all, all.fnToCard)) {
|
||||||
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// spells
|
// spells
|
||||||
sb.append(String.format("%d Spells%n----------%n", CardRules.Predicates.Presets.isNonCreatureSpell.aggregate(all, all.fnToCard, all.fnToCount)));
|
sb.append(String.format("%d Spells%n----------%n",
|
||||||
|
CardRules.Predicates.Presets.isNonCreatureSpell.aggregate(all, all.fnToCard, all.fnToCount)));
|
||||||
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.isNonCreatureSpell.select(all, all.fnToCard)) {
|
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.isNonCreatureSpell.select(all, all.fnToCard)) {
|
||||||
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// lands
|
// lands
|
||||||
sb.append(String.format("%d Land%n--------%n", CardRules.Predicates.Presets.isLand.aggregate(all, all.fnToCard, all.fnToCount)));
|
sb.append(String.format("%d Land%n--------%n",
|
||||||
|
CardRules.Predicates.Presets.isLand.aggregate(all, all.fnToCard, all.fnToCount)));
|
||||||
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.isLand.select(all, all.fnToCard)) {
|
for (Entry<CardPrinted, Integer> e : CardRules.Predicates.Presets.isLand.select(all, all.fnToCard)) {
|
||||||
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName()));
|
||||||
}
|
}
|
||||||
@@ -205,7 +228,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
} // getExportDeckText
|
} // getExportDeckText
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getFileFilter.</p>
|
* <p>
|
||||||
|
* getFileFilter.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return a {@link javax.swing.filechooser.FileFilter} object.
|
* @return a {@link javax.swing.filechooser.FileFilter} object.
|
||||||
*/
|
*/
|
||||||
@@ -226,7 +251,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
} // getFileFilter()
|
} // getFileFilter()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getExportFilename.</p>
|
* <p>
|
||||||
|
* getExportFilename.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return a {@link java.io.File} object.
|
* @return a {@link java.io.File} object.
|
||||||
*/
|
*/
|
||||||
@@ -259,7 +286,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
} // getExportFilename()
|
} // getExportFilename()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>importDeck.</p>
|
* <p>
|
||||||
|
* importDeck.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
private void importDeck() {
|
private void importDeck() {
|
||||||
File file = getImportFilename();
|
File file = getImportFilename();
|
||||||
@@ -270,7 +299,8 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
Deck newDeck = DeckManager.readDeck(file);
|
Deck newDeck = DeckManager.readDeck(file);
|
||||||
questData.addDeck(newDeck);
|
questData.addDeck(newDeck);
|
||||||
|
|
||||||
ItemPool<CardPrinted> cardpool = ItemPool.createFrom(questData.getCards().getCardpool(), CardPrinted.class);
|
ItemPool<CardPrinted> cardpool = ItemPool.createFrom(questData.getCards().getCardpool(),
|
||||||
|
CardPrinted.class);
|
||||||
ItemPool<CardPrinted> decklist = new ItemPool<CardPrinted>(CardPrinted.class);
|
ItemPool<CardPrinted> decklist = new ItemPool<CardPrinted>(CardPrinted.class);
|
||||||
for (Entry<CardPrinted, Integer> s : newDeck.getMain()) {
|
for (Entry<CardPrinted, Integer> s : newDeck.getMain()) {
|
||||||
CardPrinted cp = s.getKey();
|
CardPrinted cp = s.getKey();
|
||||||
@@ -289,7 +319,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
} // importDeck()
|
} // importDeck()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>getImportFilename.</p>
|
* <p>
|
||||||
|
* getImportFilename.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return a {@link java.io.File} object.
|
* @return a {@link java.io.File} object.
|
||||||
*/
|
*/
|
||||||
@@ -308,15 +340,16 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
return null;
|
return null;
|
||||||
} // openFileDialog()
|
} // openFileDialog()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final ActionListener addCardActionListener = new ActionListener() {
|
private final ActionListener addCardActionListener = new ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent a) {
|
public void actionPerformed(final ActionEvent a) {
|
||||||
|
|
||||||
// Provide a model here: all unique cards to be displayed by only name (unlike default toString)
|
// Provide a model here: all unique cards to be displayed by only
|
||||||
|
// name (unlike default toString)
|
||||||
Iterable<CardPrinted> uniqueCards = CardDb.instance().getAllUniqueCards();
|
Iterable<CardPrinted> uniqueCards = CardDb.instance().getAllUniqueCards();
|
||||||
List<String> cards = new ArrayList<String>();
|
List<String> cards = new ArrayList<String>();
|
||||||
for (CardPrinted c : uniqueCards) { cards.add(c.getName()); }
|
for (CardPrinted c : uniqueCards) {
|
||||||
|
cards.add(c.getName());
|
||||||
|
}
|
||||||
Collections.sort(cards);
|
Collections.sort(cards);
|
||||||
|
|
||||||
// use standard forge's list selection dialog
|
// use standard forge's list selection dialog
|
||||||
@@ -334,10 +367,13 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
String deckName = getUserInput_OpenDeck(questData.getDeckNames());
|
String deckName = getUserInput_OpenDeck(questData.getDeckNames());
|
||||||
|
|
||||||
// check if user selected "cancel"
|
// check if user selected "cancel"
|
||||||
if (StringUtils.isBlank(deckName)) { return; }
|
if (StringUtils.isBlank(deckName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setPlayerDeckName(deckName);
|
setPlayerDeckName(deckName);
|
||||||
ItemPool<CardPrinted> cards = ItemPool.createFrom(questData.getCards().getCardpool().getView(), CardPrinted.class);
|
ItemPool<CardPrinted> cards = ItemPool.createFrom(questData.getCards().getCardpool().getView(),
|
||||||
|
CardPrinted.class);
|
||||||
ItemPoolView<CardPrinted> deck = questData.getDeck(deckName).getMain();
|
ItemPoolView<CardPrinted> deck = questData.getDeck(deckName).getMain();
|
||||||
|
|
||||||
// show in pool all cards except ones used in deck
|
// show in pool all cards except ones used in deck
|
||||||
@@ -358,7 +394,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
String deckName = getUserInput_GetDeckName(questData.getDeckNames());
|
String deckName = getUserInput_GetDeckName(questData.getDeckNames());
|
||||||
|
|
||||||
// check if user cancels
|
// check if user cancels
|
||||||
if (StringUtils.isBlank(deckName)) { return; }
|
if (StringUtils.isBlank(deckName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// is the current deck already saved and in QuestData?
|
// is the current deck already saved and in QuestData?
|
||||||
if (questData.getDeckNames().contains(currentDeck.getName())) {
|
if (questData.getDeckNames().contains(currentDeck.getName())) {
|
||||||
@@ -422,8 +460,8 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int check = JOptionPane.showConfirmDialog(null, "Do you really want to delete this deck?",
|
int check = JOptionPane.showConfirmDialog(null, "Do you really want to delete this deck?", "Delete",
|
||||||
"Delete", JOptionPane.YES_NO_OPTION);
|
JOptionPane.YES_NO_OPTION);
|
||||||
if (check == JOptionPane.NO_OPTION) {
|
if (check == JOptionPane.NO_OPTION) {
|
||||||
return; // stop here
|
return; // stop here
|
||||||
}
|
}
|
||||||
@@ -439,7 +477,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
|
|
||||||
// the usual menu options that will be used
|
// the usual menu options that will be used
|
||||||
/**
|
/**
|
||||||
* <p>setupMenu.</p>
|
* <p>
|
||||||
|
* setupMenu.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
private void setupMenu() {
|
private void setupMenu() {
|
||||||
JMenuItem openDeck = new JMenuItem("Open");
|
JMenuItem openDeck = new JMenuItem("Open");
|
||||||
@@ -452,7 +492,6 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
|
|
||||||
JMenuItem addCard = new JMenuItem("Cheat - Add Card");
|
JMenuItem addCard = new JMenuItem("Cheat - Add Card");
|
||||||
|
|
||||||
|
|
||||||
addCard.addActionListener(addCardActionListener);
|
addCard.addActionListener(addCardActionListener);
|
||||||
openDeck.addActionListener(openDeckActionListener);
|
openDeck.addActionListener(openDeckActionListener);
|
||||||
newDeck.addActionListener(newDeckActionListener);
|
newDeck.addActionListener(newDeckActionListener);
|
||||||
@@ -461,7 +500,6 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
copy.addActionListener(copyDeckActionListener);
|
copy.addActionListener(copyDeckActionListener);
|
||||||
delete.addActionListener(deleteDeckActionListener);
|
delete.addActionListener(deleteDeckActionListener);
|
||||||
|
|
||||||
|
|
||||||
// human
|
// human
|
||||||
exit.addActionListener(new ActionListener() {
|
exit.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(final ActionEvent a) {
|
public void actionPerformed(final ActionEvent a) {
|
||||||
@@ -494,9 +532,12 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>convertCardPoolToDeck.</p>
|
* <p>
|
||||||
|
* convertCardPoolToDeck.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param list a {@link forge.CardPool} object.
|
* @param list
|
||||||
|
* a {@link forge.CardPool} object.
|
||||||
* @return a {@link forge.deck.Deck} object.
|
* @return a {@link forge.deck.Deck} object.
|
||||||
*/
|
*/
|
||||||
private Deck cardPoolToDeck(final ItemPoolView<InventoryItem> list) {
|
private Deck cardPoolToDeck(final ItemPoolView<InventoryItem> list) {
|
||||||
@@ -508,9 +549,12 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
|
|
||||||
// needs to be public because Gui_Quest_DeckEditor.show(Command) uses it
|
// needs to be public because Gui_Quest_DeckEditor.show(Command) uses it
|
||||||
/**
|
/**
|
||||||
* <p>setHumanPlayer.</p>
|
* <p>
|
||||||
|
* setHumanPlayer.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param deckName a {@link java.lang.String} object.
|
* @param deckName
|
||||||
|
* a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
public final void setPlayerDeckName(final String deckName) {
|
public final void setPlayerDeckName(final String deckName) {
|
||||||
// the gui uses this, Gui_Quest_DeckEditor
|
// the gui uses this, Gui_Quest_DeckEditor
|
||||||
@@ -522,9 +566,12 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
|
|
||||||
// only accepts numbers, letters or dashes up to 20 characters in length
|
// only accepts numbers, letters or dashes up to 20 characters in length
|
||||||
/**
|
/**
|
||||||
* <p>cleanString.</p>
|
* <p>
|
||||||
|
* cleanString.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param in a {@link java.lang.String} object.
|
* @param in
|
||||||
|
* a {@link java.lang.String} object.
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private String cleanString(final String in) {
|
private String cleanString(final String in) {
|
||||||
@@ -532,7 +579,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
char[] c = in.toCharArray();
|
char[] c = in.toCharArray();
|
||||||
|
|
||||||
for (int i = 0; i < c.length && i < 20; i++) {
|
for (int i = 0; i < c.length && i < 20; i++) {
|
||||||
if (Character.isLetterOrDigit(c[i]) || c[i] == '-' || c[i] == '_' || c[i] == ' ') { out.append(c[i]); }
|
if (Character.isLetterOrDigit(c[i]) || c[i] == '-' || c[i] == '_' || c[i] == ' ') {
|
||||||
|
out.append(c[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return out.toString();
|
return out.toString();
|
||||||
@@ -540,9 +589,12 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
|
|
||||||
// if user cancels, returns ""
|
// if user cancels, returns ""
|
||||||
/**
|
/**
|
||||||
* <p>getUserInput_GetDeckName.</p>
|
* <p>
|
||||||
|
* getUserInput_GetDeckName.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param nameList a {@link java.util.List} object.
|
* @param nameList
|
||||||
|
* a {@link java.util.List} object.
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private String getUserInput_GetDeckName(final List<String> nameList) {
|
private String getUserInput_GetDeckName(final List<String> nameList) {
|
||||||
@@ -562,12 +614,14 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
return deckName;
|
return deckName;
|
||||||
} // getUserInput_GetDeckName()
|
} // getUserInput_GetDeckName()
|
||||||
|
|
||||||
|
|
||||||
// if user cancels, it will return ""
|
// if user cancels, it will return ""
|
||||||
/**
|
/**
|
||||||
* <p>getUserInput_OpenDeck.</p>
|
* <p>
|
||||||
|
* getUserInput_OpenDeck.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param deckNameList a {@link java.util.List} object.
|
* @param deckNameList
|
||||||
|
* a {@link java.util.List} object.
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
private String getUserInput_OpenDeck(final List<String> deckNameList) {
|
private String getUserInput_OpenDeck(final List<String> deckNameList) {
|
||||||
@@ -577,7 +631,8 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//Object o = JOptionPane.showInputDialog(null, "Deck Name", "Open Deck", JOptionPane.OK_CANCEL_OPTION, null,
|
// Object o = JOptionPane.showInputDialog(null, "Deck Name",
|
||||||
|
// "Open Deck", JOptionPane.OK_CANCEL_OPTION, null,
|
||||||
// choices.toArray(), choices.toArray()[0]);
|
// choices.toArray(), choices.toArray()[0]);
|
||||||
Object o = GuiUtils.getChoiceOptional("Select Deck", choices.toArray());
|
Object o = GuiUtils.getChoiceOptional("Select Deck", choices.toArray());
|
||||||
|
|
||||||
@@ -590,7 +645,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
|
|
||||||
// used by Gui_Quest_DeckEditor
|
// used by Gui_Quest_DeckEditor
|
||||||
/**
|
/**
|
||||||
* <p>close.</p>
|
* <p>
|
||||||
|
* close.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public final void close() {
|
public final void close() {
|
||||||
exitCommand.execute();
|
exitCommand.execute();
|
||||||
@@ -598,7 +655,9 @@ public class DeckEditorQuestMenu extends JMenuBar {
|
|||||||
|
|
||||||
// used by Gui_Quest_DeckEditor
|
// used by Gui_Quest_DeckEditor
|
||||||
/**
|
/**
|
||||||
* <p>getDeckName.</p>
|
* <p>
|
||||||
|
* getDeckName.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return a {@link java.lang.String} object.
|
* @return a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import javax.swing.JOptionPane;
|
|||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
import forge.Command;
|
import forge.Command;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
@@ -63,8 +62,12 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
private Map<String, Integer> mapPrices = r.getPriceList();
|
private Map<String, Integer> mapPrices = r.getPriceList();
|
||||||
private Map<CardPrinted, Integer> decksUsingMyCards;
|
private Map<CardPrinted, Integer> decksUsingMyCards;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show.
|
||||||
|
*
|
||||||
|
* @param exitCommand
|
||||||
|
* the exit command
|
||||||
|
*/
|
||||||
public void show(final Command exitCommand) {
|
public void show(final Command exitCommand) {
|
||||||
final Command exit = new Command() {
|
final Command exit = new Command() {
|
||||||
private static final long serialVersionUID = -7428793574300520612L;
|
private static final long serialVersionUID = -7428793574300520612L;
|
||||||
@@ -78,7 +81,7 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
// do not change this!!!!
|
// do not change this!!!!
|
||||||
this.addWindowListener(new WindowAdapter() {
|
this.addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent ev) {
|
public void windowClosing(final WindowEvent ev) {
|
||||||
exit.execute();
|
exit.execute();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -104,8 +107,11 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
String maxSellingPrice = "";
|
String maxSellingPrice = "";
|
||||||
int maxSellPrice = questData.getCards().getSellPriceLimit();
|
int maxSellPrice = questData.getCards().getSellPriceLimit();
|
||||||
|
|
||||||
if (maxSellPrice < Integer.MAX_VALUE) { maxSellingPrice = String.format("Max selling price: %d", maxSellPrice); }
|
if (maxSellPrice < Integer.MAX_VALUE) {
|
||||||
sellPercentageLabel.setText("<html>(You can sell cards at " + formatter.format(multiPercent) + "% of their value)<br>" + maxSellingPrice + "</html>");
|
maxSellingPrice = String.format("Max selling price: %d", maxSellPrice);
|
||||||
|
}
|
||||||
|
sellPercentageLabel.setText("<html>(You can sell cards at " + formatter.format(multiPercent)
|
||||||
|
+ "% of their value)<br>" + maxSellingPrice + "</html>");
|
||||||
|
|
||||||
top.sort(1, true);
|
top.sort(1, true);
|
||||||
bottom.sort(1, true);
|
bottom.sort(1, true);
|
||||||
@@ -134,12 +140,17 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
private void setup() {
|
private void setup() {
|
||||||
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
List<TableColumnInfo<InventoryItem>> columns = new ArrayList<TableColumnInfo<InventoryItem>>();
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Qty", 30, PresetColumns.fnQtyCompare, PresetColumns.fnQtyGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.fnNameCompare, PresetColumns.fnNameGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Name", 180, PresetColumns.fnNameCompare,
|
||||||
|
PresetColumns.fnNameGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Cost", 70, PresetColumns.fnCostCompare, PresetColumns.fnCostGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare, PresetColumns.fnColorGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Color", 50, PresetColumns.fnColorCompare,
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare, PresetColumns.fnTypeGet));
|
PresetColumns.fnColorGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare, PresetColumns.fnStatsGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Type", 100, PresetColumns.fnTypeCompare,
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("R", 30, PresetColumns.fnRarityCompare, PresetColumns.fnRarityGet));
|
PresetColumns.fnTypeGet));
|
||||||
|
columns.add(new TableColumnInfo<InventoryItem>("Stats", 40, PresetColumns.fnStatsCompare,
|
||||||
|
PresetColumns.fnStatsGet));
|
||||||
|
columns.add(new TableColumnInfo<InventoryItem>("R", 30, PresetColumns.fnRarityCompare,
|
||||||
|
PresetColumns.fnRarityGet));
|
||||||
columns.add(new TableColumnInfo<InventoryItem>("Set", 35, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
columns.add(new TableColumnInfo<InventoryItem>("Set", 35, PresetColumns.fnSetCompare, PresetColumns.fnSetGet));
|
||||||
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
columns.get(2).setCellRenderer(new ManaCostRenderer());
|
||||||
|
|
||||||
@@ -148,7 +159,8 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
top.setup(columns, cardView);
|
top.setup(columns, cardView);
|
||||||
|
|
||||||
columnsBelow.add(new TableColumnInfo<InventoryItem>("Dks", 30, fnDeckCompare, fnDeckGet));
|
columnsBelow.add(new TableColumnInfo<InventoryItem>("Dks", 30, fnDeckCompare, fnDeckGet));
|
||||||
columnsBelow.add(new TableColumnInfo<InventoryItem>("New", 35, questData.getCards().fnNewCompare, questData.getCards().fnNewGet));
|
columnsBelow.add(new TableColumnInfo<InventoryItem>("New", 35, questData.getCards().fnNewCompare, questData
|
||||||
|
.getCards().fnNewGet));
|
||||||
columnsBelow.add(new TableColumnInfo<InventoryItem>("Price", 36, fnPriceCompare, fnPriceSellGet));
|
columnsBelow.add(new TableColumnInfo<InventoryItem>("Price", 36, fnPriceCompare, fnPriceSellGet));
|
||||||
bottom.setup(columnsBelow, cardView);
|
bottom.setup(columnsBelow, cardView);
|
||||||
|
|
||||||
@@ -179,7 +191,6 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* jbInit.
|
* jbInit.
|
||||||
@@ -196,23 +207,25 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
|
|
||||||
sellButton.setBounds(new Rectangle(180, 403, 146, 49));
|
sellButton.setBounds(new Rectangle(180, 403, 146, 49));
|
||||||
// removeButton.setIcon(upIcon);
|
// removeButton.setIcon(upIcon);
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
sellButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
sellButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
||||||
|
}
|
||||||
sellButton.setText("Sell Card");
|
sellButton.setText("Sell Card");
|
||||||
sellButton.addActionListener(new java.awt.event.ActionListener() {
|
sellButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
sellButton_actionPerformed(e);
|
sellButton_actionPerformed(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buyButton.setText("Buy Card");
|
buyButton.setText("Buy Card");
|
||||||
buyButton.addActionListener(new java.awt.event.ActionListener() {
|
buyButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(final ActionEvent e) {
|
||||||
buyButton_actionPerformed(e);
|
buyButton_actionPerformed(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
buyButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
buyButton.setFont(new java.awt.Font("Dialog", 0, 13));
|
||||||
|
}
|
||||||
buyButton.setBounds(new Rectangle(23, 403, 146, 49));
|
buyButton.setBounds(new Rectangle(23, 403, 146, 49));
|
||||||
|
|
||||||
cardView.setBounds(new Rectangle(765, 23, 239, 710));
|
cardView.setBounds(new Rectangle(765, 23, 239, 710));
|
||||||
@@ -222,12 +235,14 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
|
|
||||||
creditsLabel.setBounds(new Rectangle(19, 365, 720, 31));
|
creditsLabel.setBounds(new Rectangle(19, 365, 720, 31));
|
||||||
creditsLabel.setText("Total credits: " + questData.getCredits());
|
creditsLabel.setText("Total credits: " + questData.getCredits());
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
creditsLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
creditsLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
|
}
|
||||||
sellPercentageLabel.setBounds(new Rectangle(350, 403, 450, 31));
|
sellPercentageLabel.setBounds(new Rectangle(350, 403, 450, 31));
|
||||||
sellPercentageLabel.setText("(Sell percentage: " + multiplier + ")");
|
sellPercentageLabel.setText("(Sell percentage: " + multiplier + ")");
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts)
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
sellPercentageLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
sellPercentageLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
|
}
|
||||||
jLabel1.setText("Click on the column name (like name or color) to sort the cards");
|
jLabel1.setText("Click on the column name (like name or color) to sort the cards");
|
||||||
jLabel1.setBounds(new Rectangle(20, 1, 400, 19));
|
jLabel1.setBounds(new Rectangle(20, 1, 400, 19));
|
||||||
|
|
||||||
@@ -247,12 +262,18 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
return mapPrices.get(card.getName());
|
return mapPrices.get(card.getName());
|
||||||
} else if (card instanceof CardPrinted) {
|
} else if (card instanceof CardPrinted) {
|
||||||
switch (((CardPrinted) card).getRarity()) {
|
switch (((CardPrinted) card).getRarity()) {
|
||||||
case BasicLand: return Integer.valueOf(4);
|
case BasicLand:
|
||||||
case Common: return Integer.valueOf(6);
|
return Integer.valueOf(4);
|
||||||
case Uncommon: return Integer.valueOf(40);
|
case Common:
|
||||||
case Rare: return Integer.valueOf(120);
|
return Integer.valueOf(6);
|
||||||
case MythicRare: return Integer.valueOf(600);
|
case Uncommon:
|
||||||
default: return Integer.valueOf(15);
|
return Integer.valueOf(40);
|
||||||
|
case Rare:
|
||||||
|
return Integer.valueOf(120);
|
||||||
|
case MythicRare:
|
||||||
|
return Integer.valueOf(600);
|
||||||
|
default:
|
||||||
|
return Integer.valueOf(15);
|
||||||
}
|
}
|
||||||
} else if (card instanceof BoosterPack) {
|
} else if (card instanceof BoosterPack) {
|
||||||
return 395;
|
return 395;
|
||||||
@@ -260,9 +281,11 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
return 1337;
|
return 1337;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buyButton_actionPerformed(ActionEvent e) {
|
private void buyButton_actionPerformed(final ActionEvent e) {
|
||||||
InventoryItem item = top.getSelectedCard();
|
InventoryItem item = top.getSelectedCard();
|
||||||
if (item == null ) { return; }
|
if (item == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int value = getCardValue(item);
|
int value = getCardValue(item);
|
||||||
|
|
||||||
@@ -278,8 +301,11 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
BoosterPack booster = (BoosterPack) ((BoosterPack) item).clone();
|
BoosterPack booster = (BoosterPack) ((BoosterPack) item).clone();
|
||||||
questData.getCards().buyBooster(booster, value);
|
questData.getCards().buyBooster(booster, value);
|
||||||
List<CardPrinted> newCards = booster.getCards();
|
List<CardPrinted> newCards = booster.getCards();
|
||||||
for (CardPrinted card : newCards) { bottom.addCard(card); }
|
for (CardPrinted card : newCards) {
|
||||||
CardListViewer c = new CardListViewer(booster.getName(), "You have found the following cards inside:", newCards);
|
bottom.addCard(card);
|
||||||
|
}
|
||||||
|
CardListViewer c = new CardListViewer(booster.getName(), "You have found the following cards inside:",
|
||||||
|
newCards);
|
||||||
c.show();
|
c.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,14 +315,21 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see forge.gui.deckeditor.DeckEditorBase#buildFilter()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Predicate<InventoryItem> buildFilter() {
|
protected Predicate<InventoryItem> buildFilter() {
|
||||||
return Predicate.getTrue(InventoryItem.class);
|
return Predicate.getTrue(InventoryItem.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sellButton_actionPerformed(ActionEvent e) {
|
private void sellButton_actionPerformed(final ActionEvent e) {
|
||||||
InventoryItem item = bottom.getSelectedCard();
|
InventoryItem item = bottom.getSelectedCard();
|
||||||
if (item == null || !( item instanceof CardPrinted )) { return; }
|
if (item == null || !(item instanceof CardPrinted)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CardPrinted card = (CardPrinted) item;
|
CardPrinted card = (CardPrinted) item;
|
||||||
bottom.removeCard(card);
|
bottom.removeCard(card);
|
||||||
@@ -309,29 +342,39 @@ public final class DeckEditorShop extends DeckEditorBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnPriceCompare =
|
private final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnPriceCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return getCardValue(from.getKey()); } };
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnPriceGet =
|
return getCardValue(from.getKey());
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
}
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return getCardValue(from.getKey()); } };
|
};
|
||||||
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnPriceSellGet =
|
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnPriceGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return (int) (multiplier * getCardValue(from.getKey())); } };
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return getCardValue(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnPriceSellGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return (int) (multiplier * getCardValue(from.getKey()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnDeckCompare =
|
private final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnDeckCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
Integer iValue = decksUsingMyCards.get(from.getKey());
|
Integer iValue = decksUsingMyCards.get(from.getKey());
|
||||||
return iValue == null ? Integer.valueOf(0) : iValue;
|
return iValue == null ? Integer.valueOf(0) : iValue;
|
||||||
} };
|
}
|
||||||
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnDeckGet =
|
};
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnDeckGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
Integer iValue = decksUsingMyCards.get(from.getKey());
|
Integer iValue = decksUsingMyCards.get(from.getKey());
|
||||||
return iValue == null ? "" : iValue.toString();
|
return iValue == null ? "" : iValue.toString();
|
||||||
} };
|
}
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import javax.swing.text.Element;
|
|||||||
import javax.swing.text.ElementIterator;
|
import javax.swing.text.ElementIterator;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.deck.Deck;
|
import forge.deck.Deck;
|
||||||
import forge.deck.DeckRecognizer;
|
import forge.deck.DeckRecognizer;
|
||||||
@@ -33,31 +32,30 @@ import forge.gui.GuiUtils;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog for quick import of decks
|
* Dialog for quick import of decks.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class DeckImport extends JDialog {
|
public class DeckImport extends JDialog {
|
||||||
private static final long serialVersionUID = -5837776824284093004L;
|
private static final long serialVersionUID = -5837776824284093004L;
|
||||||
|
|
||||||
private JTextArea txtInput = new JTextArea();
|
private JTextArea txtInput = new JTextArea();
|
||||||
private static final String stylesheet = "<style>" +
|
private static final String stylesheet = "<style>"
|
||||||
"body, h1, h2, h3, h4, h5, h6, table, tr, td, p {margin: 1px; padding: 0; font-weight: normal; font-style: normal; text-decoration: none; font-family: Arial; font-size: 10px;} " +
|
+ "body, h1, h2, h3, h4, h5, h6, table, tr, td, p {margin: 1px; padding: 0; font-weight: normal; font-style: normal; text-decoration: none; font-family: Arial; font-size: 10px;} "
|
||||||
//"h1 {border-bottom: solid 1px black; color: blue; font-size: 12px; margin: 3px 0 9px 0; } " +
|
+
|
||||||
".comment {color: #666666;} " +
|
// "h1 {border-bottom: solid 1px black; color: blue; font-size: 12px; margin: 3px 0 9px 0; } "
|
||||||
".knowncard {color: #009900;} " +
|
// +
|
||||||
".unknowncard {color: #990000;} " +
|
".comment {color: #666666;} " + ".knowncard {color: #009900;} " + ".unknowncard {color: #990000;} "
|
||||||
".section {padding: 3px 10px; margin: 3px 0; font-weight: 700; background-color: #DDDDDD; } " +
|
+ ".section {padding: 3px 10px; margin: 3px 0; font-weight: 700; background-color: #DDDDDD; } "
|
||||||
"</style>";
|
+ "</style>";
|
||||||
private static final String htmlWelcomeText = "<html>"+stylesheet+"<h3>You'll see recognized cards here</h3>" +
|
private static final String htmlWelcomeText = "<html>"
|
||||||
"<div class='section'>Legend</div>" +
|
+ stylesheet
|
||||||
"<ul>" +
|
+ "<h3>You'll see recognized cards here</h3>"
|
||||||
"<li class='knowncard'>Recognized cards will be shown in green. These cards will be auto-imported into a new deck<BR></li>" +
|
+ "<div class='section'>Legend</div>"
|
||||||
"<li class='unknowncard'>Lines which seem to be cards but are either misspelled or unsupported by Forge, are shown in dark-red<BR></li>" +
|
+ "<ul>"
|
||||||
"<li class='comment'>Lines that appear unsignificant will be shown in gray<BR><BR></li>" +
|
+ "<li class='knowncard'>Recognized cards will be shown in green. These cards will be auto-imported into a new deck<BR></li>"
|
||||||
"</ul>" +
|
+ "<li class='unknowncard'>Lines which seem to be cards but are either misspelled or unsupported by Forge, are shown in dark-red<BR></li>"
|
||||||
"<div class='comment'>Submit feedback to Max mtg on slightlymagic.net forum</div>" +
|
+ "<li class='comment'>Lines that appear unsignificant will be shown in gray<BR><BR></li>" + "</ul>"
|
||||||
"<div class='comment'>Post bug-reports to http://cardforge.org/bugz/</div>" +
|
+ "<div class='comment'>Submit feedback to Max mtg on slightlymagic.net forum</div>"
|
||||||
"</html>";
|
+ "<div class='comment'>Post bug-reports to http://cardforge.org/bugz/</div>" + "</html>";
|
||||||
|
|
||||||
private JEditorPane htmlOutput = new JEditorPane("text/html", htmlWelcomeText);
|
private JEditorPane htmlOutput = new JEditorPane("text/html", htmlWelcomeText);
|
||||||
private JScrollPane scrollInput = new JScrollPane(txtInput);
|
private JScrollPane scrollInput = new JScrollPane(txtInput);
|
||||||
@@ -67,11 +65,18 @@ public class DeckImport extends JDialog {
|
|||||||
private JButton cmdAccept = new JButton("Import Deck");
|
private JButton cmdAccept = new JButton("Import Deck");
|
||||||
private JButton cmdCancel = new JButton("Cancel");
|
private JButton cmdCancel = new JButton("Cancel");
|
||||||
|
|
||||||
|
/** The tokens. */
|
||||||
List<DeckRecognizer.Token> tokens = new ArrayList<DeckRecognizer.Token>();
|
List<DeckRecognizer.Token> tokens = new ArrayList<DeckRecognizer.Token>();
|
||||||
|
|
||||||
private final DeckEditorBase host;
|
private final DeckEditorBase host;
|
||||||
|
|
||||||
public DeckImport(DeckEditorBase g) {
|
/**
|
||||||
|
* Instantiates a new deck import.
|
||||||
|
*
|
||||||
|
* @param g
|
||||||
|
* the g
|
||||||
|
*/
|
||||||
|
public DeckImport(final DeckEditorBase g) {
|
||||||
host = g;
|
host = g;
|
||||||
|
|
||||||
int wWidth = 600;
|
int wWidth = 600;
|
||||||
@@ -83,7 +88,6 @@ public class DeckImport extends JDialog {
|
|||||||
setResizable(false);
|
setResizable(false);
|
||||||
setTitle("Deck Import (wip)");
|
setTitle("Deck Import (wip)");
|
||||||
|
|
||||||
|
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts) {
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
Font fButtons = new java.awt.Font("Dialog", 0, 13);
|
Font fButtons = new java.awt.Font("Dialog", 0, 13);
|
||||||
cmdAccept.setFont(fButtons);
|
cmdAccept.setFont(fButtons);
|
||||||
@@ -96,7 +100,8 @@ public class DeckImport extends JDialog {
|
|||||||
htmlOutput.setEditable(false);
|
htmlOutput.setEditable(false);
|
||||||
|
|
||||||
scrollInput.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Paste or type a decklist"));
|
scrollInput.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Paste or type a decklist"));
|
||||||
scrollOutput.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Expect the recognized lines to appear"));
|
scrollOutput.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(),
|
||||||
|
"Expect the recognized lines to appear"));
|
||||||
scrollInput.setViewportBorder(BorderFactory.createLoweredBevelBorder());
|
scrollInput.setViewportBorder(BorderFactory.createLoweredBevelBorder());
|
||||||
scrollOutput.setViewportBorder(BorderFactory.createLoweredBevelBorder());
|
scrollOutput.setViewportBorder(BorderFactory.createLoweredBevelBorder());
|
||||||
|
|
||||||
@@ -111,29 +116,39 @@ public class DeckImport extends JDialog {
|
|||||||
getContentPane().add(cmdCancel, "w 100");
|
getContentPane().add(cmdCancel, "w 100");
|
||||||
|
|
||||||
cmdCancel.addActionListener(new ActionListener() {
|
cmdCancel.addActionListener(new ActionListener() {
|
||||||
@Override public void actionPerformed(ActionEvent e) {
|
@Override
|
||||||
processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING)); } });
|
public void actionPerformed(final ActionEvent e) {
|
||||||
|
processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
cmdAccept.addActionListener(new ActionListener() {
|
cmdAccept.addActionListener(new ActionListener() {
|
||||||
@Override public void actionPerformed(ActionEvent e) {
|
@Override
|
||||||
|
public void actionPerformed(final ActionEvent e) {
|
||||||
String warning = "This will replace contents of your currently open deck with whatever you are importing. Proceed?";
|
String warning = "This will replace contents of your currently open deck with whatever you are importing. Proceed?";
|
||||||
int answer = JOptionPane.showConfirmDialog(DeckImport.this, warning, "Replacing old deck", JOptionPane.YES_NO_OPTION);
|
int answer = JOptionPane.showConfirmDialog(DeckImport.this, warning, "Replacing old deck",
|
||||||
if (JOptionPane.NO_OPTION == answer) { return; }
|
JOptionPane.YES_NO_OPTION);
|
||||||
|
if (JOptionPane.NO_OPTION == answer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Deck toSet = buildDeck();
|
Deck toSet = buildDeck();
|
||||||
host.setDeck(null, toSet.getMain(), toSet.getDeckType());
|
host.setDeck(null, toSet.getMain(), toSet.getDeckType());
|
||||||
processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING)); } });
|
processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
txtInput.getDocument().addDocumentListener(new OnChangeTextUpdate());
|
txtInput.getDocument().addDocumentListener(new OnChangeTextUpdate());
|
||||||
cmdAccept.setEnabled(false);
|
cmdAccept.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readInput()
|
private void readInput() {
|
||||||
{
|
|
||||||
tokens.clear();
|
tokens.clear();
|
||||||
ElementIterator it = new ElementIterator(txtInput.getDocument().getDefaultRootElement());
|
ElementIterator it = new ElementIterator(txtInput.getDocument().getDefaultRootElement());
|
||||||
Element e;
|
Element e;
|
||||||
while ((e = it.next()) != null) {
|
while ((e = it.next()) != null) {
|
||||||
if (!e.isLeaf()) { continue; }
|
if (!e.isLeaf()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
int rangeStart = e.getStartOffset();
|
int rangeStart = e.getStartOffset();
|
||||||
int rangeEnd = e.getEndOffset();
|
int rangeEnd = e.getEndOffset();
|
||||||
try {
|
try {
|
||||||
@@ -144,8 +159,6 @@ public class DeckImport extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void displayTokens() {
|
private void displayTokens() {
|
||||||
StringBuilder sbOut = new StringBuilder("<html>");
|
StringBuilder sbOut = new StringBuilder("<html>");
|
||||||
sbOut.append(stylesheet);
|
sbOut.append(stylesheet);
|
||||||
@@ -161,12 +174,19 @@ public class DeckImport extends JDialog {
|
|||||||
int[] cardsUnknown = new int[2];
|
int[] cardsUnknown = new int[2];
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (DeckRecognizer.Token t : tokens) {
|
for (DeckRecognizer.Token t : tokens) {
|
||||||
if (t.getType() == TokenType.KnownCard) { cardsOk[idx] += t.getNumber(); }
|
if (t.getType() == TokenType.KnownCard) {
|
||||||
if (t.getType() == TokenType.UnknownCard) { cardsUnknown[idx] += t.getNumber(); }
|
cardsOk[idx] += t.getNumber();
|
||||||
if (t.getType() == TokenType.SectionName && t.getText().toLowerCase().contains("side") ) { idx = 1; }
|
}
|
||||||
|
if (t.getType() == TokenType.UnknownCard) {
|
||||||
|
cardsUnknown[idx] += t.getNumber();
|
||||||
|
}
|
||||||
|
if (t.getType() == TokenType.SectionName && t.getText().toLowerCase().contains("side")) {
|
||||||
|
idx = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
summaryMain.setText(String.format("Main: %d cards recognized, %d unknown cards", cardsOk[0], cardsUnknown[0]));
|
summaryMain.setText(String.format("Main: %d cards recognized, %d unknown cards", cardsOk[0], cardsUnknown[0]));
|
||||||
summarySide.setText(String.format("Sideboard: %d cards recognized, %d unknown cards", cardsOk[1], cardsUnknown[1]));
|
summarySide.setText(String.format("Sideboard: %d cards recognized, %d unknown cards", cardsOk[1],
|
||||||
|
cardsUnknown[1]));
|
||||||
cmdAccept.setEnabled(cardsOk[0] > 0);
|
cmdAccept.setEnabled(cardsOk[0] > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,8 +195,12 @@ public class DeckImport extends JDialog {
|
|||||||
boolean isMain = true;
|
boolean isMain = true;
|
||||||
for (DeckRecognizer.Token t : tokens) {
|
for (DeckRecognizer.Token t : tokens) {
|
||||||
DeckRecognizer.TokenType type = t.getType();
|
DeckRecognizer.TokenType type = t.getType();
|
||||||
if (type == DeckRecognizer.TokenType.SectionName && t.getText().toLowerCase().contains("side") ) { isMain = false; }
|
if (type == DeckRecognizer.TokenType.SectionName && t.getText().toLowerCase().contains("side")) {
|
||||||
if (type != DeckRecognizer.TokenType.KnownCard) { continue; }
|
isMain = false;
|
||||||
|
}
|
||||||
|
if (type != DeckRecognizer.TokenType.KnownCard) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
CardPrinted crd = t.getCard();
|
CardPrinted crd = t.getCard();
|
||||||
if (crd.isAlternate()) {
|
if (crd.isAlternate()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -190,18 +214,57 @@ public class DeckImport extends JDialog {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class OnChangeTextUpdate.
|
||||||
|
*/
|
||||||
protected class OnChangeTextUpdate implements DocumentListener {
|
protected class OnChangeTextUpdate implements DocumentListener {
|
||||||
private void onChange() { readInput(); displayTokens(); updateSummaries(); }
|
private void onChange() {
|
||||||
@Override public void insertUpdate(DocumentEvent e) { onChange(); }
|
readInput();
|
||||||
@Override public void removeUpdate(DocumentEvent e) { onChange(); }
|
displayTokens();
|
||||||
@Override public void changedUpdate(DocumentEvent e) { } // Happend only on ENTER pressed
|
updateSummaries();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeHtmlViewOfToken(DeckRecognizer.Token token) {
|
/*
|
||||||
switch(token.getType())
|
* (non-Javadoc)
|
||||||
{
|
*
|
||||||
|
* @see
|
||||||
|
* javax.swing.event.DocumentListener#insertUpdate(javax.swing.event
|
||||||
|
* .DocumentEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final void insertUpdate(final DocumentEvent e) {
|
||||||
|
onChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* javax.swing.event.DocumentListener#removeUpdate(javax.swing.event
|
||||||
|
* .DocumentEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public final void removeUpdate(final DocumentEvent e) {
|
||||||
|
onChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* javax.swing.event.DocumentListener#changedUpdate(javax.swing.event
|
||||||
|
* .DocumentEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void changedUpdate(final DocumentEvent e) {
|
||||||
|
} // Happend only on ENTER pressed
|
||||||
|
}
|
||||||
|
|
||||||
|
private String makeHtmlViewOfToken(final DeckRecognizer.Token token) {
|
||||||
|
switch (token.getType()) {
|
||||||
case KnownCard:
|
case KnownCard:
|
||||||
return String.format("<div class='knowncard'>%s * %s [%s]</div>", token.getNumber(), token.getCard().getName(), token.getCard().getSet());
|
return String.format("<div class='knowncard'>%s * %s [%s]</div>", token.getNumber(), token.getCard()
|
||||||
|
.getName(), token.getCard().getSet());
|
||||||
case UnknownCard:
|
case UnknownCard:
|
||||||
return String.format("<div class='unknowncard'>%s * %s</div>", token.getNumber(), token.getText());
|
return String.format("<div class='unknowncard'>%s * %s</div>", token.getNumber(), token.getText());
|
||||||
case SectionName:
|
case SectionName:
|
||||||
@@ -209,6 +272,8 @@ public class DeckImport extends JDialog {
|
|||||||
case UnknownText:
|
case UnknownText:
|
||||||
case Comment:
|
case Comment:
|
||||||
return String.format("<div class='comment'>%s</div>", token.getText());
|
return String.format("<div class='comment'>%s</div>", token.getText());
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,29 +11,64 @@ import forge.card.CardRules;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A structural class for some checkboxes need for a deck editor, contains no JPanel to store boxes on
|
* A structural class for some checkboxes need for a deck editor, contains no
|
||||||
* Checkboxes are public so the using class should place them in some container.
|
* JPanel to store boxes on Checkboxes are public so the using class should
|
||||||
|
* place them in some container.
|
||||||
*/
|
*/
|
||||||
class FilterCheckBoxes {
|
class FilterCheckBoxes {
|
||||||
|
|
||||||
|
/** The white. */
|
||||||
public final JCheckBox white;
|
public final JCheckBox white;
|
||||||
|
|
||||||
|
/** The blue. */
|
||||||
public final JCheckBox blue;
|
public final JCheckBox blue;
|
||||||
|
|
||||||
|
/** The black. */
|
||||||
public final JCheckBox black;
|
public final JCheckBox black;
|
||||||
|
|
||||||
|
/** The red. */
|
||||||
public final JCheckBox red;
|
public final JCheckBox red;
|
||||||
|
|
||||||
|
/** The green. */
|
||||||
public final JCheckBox green;
|
public final JCheckBox green;
|
||||||
|
|
||||||
|
/** The colorless. */
|
||||||
public final JCheckBox colorless;
|
public final JCheckBox colorless;
|
||||||
|
|
||||||
|
/** The land. */
|
||||||
public final JCheckBox land;
|
public final JCheckBox land;
|
||||||
|
|
||||||
|
/** The creature. */
|
||||||
public final JCheckBox creature;
|
public final JCheckBox creature;
|
||||||
|
|
||||||
|
/** The sorcery. */
|
||||||
public final JCheckBox sorcery;
|
public final JCheckBox sorcery;
|
||||||
|
|
||||||
|
/** The instant. */
|
||||||
public final JCheckBox instant;
|
public final JCheckBox instant;
|
||||||
|
|
||||||
|
/** The planeswalker. */
|
||||||
public final JCheckBox planeswalker;
|
public final JCheckBox planeswalker;
|
||||||
|
|
||||||
|
/** The artifact. */
|
||||||
public final JCheckBox artifact;
|
public final JCheckBox artifact;
|
||||||
|
|
||||||
|
/** The enchantment. */
|
||||||
public final JCheckBox enchantment;
|
public final JCheckBox enchantment;
|
||||||
|
|
||||||
// Very handy for classes using mass operations on an array of checkboxes
|
// Very handy for classes using mass operations on an array of checkboxes
|
||||||
|
/** The all colors. */
|
||||||
public final List<JCheckBox> allColors;
|
public final List<JCheckBox> allColors;
|
||||||
|
|
||||||
|
/** The all types. */
|
||||||
public final List<JCheckBox> allTypes;
|
public final List<JCheckBox> allTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new filter check boxes.
|
||||||
|
*
|
||||||
|
* @param useGraphicalBoxes
|
||||||
|
* the use graphical boxes
|
||||||
|
*/
|
||||||
public FilterCheckBoxes(final boolean useGraphicalBoxes) {
|
public FilterCheckBoxes(final boolean useGraphicalBoxes) {
|
||||||
if (useGraphicalBoxes) {
|
if (useGraphicalBoxes) {
|
||||||
white = new CheckBoxWithIcon("white", "White");
|
white = new CheckBoxWithIcon("white", "White");
|
||||||
@@ -68,29 +103,62 @@ class FilterCheckBoxes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
allColors = Arrays.asList(new JCheckBox[] { white, blue, black, red, green, colorless });
|
allColors = Arrays.asList(new JCheckBox[] { white, blue, black, red, green, colorless });
|
||||||
allTypes = Arrays.asList(new JCheckBox[]{ land, creature, sorcery, instant, planeswalker, artifact, enchantment });
|
allTypes = Arrays.asList(new JCheckBox[] { land, creature, sorcery, instant, planeswalker, artifact,
|
||||||
|
enchantment });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the filter.
|
||||||
|
*
|
||||||
|
* @return the predicate
|
||||||
|
*/
|
||||||
public final Predicate<CardPrinted> buildFilter() {
|
public final Predicate<CardPrinted> buildFilter() {
|
||||||
List<Predicate<CardRules>> colors = new ArrayList<Predicate<CardRules>>();
|
List<Predicate<CardRules>> colors = new ArrayList<Predicate<CardRules>>();
|
||||||
if (white.isSelected()) { colors.add(CardRules.Predicates.Presets.isWhite); }
|
if (white.isSelected()) {
|
||||||
if (blue.isSelected()) { colors.add(CardRules.Predicates.Presets.isBlue); }
|
colors.add(CardRules.Predicates.Presets.isWhite);
|
||||||
if (black.isSelected()) { colors.add(CardRules.Predicates.Presets.isBlack); }
|
}
|
||||||
if (red.isSelected()) { colors.add(CardRules.Predicates.Presets.isRed); }
|
if (blue.isSelected()) {
|
||||||
if (green.isSelected()) { colors.add(CardRules.Predicates.Presets.isGreen); }
|
colors.add(CardRules.Predicates.Presets.isBlue);
|
||||||
if (colorless.isSelected()) { colors.add(CardRules.Predicates.Presets.isColorless); }
|
}
|
||||||
Predicate<CardRules> filterByColor = colors.size() == 6 ? CardRules.Predicates.Presets.constantTrue : Predicate.or(colors);
|
if (black.isSelected()) {
|
||||||
|
colors.add(CardRules.Predicates.Presets.isBlack);
|
||||||
|
}
|
||||||
|
if (red.isSelected()) {
|
||||||
|
colors.add(CardRules.Predicates.Presets.isRed);
|
||||||
|
}
|
||||||
|
if (green.isSelected()) {
|
||||||
|
colors.add(CardRules.Predicates.Presets.isGreen);
|
||||||
|
}
|
||||||
|
if (colorless.isSelected()) {
|
||||||
|
colors.add(CardRules.Predicates.Presets.isColorless);
|
||||||
|
}
|
||||||
|
Predicate<CardRules> filterByColor = colors.size() == 6 ? CardRules.Predicates.Presets.constantTrue : Predicate
|
||||||
|
.or(colors);
|
||||||
|
|
||||||
List<Predicate<CardRules>> types = new ArrayList<Predicate<CardRules>>();
|
List<Predicate<CardRules>> types = new ArrayList<Predicate<CardRules>>();
|
||||||
if (land.isSelected()) { types.add(CardRules.Predicates.Presets.isLand); }
|
if (land.isSelected()) {
|
||||||
if (creature.isSelected()) { types.add(CardRules.Predicates.Presets.isCreature); }
|
types.add(CardRules.Predicates.Presets.isLand);
|
||||||
if (sorcery.isSelected()) { types.add(CardRules.Predicates.Presets.isSorcery); }
|
}
|
||||||
if (instant.isSelected()) { types.add(CardRules.Predicates.Presets.isInstant); }
|
if (creature.isSelected()) {
|
||||||
if (planeswalker.isSelected()) { types.add(CardRules.Predicates.Presets.isPlaneswalker); }
|
types.add(CardRules.Predicates.Presets.isCreature);
|
||||||
if (artifact.isSelected()) { types.add(CardRules.Predicates.Presets.isArtifact); }
|
}
|
||||||
if (enchantment.isSelected()) { types.add(CardRules.Predicates.Presets.isEnchantment); }
|
if (sorcery.isSelected()) {
|
||||||
Predicate<CardRules> filterByType = types.size() == 7 ? CardRules.Predicates.Presets.constantTrue : Predicate.or(types);
|
types.add(CardRules.Predicates.Presets.isSorcery);
|
||||||
|
}
|
||||||
|
if (instant.isSelected()) {
|
||||||
|
types.add(CardRules.Predicates.Presets.isInstant);
|
||||||
|
}
|
||||||
|
if (planeswalker.isSelected()) {
|
||||||
|
types.add(CardRules.Predicates.Presets.isPlaneswalker);
|
||||||
|
}
|
||||||
|
if (artifact.isSelected()) {
|
||||||
|
types.add(CardRules.Predicates.Presets.isArtifact);
|
||||||
|
}
|
||||||
|
if (enchantment.isSelected()) {
|
||||||
|
types.add(CardRules.Predicates.Presets.isEnchantment);
|
||||||
|
}
|
||||||
|
Predicate<CardRules> filterByType = types.size() == 7 ? CardRules.Predicates.Presets.constantTrue : Predicate
|
||||||
|
.or(types);
|
||||||
|
|
||||||
return Predicate.brigde(Predicate.and(filterByColor, filterByType), CardPrinted.fnGetRules);
|
return Predicate.brigde(Predicate.and(filterByColor, filterByType), CardPrinted.fnGetRules);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,24 +23,38 @@ import forge.game.GameFormat;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A panel that holds Name, Type, Rules text fields aligned horizontally together with set filter
|
* A panel that holds Name, Type, Rules text fields aligned horizontally
|
||||||
|
* together with set filter.
|
||||||
*/
|
*/
|
||||||
public class FilterNameTypeSetPanel extends JComponent {
|
public class FilterNameTypeSetPanel extends JComponent {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -6409564625432765430L;
|
private static final long serialVersionUID = -6409564625432765430L;
|
||||||
|
|
||||||
|
/** The label filter name. */
|
||||||
public final JLabel labelFilterName = new JLabel();
|
public final JLabel labelFilterName = new JLabel();
|
||||||
|
|
||||||
|
/** The label filter type. */
|
||||||
public final JLabel labelFilterType = new JLabel();
|
public final JLabel labelFilterType = new JLabel();
|
||||||
|
|
||||||
|
/** The label filter rules. */
|
||||||
public final JLabel labelFilterRules = new JLabel();
|
public final JLabel labelFilterRules = new JLabel();
|
||||||
|
|
||||||
|
/** The txt card name. */
|
||||||
public final JTextField txtCardName = new JTextField();
|
public final JTextField txtCardName = new JTextField();
|
||||||
|
|
||||||
|
/** The txt card type. */
|
||||||
public final JTextField txtCardType = new JTextField();
|
public final JTextField txtCardType = new JTextField();
|
||||||
|
|
||||||
|
/** The txt card rules. */
|
||||||
public final JTextField txtCardRules = new JTextField();
|
public final JTextField txtCardRules = new JTextField();
|
||||||
|
|
||||||
|
/** The search set combo. */
|
||||||
public final JComboBox searchSetCombo = new JComboBox();
|
public final JComboBox searchSetCombo = new JComboBox();
|
||||||
|
|
||||||
|
/**
|
||||||
public FilterNameTypeSetPanel()
|
* Instantiates a new filter name type set panel.
|
||||||
{
|
*/
|
||||||
|
public FilterNameTypeSetPanel() {
|
||||||
this.setLayout(new MigLayout("fill, ins 0"));
|
this.setLayout(new MigLayout("fill, ins 0"));
|
||||||
|
|
||||||
labelFilterName.setText("Name:");
|
labelFilterName.setText("Name:");
|
||||||
@@ -58,7 +72,6 @@ public class FilterNameTypeSetPanel extends JComponent{
|
|||||||
this.add(labelFilterRules, "");
|
this.add(labelFilterRules, "");
|
||||||
this.add(txtCardRules, "wmin 200, grow");
|
this.add(txtCardRules, "wmin 200, grow");
|
||||||
|
|
||||||
|
|
||||||
searchSetCombo.removeAllItems();
|
searchSetCombo.removeAllItems();
|
||||||
searchSetCombo.addItem("(all sets and formats)");
|
searchSetCombo.addItem("(all sets and formats)");
|
||||||
for (GameFormat s : SetUtils.getFormats()) {
|
for (GameFormat s : SetUtils.getFormats()) {
|
||||||
@@ -71,26 +84,40 @@ public class FilterNameTypeSetPanel extends JComponent{
|
|||||||
this.add(searchSetCombo, "wmin 150, grow");
|
this.add(searchSetCombo, "wmin 150, grow");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListeners(DocumentListener onTextChange, ItemListener onComboChange)
|
/**
|
||||||
{
|
* Sets the listeners.
|
||||||
|
*
|
||||||
|
* @param onTextChange
|
||||||
|
* the on text change
|
||||||
|
* @param onComboChange
|
||||||
|
* the on combo change
|
||||||
|
*/
|
||||||
|
public final void setListeners(final DocumentListener onTextChange, final ItemListener onComboChange) {
|
||||||
txtCardType.getDocument().addDocumentListener(onTextChange);
|
txtCardType.getDocument().addDocumentListener(onTextChange);
|
||||||
txtCardRules.getDocument().addDocumentListener(onTextChange);
|
txtCardRules.getDocument().addDocumentListener(onTextChange);
|
||||||
txtCardName.getDocument().addDocumentListener(onTextChange);
|
txtCardName.getDocument().addDocumentListener(onTextChange);
|
||||||
searchSetCombo.addItemListener(onComboChange);
|
searchSetCombo.addItemListener(onComboChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Predicate<CardPrinted> buildFilter() {
|
/**
|
||||||
|
* Builds the filter.
|
||||||
|
*
|
||||||
|
* @return the predicate
|
||||||
|
*/
|
||||||
|
public final Predicate<CardPrinted> buildFilter() {
|
||||||
List<Predicate<CardPrinted>> rules = new ArrayList<Predicate<CardPrinted>>(4);
|
List<Predicate<CardPrinted>> rules = new ArrayList<Predicate<CardPrinted>>(4);
|
||||||
if (StringUtils.isNotBlank(txtCardName.getText())) {
|
if (StringUtils.isNotBlank(txtCardName.getText())) {
|
||||||
rules.add(CardPrinted.Predicates.name(StringOp.CONTAINS, txtCardName.getText()));
|
rules.add(CardPrinted.Predicates.name(StringOp.CONTAINS, txtCardName.getText()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(txtCardType.getText())) {
|
if (StringUtils.isNotBlank(txtCardType.getText())) {
|
||||||
rules.add(Predicate.brigde(CardRules.Predicates.joinedType(StringOp.CONTAINS, txtCardType.getText()), CardPrinted.fnGetRules));
|
rules.add(Predicate.brigde(CardRules.Predicates.joinedType(StringOp.CONTAINS, txtCardType.getText()),
|
||||||
|
CardPrinted.fnGetRules));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(txtCardRules.getText())) {
|
if (StringUtils.isNotBlank(txtCardRules.getText())) {
|
||||||
rules.add(Predicate.brigde(CardRules.Predicates.rules(StringOp.CONTAINS, txtCardRules.getText()), CardPrinted.fnGetRules));
|
rules.add(Predicate.brigde(CardRules.Predicates.rules(StringOp.CONTAINS, txtCardRules.getText()),
|
||||||
|
CardPrinted.fnGetRules));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchSetCombo.getSelectedIndex() != 0) {
|
if (searchSetCombo.getSelectedIndex() != 0) {
|
||||||
@@ -103,17 +130,21 @@ public class FilterNameTypeSetPanel extends JComponent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (rules.size()) {
|
switch (rules.size()) {
|
||||||
case 0: return Predicate.getTrue(CardPrinted.class);
|
case 0:
|
||||||
case 1: return rules.get(0);
|
return Predicate.getTrue(CardPrinted.class);
|
||||||
case 2: return Predicate.and(rules.get(0), rules.get(1));
|
case 1:
|
||||||
default: return Predicate.and(rules);
|
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.
|
* TODO: Write javadoc for this method.
|
||||||
*/
|
*/
|
||||||
public void clearFilters() {
|
public final void clearFilters() {
|
||||||
txtCardName.setText("");
|
txtCardName.setText("");
|
||||||
txtCardType.setText("");
|
txtCardType.setText("");
|
||||||
txtCardRules.setText("");
|
txtCardRules.setText("");
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
import arcane.ui.util.ManaSymbols;
|
|
||||||
|
|
||||||
import forge.card.CardManaCostShard;
|
import arcane.ui.util.ManaSymbols;
|
||||||
import forge.card.CardManaCost;
|
import forge.card.CardManaCost;
|
||||||
|
import forge.card.CardManaCostShard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays mana cost as symbols.
|
* Displays mana cost as symbols.
|
||||||
@@ -19,17 +19,28 @@ public class ManaCostRenderer extends DefaultTableCellRenderer {
|
|||||||
|
|
||||||
private CardManaCost value;
|
private CardManaCost value;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent
|
||||||
|
* (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Component getTableCellRendererComponent(final JTable table, final Object value,
|
public final Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected,
|
||||||
final boolean isSelected, final boolean hasFocus, final int row, final int column)
|
final boolean hasFocus, final int row, final int column) {
|
||||||
{
|
|
||||||
this.value = (CardManaCost) value;
|
this.value = (CardManaCost) value;
|
||||||
setToolTipText(this.value.toString());
|
setToolTipText(this.value.toString());
|
||||||
return super.getTableCellRendererComponent(table, "", isSelected, hasFocus, row, column);
|
return super.getTableCellRendererComponent(table, "", isSelected, hasFocus, row, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see javax.swing.JComponent#paint(java.awt.Graphics)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void paint(final Graphics g) {
|
public final void paint(final Graphics g) {
|
||||||
super.paint(g);
|
super.paint(g);
|
||||||
|
|
||||||
final int elemtWidth = 13;
|
final int elemtWidth = 13;
|
||||||
@@ -44,7 +55,8 @@ public class ManaCostRenderer extends DefaultTableCellRenderer {
|
|||||||
|
|
||||||
int cellWidth = getWidth();
|
int cellWidth = getWidth();
|
||||||
int cntGlyphs = hasGeneric ? shards.size() + 1 : shards.size();
|
int cntGlyphs = hasGeneric ? shards.size() + 1 : shards.size();
|
||||||
float offsetIfNoSpace = cntGlyphs > 1 ? (cellWidth - padding - elemtWidth) / (cntGlyphs - 1f) : elemtWidth + elemtGap;
|
float offsetIfNoSpace = cntGlyphs > 1 ? (cellWidth - padding - elemtWidth) / (cntGlyphs - 1f) : elemtWidth
|
||||||
|
+ elemtGap;
|
||||||
float offset = Math.min(elemtWidth + elemtGap, offsetIfNoSpace);
|
float offset = Math.min(elemtWidth + elemtGap, offsetIfNoSpace);
|
||||||
|
|
||||||
if (hasGeneric) {
|
if (hasGeneric) {
|
||||||
|
|||||||
@@ -18,84 +18,189 @@ import forge.item.InventoryItemFromSet;
|
|||||||
*/
|
*/
|
||||||
public abstract class PresetColumns {
|
public abstract class PresetColumns {
|
||||||
|
|
||||||
private static CardManaCost toManaCost(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getManaCost() : CardManaCost.empty; }
|
private static CardManaCost toManaCost(final InventoryItem i) {
|
||||||
private static CardColor toColor(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getColor() : CardColor.nullColor; }
|
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getManaCost() : CardManaCost.empty;
|
||||||
private static String toPTL(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getPTorLoyalty() : ""; }
|
}
|
||||||
private static CardRarity toRarity(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getRarity() : CardRarity.Unknown; }
|
|
||||||
private static CardSet toSetCmp(InventoryItem i) { return i instanceof InventoryItemFromSet ? SetUtils.getSetByCode(((InventoryItemFromSet) i).getSet()) : CardSet.unknown; }
|
private static CardColor toColor(final InventoryItem i) {
|
||||||
private static String toSetStr(InventoryItem i) { return i instanceof InventoryItemFromSet ? ((InventoryItemFromSet) i).getSet() : "n/a"; }
|
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getColor() : CardColor.nullColor;
|
||||||
private static Integer toAiCmp(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getAiStatusComparable() : Integer.valueOf(-1); }
|
}
|
||||||
private static String toAiStr(InventoryItem i) { return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getAiStatus() : "n/a"; }
|
|
||||||
|
private static String toPTL(final InventoryItem i) {
|
||||||
@SuppressWarnings("rawtypes")
|
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getPTorLoyalty() : "";
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnQtyCompare =
|
}
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return from.getValue(); } };
|
private static CardRarity toRarity(final InventoryItem i) {
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnQtyGet =
|
return i instanceof CardPrinted ? ((CardPrinted) i).getRarity() : CardRarity.Unknown;
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
}
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return from.getValue(); } };
|
|
||||||
|
private static CardSet toSetCmp(final InventoryItem i) {
|
||||||
@SuppressWarnings("rawtypes")
|
return i instanceof InventoryItemFromSet ? SetUtils.getSetByCode(((InventoryItemFromSet) i).getSet())
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnNameCompare =
|
: CardSet.unknown;
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
}
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return from.getKey().getName(); } };
|
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnNameGet =
|
private static String toSetStr(final InventoryItem i) {
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
return i instanceof InventoryItemFromSet ? ((InventoryItemFromSet) i).getSet() : "n/a";
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return from.getKey().getName(); } };
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
private static Integer toAiCmp(final InventoryItem i) {
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnCostCompare =
|
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getAiStatusComparable() : Integer.valueOf(-1);
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
}
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return toManaCost(from.getKey()); } };
|
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnCostGet =
|
private static String toAiStr(final InventoryItem i) {
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
return i instanceof CardPrinted ? ((CardPrinted) i).getCard().getAiStatus() : "n/a";
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return toManaCost(from.getKey()); } };
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
/** The Constant fnQtyCompare. */
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnColorCompare =
|
@SuppressWarnings("rawtypes")
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnQtyCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return toColor(from.getKey()); } };
|
@Override
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnColorGet =
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
return from.getValue();
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return toColor(from.getKey()); } };
|
}
|
||||||
|
};
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnTypeCompare =
|
/** The Constant fnQtyGet. */
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnQtyGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return from.getKey().getType(); } };
|
@Override
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnTypeGet =
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
return from.getValue();
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return from.getKey().getType(); } };
|
}
|
||||||
|
};
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnStatsCompare =
|
/** The Constant fnNameCompare. */
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
@SuppressWarnings("rawtypes")
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return toPTL(from.getKey()); } };
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnNameCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnStatsGet =
|
@Override
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return toPTL(from.getKey()); } };
|
return from.getKey().getName();
|
||||||
|
}
|
||||||
@SuppressWarnings("rawtypes")
|
};
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnRarityCompare =
|
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
/** The Constant fnNameGet. */
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return toRarity(from.getKey()); } };
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnNameGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnRarityGet =
|
@Override
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return toRarity(from.getKey()); } };
|
return from.getKey().getName();
|
||||||
|
}
|
||||||
@SuppressWarnings("rawtypes")
|
};
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnSetCompare =
|
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
/** The Constant fnCostCompare. */
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return toSetCmp(from.getKey()); } };
|
@SuppressWarnings("rawtypes")
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnSetGet =
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnCostCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return toSetStr(from.getKey()); } };
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toManaCost(from.getKey());
|
||||||
@SuppressWarnings("rawtypes")
|
}
|
||||||
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnAiStatusCompare =
|
};
|
||||||
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override
|
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) { return toAiCmp(from.getKey()); } };
|
/** The Constant fnCostGet. */
|
||||||
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnAiStatusGet =
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnCostGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) { return toAiStr(from.getKey()); } };
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toManaCost(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnColorCompare. */
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnColorCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toColor(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnColorGet. */
|
||||||
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnColorGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toColor(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnTypeCompare. */
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnTypeCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return from.getKey().getType();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnTypeGet. */
|
||||||
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnTypeGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return from.getKey().getType();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnStatsCompare. */
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnStatsCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toPTL(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnStatsGet. */
|
||||||
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnStatsGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toPTL(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnRarityCompare. */
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnRarityCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toRarity(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnRarityGet. */
|
||||||
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnRarityGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toRarity(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnSetCompare. */
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnSetCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toSetCmp(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnSetGet. */
|
||||||
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnSetGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toSetStr(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnAiStatusCompare. */
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnAiStatusCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toAiCmp(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The Constant fnAiStatusGet. */
|
||||||
|
public static final Lambda1<Object, Entry<InventoryItem, Integer>> fnAiStatusGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
|
return toAiStr(from.getKey());
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,36 +7,79 @@ import javax.swing.table.TableCellRenderer;
|
|||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds single column set up for TableModel.
|
* Holds single column set up for TableModel. Contains name, width + functions
|
||||||
* Contains name, width + functions to retrieve column's value for compare and for display
|
* to retrieve column's value for compare and for display (they are different,
|
||||||
* (they are different, in case of sets for instance)
|
* in case of sets for instance)
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
* the generic type
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class TableColumnInfo<T> {
|
public class TableColumnInfo<T> {
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
|
/** The min width. */
|
||||||
public int minWidth;
|
public int minWidth;
|
||||||
|
|
||||||
|
/** The max width. */
|
||||||
public int maxWidth;
|
public int maxWidth;
|
||||||
|
|
||||||
|
/** The nominal width. */
|
||||||
public int nominalWidth;
|
public int nominalWidth;
|
||||||
|
|
||||||
|
/** The is min max applied. */
|
||||||
public boolean isMinMaxApplied = true;
|
public boolean isMinMaxApplied = true;
|
||||||
|
|
||||||
public final Lambda1<Comparable, Entry<T, Integer>> fnSort; // this will be used for sorting
|
/** The fn sort. */
|
||||||
public final Lambda1<Object, Entry<T, Integer>> fnDisplay; // this is used to display
|
public final Lambda1<Comparable, Entry<T, Integer>> fnSort; // this will be
|
||||||
|
// used for
|
||||||
|
// sorting
|
||||||
|
|
||||||
|
/** The fn display. */
|
||||||
|
public final Lambda1<Object, Entry<T, Integer>> fnDisplay; // this is used
|
||||||
|
// to display
|
||||||
|
|
||||||
private TableCellRenderer cellRenderer = null;
|
private TableCellRenderer cellRenderer = null;
|
||||||
|
|
||||||
public final String getName() { return name; }
|
/**
|
||||||
|
* Gets the name.
|
||||||
|
*
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
|
public final String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public TableColumnInfo(final String colName,
|
/**
|
||||||
final Lambda1<Comparable, Entry<T, Integer>> fieldSort,
|
* Instantiates a new table column info.
|
||||||
|
*
|
||||||
|
* @param colName
|
||||||
|
* the col name
|
||||||
|
* @param fieldSort
|
||||||
|
* the field sort
|
||||||
|
* @param fieldDisplay
|
||||||
|
* the field display
|
||||||
|
*/
|
||||||
|
public TableColumnInfo(final String colName, final Lambda1<Comparable, Entry<T, Integer>> fieldSort,
|
||||||
final Lambda1<Object, Entry<T, Integer>> fieldDisplay) {
|
final Lambda1<Object, Entry<T, Integer>> fieldDisplay) {
|
||||||
fnSort = fieldSort;
|
fnSort = fieldSort;
|
||||||
fnDisplay = fieldDisplay;
|
fnDisplay = fieldDisplay;
|
||||||
this.name = colName;
|
this.name = colName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new table column info.
|
||||||
|
*
|
||||||
|
* @param colName
|
||||||
|
* the col name
|
||||||
|
* @param width
|
||||||
|
* the width
|
||||||
|
* @param fieldSort
|
||||||
|
* the field sort
|
||||||
|
* @param fieldDisplay
|
||||||
|
* the field display
|
||||||
|
*/
|
||||||
public TableColumnInfo(final String colName, final int width,
|
public TableColumnInfo(final String colName, final int width,
|
||||||
final Lambda1<Comparable, Entry<T, Integer>> fieldSort,
|
final Lambda1<Comparable, Entry<T, Integer>> fieldSort,
|
||||||
final Lambda1<Object, Entry<T, Integer>> fieldDisplay) {
|
final Lambda1<Object, Entry<T, Integer>> fieldDisplay) {
|
||||||
@@ -45,6 +88,23 @@ import net.slightlymagic.braids.util.lambda.Lambda1;
|
|||||||
this.minWidth = width;
|
this.minWidth = width;
|
||||||
this.nominalWidth = width;
|
this.nominalWidth = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new table column info.
|
||||||
|
*
|
||||||
|
* @param colName
|
||||||
|
* the col name
|
||||||
|
* @param wMin
|
||||||
|
* the w min
|
||||||
|
* @param width
|
||||||
|
* the width
|
||||||
|
* @param wMax
|
||||||
|
* the w max
|
||||||
|
* @param fieldSort
|
||||||
|
* the field sort
|
||||||
|
* @param fieldDisplay
|
||||||
|
* the field display
|
||||||
|
*/
|
||||||
public TableColumnInfo(final String colName, final int wMin, final int width, final int wMax,
|
public TableColumnInfo(final String colName, final int wMin, final int width, final int wMax,
|
||||||
final Lambda1<Comparable, Entry<T, Integer>> fieldSort,
|
final Lambda1<Comparable, Entry<T, Integer>> fieldSort,
|
||||||
final Lambda1<Object, Entry<T, Integer>> fieldDisplay) {
|
final Lambda1<Object, Entry<T, Integer>> fieldDisplay) {
|
||||||
@@ -54,13 +114,22 @@ import net.slightlymagic.braids.util.lambda.Lambda1;
|
|||||||
this.nominalWidth = width;
|
this.nominalWidth = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public void setCellRenderer(final TableCellRenderer renderer) {
|
* Sets the cell renderer.
|
||||||
|
*
|
||||||
|
* @param renderer
|
||||||
|
* the new cell renderer
|
||||||
|
*/
|
||||||
|
public final void setCellRenderer(final TableCellRenderer renderer) {
|
||||||
cellRenderer = renderer;
|
cellRenderer = renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the cell renderer.
|
||||||
|
*
|
||||||
|
* @return the cell renderer
|
||||||
|
*/
|
||||||
public final TableCellRenderer getCellRenderer() {
|
public final TableCellRenderer getCellRenderer() {
|
||||||
return cellRenderer;
|
return cellRenderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,15 @@
|
|||||||
package forge.gui.deckeditor;
|
package forge.gui.deckeditor;
|
||||||
|
|
||||||
|
import java.awt.event.FocusEvent;
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.JTable;
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.event.TableModelEvent;
|
import javax.swing.event.TableModelEvent;
|
||||||
@@ -13,16 +21,13 @@ import forge.item.InventoryItem;
|
|||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
import forge.item.ItemPoolView;
|
import forge.item.ItemPoolView;
|
||||||
|
|
||||||
import java.awt.event.*;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>TableModel class.</p>
|
* <p>
|
||||||
|
* TableModel class.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
|
* @param <T>
|
||||||
|
* the generic type
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
@@ -36,13 +41,17 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
private class Order {
|
private class Order {
|
||||||
public final int sortColumn;
|
public final int sortColumn;
|
||||||
public boolean isSortAsc = true;
|
public boolean isSortAsc = true;
|
||||||
public Order(final int col) { sortColumn = col; }
|
|
||||||
|
public Order(final int col) {
|
||||||
|
sortColumn = col;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final int MAX_DEPTH = 3;
|
private final int MAX_DEPTH = 3;
|
||||||
private List<Order> orders = new ArrayList<Order>(3);
|
private List<Order> orders = new ArrayList<Order>(3);
|
||||||
private TableSorterCascade<T> sorter = null;
|
private TableSorterCascade<T> sorter = null;
|
||||||
private boolean isSorterReady = false;
|
private boolean isSorterReady = false;
|
||||||
|
|
||||||
private int indexOfColumn(final int column) {
|
private int indexOfColumn(final int column) {
|
||||||
int posColumn = orders.size() - 1;
|
int posColumn = orders.size() - 1;
|
||||||
for (; posColumn >= 0; posColumn--) {
|
for (; posColumn >= 0; posColumn--) {
|
||||||
@@ -60,7 +69,8 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
isSorterReady = false;
|
isSorterReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// puts desired direction on top, set "asc"; if already was on top, inverts direction;
|
// puts desired direction on top, set "asc"; if already was on top,
|
||||||
|
// inverts direction;
|
||||||
public void add(final int column) {
|
public void add(final int column) {
|
||||||
int posColumn = indexOfColumn(column);
|
int posColumn = indexOfColumn(column);
|
||||||
switch (posColumn) {
|
switch (posColumn) {
|
||||||
@@ -70,12 +80,15 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
case 0: // found at top-level, should invert
|
case 0: // found at top-level, should invert
|
||||||
orders.get(0).isSortAsc ^= true; // invert
|
orders.get(0).isSortAsc ^= true; // invert
|
||||||
break;
|
break;
|
||||||
default: // found somewhere, move down others, set this one onto top;
|
default: // found somewhere, move down others, set this one onto
|
||||||
|
// top;
|
||||||
orders.remove(posColumn);
|
orders.remove(posColumn);
|
||||||
orders.add(0, new Order(column));
|
orders.add(0, new Order(column));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(orders.size() > MAX_DEPTH) { orders.remove(MAX_DEPTH); }
|
if (orders.size() > MAX_DEPTH) {
|
||||||
|
orders.remove(MAX_DEPTH);
|
||||||
|
}
|
||||||
isSorterReady = false;
|
isSorterReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,14 +109,29 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
private final List<TableColumnInfo<T>> columns;
|
private final List<TableColumnInfo<T>> columns;
|
||||||
private final SortOrders sortOrders = new SortOrders();
|
private final SortOrders sortOrders = new SortOrders();
|
||||||
|
|
||||||
public TableModel(final CardPanelBase cd, final List<TableColumnInfo<T>> columnsToShow, Class<T> cls) {
|
/**
|
||||||
|
* Instantiates a new table model.
|
||||||
|
*
|
||||||
|
* @param cd
|
||||||
|
* the cd
|
||||||
|
* @param columnsToShow
|
||||||
|
* the columns to show
|
||||||
|
* @param cls
|
||||||
|
* the cls
|
||||||
|
*/
|
||||||
|
public TableModel(final CardPanelBase cd, final List<TableColumnInfo<T>> columnsToShow, final Class<T> cls) {
|
||||||
data = new ItemPool<T>(cls);
|
data = new ItemPool<T>(cls);
|
||||||
cardDisplay = cd;
|
cardDisplay = cd;
|
||||||
columns = columnsToShow;
|
columns = columnsToShow;
|
||||||
columns.get(4).isMinMaxApplied = false;
|
columns.get(4).isMinMaxApplied = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resize cols.
|
||||||
|
*
|
||||||
|
* @param table
|
||||||
|
* the table
|
||||||
|
*/
|
||||||
public void resizeCols(final JTable table) {
|
public void resizeCols(final JTable table) {
|
||||||
TableColumn tableColumn = null;
|
TableColumn tableColumn = null;
|
||||||
for (int i = 0; i < table.getColumnCount(); i++) {
|
for (int i = 0; i < table.getColumnCount(); i++) {
|
||||||
@@ -118,13 +146,29 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() { data.clear(); }
|
/**
|
||||||
public ItemPoolView<T> getCards() { return data.getView(); }
|
* Clear.
|
||||||
|
*/
|
||||||
|
public void clear() {
|
||||||
|
data.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>removeCard.</p>
|
* Gets the cards.
|
||||||
*
|
*
|
||||||
* @param c a {@link forge.Card} object.
|
* @return the cards
|
||||||
|
*/
|
||||||
|
public ItemPoolView<T> getCards() {
|
||||||
|
return data.getView();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* removeCard.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public void removeCard(final T c) {
|
public void removeCard(final T c) {
|
||||||
boolean wasThere = data.count(c) > 0;
|
boolean wasThere = data.count(c) > 0;
|
||||||
@@ -134,36 +178,89 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the card.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* the c
|
||||||
|
*/
|
||||||
public void addCard(final T c) {
|
public void addCard(final T c) {
|
||||||
data.add(c);
|
data.add(c);
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the card.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* the c
|
||||||
|
* @param count
|
||||||
|
* the count
|
||||||
|
*/
|
||||||
public void addCard(final T c, final int count) {
|
public void addCard(final T c, final int count) {
|
||||||
data.add(c, count);
|
data.add(c, count);
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the card.
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
* the e
|
||||||
|
*/
|
||||||
public void addCard(final Entry<T, Integer> e) {
|
public void addCard(final Entry<T, Integer> e) {
|
||||||
data.add(e.getKey(), e.getValue());
|
data.add(e.getKey(), e.getValue());
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the cards.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* the c
|
||||||
|
*/
|
||||||
public void addCards(final Iterable<Entry<T, Integer>> c) {
|
public void addCards(final Iterable<Entry<T, Integer>> c) {
|
||||||
data.addAll(c);
|
data.addAll(c);
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the all cards.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* the c
|
||||||
|
*/
|
||||||
public void addAllCards(final Iterable<T> c) {
|
public void addAllCards(final Iterable<T> c) {
|
||||||
data.addAllCards(c);
|
data.addAllCards(c);
|
||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Row to card.
|
||||||
|
*
|
||||||
|
* @param row
|
||||||
|
* the row
|
||||||
|
* @return the entry
|
||||||
|
*/
|
||||||
public Entry<T, Integer> rowToCard(final int row) {
|
public Entry<T, Integer> rowToCard(final int row) {
|
||||||
List<Entry<T, Integer>> model = data.getOrderedList();
|
List<Entry<T, Integer>> model = data.getOrderedList();
|
||||||
return row >= 0 && row < model.size() ? model.get(row) : null;
|
return row >= 0 && row < model.size() ? model.get(row) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see javax.swing.table.TableModel#getRowCount()
|
||||||
|
*/
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return data.countDistinct();
|
return data.countDistinct();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see javax.swing.table.TableModel#getColumnCount()
|
||||||
|
*/
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
return columns.size();
|
return columns.size();
|
||||||
}
|
}
|
||||||
@@ -179,18 +276,45 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
return columns.get(column).fnDisplay.apply(rowToCard(row));
|
return columns.get(column).fnDisplay.apply(rowToCard(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The listener interface for receiving column events. The class that is
|
||||||
|
* interested in processing a column event implements this interface, and
|
||||||
|
* the object created with that class is registered with a component using
|
||||||
|
* the component's <code>addColumnListener<code> method. When
|
||||||
|
* the column event occurs, that object's appropriate
|
||||||
|
* method is invoked.
|
||||||
|
*
|
||||||
|
* @see ColumnEvent
|
||||||
|
*/
|
||||||
class ColumnListener extends MouseAdapter {
|
class ColumnListener extends MouseAdapter {
|
||||||
|
|
||||||
|
/** The table. */
|
||||||
protected JTable table;
|
protected JTable table;
|
||||||
|
|
||||||
public ColumnListener(final JTable t) { table = t; }
|
/**
|
||||||
|
* Instantiates a new column listener.
|
||||||
|
*
|
||||||
|
* @param t
|
||||||
|
* the t
|
||||||
|
*/
|
||||||
|
public ColumnListener(final JTable t) {
|
||||||
|
table = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
|
||||||
|
*/
|
||||||
public void mouseClicked(final MouseEvent e) {
|
public void mouseClicked(final MouseEvent e) {
|
||||||
TableColumnModel colModel = table.getColumnModel();
|
TableColumnModel colModel = table.getColumnModel();
|
||||||
int columnModelIndex = colModel.getColumnIndexAtX(e.getX());
|
int columnModelIndex = colModel.getColumnIndexAtX(e.getX());
|
||||||
int modelIndex = colModel.getColumn(columnModelIndex).getModelIndex();
|
int modelIndex = colModel.getColumn(columnModelIndex).getModelIndex();
|
||||||
|
|
||||||
if (modelIndex < 0) { return; }
|
if (modelIndex < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// This will invert if needed
|
// This will invert if needed
|
||||||
sortOrders.add(modelIndex);
|
sortOrders.add(modelIndex);
|
||||||
@@ -207,6 +331,12 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show selected card.
|
||||||
|
*
|
||||||
|
* @param table
|
||||||
|
* the table
|
||||||
|
*/
|
||||||
public void showSelectedCard(final JTable table) {
|
public void showSelectedCard(final JTable table) {
|
||||||
int row = table.getSelectedRow();
|
int row = table.getSelectedRow();
|
||||||
if (row != -1) {
|
if (row != -1) {
|
||||||
@@ -216,9 +346,12 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>addListeners.</p>
|
* <p>
|
||||||
|
* addListeners.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param table a {@link javax.swing.JTable} object.
|
* @param table
|
||||||
|
* a {@link javax.swing.JTable} object.
|
||||||
*/
|
*/
|
||||||
public void addListeners(final JTable table) {
|
public void addListeners(final JTable table) {
|
||||||
// updates card detail, listens to any key strokes
|
// updates card detail, listens to any key strokes
|
||||||
@@ -231,8 +364,12 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
});
|
});
|
||||||
table.addFocusListener(new FocusListener() {
|
table.addFocusListener(new FocusListener() {
|
||||||
|
|
||||||
@Override public void focusLost(final FocusEvent e) {}
|
@Override
|
||||||
@Override public void focusGained(final FocusEvent e) {
|
public void focusLost(final FocusEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void focusGained(final FocusEvent e) {
|
||||||
showSelectedCard(table);
|
showSelectedCard(table);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -241,12 +378,22 @@ public final class TableModel<T extends InventoryItem> extends AbstractTableMode
|
|||||||
|
|
||||||
}// addCardListener()
|
}// addCardListener()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resort.
|
||||||
|
*/
|
||||||
public void resort() {
|
public void resort() {
|
||||||
Collections.sort(data.getOrderedList(), sortOrders.getSorter());
|
Collections.sort(data.getOrderedList(), sortOrders.getSorter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sort( int iCol, boolean isAsc ) {
|
/**
|
||||||
|
* Sort.
|
||||||
|
*
|
||||||
|
* @param iCol
|
||||||
|
* the i col
|
||||||
|
* @param isAsc
|
||||||
|
* the is asc
|
||||||
|
*/
|
||||||
|
public void sort(final int iCol, final boolean isAsc) {
|
||||||
sortOrders.add(iCol, isAsc);
|
sortOrders.add(iCol, isAsc);
|
||||||
resort();
|
resort();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,50 +1,66 @@
|
|||||||
package forge.gui.deckeditor;
|
package forge.gui.deckeditor;
|
||||||
|
|
||||||
|
|
||||||
import forge.item.CardPrinted;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||||
|
import forge.item.CardPrinted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>TableSorter class.</p>
|
* <p>
|
||||||
|
* TableSorter class.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
|
* @param <T>
|
||||||
|
* the generic type
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked") // Comparable needs <type>
|
@SuppressWarnings("unchecked")
|
||||||
|
// Comparable needs <type>
|
||||||
public class TableSorter<T> implements Comparator<Entry<T, Integer>> {
|
public class TableSorter<T> implements Comparator<Entry<T, Integer>> {
|
||||||
private boolean ascending;
|
private boolean ascending;
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private Lambda1<Comparable, Entry<T, Integer>> field;
|
private Lambda1<Comparable, Entry<T, Integer>> field;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for TableSorter.</p>
|
* <p>
|
||||||
|
* Constructor for TableSorter.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param in_all a {@link forge.CardList} object.
|
* @param field
|
||||||
* @param in_column a int.
|
* the field
|
||||||
* @param in_ascending a boolean.
|
* @param in_ascending
|
||||||
|
* a boolean.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public TableSorter(Lambda1<Comparable, Entry<T, Integer>> field, boolean in_ascending) {
|
public TableSorter(final Lambda1<Comparable, Entry<T, Integer>> field, final boolean in_ascending) {
|
||||||
this.field = field;
|
this.field = field;
|
||||||
ascending = in_ascending;
|
ascending = in_ascending;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The Constant byNameThenSet. */
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public static final TableSorter<CardPrinted> byNameThenSet = new TableSorter<CardPrinted>(
|
public static final TableSorter<CardPrinted> byNameThenSet = new TableSorter<CardPrinted>(
|
||||||
new Lambda1<Comparable, Entry<CardPrinted, Integer>>() {
|
new Lambda1<Comparable, Entry<CardPrinted, Integer>>() {
|
||||||
@Override public Comparable apply(final Entry<CardPrinted, Integer> from) { return from.getKey(); }
|
@Override
|
||||||
|
public Comparable apply(final Entry<CardPrinted, Integer> from) {
|
||||||
|
return from.getKey();
|
||||||
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||||
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public int compare(Entry<T, Integer> arg0, Entry<T, Integer> arg1) {
|
public final int compare(final Entry<T, Integer> arg0, final Entry<T, Integer> arg1) {
|
||||||
Comparable obj1 = field.apply(arg0);
|
Comparable obj1 = field.apply(arg0);
|
||||||
Comparable obj2 = field.apply(arg1);
|
Comparable obj2 = field.apply(arg1);
|
||||||
//System.out.println(String.format("%s vs %s _______ %s vs %s", arg0, arg1, obj1, obj2));
|
// System.out.println(String.format("%s vs %s _______ %s vs %s", arg0,
|
||||||
|
// arg1, obj1, obj2));
|
||||||
return ascending ? obj1.compareTo(obj2) : obj2.compareTo(obj1);
|
return ascending ? obj1.compareTo(obj2) : obj2.compareTo(obj1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
package forge.gui.deckeditor;
|
package forge.gui.deckeditor;
|
||||||
|
|
||||||
import forge.item.InventoryItem;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import forge.item.InventoryItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>TableSorter class.</p>
|
* <p>
|
||||||
|
* TableSorter class.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
|
* @param <T>
|
||||||
|
* extends InventoryItem
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id: TableSorter.java 10146 2011-09-01 18:11:00Z Max mtg $
|
* @version $Id: TableSorter.java 10146 2011-09-01 18:11:00Z Max mtg $
|
||||||
*
|
|
||||||
* @param <T> extends InventoryItem
|
|
||||||
*/
|
*/
|
||||||
public class TableSorterCascade<T extends InventoryItem> implements Comparator<Entry<T, Integer>> {
|
public class TableSorterCascade<T extends InventoryItem> implements Comparator<Entry<T, Integer>> {
|
||||||
private List<TableSorter<T>> sorters;
|
private List<TableSorter<T>> sorters;
|
||||||
@@ -21,20 +23,29 @@ public class TableSorterCascade<T extends InventoryItem> implements Comparator<E
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* TableSorterCascade Constructor.
|
* TableSorterCascade Constructor.
|
||||||
* @param sortersCascade a List<TableSorter<T>>
|
*
|
||||||
|
* @param sortersCascade
|
||||||
|
* a List<TableSorter<T>>
|
||||||
*/
|
*/
|
||||||
public TableSorterCascade(final List<TableSorter<T>> sortersCascade) {
|
public TableSorterCascade(final List<TableSorter<T>> sortersCascade) {
|
||||||
this.sorters = sortersCascade;
|
this.sorters = sortersCascade;
|
||||||
cntFields = sortersCascade.size();
|
cntFields = sortersCascade.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final int compare(final Entry<T, Integer> arg0, final Entry<T, Integer> arg1) {
|
public final int compare(final Entry<T, Integer> arg0, final Entry<T, Integer> arg1) {
|
||||||
int lastCompare = 0;
|
int lastCompare = 0;
|
||||||
int iField = -1;
|
int iField = -1;
|
||||||
while (++iField < cntFields && lastCompare == 0) { // reverse iteration
|
while (++iField < cntFields && lastCompare == 0) { // reverse iteration
|
||||||
TableSorter<T> sorter = sorters.get(iField);
|
TableSorter<T> sorter = sorters.get(iField);
|
||||||
if (sorter == null) { break; }
|
if (sorter == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
lastCompare = sorter.compare(arg0, arg1);
|
lastCompare = sorter.compare(arg0, arg1);
|
||||||
}
|
}
|
||||||
return lastCompare;
|
return lastCompare;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import javax.swing.event.TableModelListener;
|
|||||||
import javax.swing.table.TableCellRenderer;
|
import javax.swing.table.TableCellRenderer;
|
||||||
|
|
||||||
import net.slightlymagic.maxmtg.Predicate;
|
import net.slightlymagic.maxmtg.Predicate;
|
||||||
|
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.CardRules;
|
import forge.card.CardRules;
|
||||||
@@ -28,42 +27,69 @@ import forge.item.ItemPoolView;
|
|||||||
*/
|
*/
|
||||||
public final class TableWithCards {
|
public final class TableWithCards {
|
||||||
|
|
||||||
|
/** The pool. */
|
||||||
protected ItemPool<InventoryItem> pool;
|
protected ItemPool<InventoryItem> pool;
|
||||||
|
|
||||||
|
/** The model. */
|
||||||
protected TableModel<InventoryItem> model;
|
protected TableModel<InventoryItem> model;
|
||||||
|
|
||||||
|
/** The table. */
|
||||||
protected JTable table = new JTable();
|
protected JTable table = new JTable();
|
||||||
|
|
||||||
|
/** The j scroll pane. */
|
||||||
protected JScrollPane jScrollPane = new JScrollPane();
|
protected JScrollPane jScrollPane = new JScrollPane();
|
||||||
|
|
||||||
|
/** The stats label. */
|
||||||
protected JLabel statsLabel = new JLabel();
|
protected JLabel statsLabel = new JLabel();
|
||||||
|
|
||||||
|
/** The filter. */
|
||||||
protected Predicate<InventoryItem> filter = null;
|
protected Predicate<InventoryItem> filter = null;
|
||||||
|
|
||||||
|
/** The is tracking stats. */
|
||||||
protected boolean isTrackingStats = false;
|
protected boolean isTrackingStats = false;
|
||||||
|
|
||||||
|
/** The want unique. */
|
||||||
protected boolean wantUnique = false;
|
protected boolean wantUnique = false;
|
||||||
|
|
||||||
// need this to allow users place its contents
|
// need this to allow users place its contents
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* getTableDecorated.
|
* getTableDecorated.
|
||||||
|
*
|
||||||
* @return JComponent
|
* @return JComponent
|
||||||
*/
|
*/
|
||||||
public JComponent getTableDecorated() { return jScrollPane; }
|
public JComponent getTableDecorated() {
|
||||||
|
return jScrollPane;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* getTable.
|
* getTable.
|
||||||
|
*
|
||||||
* @return JTable
|
* @return JTable
|
||||||
*/
|
*/
|
||||||
public JTable getTable() { return table; }
|
public JTable getTable() {
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* getLabel.
|
* getLabel.
|
||||||
|
*
|
||||||
* @return JComponent
|
* @return JComponent
|
||||||
*/
|
*/
|
||||||
public JComponent getLabel() { return statsLabel; }
|
public JComponent getLabel() {
|
||||||
|
return statsLabel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* TableWithCards.
|
* TableWithCards.
|
||||||
* @param title a String
|
*
|
||||||
* @param showStats a boolean
|
* @param title
|
||||||
|
* a String
|
||||||
|
* @param showStats
|
||||||
|
* a boolean
|
||||||
*/
|
*/
|
||||||
public TableWithCards(final String title, final boolean showStats) {
|
public TableWithCards(final String title, final boolean showStats) {
|
||||||
this(title, showStats, false);
|
this(title, showStats, false);
|
||||||
@@ -72,9 +98,13 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* TableWithCards Constructor.
|
* TableWithCards Constructor.
|
||||||
* @param title a String
|
*
|
||||||
* @param showStats a boolean
|
* @param title
|
||||||
* @param forceUnique a boolean
|
* a String
|
||||||
|
* @param showStats
|
||||||
|
* a boolean
|
||||||
|
* @param forceUnique
|
||||||
|
* a boolean
|
||||||
*/
|
*/
|
||||||
public TableWithCards(final String title, final boolean showStats, final boolean forceUnique) {
|
public TableWithCards(final String title, final boolean showStats, final boolean forceUnique) {
|
||||||
// components
|
// components
|
||||||
@@ -99,11 +129,13 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* setup.
|
* setup.
|
||||||
* @param columns a List<TableColumnInfo<InventoryItem>>
|
*
|
||||||
* @param cardView a CardPanelBase
|
* @param columns
|
||||||
|
* a List<TableColumnInfo<InventoryItem>>
|
||||||
|
* @param cardView
|
||||||
|
* a CardPanelBase
|
||||||
*/
|
*/
|
||||||
public void setup(final List<TableColumnInfo<InventoryItem>> columns, final CardPanelBase cardView)
|
public void setup(final List<TableColumnInfo<InventoryItem>> columns, final CardPanelBase cardView) {
|
||||||
{
|
|
||||||
model = new TableModel<InventoryItem>(cardView, columns, InventoryItem.class);
|
model = new TableModel<InventoryItem>(cardView, columns, InventoryItem.class);
|
||||||
model.addListeners(table);
|
model.addListeners(table);
|
||||||
table.setModel(model);
|
table.setModel(model);
|
||||||
@@ -131,7 +163,9 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* getStats.
|
* getStats.
|
||||||
* @param deck an ItemPoolView<InventoryITem>
|
*
|
||||||
|
* @param deck
|
||||||
|
* an ItemPoolView<InventoryITem>
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public static String getStats(final ItemPoolView<InventoryItem> deck) {
|
public static String getStats(final ItemPoolView<InventoryItem> deck) {
|
||||||
@@ -140,8 +174,8 @@ public final class TableWithCards {
|
|||||||
int land = CardRules.Predicates.Presets.isLand.aggregate(deck, deck.fnToCard, deck.fnToCount);
|
int land = CardRules.Predicates.Presets.isLand.aggregate(deck, deck.fnToCard, deck.fnToCount);
|
||||||
|
|
||||||
StringBuffer show = new StringBuffer();
|
StringBuffer show = new StringBuffer();
|
||||||
show.append("Total - ").append(total).append(", Creatures - ")
|
show.append("Total - ").append(total).append(", Creatures - ").append(creature).append(", Land - ")
|
||||||
.append(creature).append(", Land - ").append(land);
|
.append(land);
|
||||||
String[] color = Constant.Color.onlyColors;
|
String[] color = Constant.Color.onlyColors;
|
||||||
List<Predicate<CardRules>> predicates = CardRules.Predicates.Presets.colors;
|
List<Predicate<CardRules>> predicates = CardRules.Predicates.Presets.colors;
|
||||||
for (int i = 0; i < color.length; ++i) {
|
for (int i = 0; i < color.length; ++i) {
|
||||||
@@ -154,16 +188,23 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* sort.
|
* sort.
|
||||||
* @param iCol an int
|
*
|
||||||
|
* @param iCol
|
||||||
|
* an int
|
||||||
* @return TableWithCards
|
* @return TableWithCards
|
||||||
*/
|
*/
|
||||||
public TableWithCards sort(final int iCol) { return sort(iCol, true); }
|
public TableWithCards sort(final int iCol) {
|
||||||
|
return sort(iCol, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* sort.
|
* sort.
|
||||||
* @param iCol an int
|
*
|
||||||
* @param isAsc a boolean
|
* @param iCol
|
||||||
|
* an int
|
||||||
|
* @param isAsc
|
||||||
|
* a boolean
|
||||||
* @return TableWithCards
|
* @return TableWithCards
|
||||||
*/
|
*/
|
||||||
public TableWithCards sort(final int iCol, final boolean isAsc) {
|
public TableWithCards sort(final int iCol, final boolean isAsc) {
|
||||||
@@ -174,14 +215,18 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* fixSelection. Call this after deleting an item from table.
|
* fixSelection. Call this after deleting an item from table.
|
||||||
* @param rowLastSelected an int
|
*
|
||||||
|
* @param rowLastSelected
|
||||||
|
* an int
|
||||||
*/
|
*/
|
||||||
public void fixSelection(final int rowLastSelected) {
|
public void fixSelection(final int rowLastSelected) {
|
||||||
// 3 cases: 0 cards left, select the same row, select prev row
|
// 3 cases: 0 cards left, select the same row, select prev row
|
||||||
int newRow = rowLastSelected;
|
int newRow = rowLastSelected;
|
||||||
int cntRowsAbove = model.getRowCount();
|
int cntRowsAbove = model.getRowCount();
|
||||||
if (cntRowsAbove != 0) {
|
if (cntRowsAbove != 0) {
|
||||||
if (cntRowsAbove == newRow) { newRow--; } // move selection away from the last, already missing, option
|
if (cntRowsAbove == newRow) {
|
||||||
|
newRow--;
|
||||||
|
} // move selection away from the last, already missing, option
|
||||||
table.setRowSelectionInterval(newRow, newRow);
|
table.setRowSelectionInterval(newRow, newRow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,17 +234,21 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* setDeck.
|
* setDeck.
|
||||||
* @param cards an Iterable<InventoryITem>
|
*
|
||||||
|
* @param cards
|
||||||
|
* an Iterable<InventoryITem>
|
||||||
*/
|
*/
|
||||||
public void setDeck(final Iterable<InventoryItem> cards) {
|
public void setDeck(final Iterable<InventoryItem> cards) {
|
||||||
setDeckImpl(ItemPool.createFrom(cards, InventoryItem.class));
|
setDeckImpl(ItemPool.createFrom(cards, InventoryItem.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* setDeck.
|
* setDeck.
|
||||||
* @param poolView an ItemPoolView
|
*
|
||||||
* @param <T> an Object
|
* @param <T>
|
||||||
|
* an Object
|
||||||
|
* @param poolView
|
||||||
|
* an ItemPoolView
|
||||||
*/
|
*/
|
||||||
public <T extends InventoryItem> void setDeck(final ItemPoolView<T> poolView) {
|
public <T extends InventoryItem> void setDeck(final ItemPoolView<T> poolView) {
|
||||||
setDeckImpl(ItemPool.createFrom(poolView, InventoryItem.class));
|
setDeckImpl(ItemPool.createFrom(poolView, InventoryItem.class));
|
||||||
@@ -208,7 +257,9 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* setDeckImpl.
|
* setDeckImpl.
|
||||||
* @param thePool an ItemPool
|
*
|
||||||
|
* @param thePool
|
||||||
|
* an ItemPool
|
||||||
*/
|
*/
|
||||||
protected void setDeckImpl(final ItemPool<InventoryItem> thePool) {
|
protected void setDeckImpl(final ItemPool<InventoryItem> thePool) {
|
||||||
model.clear();
|
model.clear();
|
||||||
@@ -220,6 +271,7 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* getSelectedCard.
|
* getSelectedCard.
|
||||||
|
*
|
||||||
* @return InventoryItem
|
* @return InventoryItem
|
||||||
*/
|
*/
|
||||||
public InventoryItem getSelectedCard() {
|
public InventoryItem getSelectedCard() {
|
||||||
@@ -227,12 +279,16 @@ public final class TableWithCards {
|
|||||||
return iRow >= 0 ? model.rowToCard(iRow).getKey() : null;
|
return iRow >= 0 ? model.rowToCard(iRow).getKey() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isUnfiltered() { return filter == null || filter.is1(); }
|
private boolean isUnfiltered() {
|
||||||
|
return filter == null || filter.is1();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* setFilter.
|
* setFilter.
|
||||||
* @param filterToSet a Predicate
|
*
|
||||||
|
* @param filterToSet
|
||||||
|
* a Predicate
|
||||||
*/
|
*/
|
||||||
public void setFilter(final Predicate<InventoryItem> filterToSet) {
|
public void setFilter(final Predicate<InventoryItem> filterToSet) {
|
||||||
filter = filterToSet;
|
filter = filterToSet;
|
||||||
@@ -242,24 +298,32 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* addCard.
|
* addCard.
|
||||||
* @param card an InventoryItem
|
*
|
||||||
|
* @param card
|
||||||
|
* an InventoryItem
|
||||||
*/
|
*/
|
||||||
public void addCard(final InventoryItem card) {
|
public void addCard(final InventoryItem 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(false);
|
updateView(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* removeCard.
|
* removeCard.
|
||||||
* @param card an InventoryItem
|
*
|
||||||
|
* @param card
|
||||||
|
* an InventoryItem
|
||||||
*/
|
*/
|
||||||
public void removeCard(final InventoryItem card) {
|
public void removeCard(final InventoryItem 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(false);
|
updateView(false);
|
||||||
fixSelection(n);
|
fixSelection(n);
|
||||||
}
|
}
|
||||||
@@ -267,7 +331,9 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* updateView.
|
* updateView.
|
||||||
* @param bForceFilter a boolean
|
*
|
||||||
|
* @param bForceFilter
|
||||||
|
* a boolean
|
||||||
*/
|
*/
|
||||||
public void updateView(final boolean bForceFilter) {
|
public void updateView(final boolean bForceFilter) {
|
||||||
boolean useFilter = (bForceFilter && filter != null) || !isUnfiltered();
|
boolean useFilter = (bForceFilter && filter != null) || !isUnfiltered();
|
||||||
@@ -281,9 +347,8 @@ public final class TableWithCards {
|
|||||||
} else if (useFilter) {
|
} else if (useFilter) {
|
||||||
model.addCards(filter.select(pool, pool.fnToPrinted));
|
model.addCards(filter.select(pool, pool.fnToPrinted));
|
||||||
} else if (wantUnique) {
|
} else if (wantUnique) {
|
||||||
model.addCards(
|
model.addCards(CardRules.Predicates.Presets.constantTrue.uniqueByLast(pool, pool.fnToCardName,
|
||||||
CardRules.Predicates.Presets.constantTrue.uniqueByLast(
|
pool.fnToCard));
|
||||||
pool, pool.fnToCardName, pool.fnToCard));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
model.resort();
|
model.resort();
|
||||||
@@ -292,6 +357,7 @@ public final class TableWithCards {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* getCards.
|
* getCards.
|
||||||
|
*
|
||||||
* @return ItemPoolView
|
* @return ItemPoolView
|
||||||
*/
|
*/
|
||||||
public ItemPoolView<InventoryItem> getCards() {
|
public ItemPoolView<InventoryItem> getCards() {
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
/** Forge Card Game */
|
/** Forge Card Game. */
|
||||||
package forge.gui.deckeditor;
|
package forge.gui.deckeditor;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user