1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-03 01:08:59 -09:00

Added tab switching into Collection Viewer.

This commit is contained in:
magenoxx 2011-10-15 19:45:16 +04:00
parent 74b21979a5
commit ba19cc7f61
3 changed files with 65 additions and 2 deletions
Mage.Client/src/main/java/mage/client
components
deckeditor/collection/viewer

View file

@ -219,4 +219,10 @@ public class HoverButton extends JPanel implements MouseListener {
this.text = text;
repaint();
}
public void execute() {
if (isEnabled() && observer != null) {
observer.execute();
}
}
}

View file

@ -27,7 +27,6 @@
*/
package mage.client.deckeditor.collection.viewer;
import mage.cards.decks.Constructed;
import mage.client.cards.BigCard;
import mage.client.util.sets.ConstructedFormats;
@ -35,7 +34,6 @@ 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.
@ -95,6 +93,35 @@ public final class CollectionViewerPanel extends JPanel {
});
jPanel1.add(big4x4);
JLabel label3 = new JLabel("Switch tabs:");
label3.setAlignmentX(Component.LEFT_ALIGNMENT);
jPanel1.add(label3);
JPanel buttonPanel = new JPanel();
buttonPanel.setPreferredSize(new Dimension(200, 100));
buttonPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 100));
//buttonPanel.setBorder(BorderFactory.createLineBorder(Color.RED));
buttonPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
jPanel1.add(buttonPanel);
JButton prev = new JButton("Prev");
prev.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mageBook.prev();
}
});
buttonPanel.add(prev);
JButton next = new JButton("Next");
next.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mageBook.next();
}
});
buttonPanel.add(next);
formats.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {

View file

@ -52,7 +52,9 @@ import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.UUID;
/**
@ -167,11 +169,15 @@ public class MageBook extends JComponent {
tab.setSet(set);
tab.setBounds(0, y, 39, 120);
final String _set = set;
final int _index = count;
tab.setObserver(new Command() {
@Override
public void execute() {
if (!currentSet.equals(_set) || currentPage != 0) {
AudioManager.playAnotherTab();
synchronized (this) {
selectedTab = _index;
}
currentPage = 0;
currentSet = _set;
pageLeft.setVisible(false);
@ -181,12 +187,14 @@ public class MageBook extends JComponent {
}
}
});
tabs.add(tab);
currentPanel.add(tab, JLayeredPane.DEFAULT_LAYER + count++, 0);
y += dy;
if (set.equals(currentSet)) {
currentPanel = jPanelRight;
image = imageRight;
currentTab = tab;
selectedTab = count-1;
}
}
jPanelLeft.revalidate();
@ -287,6 +295,26 @@ public class MageBook extends JComponent {
addSetTabs();
}
public void next() {
synchronized (this) {
selectedTab++;
if (selectedTab >= tabs.size()) {
selectedTab = 0;
}
tabs.get(selectedTab).execute();
}
}
public void prev() {
synchronized (this) {
selectedTab--;
if (selectedTab < 0) {
selectedTab = tabs.size() - 1;
}
tabs.get(selectedTab).execute();
}
}
public void updateSize(String size) {
if (size.equals("small")) {
this.conf = new _3x3Configuration();
@ -372,6 +400,8 @@ public class MageBook extends JComponent {
private static final Logger log = Logger.getLogger(MageBook.class);
private Dimension cardDimension;
private java.util.List<String> setsToDisplay = new ArrayList<String>();
private java.util.List<HoverButton> tabs = new ArrayList<HoverButton>();
private int selectedTab;
static private final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg";
static private final String RIGHT_PANEL_IMAGE_PATH = "/book_right.jpg";