mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22: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,52 +305,7 @@ 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.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
|
||||
jSplitPane1.setResizeWeight(0.5);
|
||||
jSplitPane1.setTopComponent(cardSelector);
|
||||
jSplitPane1.setBottomComponent(deckArea);
|
||||
|
|
@ -584,8 +530,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();
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
|
@ -108,8 +136,9 @@ public final class CollectionViewerPanel extends JPanel {
|
|||
jScrollPane1.getViewport().setBackground(new Color(0,0,0,0));
|
||||
|
||||
jPanel.setLayout(new GridBagLayout()); // centers mage book
|
||||
jPanel.setBackground(new Color(0,0,0,0));
|
||||
jPanel.add(new MageBook(bigCard));
|
||||
jPanel.setBackground(new Color(0, 0, 0, 0));
|
||||
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.
|
||||
|
|
@ -60,269 +63,280 @@ import org.mage.card.arcane.ManaSymbols;
|
|||
*/
|
||||
public class MageBook extends JComponent {
|
||||
|
||||
public MageBook(BigCard bigCard) {
|
||||
super();
|
||||
this.bigCard = bigCard;
|
||||
initComponents();
|
||||
}
|
||||
public MageBook(BigCard bigCard) {
|
||||
super();
|
||||
this.bigCard = bigCard;
|
||||
this.setsToDisplay = ConstructedFormats.getSetsByFormat(ConstructedFormats.getDefault());
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
setOpaque(false);
|
||||
setSize(WIDTH, HEIGHT);
|
||||
setPreferredSize(new Dimension(WIDTH, HEIGHT));
|
||||
setMinimumSize(new Dimension(WIDTH, HEIGHT));
|
||||
//setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
private void initComponents() {
|
||||
setOpaque(false);
|
||||
setSize(WIDTH, HEIGHT);
|
||||
setPreferredSize(new Dimension(WIDTH, HEIGHT));
|
||||
setMinimumSize(new Dimension(WIDTH, HEIGHT));
|
||||
//setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
|
||||
jPanelLeft = getImagePanel(LEFT_PANEL_IMAGE_PATH, ImagePanel.TILED);
|
||||
jPanelLeft.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
|
||||
jPanelLeft.setLayout(null);
|
||||
jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanel.SCALED);
|
||||
jPanelCenter.setLayout(new BorderLayout());
|
||||
jPanelRight = getImagePanel(RIGHT_PANEL_IMAGE_PATH, ImagePanel.TILED);
|
||||
jPanelRight.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
|
||||
jPanelRight.setLayout(null);
|
||||
jPanelLeft = getImagePanel(LEFT_PANEL_IMAGE_PATH, ImagePanel.TILED);
|
||||
jPanelLeft.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
|
||||
jPanelLeft.setLayout(null);
|
||||
jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanel.SCALED);
|
||||
jPanelCenter.setLayout(new BorderLayout());
|
||||
jPanelRight = getImagePanel(RIGHT_PANEL_IMAGE_PATH, ImagePanel.TILED);
|
||||
jPanelRight.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0));
|
||||
jPanelRight.setLayout(null);
|
||||
|
||||
jLayeredPane = new JLayeredPane();
|
||||
jPanelCenter.add(jLayeredPane, BorderLayout.CENTER);
|
||||
jLayeredPane = new JLayeredPane();
|
||||
jPanelCenter.add(jLayeredPane, BorderLayout.CENTER);
|
||||
|
||||
Image image = ImageHelper.loadImage(LEFT_PAGE_BUTTON_IMAGE_PATH);
|
||||
pageLeft = new HoverButton(null, image, image, image, new Rectangle(64, 64));
|
||||
pageLeft.setBounds(0, 0, 64, 64);
|
||||
pageLeft.setVisible(false);
|
||||
pageLeft.setObserver(new Command() {
|
||||
Image image = ImageHelper.loadImage(LEFT_PAGE_BUTTON_IMAGE_PATH);
|
||||
pageLeft = new HoverButton(null, image, image, image, new Rectangle(64, 64));
|
||||
pageLeft.setBounds(0, 0, 64, 64);
|
||||
pageLeft.setVisible(false);
|
||||
pageLeft.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
currentPage--;
|
||||
if (currentPage == 0) {
|
||||
pageLeft.setVisible(false);
|
||||
}
|
||||
pageRight.setVisible(true);
|
||||
AudioManager.playPrevPage();
|
||||
showCards();
|
||||
}
|
||||
});
|
||||
public void execute() {
|
||||
currentPage--;
|
||||
if (currentPage == 0) {
|
||||
pageLeft.setVisible(false);
|
||||
}
|
||||
pageRight.setVisible(true);
|
||||
AudioManager.playPrevPage();
|
||||
showCards();
|
||||
}
|
||||
});
|
||||
|
||||
image = ImageHelper.loadImage(RIGHT_PAGE_BUTTON_IMAGE_PATH);
|
||||
pageRight = new HoverButton(null, image, image, image, new Rectangle(64, 64));
|
||||
pageRight.setBounds(WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH - 64, 0, 64, 64);
|
||||
pageRight.setVisible(false);
|
||||
pageRight.setObserver(new Command() {
|
||||
image = ImageHelper.loadImage(RIGHT_PAGE_BUTTON_IMAGE_PATH);
|
||||
pageRight = new HoverButton(null, image, image, image, new Rectangle(64, 64));
|
||||
pageRight.setBounds(WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH - 64, 0, 64, 64);
|
||||
pageRight.setVisible(false);
|
||||
pageRight.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
currentPage++;
|
||||
pageLeft.setVisible(true);
|
||||
pageRight.setVisible(false);
|
||||
AudioManager.playNextPage();
|
||||
showCards();
|
||||
}
|
||||
});
|
||||
public void execute() {
|
||||
currentPage++;
|
||||
pageLeft.setVisible(true);
|
||||
pageRight.setVisible(false);
|
||||
AudioManager.playNextPage();
|
||||
showCards();
|
||||
}
|
||||
});
|
||||
|
||||
addSetTabs();
|
||||
addSetTabs();
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add(jPanelLeft, BorderLayout.LINE_START);
|
||||
add(jPanelCenter, BorderLayout.CENTER);
|
||||
add(jPanelRight, BorderLayout.LINE_END);
|
||||
setLayout(new BorderLayout());
|
||||
add(jPanelLeft, BorderLayout.LINE_START);
|
||||
add(jPanelCenter, BorderLayout.CENTER);
|
||||
add(jPanelRight, BorderLayout.LINE_END);
|
||||
|
||||
cardDimensions = new CardDimensions(0.45d);
|
||||
cardDimensions = new CardDimensions(0.45d);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showCards();
|
||||
}
|
||||
});
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showCards();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addLeftRightPageButtons() {
|
||||
jLayeredPane.add(pageLeft, JLayeredPane.DEFAULT_LAYER, 0);
|
||||
jLayeredPane.add(pageRight, JLayeredPane.DEFAULT_LAYER, 1);
|
||||
}
|
||||
private void addLeftRightPageButtons() {
|
||||
jLayeredPane.add(pageLeft, JLayeredPane.DEFAULT_LAYER, 0);
|
||||
jLayeredPane.add(pageRight, JLayeredPane.DEFAULT_LAYER, 1);
|
||||
}
|
||||
|
||||
private void addSetTabs() {
|
||||
jPanelLeft.removeAll();
|
||||
jPanelRight.removeAll();
|
||||
Image image = ImageHelper.loadImage(LEFT_TAB_IMAGE_PATH);
|
||||
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;
|
||||
}
|
||||
int count = 0;
|
||||
JPanel currentPanel = jPanelLeft;
|
||||
HoverButton currentTab = null;
|
||||
for (String set : CardsStorage.getSetCodes()) {
|
||||
HoverButton tab = new HoverButton(null, image, image, image, new Rectangle(39, 120));
|
||||
Image setImage = ManaSymbols.getSetSymbolImage(set);
|
||||
if (setImage != null) {
|
||||
tab.setOverlayImage(setImage);
|
||||
} else {
|
||||
System.out.println("Couldn't find: " + "/plugins/images/sets/" + set + "-C.jpg");
|
||||
}
|
||||
tab.setSet(set);
|
||||
tab.setBounds(0, y, 39, 120);
|
||||
final String _set = set;
|
||||
tab.setObserver(new Command() {
|
||||
private void addSetTabs() {
|
||||
jPanelLeft.removeAll();
|
||||
jPanelRight.removeAll();
|
||||
Image image = ImageHelper.loadImage(LEFT_TAB_IMAGE_PATH);
|
||||
Image imageRight = ImageHelper.loadImage(RIGHT_TAB_IMAGE_PATH);
|
||||
int y = 0;
|
||||
int dy = 0;
|
||||
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 : this.setsToDisplay) {
|
||||
HoverButton tab = new HoverButton(null, image, image, image, new Rectangle(39, 120));
|
||||
Image setImage = ManaSymbols.getSetSymbolImage(set);
|
||||
if (setImage != null) {
|
||||
tab.setOverlayImage(setImage);
|
||||
} else {
|
||||
System.out.println("Couldn't find: " + "/plugins/images/sets/" + set + "-C.jpg");
|
||||
}
|
||||
tab.setSet(set);
|
||||
tab.setBounds(0, y, 39, 120);
|
||||
final String _set = set;
|
||||
tab.setObserver(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!currentSet.equals(_set) || currentPage != 0) {
|
||||
AudioManager.playAnotherTab();
|
||||
currentPage = 0;
|
||||
currentSet = _set;
|
||||
pageLeft.setVisible(false);
|
||||
pageRight.setVisible(false);
|
||||
addSetTabs();
|
||||
showCards();
|
||||
}
|
||||
}
|
||||
});
|
||||
currentPanel.add(tab, JLayeredPane.DEFAULT_LAYER + count++, 0);
|
||||
y += dy;
|
||||
if (set.equals(currentSet)) {
|
||||
currentPanel = jPanelRight;
|
||||
image = imageRight;
|
||||
currentTab = tab;
|
||||
}
|
||||
}
|
||||
jPanelLeft.revalidate();
|
||||
jPanelLeft.repaint();
|
||||
jPanelRight.revalidate();
|
||||
jPanelRight.repaint();
|
||||
if (currentTab != null) {
|
||||
currentTab.drawSet();
|
||||
currentTab.repaint();
|
||||
}
|
||||
}
|
||||
public void execute() {
|
||||
if (!currentSet.equals(_set) || currentPage != 0) {
|
||||
AudioManager.playAnotherTab();
|
||||
currentPage = 0;
|
||||
currentSet = _set;
|
||||
pageLeft.setVisible(false);
|
||||
pageRight.setVisible(false);
|
||||
addSetTabs();
|
||||
showCards();
|
||||
}
|
||||
}
|
||||
});
|
||||
currentPanel.add(tab, JLayeredPane.DEFAULT_LAYER + count++, 0);
|
||||
y += dy;
|
||||
if (set.equals(currentSet)) {
|
||||
currentPanel = jPanelRight;
|
||||
image = imageRight;
|
||||
currentTab = tab;
|
||||
}
|
||||
}
|
||||
jPanelLeft.revalidate();
|
||||
jPanelLeft.repaint();
|
||||
jPanelRight.revalidate();
|
||||
jPanelRight.repaint();
|
||||
if (currentTab != null) {
|
||||
currentTab.drawSet();
|
||||
currentTab.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
private void showCards() {
|
||||
jLayeredPane.removeAll();
|
||||
addLeftRightPageButtons();
|
||||
private void showCards() {
|
||||
jLayeredPane.removeAll();
|
||||
addLeftRightPageButtons();
|
||||
|
||||
java.util.List<Card> cards = getCards(currentPage, currentSet);
|
||||
int size = cards.size();
|
||||
java.util.List<Card> cards = getCards(currentPage, currentSet);
|
||||
int size = cards.size();
|
||||
|
||||
Rectangle rectangle = new Rectangle();
|
||||
rectangle.translate(OFFSET_X, OFFSET_Y);
|
||||
for (int i = 0; i < Math.min(CARDS_PER_PAGE / 2, size); i++) {
|
||||
addCard(new CardView(cards.get(i)), bigCard, null, rectangle);
|
||||
rectangle = CardPosition.translatePosition(i, rectangle);
|
||||
}
|
||||
Rectangle rectangle = new Rectangle();
|
||||
rectangle.translate(OFFSET_X, OFFSET_Y);
|
||||
for (int i = 0; i < Math.min(CARDS_PER_PAGE / 2, size); i++) {
|
||||
addCard(new CardView(cards.get(i)), bigCard, null, rectangle);
|
||||
rectangle = CardPosition.translatePosition(i, rectangle);
|
||||
}
|
||||
|
||||
// calculate the x offset of the second (right) page
|
||||
int second_page_x = (WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH) -
|
||||
(cardDimensions.frameWidth + CardPosition.GAP_X) * 3 + CardPosition.GAP_X - OFFSET_X;
|
||||
// calculate the x offset of the second (right) page
|
||||
int second_page_x = (WIDTH - 2 * LEFT_RIGHT_PAGES_WIDTH) -
|
||||
(cardDimensions.frameWidth + CardPosition.GAP_X) * 3 + CardPosition.GAP_X - OFFSET_X;
|
||||
|
||||
rectangle.setLocation(second_page_x, OFFSET_Y);
|
||||
for (int i = CARDS_PER_PAGE / 2; i < Math.min(CARDS_PER_PAGE, size); i++) {
|
||||
addCard(new CardView(cards.get(i)), bigCard, null, rectangle);
|
||||
rectangle = CardPosition.translatePosition(i - CARDS_PER_PAGE / 2, rectangle);
|
||||
}
|
||||
rectangle.setLocation(second_page_x, OFFSET_Y);
|
||||
for (int i = CARDS_PER_PAGE / 2; i < Math.min(CARDS_PER_PAGE, size); i++) {
|
||||
addCard(new CardView(cards.get(i)), bigCard, null, rectangle);
|
||||
rectangle = CardPosition.translatePosition(i - CARDS_PER_PAGE / 2, rectangle);
|
||||
}
|
||||
|
||||
jLayeredPane.repaint();
|
||||
}
|
||||
jLayeredPane.repaint();
|
||||
}
|
||||
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
final MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||
cardImg.update(card);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight);
|
||||
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
|
||||
if (cardDimension == null) {
|
||||
cardDimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
|
||||
}
|
||||
final MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, cardDimension, gameId, true);
|
||||
cardImg.setBounds(rectangle);
|
||||
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
|
||||
cardImg.update(card);
|
||||
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight);
|
||||
|
||||
boolean implemented = !card.getRarity().equals(mage.Constants.Rarity.NA);
|
||||
boolean implemented = !card.getRarity().equals(mage.Constants.Rarity.NA);
|
||||
|
||||
GlowText label = new GlowText();
|
||||
label.setGlow(implemented ? Color.green : NOT_IMPLEMENTED, 12, 0.0f);
|
||||
label.setText(implemented ? "Implemented" : "Not implemented");
|
||||
int dx = implemented ? 15 : 5;
|
||||
label.setBounds(rectangle.x + dx, rectangle.y + cardDimensions.frameHeight + 7, 110, 30);
|
||||
jLayeredPane.add(label);
|
||||
}
|
||||
GlowText label = new GlowText();
|
||||
label.setGlow(implemented ? Color.green : NOT_IMPLEMENTED, 12, 0.0f);
|
||||
label.setText(implemented ? "Implemented" : "Not implemented");
|
||||
int dx = implemented ? 15 : 5;
|
||||
label.setBounds(rectangle.x + dx, rectangle.y + cardDimensions.frameHeight + 7, 110, 30);
|
||||
jLayeredPane.add(label);
|
||||
}
|
||||
|
||||
private java.util.List<Card> getCards(int page, String set) {
|
||||
int start = page * CARDS_PER_PAGE;
|
||||
int end = (page + 1) * CARDS_PER_PAGE;
|
||||
java.util.List<Card> cards = CardsStorage.getAllCards(start, end, currentSet, false);
|
||||
if (cards.size() > CARDS_PER_PAGE) {
|
||||
pageRight.setVisible(true);
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
private java.util.List<Card> getCards(int page, String set) {
|
||||
int start = page * CARDS_PER_PAGE;
|
||||
int end = (page + 1) * CARDS_PER_PAGE;
|
||||
java.util.List<Card> cards = CardsStorage.getAllCards(start, end, currentSet, false);
|
||||
if (cards.size() > CARDS_PER_PAGE) {
|
||||
pageRight.setVisible(true);
|
||||
}
|
||||
return cards;
|
||||
}
|
||||
|
||||
private ImagePanel getImagePanel(String filename, int type) {
|
||||
try {
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
private ImagePanel getImagePanel(String filename, int type) {
|
||||
try {
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
|
||||
if (is == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
if (is == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
|
||||
BufferedImage background = ImageIO.read(is);
|
||||
BufferedImage background = ImageIO.read(is);
|
||||
|
||||
if (background == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
if (background == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
|
||||
return new ImagePanel(background, type);
|
||||
return new ImagePanel(background, type);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the position of the next card on the mage book
|
||||
*/
|
||||
private static class CardPosition {
|
||||
private CardPosition() {
|
||||
}
|
||||
public void updateDispayedSets(String format) {
|
||||
this.setsToDisplay = ConstructedFormats.getSetsByFormat(format);
|
||||
if (this.setsToDisplay.isEmpty()) {
|
||||
// display all
|
||||
this.setsToDisplay = CardsStorage.getSetCodes();
|
||||
}
|
||||
addSetTabs();
|
||||
}
|
||||
|
||||
public static Rectangle translatePosition(int index, Rectangle r) {
|
||||
Rectangle rect = new Rectangle(r);
|
||||
rect.translate((cardDimensions.frameWidth + GAP_X) * dx[index],
|
||||
(cardDimensions.frameHeight + GAP_Y) * dy[index]);
|
||||
return rect;
|
||||
}
|
||||
/**
|
||||
* Defines the position of the next card on the mage book
|
||||
*/
|
||||
private static class CardPosition {
|
||||
private CardPosition() {
|
||||
}
|
||||
|
||||
private static final int[] dx = {1, 1, -2, 1, 1, -2, 1, 1, 2, 1, -2, 1, 1, -2, 1, 1};
|
||||
private static final int[] dy = {0, 0, 1, 0, 0, 1, 0, 0, -2, 0, 1, 0, 0, 1, 0, 0};
|
||||
public static final int GAP_X = 17;
|
||||
public static final int GAP_Y = 45;
|
||||
private static int cardWidth;
|
||||
private static int cardHeight;
|
||||
}
|
||||
public static Rectangle translatePosition(int index, Rectangle r) {
|
||||
Rectangle rect = new Rectangle(r);
|
||||
rect.translate((cardDimensions.frameWidth + GAP_X) * dx[index],
|
||||
(cardDimensions.frameHeight + GAP_Y) * dy[index]);
|
||||
return rect;
|
||||
}
|
||||
|
||||
private JPanel jPanelLeft;
|
||||
private ImagePanel jPanelCenter;
|
||||
private JPanel jPanelRight;
|
||||
private JLayeredPane jLayeredPane;
|
||||
private BigCard bigCard;
|
||||
private HoverButton pageLeft;
|
||||
private HoverButton pageRight;
|
||||
private static final int[] dx = {1, 1, -2, 1, 1, -2, 1, 1, 2, 1, -2, 1, 1, -2, 1, 1};
|
||||
private static final int[] dy = {0, 0, 1, 0, 0, 1, 0, 0, -2, 0, 1, 0, 0, 1, 0, 0};
|
||||
public static final int GAP_X = 17;
|
||||
public static final int GAP_Y = 45;
|
||||
private static int cardWidth;
|
||||
private static int cardHeight;
|
||||
}
|
||||
|
||||
private int currentPage = 0;
|
||||
private String currentSet = "ISD";
|
||||
private JPanel jPanelLeft;
|
||||
private ImagePanel jPanelCenter;
|
||||
private JPanel jPanelRight;
|
||||
private JLayeredPane jLayeredPane;
|
||||
private BigCard bigCard;
|
||||
private HoverButton pageLeft;
|
||||
private HoverButton pageRight;
|
||||
|
||||
private static CardDimensions cardDimensions = new CardDimensions(1.2d);
|
||||
private static final Logger log = Logger.getLogger(MageBook.class);
|
||||
private Dimension cardDimension;
|
||||
private int currentPage = 0;
|
||||
private String currentSet = "ISD";
|
||||
|
||||
static private final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg";
|
||||
static private final String RIGHT_PANEL_IMAGE_PATH = "/book_right.jpg";
|
||||
static private final String LEFT_PANEL_IMAGE_PATH = "/book_left.jpg";
|
||||
static private final String LEFT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_left.png";
|
||||
static private final String RIGHT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_right.png";
|
||||
static private final String LEFT_TAB_IMAGE_PATH = "/tab_left.png";
|
||||
static private final String RIGHT_TAB_IMAGE_PATH = "/tab_right.png";
|
||||
static private final int CARDS_PER_PAGE = 18;
|
||||
static private final int WIDTH = 950;
|
||||
static private final int HEIGHT = 650;
|
||||
static private final int OFFSET_X = 25;
|
||||
static private final int OFFSET_Y = 20;
|
||||
static private final int LEFT_RIGHT_PAGES_WIDTH = 40;
|
||||
static private final Color NOT_IMPLEMENTED = new Color(220, 220, 220, 150);
|
||||
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";
|
||||
static private final String LEFT_PANEL_IMAGE_PATH = "/book_left.jpg";
|
||||
static private final String LEFT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_left.png";
|
||||
static private final String RIGHT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_right.png";
|
||||
static private final String LEFT_TAB_IMAGE_PATH = "/tab_left.png";
|
||||
static private final String RIGHT_TAB_IMAGE_PATH = "/tab_right.png";
|
||||
static private final int CARDS_PER_PAGE = 18;
|
||||
static private final int WIDTH = 950;
|
||||
static private final int HEIGHT = 650;
|
||||
static private final int OFFSET_X = 25;
|
||||
static private final int OFFSET_Y = 20;
|
||||
static private final int LEFT_RIGHT_PAGES_WIDTH = 40;
|
||||
static private final Color NOT_IMPLEMENTED = new Color(220, 220, 220, 150);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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