mirror of
https://github.com/correl/mage.git
synced 2025-01-11 11:05:23 +00:00
[deck.editor] Switching between card selectors. Displaying cards from the list. --All sets-- option to show all cards at once (appears only in CardTableSelector).
This commit is contained in:
parent
6e3a7ede39
commit
f66fd8fc97
11 changed files with 221 additions and 150 deletions
Binary file not shown.
|
@ -34,9 +34,7 @@
|
|||
|
||||
package mage.client.deckeditor;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
|
@ -125,6 +123,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
case Sideboard:
|
||||
this.btnSubmit.setVisible(true);
|
||||
this.cardSelector.loadCards(new ArrayList<Card>(deck.getSideboard()), this.bigCard, mode == DeckEditorMode.Limited);
|
||||
this.cardTableSelector.loadCards(new ArrayList<Card>(deck.getSideboard()), this.bigCard, mode == DeckEditorMode.Limited);
|
||||
this.btnExit.setVisible(false);
|
||||
this.btnImport.setVisible(false);
|
||||
if (!MageFrame.getSession().isTestMode())
|
||||
|
@ -140,6 +139,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
case Constructed:
|
||||
this.btnSubmit.setVisible(false);
|
||||
this.cardSelector.loadCards(this.bigCard);
|
||||
this.cardTableSelector.loadCards(this.bigCard);
|
||||
this.btnExit.setVisible(true);
|
||||
this.btnImport.setVisible(true);
|
||||
if (!MageFrame.getSession().isTestMode())
|
||||
|
@ -153,6 +153,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
|
||||
private void init() {
|
||||
this.cardSelector.setVisible(true);
|
||||
this.cardTableSelector.setVisible(false);
|
||||
this.jRadioButtonFullCards.setSelected(true);
|
||||
this.jRadioButtonListTable.setSelected(false);
|
||||
this.jPanel1.setVisible(true);
|
||||
this.cardSelector.getCardsList().clearCardEventListeners();
|
||||
this.cardSelector.getCardsList().addCardEventListener(
|
||||
|
@ -188,6 +191,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
if (mode == DeckEditorMode.Limited || mode == DeckEditorMode.Sideboard) {
|
||||
deck.getSideboard().add(card);
|
||||
cardSelector.loadCards(new ArrayList<Card>(deck.getSideboard()), getBigCard(), mode == DeckEditorMode.Limited);
|
||||
cardTableSelector.loadCards(new ArrayList<Card>(deck.getSideboard()), getBigCard(), mode == DeckEditorMode.Limited);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -260,9 +264,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
private void initComponents() {
|
||||
|
||||
jSplitPane1 = new javax.swing.JSplitPane();
|
||||
//cardSelector = new mage.client.deckeditor.table.CardTableSelector();
|
||||
cardSelector = new mage.client.deckeditor.CardSelector();
|
||||
deckArea = new mage.client.deckeditor.DeckArea();
|
||||
cardTableSelector = new mage.client.deckeditor.table.CardTableSelector();
|
||||
deckArea = new mage.client.deckeditor.DeckArea();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
bigCard = new mage.client.cards.BigCard();
|
||||
txtDeckName = new javax.swing.JTextField();
|
||||
|
@ -276,6 +280,48 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
btnAddLand = new javax.swing.JButton();
|
||||
txtTimeRemaining = new javax.swing.JTextField();
|
||||
|
||||
jLayeredPane1 = new javax.swing.JLayeredPane();
|
||||
jRadioButtonFullCards = new javax.swing.JRadioButton();
|
||||
jRadioButtonListTable = new javax.swing.JRadioButton();
|
||||
|
||||
jLayeredPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "View", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", Font.BOLD, 13), new java.awt.Color(0, 0, 0))); // NOI18N
|
||||
|
||||
jRadioButtonFullCards.setLabel("Full cards");
|
||||
jRadioButtonFullCards.setBounds(50, 27, 80, 23);
|
||||
jLayeredPane1.add(jRadioButtonFullCards, javax.swing.JLayeredPane.DEFAULT_LAYER);
|
||||
jRadioButtonFullCards.getAccessibleContext().setAccessibleName("Full cards");
|
||||
jRadioButtonFullCards.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (jRadioButtonListTable.isSelected()) {
|
||||
jRadioButtonListTable.setSelected(false);
|
||||
cardTableSelector.setVisible(false);
|
||||
cardSelector.setVisible(true);
|
||||
jSplitPane1.setTopComponent(cardSelector);
|
||||
jSplitPane1.revalidate();
|
||||
jSplitPane1.repaint();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
jRadioButtonListTable.setActionCommand("List");
|
||||
jRadioButtonListTable.setText("List");
|
||||
jRadioButtonListTable.setBounds(140, 27, 70, 23);
|
||||
jLayeredPane1.add(jRadioButtonListTable, javax.swing.JLayeredPane.DEFAULT_LAYER);
|
||||
jRadioButtonListTable.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (jRadioButtonFullCards.isSelected()) {
|
||||
jRadioButtonFullCards.setSelected(false);
|
||||
cardTableSelector.setVisible(true);
|
||||
cardSelector.setVisible(false);
|
||||
jSplitPane1.setTopComponent(cardTableSelector);
|
||||
jSplitPane1.revalidate();
|
||||
jSplitPane1.repaint();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
jSplitPane1.setResizeWeight(0.5);
|
||||
jSplitPane1.setTopComponent(cardSelector);
|
||||
|
@ -343,9 +389,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
btnAddLand.setText("Add Land");
|
||||
btnAddLand.setName("btnAddLand"); // NOI18N
|
||||
btnAddLand.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnAddLandActionPerformed(evt);
|
||||
}
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnAddLandActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
txtTimeRemaining.setEditable(false);
|
||||
|
@ -356,61 +402,66 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(lblDeckName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnSave)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnLoad)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnNew)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnExit))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnImport)
|
||||
.addContainerGap()
|
||||
.addComponent(btnAddLand)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmit))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(txtTimeRemaining))
|
||||
)
|
||||
.addContainerGap())
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(lblDeckName)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnSave)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnLoad)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnNew)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnExit))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(btnImport)
|
||||
.addContainerGap()
|
||||
.addComponent(btnAddLand)
|
||||
.addContainerGap()
|
||||
.addComponent(btnSubmit))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(txtTimeRemaining))
|
||||
)
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblDeckName))
|
||||
.addComponent(txtDeckName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblDeckName))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnSave)
|
||||
.addComponent(btnLoad)
|
||||
.addComponent(btnNew)
|
||||
.addComponent(btnExit))
|
||||
.addComponent(btnSave)
|
||||
.addComponent(btnLoad)
|
||||
.addComponent(btnNew)
|
||||
.addComponent(btnExit))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnImport)
|
||||
.addComponent(btnAddLand)
|
||||
.addComponent(btnSubmit))
|
||||
.addComponent(btnImport)
|
||||
.addComponent(btnAddLand)
|
||||
.addComponent(btnSubmit))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(txtTimeRemaining))
|
||||
.addComponent(txtTimeRemaining))
|
||||
.addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
|
||||
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 104, Short.MAX_VALUE)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
|
||||
|
@ -489,6 +540,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}
|
||||
deck.getCards().clear();
|
||||
cardSelector.loadCards(new ArrayList<Card>(deck.getSideboard()), this.bigCard, mode == DeckEditorMode.Limited);
|
||||
cardTableSelector.loadCards(new ArrayList<Card>(deck.getSideboard()), this.bigCard, mode == DeckEditorMode.Limited);
|
||||
}
|
||||
else {
|
||||
deck = new Deck();
|
||||
|
@ -559,13 +611,16 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
private javax.swing.JButton btnLoad;
|
||||
private javax.swing.JButton btnNew;
|
||||
private javax.swing.JButton btnSave;
|
||||
//private mage.client.deckeditor.table.CardTableSelector cardSelector;
|
||||
private mage.client.deckeditor.table.CardTableSelector cardTableSelector;
|
||||
private mage.client.deckeditor.CardSelector cardSelector;
|
||||
private mage.client.deckeditor.DeckArea deckArea;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
private javax.swing.JLabel lblDeckName;
|
||||
private javax.swing.JTextField txtDeckName;
|
||||
private javax.swing.JRadioButton jRadioButtonFullCards;
|
||||
private javax.swing.JRadioButton jRadioButtonListTable;
|
||||
private javax.swing.JLayeredPane jLayeredPane1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
private JComponent cardInfoPane;
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.client.deckeditor.table;
|
|||
|
||||
import mage.Constants.CardType;
|
||||
import mage.cards.MageCard;
|
||||
import mage.view.CardView;
|
||||
|
||||
/**
|
||||
* Helper methods for {@link MageCard}.
|
||||
|
@ -40,30 +41,30 @@ public class CardHelper {
|
|||
private CardHelper() {
|
||||
}
|
||||
|
||||
public static String getColor(MageCard c) {
|
||||
if (c.getOriginal().getColor().getColorCount() == 0) return "Colorless";
|
||||
else if (c.getOriginal().getColor().getColorCount() > 1) return "Gold";
|
||||
else if (c.getOriginal().getColor().isBlack()) return "Black";
|
||||
else if (c.getOriginal().getColor().isBlue()) return "Blue";
|
||||
else if (c.getOriginal().getColor().isWhite()) return "White";
|
||||
else if (c.getOriginal().getColor().isGreen()) return "Green";
|
||||
else if (c.getOriginal().getColor().isRed()) return "Red";
|
||||
public static String getColor(CardView c) {
|
||||
if (c.getColor().getColorCount() == 0) return "Colorless";
|
||||
else if (c.getColor().getColorCount() > 1) return "Gold";
|
||||
else if (c.getColor().isBlack()) return "Black";
|
||||
else if (c.getColor().isBlue()) return "Blue";
|
||||
else if (c.getColor().isWhite()) return "White";
|
||||
else if (c.getColor().isGreen()) return "Green";
|
||||
else if (c.getColor().isRed()) return "Red";
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getType(MageCard c) {
|
||||
public static String getType(CardView c) {
|
||||
StringBuilder type = new StringBuilder();
|
||||
for (String superType : c.getOriginal().getSuperTypes()) {
|
||||
for (String superType : c.getSuperTypes()) {
|
||||
type.append(superType);
|
||||
type.append(" ");
|
||||
}
|
||||
for (CardType cardType : c.getOriginal().getCardTypes()) {
|
||||
for (CardType cardType : c.getCardTypes()) {
|
||||
type.append(cardType.toString());
|
||||
type.append(" ");
|
||||
}
|
||||
if (c.getOriginal().getSubTypes().size() > 0) {
|
||||
if (c.getSubTypes().size() > 0) {
|
||||
type.append("- ");
|
||||
for (String subType : c.getOriginal().getSubTypes()) {
|
||||
for (String subType : c.getSubTypes()) {
|
||||
type.append(subType);
|
||||
type.append(" ");
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ public class CardHelper {
|
|||
return type.toString();
|
||||
}
|
||||
|
||||
public static boolean isCreature(MageCard c) {
|
||||
return c.getOriginal().getCardTypes().contains(CardType.CREATURE);
|
||||
public static boolean isCreature(CardView c) {
|
||||
return c.getCardTypes().contains(CardType.CREATURE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,10 +100,12 @@ public class CardTableSelector extends javax.swing.JPanel implements ComponentLi
|
|||
}
|
||||
});
|
||||
cbExpansionSet.setModel(new DefaultComboBoxModel(l));
|
||||
// cbExpansionSet.insertItemAt("All sets", 0);
|
||||
cbExpansionSet.insertItemAt("-- All sets -- ", 0);
|
||||
cbExpansionSet.setSelectedIndex(0);
|
||||
initFilter();
|
||||
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
if (this.cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
|
||||
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
|
||||
}
|
||||
filterCards();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,13 +31,14 @@ import java.util.Comparator;
|
|||
import java.util.List;
|
||||
|
||||
import mage.cards.MageCard;
|
||||
import mage.view.CardView;
|
||||
|
||||
/**
|
||||
* {@link MageCard} comparator. Used to sort cards in Deck Editor Table View pane.
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class MageCardComparator implements Comparator<MageCard> {
|
||||
public class MageCardComparator implements Comparator<CardView> {
|
||||
private final int column;
|
||||
private boolean ascending;
|
||||
|
||||
|
@ -46,7 +47,7 @@ public class MageCardComparator implements Comparator<MageCard> {
|
|||
this.ascending = ascending;
|
||||
}
|
||||
|
||||
public int compare(MageCard a, MageCard b) {
|
||||
public int compare(CardView a, CardView b) {
|
||||
Comparable aCom = null;
|
||||
Comparable bCom = null;
|
||||
|
||||
|
@ -56,16 +57,16 @@ public class MageCardComparator implements Comparator<MageCard> {
|
|||
bCom = Integer.valueOf(1);
|
||||
} else if (column == 1)// Name
|
||||
{
|
||||
aCom = a.getOriginal().getName();
|
||||
bCom = b.getOriginal().getName();
|
||||
if (aCom.equals(bCom) && a.getOriginal().getExpansionSetCode().equals(b.getOriginal().getExpansionSetCode())) {
|
||||
aCom = a.getOriginal().getCardNumber();
|
||||
bCom = b.getOriginal().getCardNumber();
|
||||
aCom = a.getName();
|
||||
bCom = b.getName();
|
||||
if (aCom.equals(bCom) && a.getExpansionSetCode().equals(b.getExpansionSetCode())) {
|
||||
aCom = a.getCardNumber();
|
||||
bCom = b.getCardNumber();
|
||||
}
|
||||
} else if (column == 2)// Cost
|
||||
{
|
||||
aCom = a.getOriginal().getConvertedManaCost();
|
||||
bCom = b.getOriginal().getConvertedManaCost();
|
||||
aCom = a.getConvertedManaCost();
|
||||
bCom = b.getConvertedManaCost();
|
||||
} else if (column == 3)// Color
|
||||
{
|
||||
aCom = CardHelper.getColor(a);
|
||||
|
@ -80,17 +81,17 @@ public class MageCardComparator implements Comparator<MageCard> {
|
|||
bCom = new Float(-1);
|
||||
|
||||
if (CardHelper.isCreature(a))
|
||||
aCom = new Float(a.getOriginal().getPower() + "." + a.getOriginal().getToughness());
|
||||
aCom = new Float(a.getPower() + "." + a.getToughness());
|
||||
if (CardHelper.isCreature(b))
|
||||
bCom = new Float(b.getOriginal().getPower() + "." + b.getOriginal().getToughness());
|
||||
bCom = new Float(b.getPower() + "." + b.getToughness());
|
||||
} else if (column == 6)// Rarity
|
||||
{
|
||||
aCom = a.getOriginal().getRarity().toString();
|
||||
bCom = b.getOriginal().getRarity().toString();
|
||||
aCom = a.getRarity().toString();
|
||||
bCom = b.getRarity().toString();
|
||||
} else if (column == 7)// Set name
|
||||
{
|
||||
aCom = a.getOriginal().getExpansionSetCode();
|
||||
bCom = b.getOriginal().getExpansionSetCode();
|
||||
aCom = a.getExpansionSetCode();
|
||||
bCom = b.getExpansionSetCode();
|
||||
}
|
||||
|
||||
if (ascending)
|
||||
|
|
|
@ -28,25 +28,6 @@
|
|||
|
||||
package mage.client.deckeditor.table;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
|
||||
import mage.cards.MageCard;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.CardEventSource;
|
||||
|
@ -59,6 +40,17 @@ import mage.client.util.ImageHelper;
|
|||
import mage.client.util.Listener;
|
||||
import mage.view.CardView;
|
||||
import mage.view.CardsView;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import javax.swing.table.TableColumnModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Table Model for card list.
|
||||
|
@ -69,11 +61,13 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
|
||||
private static final long serialVersionUID = -528008802935423088L;
|
||||
|
||||
private static final Logger log = Logger.getLogger(TableModel.class);
|
||||
|
||||
protected CardEventSource cardEventSource = new CardEventSource();
|
||||
protected BigCard bigCard;
|
||||
protected UUID gameId;
|
||||
private Map<UUID, MageCard> cards = new LinkedHashMap<UUID, MageCard>();
|
||||
private List<MageCard> view = new ArrayList<MageCard>();
|
||||
private Map<UUID, CardView> cards = new LinkedHashMap<UUID, CardView>();
|
||||
private List<CardView> view = new ArrayList<CardView>();
|
||||
private Dimension cardDimension;
|
||||
|
||||
private String column[] = { "", "Name", "Cost", "Color", "Type", "Stats",
|
||||
|
@ -91,19 +85,20 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
addCard(card, bigCard, gameId);
|
||||
}
|
||||
}
|
||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i
|
||||
for (Iterator<Entry<UUID, CardView>> i = cards.entrySet().iterator(); i
|
||||
.hasNext();) {
|
||||
Entry<UUID, MageCard> entry = i.next();
|
||||
Entry<UUID, CardView> entry = i.next();
|
||||
if (!showCards.containsKey(entry.getKey())) {
|
||||
i.remove();
|
||||
for (MageCard v : view) {
|
||||
if (v.getOriginal().getId().equals(entry.getKey())) {
|
||||
view.remove(v);
|
||||
for (CardView cv : view) {
|
||||
if (cv.getId().equals(entry.getKey())) {
|
||||
view.remove(cv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sort(1, true);
|
||||
drawCards(sortBy, piles);
|
||||
}
|
||||
|
||||
|
@ -129,15 +124,15 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
}
|
||||
|
||||
private Object getColumn(Object obj, int column) {
|
||||
MageCard c = (MageCard) obj;
|
||||
CardView c = (CardView) obj;
|
||||
switch (column) {
|
||||
case 0:
|
||||
return "";
|
||||
case 1:
|
||||
return c.getOriginal().getName();
|
||||
return c.getName();
|
||||
case 2:
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (String cost : c.getOriginal().getManaCost()) {
|
||||
for (String cost : c.getManaCost()) {
|
||||
s.append(cost);
|
||||
}
|
||||
String cost = s.toString();
|
||||
|
@ -150,12 +145,12 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
case 4:
|
||||
return CardHelper.getType(c);
|
||||
case 5:
|
||||
return CardHelper.isCreature(c) ? c.getOriginal().getPower() + "/"
|
||||
+ c.getOriginal().getToughness() : "-";
|
||||
return CardHelper.isCreature(c) ? c.getPower() + "/"
|
||||
+ c.getToughness() : "-";
|
||||
case 6:
|
||||
return c.getOriginal().getRarity().toString();
|
||||
return c.getRarity().toString();
|
||||
case 7:
|
||||
return c.getOriginal().getExpansionSetCode();
|
||||
return c.getExpansionSetCode();
|
||||
default:
|
||||
return "error";
|
||||
}
|
||||
|
@ -166,11 +161,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
cardDimension = new Dimension(Config.dimensions.frameWidth,
|
||||
Config.dimensions.frameHeight);
|
||||
}
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard,
|
||||
cardDimension, gameId, true);
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardImg.update(card);
|
||||
view.add(cardImg);
|
||||
cards.put(card.getId(), card);
|
||||
view.add(card);
|
||||
}
|
||||
|
||||
public void drawCards(SortBy sortBy, boolean piles) {
|
||||
|
@ -179,9 +171,9 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
|
||||
public void removeCard(UUID cardId) {
|
||||
cards.remove(cardId);
|
||||
for (MageCard v : view) {
|
||||
if (v.getOriginal().getId().equals(cardId)) {
|
||||
view.remove(v);
|
||||
for (CardView cv : view) {
|
||||
if (cv.getId().equals(cardId)) {
|
||||
view.remove(cv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -197,34 +189,25 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
|
||||
public void addListeners(final JTable table) {
|
||||
// updates card detail, listens to any key strokes
|
||||
/*
|
||||
* table.addKeyListener(new KeyListener() { public void
|
||||
* keyPressed(KeyEvent ev) { }
|
||||
*
|
||||
* public void keyTyped(KeyEvent ev) { }
|
||||
*
|
||||
* public void keyReleased(KeyEvent ev) { int row =
|
||||
* table.getSelectedRow(); if (row != -1) { MageCard card =
|
||||
* (MageCard)cards.values().toArray()[row];
|
||||
* bigCard.setCard(card.getOriginal().getId(), card.getImage(), new
|
||||
* ArrayList<String>(), false); } } });
|
||||
*/
|
||||
|
||||
table.addKeyListener(new KeyListener() {
|
||||
public void keyPressed(KeyEvent ev) {}
|
||||
public void keyTyped(KeyEvent ev) {}
|
||||
|
||||
public void keyReleased(KeyEvent ev) {
|
||||
int row = table.getSelectedRow();
|
||||
if (row != -1) {
|
||||
showImage(row);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// updates card detail, listens to any mouse clicks
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
int row = table.getSelectedRow();
|
||||
if (row != -1) {
|
||||
MageCard card = view.get(row);
|
||||
if (card.getOriginal().getId().equals(bigCard.getCardId())) {
|
||||
Image image = card.getImage();
|
||||
if (image != null && image instanceof BufferedImage) {
|
||||
image = ImageHelper.getResizedImage(
|
||||
(BufferedImage) image, bigCard.getWidth(),
|
||||
bigCard.getHeight());
|
||||
}
|
||||
bigCard.setCard(card.getOriginal().getId(), image,
|
||||
new ArrayList<String>(), false);
|
||||
}
|
||||
showImage(row);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -242,8 +225,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
if (recentSortedColumn == column) {
|
||||
asc = !recentAscending;
|
||||
}
|
||||
boolean change = sort(column, asc);
|
||||
|
||||
sort(column, asc);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
|
@ -251,6 +233,18 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
|
|||
table.getTableHeader().addMouseListener(mouse);
|
||||
}
|
||||
|
||||
private void showImage(int row) {
|
||||
CardView card = view.get(row);
|
||||
if (!card.getId().equals(bigCard.getCardId())) {
|
||||
Image image = Plugins.getInstance().getOriginalImage(card);
|
||||
if (image != null && image instanceof BufferedImage) {
|
||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth(),
|
||||
bigCard.getHeight());
|
||||
bigCard.setCard(card.getId(), image, new ArrayList<String>(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean sort(int column, boolean ascending) {
|
||||
// used by addCard() to resort the cards
|
||||
recentSortedColumn = column;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mage.client.plugins;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -35,4 +36,5 @@ public interface MagePlugins {
|
|||
void onAddCard(MagePermanent card, int count);
|
||||
void onRemoveCard(MagePermanent card, int count);
|
||||
JComponent getCardInfoPane();
|
||||
BufferedImage getOriginalImage(CardView card);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mage.client.plugins.impl;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
@ -190,5 +191,12 @@ public class Plugins implements MagePlugins {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedImage getOriginalImage(CardView card) {
|
||||
if (this.cardPlugin != null) {
|
||||
return this.cardPlugin.getOriginalImage(card);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mage.interfaces.plugin;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -34,4 +35,5 @@ public interface CardPlugin extends Plugin {
|
|||
void onAddCard(MagePermanent card, int count);
|
||||
void onRemoveCard(MagePermanent card, int count);
|
||||
JComponent getCardInfoPane();
|
||||
BufferedImage getOriginalImage(CardView card);
|
||||
}
|
||||
|
|
|
@ -23,12 +23,14 @@ import org.mage.plugins.card.dl.Downloader;
|
|||
import org.mage.plugins.card.dl.sources.GathererSets;
|
||||
import org.mage.plugins.card.dl.sources.GathererSymbols;
|
||||
import org.mage.plugins.card.images.DownloadPictures;
|
||||
import org.mage.plugins.card.images.ImageCache;
|
||||
import org.mage.plugins.card.info.CardInfoPaneImpl;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -463,4 +465,8 @@ public class CardPluginImpl implements CardPlugin {
|
|||
public JComponent getCardInfoPane() {
|
||||
return new CardInfoPaneImpl();
|
||||
}
|
||||
|
||||
public BufferedImage getOriginalImage(CardView card) {
|
||||
return ImageCache.getImageOriginal(card);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,12 +75,12 @@ public class ImageCache {
|
|||
String thumbnailPath = path.replace(".jpg", ".thumb.jpg");
|
||||
File thumbnailFile = new File(thumbnailPath);
|
||||
if (thumbnailFile.exists()) {
|
||||
log.info("loading thumbnail for " + key + ", path="+thumbnailPath);
|
||||
//log.debug("loading thumbnail for " + key + ", path="+thumbnailPath);
|
||||
return loadImage(thumbnailFile);
|
||||
} else {
|
||||
BufferedImage image = loadImage(file);
|
||||
if (image == null) return null;
|
||||
log.info("creating thumbnail for " + key);
|
||||
//log.debug("creating thumbnail for " + key);
|
||||
return makeThumbnail(image, thumbnailPath);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue