mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
Sorting by formats in Collection Viewer.
This commit is contained in:
parent
ec3305478d
commit
5fbb8b1053
5 changed files with 363 additions and 304 deletions
|
|
@ -37,8 +37,6 @@ package mage.client.deckeditor;
|
|||
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.CardsList;
|
||||
import mage.client.constants.Constants.SortBy;
|
||||
import mage.client.util.Event;
|
||||
import mage.client.util.Listener;
|
||||
import mage.view.CardsView;
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
this.tableId = tableId;
|
||||
this.mode = mode;
|
||||
this.btnAddLand.setVisible(false);
|
||||
//this.cardTableSelector.setMode(mode);
|
||||
switch (mode) {
|
||||
case Limited:
|
||||
this.btnAddLand.setVisible(true);
|
||||
|
|
@ -129,7 +128,6 @@ 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())
|
||||
|
|
@ -163,9 +161,6 @@ 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);
|
||||
for (ICardGrid component : this.cardSelector.getCardGridComponents()) {
|
||||
component.clearCardEventListeners();
|
||||
|
|
@ -240,13 +235,10 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("double-click")) {
|
||||
//boolean isListView = cardSelector.getCardsList() instanceof TableModel;
|
||||
for (Card card: deck.getSideboard()) {
|
||||
if (card.getId().equals(event.getSource())) {
|
||||
deck.getSideboard().remove(card);
|
||||
//if (!isListView) {
|
||||
deck.getCards().add(card);
|
||||
//}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -299,7 +291,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
|
||||
jSplitPane1 = new javax.swing.JSplitPane();
|
||||
cardSelector = new mage.client.deckeditor.CardSelector();
|
||||
//cardTableSelector = new mage.client.deckeditor.table.CardTableSelector();
|
||||
deckArea = new mage.client.deckeditor.DeckArea();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
bigCard = new mage.client.cards.BigCard();
|
||||
|
|
@ -314,51 +305,6 @@ 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.setDividerLocation(0.6);
|
||||
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.setDividerLocation(0.6);
|
||||
jSplitPane1.revalidate();
|
||||
jSplitPane1.repaint();
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
jSplitPane1.setResizeWeight(0.5);
|
||||
jSplitPane1.setTopComponent(cardSelector);
|
||||
|
|
@ -584,7 +530,6 @@ 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();
|
||||
|
|
@ -659,16 +604,12 @@ 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 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;
|
||||
|
|
|
|||
|
|
@ -27,14 +27,15 @@
|
|||
*/
|
||||
package mage.client.deckeditor.collection.viewer;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.GridBagLayout;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import mage.cards.decks.Constructed;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.util.sets.ConstructedFormats;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.Console;
|
||||
|
||||
/**
|
||||
* Pane with big card and mage book.
|
||||
|
|
@ -42,6 +43,8 @@ import mage.client.cards.BigCard;
|
|||
* @author nantuko
|
||||
*/
|
||||
public final class CollectionViewerPanel extends JPanel {
|
||||
|
||||
|
||||
public CollectionViewerPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
|
@ -50,13 +53,38 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
jPanel1 = new javax.swing.JPanel();
|
||||
jPanel1.setOpaque(false);
|
||||
bigCard = new BigCard();
|
||||
BoxLayout boxlayout = new BoxLayout(jPanel1, BoxLayout.Y_AXIS);
|
||||
BoxLayout boxlayout = new BoxLayout(jPanel1, BoxLayout.PAGE_AXIS);
|
||||
jPanel1.setLayout(boxlayout);
|
||||
btnExit = new javax.swing.JButton();
|
||||
btnExit.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jPanel1.add(btnExit);
|
||||
|
||||
JLabel label1 = new JLabel("Choose sets to display:");
|
||||
label1.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jPanel1.add(label1);
|
||||
|
||||
formats = new JComboBox(ConstructedFormats.getTypes());
|
||||
formats.setSelectedItem(ConstructedFormats.getDefault());
|
||||
formats.setPreferredSize(new Dimension(100, 25));
|
||||
formats.setMaximumSize(new Dimension(100, 25));
|
||||
formats.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
jPanel1.add(formats);
|
||||
|
||||
formats.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (mageBook != null) {
|
||||
String format = (String)formats.getSelectedItem();
|
||||
mageBook.updateDispayedSets(format);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
jPanel1.add(Box.createVerticalGlue());
|
||||
bigCard.setAlignmentY(Component.BOTTOM_ALIGNMENT);
|
||||
|
||||
bigCard.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
bigCard.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
bigCard.setAlignmentY(Component.BOTTOM_ALIGNMENT);
|
||||
jPanel1.add(bigCard);
|
||||
|
||||
jPanel2 = new MageBookContainer();
|
||||
|
|
@ -109,7 +137,8 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
|
||||
jPanel.setLayout(new GridBagLayout()); // centers mage book
|
||||
jPanel.setBackground(new Color(0, 0, 0, 0));
|
||||
jPanel.add(new MageBook(bigCard));
|
||||
mageBook = new MageBook(bigCard);
|
||||
jPanel.add(mageBook);
|
||||
|
||||
setLayout(new java.awt.BorderLayout());
|
||||
add(jScrollPane1, java.awt.BorderLayout.CENTER);
|
||||
|
|
@ -123,5 +152,7 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
private javax.swing.JPanel jPanel2;
|
||||
private mage.client.cards.BigCard bigCard;
|
||||
private javax.swing.JButton btnExit;
|
||||
private JComboBox formats;
|
||||
private MageBook mageBook;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ package mage.client.deckeditor.collection.viewer;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.cards.MageCard;
|
||||
import mage.cards.decks.Constructed;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.CardsStorage;
|
||||
import mage.client.components.HoverButton;
|
||||
|
|
@ -39,10 +40,12 @@ import mage.client.util.AudioManager;
|
|||
import mage.client.util.Command;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.sets.ConstructedFormats;
|
||||
import mage.components.ImagePanel;
|
||||
import mage.view.CardView;
|
||||
import org.mage.card.arcane.GlowText;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.card.arcane.GlowText;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
|
|
@ -50,8 +53,8 @@ import java.awt.*;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import org.mage.card.arcane.ManaSymbols;
|
||||
|
||||
/**
|
||||
* Mage book with cards and page flipping.
|
||||
|
|
@ -63,6 +66,7 @@ public class MageBook extends JComponent {
|
|||
public MageBook(BigCard bigCard) {
|
||||
super();
|
||||
this.bigCard = bigCard;
|
||||
this.setsToDisplay = ConstructedFormats.getSetsByFormat(ConstructedFormats.getDefault());
|
||||
initComponents();
|
||||
}
|
||||
|
||||
|
|
@ -146,13 +150,13 @@ public class MageBook extends JComponent {
|
|||
Image imageRight = ImageHelper.loadImage(RIGHT_TAB_IMAGE_PATH);
|
||||
int y = 0;
|
||||
int dy = 0;
|
||||
if (CardsStorage.getSetCodes().size() > 1) {
|
||||
dy = (HEIGHT - 120) / (CardsStorage.getSetCodes().size() - 1) + 1;
|
||||
if (this.setsToDisplay.size() > 1) {
|
||||
dy = (HEIGHT - 120) / (this.setsToDisplay.size() - 1) + 1;
|
||||
}
|
||||
int count = 0;
|
||||
JPanel currentPanel = jPanelLeft;
|
||||
HoverButton currentTab = null;
|
||||
for (String set : CardsStorage.getSetCodes()) {
|
||||
for (String set : this.setsToDisplay) {
|
||||
HoverButton tab = new HoverButton(null, image, image, image, new Rectangle(39, 120));
|
||||
Image setImage = ManaSymbols.getSetSymbolImage(set);
|
||||
if (setImage != null) {
|
||||
|
|
@ -274,6 +278,15 @@ public class MageBook extends JComponent {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateDispayedSets(String format) {
|
||||
this.setsToDisplay = ConstructedFormats.getSetsByFormat(format);
|
||||
if (this.setsToDisplay.isEmpty()) {
|
||||
// display all
|
||||
this.setsToDisplay = CardsStorage.getSetCodes();
|
||||
}
|
||||
addSetTabs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the position of the next card on the mage book
|
||||
*/
|
||||
|
|
@ -310,6 +323,7 @@ public class MageBook extends JComponent {
|
|||
private static CardDimensions cardDimensions = new CardDimensions(1.2d);
|
||||
private static final Logger log = Logger.getLogger(MageBook.class);
|
||||
private Dimension cardDimension;
|
||||
private java.util.List<String> setsToDisplay = new ArrayList<String>();
|
||||
|
||||
static private final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg";
|
||||
static private final String RIGHT_PANEL_IMAGE_PATH = "/book_right.jpg";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
package mage.client.util.sets;
|
||||
|
||||
import mage.cards.ExpansionSet;
|
||||
import mage.client.cards.CardsStorage;
|
||||
import mage.sets.Sets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utility class for constructed formats.
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class ConstructedFormats {
|
||||
|
||||
private static final String[] constructedFormats = {"Standard", "Extended", "Modern", "All"};
|
||||
|
||||
private ConstructedFormats() {
|
||||
}
|
||||
|
||||
public static String[] getTypes() {
|
||||
return constructedFormats;
|
||||
}
|
||||
|
||||
public static String getDefault() {
|
||||
return constructedFormats[1];
|
||||
}
|
||||
|
||||
public static List<String> getSetsByFormat(String format) {
|
||||
if (format.equals("Standard")) {
|
||||
return standard;
|
||||
}
|
||||
if (format.equals("Extended")) {
|
||||
return extended;
|
||||
}
|
||||
if (format.equals("Modern")) {
|
||||
return modern;
|
||||
}
|
||||
return all;
|
||||
}
|
||||
|
||||
private static void buildLists() {
|
||||
for (String setCode : CardsStorage.getSetCodes()) {
|
||||
ExpansionSet set = Sets.findSet(setCode);
|
||||
if (set.getReleaseDate().after(standardDate)) {
|
||||
standard.add(set.getCode());
|
||||
}
|
||||
if (set.getReleaseDate().after(extendedDate)) {
|
||||
extended.add(set.getCode());
|
||||
}
|
||||
if (set.getReleaseDate().after(modernDate)) {
|
||||
modern.add(set.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final List<String> standard = new ArrayList<String>();
|
||||
private static final Date standardDate = new GregorianCalendar(2010, 9, 20).getTime();
|
||||
|
||||
private static final List<String> extended = new ArrayList<String>();
|
||||
private static final Date extendedDate = new GregorianCalendar(2008, 9, 20).getTime();
|
||||
|
||||
private static final List<String> modern = new ArrayList<String>();
|
||||
private static final Date modernDate = new GregorianCalendar(2003, 7, 20).getTime();
|
||||
|
||||
// for all sets just return empty list
|
||||
private static final List<String> all = new ArrayList<String>();
|
||||
|
||||
static {
|
||||
buildLists();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue